diff --git a/.eslintrc b/.eslintrc
new file mode 100644
index 0000000..84e39d6
--- /dev/null
+++ b/.eslintrc
@@ -0,0 +1,37 @@
+{
+ "parserOptions": {
+ "ecmaVersion": 6,
+ "sourceType": "module",
+ "ecmaFeatures": {
+ "jsx": true
+ }
+ },
+ "rules": {
+ "semi": 2,
+ "no-unused-vars": 2,
+ "react/display-name": 2,
+ "react/jsx-key": 2,
+ "react/jsx-no-comment-textnodes": 2,
+ "react/jsx-no-duplicate-props": 2,
+ "react/jsx-no-target-blank": 2,
+ "react/jsx-no-undef": 2,
+ "react/jsx-uses-react": 2,
+ "react/jsx-uses-vars": 2,
+ "react/no-children-prop": 2,
+ "react/no-danger-with-children": 2,
+ "react/no-deprecated": 2,
+ "react/no-direct-mutation-state": 2,
+ "react/no-find-dom-node": 2,
+ "react/no-is-mounted": 2,
+ "react/no-render-return-value": 2,
+ "react/no-string-refs": 2,
+ "react/no-unescaped-entities": 2,
+ "react/no-unknown-property": 2,
+ "react/prop-types": 2,
+ "react/react-in-jsx-scope": 2,
+ "react/require-render-return": 2,
+ },
+ "plugins": [
+ "react"
+ ]
+}
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..bacedf9
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2017 Plotly, Inc.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/README.md b/README.md
index 3b56371..9edeed2 100644
--- a/README.md
+++ b/README.md
@@ -1,25 +1,30 @@
-# plotly.js-react
+# react-plotly.js
-> A React component for plotly.js charts → See demo
+> A [plotly.js](https://github.com/plotly/plotly.js) React component from [Plotly](https://plot.ly/)
## Installation
-Not yet published
-
```bash
-$ npm install plotly.js-react
+$ npm install react-plotly.js plotly.js
```
## Usage
-The component definition is created by dependency injection so that you can use whichever version of plotly.js you'd like, including the [CDN versions](https://plot.ly/javascript/getting-started/#plotlyjs-cdn).
+### With bundled `plotly.js`
+
+[`plotly.js`](https://github.com/plotly/plotly.js) is a peer dependency of `react-plotly.js`. If you would like to bundle `plotly.js` with the rest of your project and use it in this component, you must install it separately.
+
+```bash
+$ npm install -S react-plotly.js plotly.js
+```
+
+Since `plotly.js` is a peer dependency, you do not need to require it separately to use it.
```javascript
-const createPlotlyComponent = require('plotly.js-react');
-const PlotlyComponent = createPlotlyComponent(Plotly);
+import Plot from 'react-plotly.js'
render () {
-
+```
+
+you may then inject Plotly and use the returned React component:
+
+```javascript
+import plotComponentFactory from 'react-plotly.js/factory'
+const Plot = plotComponentFactory(Plotly);
+
+render () {
+ return
+}
+```
+
+**Note**: You must ensure `Plotly` is available before your React app tries to render the component. That could mean perhaps using script tag (without `async` or `defer`) or a utility like [load-script](https://www.npmjs.com/package/load-script).
## API
@@ -42,12 +77,14 @@ The only requirement is that plotly.js is loaded before you inject it. You may n
| `frames` | `Array` | `undefined` | list of frame objects |
| `fit` | `Boolean` | `false` | When true, disregards `layout.width` and `layout.height` and fits to the parent div size, updating on `window.resize` |
| `debug` | `Boolean` | `false` | Assign the graph div to `window.gd` for debugging |
-| `onInitialized | `Function` | null | Callback executed once after plot is initialized |
-| `onUpdate | `Function` | null | Callback executed when a plotly.js API method is invoked |
-| `onError | `Function` | null | Callback executed when a plotly.js API method rejects |
+| `onInitialized` | `Function` | `undefined` | Callback executed once after plot is initialized |
+| `onUpdate` | `Function` | `undefined` | Callback executed when a plotly.js API method is invoked |
+| `onError` | `Function` | `undefined` | Callback executed when a plotly.js API method rejects |
### Event handler props
+Event handlers for [`plotly.js` events](https://plot.ly/javascript/plotlyjs-events/) may be attached through the following props.
+
| Prop | Type | Plotly Event |
| ---- | ---- | ----------- |
| `onAfterExport` | `Function` | `plotly_afterexport` |
@@ -76,6 +113,10 @@ The only requirement is that plotly.js is loaded before you inject it. You may n
| `onTransitionInterrupted` | `Function` | `plotly_transitioninterrupted` |
| `onUnhover` | `Function` | `plotly_unhover` |
+## Roadmap
+
+This component currently creates a new plot every time the input changes. That makes it stable and good enough for production use, but `plotly.js` will soon gain react-style support for computing and drawing changes incrementally. What does that mean for you? That means you can expect to keep using this component with little or no modification but that the plotting will simply happen much faster when you upgrade to the first version of `plotly.js` to support this feature. If this component requires any significant changes, a new major version will be released at the same time to ensure stability.
+
## Development
To get started:
@@ -85,15 +126,17 @@ $ npm install
$ npm start
```
-To build the dist version:
+To transpile from ES2015 + JSX into the ES5 npm-distributed version:
```bash
-$ npm run prepublish
+$ npm run prepublishOnly
```
-## See also
+To run the tests:
-- [plotly-react-editor](https://github.com/plotly/plotly-react-editor)
+```bash
+$ npm run test
+```
## License
diff --git a/build/plotly.js-react.js b/build/plotly.js-react.js
deleted file mode 100644
index 7c37cf3..0000000
--- a/build/plotly.js-react.js
+++ /dev/null
@@ -1,1578 +0,0 @@
-(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.createPlotlyComponent = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o
- * but significantly simplified and sped up by ignoring number and string constructors
- * ie these return false:
- * new Number(1)
- * new String('1')
- */
-
-'use strict';
-
-/**
- * Is this string all whitespace?
- * This solution kind of makes my brain hurt, but it's significantly faster
- * than !str.trim() or any other solution I could find.
- *
- * whitespace codes from: http://en.wikipedia.org/wiki/Whitespace_character
- * and verified with:
- *
- * for(var i = 0; i < 65536; i++) {
- * var s = String.fromCharCode(i);
- * if(+s===0 && !s.trim()) console.log(i, s);
- * }
- *
- * which counts a couple of these as *not* whitespace, but finds nothing else
- * that *is* whitespace. Note that charCodeAt stops at 16 bits, but it appears
- * that there are no whitespace characters above this, and code points above
- * this do not map onto white space characters.
- */
-function allBlankCharCodes(str){
- var l = str.length,
- a;
- for(var i = 0; i < l; i++) {
- a = str.charCodeAt(i);
- if((a < 9 || a > 13) && (a !== 32) && (a !== 133) && (a !== 160) &&
- (a !== 5760) && (a !== 6158) && (a < 8192 || a > 8205) &&
- (a !== 8232) && (a !== 8233) && (a !== 8239) && (a !== 8287) &&
- (a !== 8288) && (a !== 12288) && (a !== 65279)) {
- return false;
- }
- }
- return true;
-}
-
-module.exports = function(n) {
- var type = typeof n;
- if(type === 'string') {
- var original = n;
- n = +n;
- // whitespace strings cast to zero - filter them out
- if(n===0 && allBlankCharCodes(original)) return false;
- }
- else if(type !== 'number') return false;
-
- return n - n < 1;
-};
-
-},{}],2:[function(require,module,exports){
-"use strict";
-
-/**
- * Copyright (c) 2013-present, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- *
- */
-
-function makeEmptyFunction(arg) {
- return function () {
- return arg;
- };
-}
-
-/**
- * This function accepts and discards inputs; it has no side effects. This is
- * primarily useful idiomatically for overridable function endpoints which
- * always need to be callable, since JS lacks a null-call idiom ala Cocoa.
- */
-var emptyFunction = function emptyFunction() {};
-
-emptyFunction.thatReturns = makeEmptyFunction;
-emptyFunction.thatReturnsFalse = makeEmptyFunction(false);
-emptyFunction.thatReturnsTrue = makeEmptyFunction(true);
-emptyFunction.thatReturnsNull = makeEmptyFunction(null);
-emptyFunction.thatReturnsThis = function () {
- return this;
-};
-emptyFunction.thatReturnsArgument = function (arg) {
- return arg;
-};
-
-module.exports = emptyFunction;
-},{}],3:[function(require,module,exports){
-(function (process){
-/**
- * Copyright (c) 2013-present, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- */
-
-'use strict';
-
-/**
- * Use invariant() to assert state which your program assumes to be true.
- *
- * Provide sprintf-style format (only %s is supported) and arguments
- * to provide information about what broke and what you were
- * expecting.
- *
- * The invariant message will be stripped in production, but the invariant
- * will remain to ensure logic does not differ in production.
- */
-
-var validateFormat = function validateFormat(format) {};
-
-if (process.env.NODE_ENV !== 'production') {
- validateFormat = function validateFormat(format) {
- if (format === undefined) {
- throw new Error('invariant requires an error message argument');
- }
- };
-}
-
-function invariant(condition, format, a, b, c, d, e, f) {
- validateFormat(format);
-
- if (!condition) {
- var error;
- if (format === undefined) {
- error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
- } else {
- var args = [a, b, c, d, e, f];
- var argIndex = 0;
- error = new Error(format.replace(/%s/g, function () {
- return args[argIndex++];
- }));
- error.name = 'Invariant Violation';
- }
-
- error.framesToPop = 1; // we don't care about invariant's own frame
- throw error;
- }
-}
-
-module.exports = invariant;
-}).call(this,require('_process'))
-},{"_process":6}],4:[function(require,module,exports){
-(function (process){
-/**
- * Copyright 2014-2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- */
-
-'use strict';
-
-var emptyFunction = require('./emptyFunction');
-
-/**
- * Similar to invariant but only logs a warning if the condition is not met.
- * This can be used to log issues in development environments in critical
- * paths. Removing the logging code for production environments will keep the
- * same logic and follow the same code paths.
- */
-
-var warning = emptyFunction;
-
-if (process.env.NODE_ENV !== 'production') {
- var printWarning = function printWarning(format) {
- for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
- args[_key - 1] = arguments[_key];
- }
-
- var argIndex = 0;
- var message = 'Warning: ' + format.replace(/%s/g, function () {
- return args[argIndex++];
- });
- if (typeof console !== 'undefined') {
- console.error(message);
- }
- try {
- // --- Welcome to debugging React ---
- // This error was thrown as a convenience so that you can use this stack
- // to find the callsite that caused this warning to fire.
- throw new Error(message);
- } catch (x) {}
- };
-
- warning = function warning(condition, format) {
- if (format === undefined) {
- throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument');
- }
-
- if (format.indexOf('Failed Composite propType: ') === 0) {
- return; // Ignore CompositeComponent proptype check.
- }
-
- if (!condition) {
- for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
- args[_key2 - 2] = arguments[_key2];
- }
-
- printWarning.apply(undefined, [format].concat(args));
- }
- };
-}
-
-module.exports = warning;
-}).call(this,require('_process'))
-},{"./emptyFunction":2,"_process":6}],5:[function(require,module,exports){
-/*
-object-assign
-(c) Sindre Sorhus
-@license MIT
-*/
-
-'use strict';
-/* eslint-disable no-unused-vars */
-var getOwnPropertySymbols = Object.getOwnPropertySymbols;
-var hasOwnProperty = Object.prototype.hasOwnProperty;
-var propIsEnumerable = Object.prototype.propertyIsEnumerable;
-
-function toObject(val) {
- if (val === null || val === undefined) {
- throw new TypeError('Object.assign cannot be called with null or undefined');
- }
-
- return Object(val);
-}
-
-function shouldUseNative() {
- try {
- if (!Object.assign) {
- return false;
- }
-
- // Detect buggy property enumeration order in older V8 versions.
-
- // https://bugs.chromium.org/p/v8/issues/detail?id=4118
- var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
- test1[5] = 'de';
- if (Object.getOwnPropertyNames(test1)[0] === '5') {
- return false;
- }
-
- // https://bugs.chromium.org/p/v8/issues/detail?id=3056
- var test2 = {};
- for (var i = 0; i < 10; i++) {
- test2['_' + String.fromCharCode(i)] = i;
- }
- var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
- return test2[n];
- });
- if (order2.join('') !== '0123456789') {
- return false;
- }
-
- // https://bugs.chromium.org/p/v8/issues/detail?id=3056
- var test3 = {};
- 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
- test3[letter] = letter;
- });
- if (Object.keys(Object.assign({}, test3)).join('') !==
- 'abcdefghijklmnopqrst') {
- return false;
- }
-
- return true;
- } catch (err) {
- // We don't expect any of the above to throw, but better to be safe.
- return false;
- }
-}
-
-module.exports = shouldUseNative() ? Object.assign : function (target, source) {
- var from;
- var to = toObject(target);
- var symbols;
-
- for (var s = 1; s < arguments.length; s++) {
- from = Object(arguments[s]);
-
- for (var key in from) {
- if (hasOwnProperty.call(from, key)) {
- to[key] = from[key];
- }
- }
-
- if (getOwnPropertySymbols) {
- symbols = getOwnPropertySymbols(from);
- for (var i = 0; i < symbols.length; i++) {
- if (propIsEnumerable.call(from, symbols[i])) {
- to[symbols[i]] = from[symbols[i]];
- }
- }
- }
- }
-
- return to;
-};
-
-},{}],6:[function(require,module,exports){
-// shim for using process in browser
-var process = module.exports = {};
-
-// cached from whatever global is present so that test runners that stub it
-// don't break things. But we need to wrap it in a try catch in case it is
-// wrapped in strict mode code which doesn't define any globals. It's inside a
-// function because try/catches deoptimize in certain engines.
-
-var cachedSetTimeout;
-var cachedClearTimeout;
-
-function defaultSetTimout() {
- throw new Error('setTimeout has not been defined');
-}
-function defaultClearTimeout () {
- throw new Error('clearTimeout has not been defined');
-}
-(function () {
- try {
- if (typeof setTimeout === 'function') {
- cachedSetTimeout = setTimeout;
- } else {
- cachedSetTimeout = defaultSetTimout;
- }
- } catch (e) {
- cachedSetTimeout = defaultSetTimout;
- }
- try {
- if (typeof clearTimeout === 'function') {
- cachedClearTimeout = clearTimeout;
- } else {
- cachedClearTimeout = defaultClearTimeout;
- }
- } catch (e) {
- cachedClearTimeout = defaultClearTimeout;
- }
-} ())
-function runTimeout(fun) {
- if (cachedSetTimeout === setTimeout) {
- //normal enviroments in sane situations
- return setTimeout(fun, 0);
- }
- // if setTimeout wasn't available but was latter defined
- if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
- cachedSetTimeout = setTimeout;
- return setTimeout(fun, 0);
- }
- try {
- // when when somebody has screwed with setTimeout but no I.E. maddness
- return cachedSetTimeout(fun, 0);
- } catch(e){
- try {
- // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
- return cachedSetTimeout.call(null, fun, 0);
- } catch(e){
- // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
- return cachedSetTimeout.call(this, fun, 0);
- }
- }
-
-
-}
-function runClearTimeout(marker) {
- if (cachedClearTimeout === clearTimeout) {
- //normal enviroments in sane situations
- return clearTimeout(marker);
- }
- // if clearTimeout wasn't available but was latter defined
- if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
- cachedClearTimeout = clearTimeout;
- return clearTimeout(marker);
- }
- try {
- // when when somebody has screwed with setTimeout but no I.E. maddness
- return cachedClearTimeout(marker);
- } catch (e){
- try {
- // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
- return cachedClearTimeout.call(null, marker);
- } catch (e){
- // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
- // Some versions of I.E. have different rules for clearTimeout vs setTimeout
- return cachedClearTimeout.call(this, marker);
- }
- }
-
-
-
-}
-var queue = [];
-var draining = false;
-var currentQueue;
-var queueIndex = -1;
-
-function cleanUpNextTick() {
- if (!draining || !currentQueue) {
- return;
- }
- draining = false;
- if (currentQueue.length) {
- queue = currentQueue.concat(queue);
- } else {
- queueIndex = -1;
- }
- if (queue.length) {
- drainQueue();
- }
-}
-
-function drainQueue() {
- if (draining) {
- return;
- }
- var timeout = runTimeout(cleanUpNextTick);
- draining = true;
-
- var len = queue.length;
- while(len) {
- currentQueue = queue;
- queue = [];
- while (++queueIndex < len) {
- if (currentQueue) {
- currentQueue[queueIndex].run();
- }
- }
- queueIndex = -1;
- len = queue.length;
- }
- currentQueue = null;
- draining = false;
- runClearTimeout(timeout);
-}
-
-process.nextTick = function (fun) {
- var args = new Array(arguments.length - 1);
- if (arguments.length > 1) {
- for (var i = 1; i < arguments.length; i++) {
- args[i - 1] = arguments[i];
- }
- }
- queue.push(new Item(fun, args));
- if (queue.length === 1 && !draining) {
- runTimeout(drainQueue);
- }
-};
-
-// v8 likes predictible objects
-function Item(fun, array) {
- this.fun = fun;
- this.array = array;
-}
-Item.prototype.run = function () {
- this.fun.apply(null, this.array);
-};
-process.title = 'browser';
-process.browser = true;
-process.env = {};
-process.argv = [];
-process.version = ''; // empty string to avoid regexp issues
-process.versions = {};
-
-function noop() {}
-
-process.on = noop;
-process.addListener = noop;
-process.once = noop;
-process.off = noop;
-process.removeListener = noop;
-process.removeAllListeners = noop;
-process.emit = noop;
-process.prependListener = noop;
-process.prependOnceListener = noop;
-
-process.listeners = function (name) { return [] }
-
-process.binding = function (name) {
- throw new Error('process.binding is not supported');
-};
-
-process.cwd = function () { return '/' };
-process.chdir = function (dir) {
- throw new Error('process.chdir is not supported');
-};
-process.umask = function() { return 0; };
-
-},{}],7:[function(require,module,exports){
-(function (process){
-/**
- * Copyright 2013-present, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
-
-'use strict';
-
-if (process.env.NODE_ENV !== 'production') {
- var invariant = require('fbjs/lib/invariant');
- var warning = require('fbjs/lib/warning');
- var ReactPropTypesSecret = require('./lib/ReactPropTypesSecret');
- var loggedTypeFailures = {};
-}
-
-/**
- * Assert that the values match with the type specs.
- * Error messages are memorized and will only be shown once.
- *
- * @param {object} typeSpecs Map of name to a ReactPropType
- * @param {object} values Runtime values that need to be type-checked
- * @param {string} location e.g. "prop", "context", "child context"
- * @param {string} componentName Name of the component for error messages.
- * @param {?Function} getStack Returns the component stack.
- * @private
- */
-function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
- if (process.env.NODE_ENV !== 'production') {
- for (var typeSpecName in typeSpecs) {
- if (typeSpecs.hasOwnProperty(typeSpecName)) {
- var error;
- // Prop type validation may throw. In case they do, we don't want to
- // fail the render phase where it didn't fail before. So we log it.
- // After these have been cleaned up, we'll let them throw.
- try {
- // This is intentionally an invariant that gets caught. It's the same
- // behavior as without this statement except with a better message.
- invariant(typeof typeSpecs[typeSpecName] === 'function', '%s: %s type `%s` is invalid; it must be a function, usually from ' + 'React.PropTypes.', componentName || 'React class', location, typeSpecName);
- error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
- } catch (ex) {
- error = ex;
- }
- warning(!error || error instanceof Error, '%s: type specification of %s `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error);
- if (error instanceof Error && !(error.message in loggedTypeFailures)) {
- // Only monitor this failure once because there tends to be a lot of the
- // same error.
- loggedTypeFailures[error.message] = true;
-
- var stack = getStack ? getStack() : '';
-
- warning(false, 'Failed %s type: %s%s', location, error.message, stack != null ? stack : '');
- }
- }
- }
- }
-}
-
-module.exports = checkPropTypes;
-
-}).call(this,require('_process'))
-},{"./lib/ReactPropTypesSecret":11,"_process":6,"fbjs/lib/invariant":3,"fbjs/lib/warning":4}],8:[function(require,module,exports){
-/**
- * Copyright 2013-present, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
-
-'use strict';
-
-var emptyFunction = require('fbjs/lib/emptyFunction');
-var invariant = require('fbjs/lib/invariant');
-var ReactPropTypesSecret = require('./lib/ReactPropTypesSecret');
-
-module.exports = function() {
- function shim(props, propName, componentName, location, propFullName, secret) {
- if (secret === ReactPropTypesSecret) {
- // It is still safe when called from React.
- return;
- }
- invariant(
- false,
- 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
- 'Use PropTypes.checkPropTypes() to call them. ' +
- 'Read more at http://fb.me/use-check-prop-types'
- );
- };
- shim.isRequired = shim;
- function getShim() {
- return shim;
- };
- // Important!
- // Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.
- var ReactPropTypes = {
- array: shim,
- bool: shim,
- func: shim,
- number: shim,
- object: shim,
- string: shim,
- symbol: shim,
-
- any: shim,
- arrayOf: getShim,
- element: shim,
- instanceOf: getShim,
- node: shim,
- objectOf: getShim,
- oneOf: getShim,
- oneOfType: getShim,
- shape: getShim
- };
-
- ReactPropTypes.checkPropTypes = emptyFunction;
- ReactPropTypes.PropTypes = ReactPropTypes;
-
- return ReactPropTypes;
-};
-
-},{"./lib/ReactPropTypesSecret":11,"fbjs/lib/emptyFunction":2,"fbjs/lib/invariant":3}],9:[function(require,module,exports){
-(function (process){
-/**
- * Copyright 2013-present, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
-
-'use strict';
-
-var emptyFunction = require('fbjs/lib/emptyFunction');
-var invariant = require('fbjs/lib/invariant');
-var warning = require('fbjs/lib/warning');
-
-var ReactPropTypesSecret = require('./lib/ReactPropTypesSecret');
-var checkPropTypes = require('./checkPropTypes');
-
-module.exports = function(isValidElement, throwOnDirectAccess) {
- /* global Symbol */
- var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
- var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec.
-
- /**
- * Returns the iterator method function contained on the iterable object.
- *
- * Be sure to invoke the function with the iterable as context:
- *
- * var iteratorFn = getIteratorFn(myIterable);
- * if (iteratorFn) {
- * var iterator = iteratorFn.call(myIterable);
- * ...
- * }
- *
- * @param {?object} maybeIterable
- * @return {?function}
- */
- function getIteratorFn(maybeIterable) {
- var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);
- if (typeof iteratorFn === 'function') {
- return iteratorFn;
- }
- }
-
- /**
- * Collection of methods that allow declaration and validation of props that are
- * supplied to React components. Example usage:
- *
- * var Props = require('ReactPropTypes');
- * var MyArticle = React.createClass({
- * propTypes: {
- * // An optional string prop named "description".
- * description: Props.string,
- *
- * // A required enum prop named "category".
- * category: Props.oneOf(['News','Photos']).isRequired,
- *
- * // A prop named "dialog" that requires an instance of Dialog.
- * dialog: Props.instanceOf(Dialog).isRequired
- * },
- * render: function() { ... }
- * });
- *
- * A more formal specification of how these methods are used:
- *
- * type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...)
- * decl := ReactPropTypes.{type}(.isRequired)?
- *
- * Each and every declaration produces a function with the same signature. This
- * allows the creation of custom validation functions. For example:
- *
- * var MyLink = React.createClass({
- * propTypes: {
- * // An optional string or URI prop named "href".
- * href: function(props, propName, componentName) {
- * var propValue = props[propName];
- * if (propValue != null && typeof propValue !== 'string' &&
- * !(propValue instanceof URI)) {
- * return new Error(
- * 'Expected a string or an URI for ' + propName + ' in ' +
- * componentName
- * );
- * }
- * }
- * },
- * render: function() {...}
- * });
- *
- * @internal
- */
-
- var ANONYMOUS = '<>';
-
- // Important!
- // Keep this list in sync with production version in `./factoryWithThrowingShims.js`.
- var ReactPropTypes = {
- array: createPrimitiveTypeChecker('array'),
- bool: createPrimitiveTypeChecker('boolean'),
- func: createPrimitiveTypeChecker('function'),
- number: createPrimitiveTypeChecker('number'),
- object: createPrimitiveTypeChecker('object'),
- string: createPrimitiveTypeChecker('string'),
- symbol: createPrimitiveTypeChecker('symbol'),
-
- any: createAnyTypeChecker(),
- arrayOf: createArrayOfTypeChecker,
- element: createElementTypeChecker(),
- instanceOf: createInstanceTypeChecker,
- node: createNodeChecker(),
- objectOf: createObjectOfTypeChecker,
- oneOf: createEnumTypeChecker,
- oneOfType: createUnionTypeChecker,
- shape: createShapeTypeChecker
- };
-
- /**
- * inlined Object.is polyfill to avoid requiring consumers ship their own
- * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
- */
- /*eslint-disable no-self-compare*/
- function is(x, y) {
- // SameValue algorithm
- if (x === y) {
- // Steps 1-5, 7-10
- // Steps 6.b-6.e: +0 != -0
- return x !== 0 || 1 / x === 1 / y;
- } else {
- // Step 6.a: NaN == NaN
- return x !== x && y !== y;
- }
- }
- /*eslint-enable no-self-compare*/
-
- /**
- * We use an Error-like object for backward compatibility as people may call
- * PropTypes directly and inspect their output. However, we don't use real
- * Errors anymore. We don't inspect their stack anyway, and creating them
- * is prohibitively expensive if they are created too often, such as what
- * happens in oneOfType() for any type before the one that matched.
- */
- function PropTypeError(message) {
- this.message = message;
- this.stack = '';
- }
- // Make `instanceof Error` still work for returned errors.
- PropTypeError.prototype = Error.prototype;
-
- function createChainableTypeChecker(validate) {
- if (process.env.NODE_ENV !== 'production') {
- var manualPropTypeCallCache = {};
- var manualPropTypeWarningCount = 0;
- }
- function checkType(isRequired, props, propName, componentName, location, propFullName, secret) {
- componentName = componentName || ANONYMOUS;
- propFullName = propFullName || propName;
-
- if (secret !== ReactPropTypesSecret) {
- if (throwOnDirectAccess) {
- // New behavior only for users of `prop-types` package
- invariant(
- false,
- 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
- 'Use `PropTypes.checkPropTypes()` to call them. ' +
- 'Read more at http://fb.me/use-check-prop-types'
- );
- } else if (process.env.NODE_ENV !== 'production' && typeof console !== 'undefined') {
- // Old behavior for people using React.PropTypes
- var cacheKey = componentName + ':' + propName;
- if (
- !manualPropTypeCallCache[cacheKey] &&
- // Avoid spamming the console because they are often not actionable except for lib authors
- manualPropTypeWarningCount < 3
- ) {
- warning(
- false,
- 'You are manually calling a React.PropTypes validation ' +
- 'function for the `%s` prop on `%s`. This is deprecated ' +
- 'and will throw in the standalone `prop-types` package. ' +
- 'You may be seeing this warning due to a third-party PropTypes ' +
- 'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.',
- propFullName,
- componentName
- );
- manualPropTypeCallCache[cacheKey] = true;
- manualPropTypeWarningCount++;
- }
- }
- }
- if (props[propName] == null) {
- if (isRequired) {
- if (props[propName] === null) {
- return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.'));
- }
- return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.'));
- }
- return null;
- } else {
- return validate(props, propName, componentName, location, propFullName);
- }
- }
-
- var chainedCheckType = checkType.bind(null, false);
- chainedCheckType.isRequired = checkType.bind(null, true);
-
- return chainedCheckType;
- }
-
- function createPrimitiveTypeChecker(expectedType) {
- function validate(props, propName, componentName, location, propFullName, secret) {
- var propValue = props[propName];
- var propType = getPropType(propValue);
- if (propType !== expectedType) {
- // `propValue` being instance of, say, date/regexp, pass the 'object'
- // check, but we can offer a more precise error message here rather than
- // 'of type `object`'.
- var preciseType = getPreciseType(propValue);
-
- return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'));
- }
- return null;
- }
- return createChainableTypeChecker(validate);
- }
-
- function createAnyTypeChecker() {
- return createChainableTypeChecker(emptyFunction.thatReturnsNull);
- }
-
- function createArrayOfTypeChecker(typeChecker) {
- function validate(props, propName, componentName, location, propFullName) {
- if (typeof typeChecker !== 'function') {
- return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.');
- }
- var propValue = props[propName];
- if (!Array.isArray(propValue)) {
- var propType = getPropType(propValue);
- return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));
- }
- for (var i = 0; i < propValue.length; i++) {
- var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret);
- if (error instanceof Error) {
- return error;
- }
- }
- return null;
- }
- return createChainableTypeChecker(validate);
- }
-
- function createElementTypeChecker() {
- function validate(props, propName, componentName, location, propFullName) {
- var propValue = props[propName];
- if (!isValidElement(propValue)) {
- var propType = getPropType(propValue);
- return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.'));
- }
- return null;
- }
- return createChainableTypeChecker(validate);
- }
-
- function createInstanceTypeChecker(expectedClass) {
- function validate(props, propName, componentName, location, propFullName) {
- if (!(props[propName] instanceof expectedClass)) {
- var expectedClassName = expectedClass.name || ANONYMOUS;
- var actualClassName = getClassName(props[propName]);
- return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.'));
- }
- return null;
- }
- return createChainableTypeChecker(validate);
- }
-
- function createEnumTypeChecker(expectedValues) {
- if (!Array.isArray(expectedValues)) {
- process.env.NODE_ENV !== 'production' ? warning(false, 'Invalid argument supplied to oneOf, expected an instance of array.') : void 0;
- return emptyFunction.thatReturnsNull;
- }
-
- function validate(props, propName, componentName, location, propFullName) {
- var propValue = props[propName];
- for (var i = 0; i < expectedValues.length; i++) {
- if (is(propValue, expectedValues[i])) {
- return null;
- }
- }
-
- var valuesString = JSON.stringify(expectedValues);
- return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + propValue + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));
- }
- return createChainableTypeChecker(validate);
- }
-
- function createObjectOfTypeChecker(typeChecker) {
- function validate(props, propName, componentName, location, propFullName) {
- if (typeof typeChecker !== 'function') {
- return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.');
- }
- var propValue = props[propName];
- var propType = getPropType(propValue);
- if (propType !== 'object') {
- return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
- }
- for (var key in propValue) {
- if (propValue.hasOwnProperty(key)) {
- var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
- if (error instanceof Error) {
- return error;
- }
- }
- }
- return null;
- }
- return createChainableTypeChecker(validate);
- }
-
- function createUnionTypeChecker(arrayOfTypeCheckers) {
- if (!Array.isArray(arrayOfTypeCheckers)) {
- process.env.NODE_ENV !== 'production' ? warning(false, 'Invalid argument supplied to oneOfType, expected an instance of array.') : void 0;
- return emptyFunction.thatReturnsNull;
- }
-
- for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
- var checker = arrayOfTypeCheckers[i];
- if (typeof checker !== 'function') {
- warning(
- false,
- 'Invalid argument supplid to oneOfType. Expected an array of check functions, but ' +
- 'received %s at index %s.',
- getPostfixForTypeWarning(checker),
- i
- );
- return emptyFunction.thatReturnsNull;
- }
- }
-
- function validate(props, propName, componentName, location, propFullName) {
- for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
- var checker = arrayOfTypeCheckers[i];
- if (checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret) == null) {
- return null;
- }
- }
-
- return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`.'));
- }
- return createChainableTypeChecker(validate);
- }
-
- function createNodeChecker() {
- function validate(props, propName, componentName, location, propFullName) {
- if (!isNode(props[propName])) {
- return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));
- }
- return null;
- }
- return createChainableTypeChecker(validate);
- }
-
- function createShapeTypeChecker(shapeTypes) {
- function validate(props, propName, componentName, location, propFullName) {
- var propValue = props[propName];
- var propType = getPropType(propValue);
- if (propType !== 'object') {
- return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
- }
- for (var key in shapeTypes) {
- var checker = shapeTypes[key];
- if (!checker) {
- continue;
- }
- var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
- if (error) {
- return error;
- }
- }
- return null;
- }
- return createChainableTypeChecker(validate);
- }
-
- function isNode(propValue) {
- switch (typeof propValue) {
- case 'number':
- case 'string':
- case 'undefined':
- return true;
- case 'boolean':
- return !propValue;
- case 'object':
- if (Array.isArray(propValue)) {
- return propValue.every(isNode);
- }
- if (propValue === null || isValidElement(propValue)) {
- return true;
- }
-
- var iteratorFn = getIteratorFn(propValue);
- if (iteratorFn) {
- var iterator = iteratorFn.call(propValue);
- var step;
- if (iteratorFn !== propValue.entries) {
- while (!(step = iterator.next()).done) {
- if (!isNode(step.value)) {
- return false;
- }
- }
- } else {
- // Iterator will provide entry [k,v] tuples rather than values.
- while (!(step = iterator.next()).done) {
- var entry = step.value;
- if (entry) {
- if (!isNode(entry[1])) {
- return false;
- }
- }
- }
- }
- } else {
- return false;
- }
-
- return true;
- default:
- return false;
- }
- }
-
- function isSymbol(propType, propValue) {
- // Native Symbol.
- if (propType === 'symbol') {
- return true;
- }
-
- // 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol'
- if (propValue['@@toStringTag'] === 'Symbol') {
- return true;
- }
-
- // Fallback for non-spec compliant Symbols which are polyfilled.
- if (typeof Symbol === 'function' && propValue instanceof Symbol) {
- return true;
- }
-
- return false;
- }
-
- // Equivalent of `typeof` but with special handling for array and regexp.
- function getPropType(propValue) {
- var propType = typeof propValue;
- if (Array.isArray(propValue)) {
- return 'array';
- }
- if (propValue instanceof RegExp) {
- // Old webkits (at least until Android 4.0) return 'function' rather than
- // 'object' for typeof a RegExp. We'll normalize this here so that /bla/
- // passes PropTypes.object.
- return 'object';
- }
- if (isSymbol(propType, propValue)) {
- return 'symbol';
- }
- return propType;
- }
-
- // This handles more types than `getPropType`. Only used for error messages.
- // See `createPrimitiveTypeChecker`.
- function getPreciseType(propValue) {
- if (typeof propValue === 'undefined' || propValue === null) {
- return '' + propValue;
- }
- var propType = getPropType(propValue);
- if (propType === 'object') {
- if (propValue instanceof Date) {
- return 'date';
- } else if (propValue instanceof RegExp) {
- return 'regexp';
- }
- }
- return propType;
- }
-
- // Returns a string that is postfixed to a warning about an invalid type.
- // For example, "undefined" or "of type array"
- function getPostfixForTypeWarning(value) {
- var type = getPreciseType(value);
- switch (type) {
- case 'array':
- case 'object':
- return 'an ' + type;
- case 'boolean':
- case 'date':
- case 'regexp':
- return 'a ' + type;
- default:
- return type;
- }
- }
-
- // Returns class name of the object, if any.
- function getClassName(propValue) {
- if (!propValue.constructor || !propValue.constructor.name) {
- return ANONYMOUS;
- }
- return propValue.constructor.name;
- }
-
- ReactPropTypes.checkPropTypes = checkPropTypes;
- ReactPropTypes.PropTypes = ReactPropTypes;
-
- return ReactPropTypes;
-};
-
-}).call(this,require('_process'))
-},{"./checkPropTypes":7,"./lib/ReactPropTypesSecret":11,"_process":6,"fbjs/lib/emptyFunction":2,"fbjs/lib/invariant":3,"fbjs/lib/warning":4}],10:[function(require,module,exports){
-(function (process){
-/**
- * Copyright 2013-present, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
-
-if (process.env.NODE_ENV !== 'production') {
- var REACT_ELEMENT_TYPE = (typeof Symbol === 'function' &&
- Symbol.for &&
- Symbol.for('react.element')) ||
- 0xeac7;
-
- var isValidElement = function(object) {
- return typeof object === 'object' &&
- object !== null &&
- object.$$typeof === REACT_ELEMENT_TYPE;
- };
-
- // By explicitly using `prop-types` you are opting into new development behavior.
- // http://fb.me/prop-types-in-prod
- var throwOnDirectAccess = true;
- module.exports = require('./factoryWithTypeCheckers')(isValidElement, throwOnDirectAccess);
-} else {
- // By explicitly using `prop-types` you are opting into new production behavior.
- // http://fb.me/prop-types-in-prod
- module.exports = require('./factoryWithThrowingShims')();
-}
-
-}).call(this,require('_process'))
-},{"./factoryWithThrowingShims":8,"./factoryWithTypeCheckers":9,"_process":6}],11:[function(require,module,exports){
-/**
- * Copyright 2013-present, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
-
-'use strict';
-
-var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
-
-module.exports = ReactPropTypesSecret;
-
-},{}],12:[function(require,module,exports){
-/* eslint-disable no-undefined,no-param-reassign,no-shadow */
-
-/**
- * Throttle execution of a function. Especially useful for rate limiting
- * execution of handlers on events like resize and scroll.
- *
- * @param {Number} delay A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful.
- * @param {Boolean} noTrailing Optional, defaults to false. If noTrailing is true, callback will only execute every `delay` milliseconds while the
- * throttled-function is being called. If noTrailing is false or unspecified, callback will be executed one final time
- * after the last throttled-function call. (After the throttled-function has not been called for `delay` milliseconds,
- * the internal counter is reset)
- * @param {Function} callback A function to be executed after delay milliseconds. The `this` context and all arguments are passed through, as-is,
- * to `callback` when the throttled-function is executed.
- * @param {Boolean} debounceMode If `debounceMode` is true (at begin), schedule `clear` to execute after `delay` ms. If `debounceMode` is false (at end),
- * schedule `callback` to execute after `delay` ms.
- *
- * @return {Function} A new, throttled, function.
- */
-module.exports = function ( delay, noTrailing, callback, debounceMode ) {
-
- // After wrapper has stopped being called, this timeout ensures that
- // `callback` is executed at the proper times in `throttle` and `end`
- // debounce modes.
- var timeoutID;
-
- // Keep track of the last time `callback` was executed.
- var lastExec = 0;
-
- // `noTrailing` defaults to falsy.
- if ( typeof noTrailing !== 'boolean' ) {
- debounceMode = callback;
- callback = noTrailing;
- noTrailing = undefined;
- }
-
- // The `wrapper` function encapsulates all of the throttling / debouncing
- // functionality and when executed will limit the rate at which `callback`
- // is executed.
- function wrapper () {
-
- var self = this;
- var elapsed = Number(new Date()) - lastExec;
- var args = arguments;
-
- // Execute `callback` and update the `lastExec` timestamp.
- function exec () {
- lastExec = Number(new Date());
- callback.apply(self, args);
- }
-
- // If `debounceMode` is true (at begin) this is used to clear the flag
- // to allow future `callback` executions.
- function clear () {
- timeoutID = undefined;
- }
-
- if ( debounceMode && !timeoutID ) {
- // Since `wrapper` is being called for the first time and
- // `debounceMode` is true (at begin), execute `callback`.
- exec();
- }
-
- // Clear any existing timeout.
- if ( timeoutID ) {
- clearTimeout(timeoutID);
- }
-
- if ( debounceMode === undefined && elapsed > delay ) {
- // In throttle mode, if `delay` time has been exceeded, execute
- // `callback`.
- exec();
-
- } else if ( noTrailing !== true ) {
- // In trailing throttle mode, since `delay` time has not been
- // exceeded, schedule `callback` to execute `delay` ms after most
- // recent execution.
- //
- // If `debounceMode` is true (at begin), schedule `clear` to execute
- // after `delay` ms.
- //
- // If `debounceMode` is false (at end), schedule `callback` to
- // execute after `delay` ms.
- timeoutID = setTimeout(debounceMode ? clear : exec, debounceMode === undefined ? delay - elapsed : delay);
- }
-
- }
-
- // Return the wrapper function.
- return wrapper;
-
-};
-
-},{}],13:[function(require,module,exports){
-"use strict";
-
-Object.defineProperty(exports, "__esModule", {
- value: true
-});
-
-var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
-
-exports.default = createPlotlyComponent;
-
-var _react = (window.React);
-
-var _react2 = _interopRequireDefault(_react);
-
-var _propTypes = require("prop-types");
-
-var _propTypes2 = _interopRequireDefault(_propTypes);
-
-var _fastIsnumeric = require("fast-isnumeric");
-
-var _fastIsnumeric2 = _interopRequireDefault(_fastIsnumeric);
-
-var _objectAssign = require("object-assign");
-
-var _objectAssign2 = _interopRequireDefault(_objectAssign);
-
-var _throttle = require("throttle-debounce/throttle");
-
-var _throttle2 = _interopRequireDefault(_throttle);
-
-function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
-
-function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
-
-function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
-
-function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
-
-function constructUpdate(diff) {
- var keys = Object.keys(diff);
-}
-
-// The naming convention is:
-// - events are attached as `'plotly_' + eventName.toLowerCase()`
-// - react props are `'on' + eventName`
-var eventNames = ["AfterExport", "AfterPlot", "Animated", "AnimatingFrame", "AnimationInterrupted", "AutoSize", "BeforeExport", "ButtonClicked", "Click", "ClickAnnotation", "Deselect", "DoubleClick", "Framework", "Hover", "Relayout", "Restyle", "Redraw", "Selected", "Selecting", "SliderChange", "SliderEnd", "SliderStart", "Transitioning", "TransitionInterrupted", "Unhover"];
-
-var updateEvents = ["plotly_restyle", "plotly_redraw", "plotly_relayout", "plotly_doubleclick", "plotly_animated"];
-
-// Check if a window is available since SSR (server-side rendering)
-// breaks unnecessarily if you try to use it server-side.
-var isBrowser = typeof window !== "undefined";
-
-function createPlotlyComponent(Plotly) {
- var hasReactAPIMethod = !!Plotly.react;
-
- var PlotlyComponent = function (_Component) {
- _inherits(PlotlyComponent, _Component);
-
- function PlotlyComponent(props) {
- _classCallCheck(this, PlotlyComponent);
-
- var _this = _possibleConstructorReturn(this, (PlotlyComponent.__proto__ || Object.getPrototypeOf(PlotlyComponent)).call(this, props));
-
- _this.p = Promise.resolve();
- _this.resizeHandler = null;
- _this.handlers = {};
-
- _this.syncWindowResize = _this.syncWindowResize.bind(_this);
- _this.syncEventHandlers = _this.syncEventHandlers.bind(_this);
- _this.attachUpdateEvents = _this.attachUpdateEvents.bind(_this);
- _this.getRef = _this.getRef.bind(_this);
-
- _this.handleUpdate = (0, _throttle2.default)(20, _this.handleUpdate.bind(_this));
- return _this;
- }
-
- _createClass(PlotlyComponent, [{
- key: "componentDidMount",
- value: function componentDidMount() {
- var _this2 = this;
-
- this.p = this.p.then(function () {
- return Plotly.newPlot(_this2.el, {
- data: _this2.props.data,
- layout: _this2.sizeAdjustedLayout(_this2.props.layout),
- config: _this2.props.config,
- frames: _this2.props.frames
- });
- }).then(this.attachUpdateEvents).then(function () {
- return _this2.syncWindowResize(null, false);
- }).then(function () {
- return _this2.syncEventHandlers();
- }).then(function () {
- _this2.props.onInitialized && _this2.props.onInitialized();
- }, function () {
- _this2.props.onError && _this2.props.onError();
- });
- }
- }, {
- key: "componentWillReceiveProps",
- value: function componentWillReceiveProps(nextProps) {
- var _this3 = this;
-
- var dataDiff = void 0,
- layoutDiff = void 0,
- configDiff = void 0;
- var nextLayout = this.sizeAdjustedLayout(nextProps.layout);
-
- this.p = this.p.then(function () {
- if (hasReactAPIMethod) {
- return Plotly.react(_this3.el, {
- data: nextProps.data,
- layout: nextLayout,
- config: nextProps.config,
- frames: nextProps.frames
- });
- } else {
- return Plotly.newPlot(_this3.el, {
- data: nextProps.data,
- layout: nextLayout,
- config: nextProps.config,
- frames: nextProps.frames
- });
- }
- }).then(function () {
- return _this3.syncEventHandlers(nextProps);
- }).then(function () {
- return _this3.syncWindowResize(nextProps);
- }).then(function () {
- return function () {
- return _this3.handleUpdate(nextProps);
- };
- }).catch(function (err) {
- _this3.props.onError && _this3.props.onError(err);
- });
- }
- }, {
- key: "componentWillUnmount",
- value: function componentWillUnmount() {
- if (this.resizeHandler && isBrowser) {
- window.removeEventListener("resize", this.handleResize);
- this.resizeHandler = null;
- }
-
- this.removeUpdateEvents();
-
- Plotly.purge(this.el);
- }
- }, {
- key: "attachUpdateEvents",
- value: function attachUpdateEvents() {
- for (var i = 0; i < updateEvents.length; i++) {
- this.el.on(updateEvents[i], this.handleUpdate);
- }
- }
- }, {
- key: "removeUpdateEvents",
- value: function removeUpdateEvents() {
- if (!this.el || !this.el.off) return;
-
- for (var i = 0; i < updateEvents.length; i++) {
- this.el.off(updateEvents[i], this.handleUpdate);
- }
- }
- }, {
- key: "handleUpdate",
- value: function handleUpdate(props) {
- props = props || this.props;
- if (props.onUpdate && typeof props.onUpdate === "function") {
- props.onUpdate(this.el);
- }
- }
- }, {
- key: "syncWindowResize",
- value: function syncWindowResize(props, invoke) {
- var _this4 = this;
-
- props = props || this.props;
- if (!isBrowser) return;
-
- if (props.fit && !this.resizeHandler) {
- this.resizeHandler = function () {
- return Plotly.relayout(_this4.el, _this4.getSize());
- };
- window.addEventListener("resize", this.resizeHandler);
-
- if (invoke) return this.resizeHandler();
- } else if (!props.fit && this.resizeHandler) {
- window.removeEventListener("resize", this.resizeHandler);
- this.resizeHandler = null;
- }
- }
- }, {
- key: "getRef",
- value: function getRef(el) {
- this.el = el;
-
- if (this.props.debug && isBrowser) {
- window.gd = this.el;
- }
- }
-
- // Attach and remove event handlers as they're added or removed from props:
-
- }, {
- key: "syncEventHandlers",
- value: function syncEventHandlers(props) {
- // Allow use of nextProps if passed explicitly:
- props = props || this.props;
-
- for (var i = 0; i < eventNames.length; i++) {
- var eventName = eventNames[i];
- var prop = props["on" + eventName];
- var hasHandler = !!this.handlers[eventName];
-
- if (prop && !hasHandler) {
- var handler = this.handlers[eventName] = props["on" + eventName];
- this.el.on("plotly_" + eventName.toLowerCase(), handler);
- } else if (!prop && hasHandler) {
- // Needs to be removed:
- this.el.off("plotly_" + eventName.toLowerCase(), this.handlers[eventName]);
- delete this.handlers[eventName];
- }
- }
- }
- }, {
- key: "sizeAdjustedLayout",
- value: function sizeAdjustedLayout(layout) {
- if (this.props.fit) {
- layout = (0, _objectAssign2.default)({}, layout);
- (0, _objectAssign2.default)(layout, this.getSize(layout));
- }
-
- return layout;
- }
- }, {
- key: "getParentSize",
- value: function getParentSize() {
- return this.el.parentElement.getBoundingClientRect();
- }
- }, {
- key: "getSize",
- value: function getSize(layout) {
- var rect = void 0;
- layout = layout || this.props.layout;
- var layoutWidth = layout ? layout.width : null;
- var layoutHeight = layout ? layout.height : null;
- var hasWidth = (0, _fastIsnumeric2.default)(layoutWidth);
- var hasHeight = (0, _fastIsnumeric2.default)(layoutHeight);
-
- if (!hasWidth || !hasHeight) {
- rect = this.getParentSize();
- }
-
- return {
- width: hasWidth ? parseInt(layoutWidth) : rect.width,
- height: hasHeight ? parseInt(layoutHeight) : rect.height
- };
- }
- }, {
- key: "render",
- value: function render() {
- return _react2.default.createElement("div", { ref: this.getRef });
- }
- }]);
-
- return PlotlyComponent;
- }(_react.Component);
-
- PlotlyComponent.propTypes = {
- fit: _propTypes2.default.bool,
- data: _propTypes2.default.arrayOf(_propTypes2.default.object),
- config: _propTypes2.default.object,
- layout: _propTypes2.default.object,
- frames: _propTypes2.default.arrayOf(_propTypes2.default.object),
- onInitialized: _propTypes2.default.func
- };
-
- for (var i = 0; i < eventNames.length; i++) {
- PlotlyComponent.propTypes["on" + eventNames[i]] = _propTypes2.default.func;
- }
-
- PlotlyComponent.defaultProps = {
- fit: false,
- data: []
- };
-
- return PlotlyComponent;
-}
-
-},{"fast-isnumeric":1,"object-assign":5,"prop-types":10,"throttle-debounce/throttle":12}]},{},[13])(13)
-});
\ No newline at end of file
diff --git a/build/plotly.js-react.min.js b/build/plotly.js-react.min.js
deleted file mode 100644
index a916113..0000000
--- a/build/plotly.js-react.min.js
+++ /dev/null
@@ -1 +0,0 @@
-!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).createPlotlyComponent=e()}}(function(){return function e(t,n,r){function o(a,u){if(!n[a]){if(!t[a]){var s="function"==typeof require&&require;if(!u&&s)return s(a,!0);if(i)return i(a,!0);var c=new Error("Cannot find module '"+a+"'");throw c.code="MODULE_NOT_FOUND",c}var f=n[a]={exports:{}};t[a][0].call(f.exports,function(e){var n=t[a][1][e];return o(n||e)},f,f.exports,e,t,n,r)}return n[a].exports}for(var i="function"==typeof require&&require,a=0;a13)&&32!==t&&133!==t&&160!==t&&5760!==t&&6158!==t&&(t<8192||t>8205)&&8232!==t&&8233!==t&&8239!==t&&8287!==t&&8288!==t&&12288!==t&&65279!==t)return!1;return!0}t.exports=function(e){var t=typeof e;if("string"===t){var n=e;if(0===(e=+e)&&r(n))return!1}else if("number"!==t)return!1;return e-e<1}},{}],2:[function(e,t,n){"use strict";function r(e){return function(){return e}}var o=function(){};o.thatReturns=r,o.thatReturnsFalse=r(!1),o.thatReturnsTrue=r(!0),o.thatReturnsNull=r(null),o.thatReturnsThis=function(){return this},o.thatReturnsArgument=function(e){return e},t.exports=o},{}],3:[function(e,t,n){(function(e){"use strict";var n=function(e){};"production"!==e.env.NODE_ENV&&(n=function(e){if(void 0===e)throw new Error("invariant requires an error message argument")}),t.exports=function(e,t,r,o,i,a,u,s){if(n(t),!e){var c;if(void 0===t)c=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var f=[r,o,i,a,u,s],l=0;(c=new Error(t.replace(/%s/g,function(){return f[l++]}))).name="Invariant Violation"}throw c.framesToPop=1,c}}}).call(this,e("_process"))},{_process:6}],4:[function(e,t,n){(function(n){"use strict";var r=e("./emptyFunction");if("production"!==n.env.NODE_ENV){var o=function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r2?n-2:0),i=2;i1)for(var n=1;n>",T={array:p("array"),bool:p("boolean"),func:p("function"),number:p("number"),object:p("object"),string:p("string"),symbol:p("symbol"),any:l(r.thatReturnsNull),arrayOf:function(e){return l(function(t,n,r,o,i){if("function"!=typeof e)return new f("Property `"+i+"` of component `"+r+"` has invalid PropType notation inside arrayOf.");var u=t[n];if(!Array.isArray(u))return new f("Invalid "+o+" `"+i+"` of type `"+h(u)+"` supplied to `"+r+"`, expected an array.");for(var s=0;se?a():!0!==t&&(o=setTimeout(r?function(){o=void 0}:a,void 0===r?e-s:e))}}},{}],13:[function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(n,"__esModule",{value:!0});var u=function(){function e(e,t){for(var n=0;n
- * but significantly simplified and sped up by ignoring number and string constructors
- * ie these return false:
- * new Number(1)
- * new String('1')
- */
-
-'use strict';
-
-/**
- * Is this string all whitespace?
- * This solution kind of makes my brain hurt, but it's significantly faster
- * than !str.trim() or any other solution I could find.
- *
- * whitespace codes from: http://en.wikipedia.org/wiki/Whitespace_character
- * and verified with:
- *
- * for(var i = 0; i < 65536; i++) {
- * var s = String.fromCharCode(i);
- * if(+s===0 && !s.trim()) console.log(i, s);
- * }
- *
- * which counts a couple of these as *not* whitespace, but finds nothing else
- * that *is* whitespace. Note that charCodeAt stops at 16 bits, but it appears
- * that there are no whitespace characters above this, and code points above
- * this do not map onto white space characters.
- */
-function allBlankCharCodes(str){
- var l = str.length,
- a;
- for(var i = 0; i < l; i++) {
- a = str.charCodeAt(i);
- if((a < 9 || a > 13) && (a !== 32) && (a !== 133) && (a !== 160) &&
- (a !== 5760) && (a !== 6158) && (a < 8192 || a > 8205) &&
- (a !== 8232) && (a !== 8233) && (a !== 8239) && (a !== 8287) &&
- (a !== 8288) && (a !== 12288) && (a !== 65279)) {
- return false;
- }
- }
- return true;
-}
-
-module.exports = function(n) {
- var type = typeof n;
- if(type === 'string') {
- var original = n;
- n = +n;
- // whitespace strings cast to zero - filter them out
- if(n===0 && allBlankCharCodes(original)) return false;
- }
- else if(type !== 'number') return false;
-
- return n - n < 1;
-};
-
-},{}],2:[function(require,module,exports){
-"use strict";
-
-/**
- * Copyright (c) 2013-present, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- *
- */
-
-function makeEmptyFunction(arg) {
- return function () {
- return arg;
- };
-}
-
-/**
- * This function accepts and discards inputs; it has no side effects. This is
- * primarily useful idiomatically for overridable function endpoints which
- * always need to be callable, since JS lacks a null-call idiom ala Cocoa.
- */
-var emptyFunction = function emptyFunction() {};
-
-emptyFunction.thatReturns = makeEmptyFunction;
-emptyFunction.thatReturnsFalse = makeEmptyFunction(false);
-emptyFunction.thatReturnsTrue = makeEmptyFunction(true);
-emptyFunction.thatReturnsNull = makeEmptyFunction(null);
-emptyFunction.thatReturnsThis = function () {
- return this;
-};
-emptyFunction.thatReturnsArgument = function (arg) {
- return arg;
-};
-
-module.exports = emptyFunction;
-},{}],3:[function(require,module,exports){
-(function (process){
-/**
- * Copyright (c) 2013-present, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- */
-
-'use strict';
-
-/**
- * Use invariant() to assert state which your program assumes to be true.
- *
- * Provide sprintf-style format (only %s is supported) and arguments
- * to provide information about what broke and what you were
- * expecting.
- *
- * The invariant message will be stripped in production, but the invariant
- * will remain to ensure logic does not differ in production.
- */
-
-var validateFormat = function validateFormat(format) {};
-
-if (process.env.NODE_ENV !== 'production') {
- validateFormat = function validateFormat(format) {
- if (format === undefined) {
- throw new Error('invariant requires an error message argument');
- }
- };
-}
-
-function invariant(condition, format, a, b, c, d, e, f) {
- validateFormat(format);
-
- if (!condition) {
- var error;
- if (format === undefined) {
- error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
- } else {
- var args = [a, b, c, d, e, f];
- var argIndex = 0;
- error = new Error(format.replace(/%s/g, function () {
- return args[argIndex++];
- }));
- error.name = 'Invariant Violation';
- }
-
- error.framesToPop = 1; // we don't care about invariant's own frame
- throw error;
- }
-}
-
-module.exports = invariant;
-}).call(this,require('_process'))
-},{"_process":6}],4:[function(require,module,exports){
-(function (process){
-/**
- * Copyright 2014-2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- */
-
-'use strict';
-
-var emptyFunction = require('./emptyFunction');
-
-/**
- * Similar to invariant but only logs a warning if the condition is not met.
- * This can be used to log issues in development environments in critical
- * paths. Removing the logging code for production environments will keep the
- * same logic and follow the same code paths.
- */
-
-var warning = emptyFunction;
-
-if (process.env.NODE_ENV !== 'production') {
- var printWarning = function printWarning(format) {
- for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
- args[_key - 1] = arguments[_key];
- }
-
- var argIndex = 0;
- var message = 'Warning: ' + format.replace(/%s/g, function () {
- return args[argIndex++];
- });
- if (typeof console !== 'undefined') {
- console.error(message);
- }
- try {
- // --- Welcome to debugging React ---
- // This error was thrown as a convenience so that you can use this stack
- // to find the callsite that caused this warning to fire.
- throw new Error(message);
- } catch (x) {}
- };
-
- warning = function warning(condition, format) {
- if (format === undefined) {
- throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument');
- }
-
- if (format.indexOf('Failed Composite propType: ') === 0) {
- return; // Ignore CompositeComponent proptype check.
- }
-
- if (!condition) {
- for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
- args[_key2 - 2] = arguments[_key2];
- }
-
- printWarning.apply(undefined, [format].concat(args));
- }
- };
-}
-
-module.exports = warning;
-}).call(this,require('_process'))
-},{"./emptyFunction":2,"_process":6}],5:[function(require,module,exports){
-/*
-object-assign
-(c) Sindre Sorhus
-@license MIT
-*/
-
-'use strict';
-/* eslint-disable no-unused-vars */
-var getOwnPropertySymbols = Object.getOwnPropertySymbols;
-var hasOwnProperty = Object.prototype.hasOwnProperty;
-var propIsEnumerable = Object.prototype.propertyIsEnumerable;
-
-function toObject(val) {
- if (val === null || val === undefined) {
- throw new TypeError('Object.assign cannot be called with null or undefined');
- }
-
- return Object(val);
-}
-
-function shouldUseNative() {
- try {
- if (!Object.assign) {
- return false;
- }
-
- // Detect buggy property enumeration order in older V8 versions.
-
- // https://bugs.chromium.org/p/v8/issues/detail?id=4118
- var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
- test1[5] = 'de';
- if (Object.getOwnPropertyNames(test1)[0] === '5') {
- return false;
- }
-
- // https://bugs.chromium.org/p/v8/issues/detail?id=3056
- var test2 = {};
- for (var i = 0; i < 10; i++) {
- test2['_' + String.fromCharCode(i)] = i;
- }
- var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
- return test2[n];
- });
- if (order2.join('') !== '0123456789') {
- return false;
- }
-
- // https://bugs.chromium.org/p/v8/issues/detail?id=3056
- var test3 = {};
- 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
- test3[letter] = letter;
- });
- if (Object.keys(Object.assign({}, test3)).join('') !==
- 'abcdefghijklmnopqrst') {
- return false;
- }
-
- return true;
- } catch (err) {
- // We don't expect any of the above to throw, but better to be safe.
- return false;
- }
-}
-
-module.exports = shouldUseNative() ? Object.assign : function (target, source) {
- var from;
- var to = toObject(target);
- var symbols;
-
- for (var s = 1; s < arguments.length; s++) {
- from = Object(arguments[s]);
-
- for (var key in from) {
- if (hasOwnProperty.call(from, key)) {
- to[key] = from[key];
- }
- }
-
- if (getOwnPropertySymbols) {
- symbols = getOwnPropertySymbols(from);
- for (var i = 0; i < symbols.length; i++) {
- if (propIsEnumerable.call(from, symbols[i])) {
- to[symbols[i]] = from[symbols[i]];
- }
- }
- }
- }
-
- return to;
-};
-
-},{}],6:[function(require,module,exports){
-// shim for using process in browser
-var process = module.exports = {};
-
-// cached from whatever global is present so that test runners that stub it
-// don't break things. But we need to wrap it in a try catch in case it is
-// wrapped in strict mode code which doesn't define any globals. It's inside a
-// function because try/catches deoptimize in certain engines.
-
-var cachedSetTimeout;
-var cachedClearTimeout;
-
-function defaultSetTimout() {
- throw new Error('setTimeout has not been defined');
-}
-function defaultClearTimeout () {
- throw new Error('clearTimeout has not been defined');
-}
-(function () {
- try {
- if (typeof setTimeout === 'function') {
- cachedSetTimeout = setTimeout;
- } else {
- cachedSetTimeout = defaultSetTimout;
- }
- } catch (e) {
- cachedSetTimeout = defaultSetTimout;
- }
- try {
- if (typeof clearTimeout === 'function') {
- cachedClearTimeout = clearTimeout;
- } else {
- cachedClearTimeout = defaultClearTimeout;
- }
- } catch (e) {
- cachedClearTimeout = defaultClearTimeout;
- }
-} ())
-function runTimeout(fun) {
- if (cachedSetTimeout === setTimeout) {
- //normal enviroments in sane situations
- return setTimeout(fun, 0);
- }
- // if setTimeout wasn't available but was latter defined
- if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
- cachedSetTimeout = setTimeout;
- return setTimeout(fun, 0);
- }
- try {
- // when when somebody has screwed with setTimeout but no I.E. maddness
- return cachedSetTimeout(fun, 0);
- } catch(e){
- try {
- // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
- return cachedSetTimeout.call(null, fun, 0);
- } catch(e){
- // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
- return cachedSetTimeout.call(this, fun, 0);
- }
- }
-
-
-}
-function runClearTimeout(marker) {
- if (cachedClearTimeout === clearTimeout) {
- //normal enviroments in sane situations
- return clearTimeout(marker);
- }
- // if clearTimeout wasn't available but was latter defined
- if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
- cachedClearTimeout = clearTimeout;
- return clearTimeout(marker);
- }
- try {
- // when when somebody has screwed with setTimeout but no I.E. maddness
- return cachedClearTimeout(marker);
- } catch (e){
- try {
- // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
- return cachedClearTimeout.call(null, marker);
- } catch (e){
- // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
- // Some versions of I.E. have different rules for clearTimeout vs setTimeout
- return cachedClearTimeout.call(this, marker);
- }
- }
-
-
-
-}
-var queue = [];
-var draining = false;
-var currentQueue;
-var queueIndex = -1;
-
-function cleanUpNextTick() {
- if (!draining || !currentQueue) {
- return;
- }
- draining = false;
- if (currentQueue.length) {
- queue = currentQueue.concat(queue);
- } else {
- queueIndex = -1;
- }
- if (queue.length) {
- drainQueue();
- }
-}
-
-function drainQueue() {
- if (draining) {
- return;
- }
- var timeout = runTimeout(cleanUpNextTick);
- draining = true;
-
- var len = queue.length;
- while(len) {
- currentQueue = queue;
- queue = [];
- while (++queueIndex < len) {
- if (currentQueue) {
- currentQueue[queueIndex].run();
- }
- }
- queueIndex = -1;
- len = queue.length;
- }
- currentQueue = null;
- draining = false;
- runClearTimeout(timeout);
-}
-
-process.nextTick = function (fun) {
- var args = new Array(arguments.length - 1);
- if (arguments.length > 1) {
- for (var i = 1; i < arguments.length; i++) {
- args[i - 1] = arguments[i];
- }
- }
- queue.push(new Item(fun, args));
- if (queue.length === 1 && !draining) {
- runTimeout(drainQueue);
- }
-};
-
-// v8 likes predictible objects
-function Item(fun, array) {
- this.fun = fun;
- this.array = array;
-}
-Item.prototype.run = function () {
- this.fun.apply(null, this.array);
-};
-process.title = 'browser';
-process.browser = true;
-process.env = {};
-process.argv = [];
-process.version = ''; // empty string to avoid regexp issues
-process.versions = {};
-
-function noop() {}
-
-process.on = noop;
-process.addListener = noop;
-process.once = noop;
-process.off = noop;
-process.removeListener = noop;
-process.removeAllListeners = noop;
-process.emit = noop;
-process.prependListener = noop;
-process.prependOnceListener = noop;
-
-process.listeners = function (name) { return [] }
-
-process.binding = function (name) {
- throw new Error('process.binding is not supported');
-};
-
-process.cwd = function () { return '/' };
-process.chdir = function (dir) {
- throw new Error('process.chdir is not supported');
-};
-process.umask = function() { return 0; };
-
-},{}],7:[function(require,module,exports){
-(function (process){
-/**
- * Copyright 2013-present, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
-
-'use strict';
-
-if (process.env.NODE_ENV !== 'production') {
- var invariant = require('fbjs/lib/invariant');
- var warning = require('fbjs/lib/warning');
- var ReactPropTypesSecret = require('./lib/ReactPropTypesSecret');
- var loggedTypeFailures = {};
-}
-
-/**
- * Assert that the values match with the type specs.
- * Error messages are memorized and will only be shown once.
- *
- * @param {object} typeSpecs Map of name to a ReactPropType
- * @param {object} values Runtime values that need to be type-checked
- * @param {string} location e.g. "prop", "context", "child context"
- * @param {string} componentName Name of the component for error messages.
- * @param {?Function} getStack Returns the component stack.
- * @private
- */
-function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
- if (process.env.NODE_ENV !== 'production') {
- for (var typeSpecName in typeSpecs) {
- if (typeSpecs.hasOwnProperty(typeSpecName)) {
- var error;
- // Prop type validation may throw. In case they do, we don't want to
- // fail the render phase where it didn't fail before. So we log it.
- // After these have been cleaned up, we'll let them throw.
- try {
- // This is intentionally an invariant that gets caught. It's the same
- // behavior as without this statement except with a better message.
- invariant(typeof typeSpecs[typeSpecName] === 'function', '%s: %s type `%s` is invalid; it must be a function, usually from ' + 'React.PropTypes.', componentName || 'React class', location, typeSpecName);
- error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
- } catch (ex) {
- error = ex;
- }
- warning(!error || error instanceof Error, '%s: type specification of %s `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error);
- if (error instanceof Error && !(error.message in loggedTypeFailures)) {
- // Only monitor this failure once because there tends to be a lot of the
- // same error.
- loggedTypeFailures[error.message] = true;
-
- var stack = getStack ? getStack() : '';
-
- warning(false, 'Failed %s type: %s%s', location, error.message, stack != null ? stack : '');
- }
- }
- }
- }
-}
-
-module.exports = checkPropTypes;
-
-}).call(this,require('_process'))
-},{"./lib/ReactPropTypesSecret":11,"_process":6,"fbjs/lib/invariant":3,"fbjs/lib/warning":4}],8:[function(require,module,exports){
-/**
- * Copyright 2013-present, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
-
-'use strict';
-
-var emptyFunction = require('fbjs/lib/emptyFunction');
-var invariant = require('fbjs/lib/invariant');
-var ReactPropTypesSecret = require('./lib/ReactPropTypesSecret');
-
-module.exports = function() {
- function shim(props, propName, componentName, location, propFullName, secret) {
- if (secret === ReactPropTypesSecret) {
- // It is still safe when called from React.
- return;
- }
- invariant(
- false,
- 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
- 'Use PropTypes.checkPropTypes() to call them. ' +
- 'Read more at http://fb.me/use-check-prop-types'
- );
- };
- shim.isRequired = shim;
- function getShim() {
- return shim;
- };
- // Important!
- // Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.
- var ReactPropTypes = {
- array: shim,
- bool: shim,
- func: shim,
- number: shim,
- object: shim,
- string: shim,
- symbol: shim,
-
- any: shim,
- arrayOf: getShim,
- element: shim,
- instanceOf: getShim,
- node: shim,
- objectOf: getShim,
- oneOf: getShim,
- oneOfType: getShim,
- shape: getShim
- };
-
- ReactPropTypes.checkPropTypes = emptyFunction;
- ReactPropTypes.PropTypes = ReactPropTypes;
-
- return ReactPropTypes;
-};
-
-},{"./lib/ReactPropTypesSecret":11,"fbjs/lib/emptyFunction":2,"fbjs/lib/invariant":3}],9:[function(require,module,exports){
-(function (process){
-/**
- * Copyright 2013-present, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
-
-'use strict';
-
-var emptyFunction = require('fbjs/lib/emptyFunction');
-var invariant = require('fbjs/lib/invariant');
-var warning = require('fbjs/lib/warning');
-
-var ReactPropTypesSecret = require('./lib/ReactPropTypesSecret');
-var checkPropTypes = require('./checkPropTypes');
-
-module.exports = function(isValidElement, throwOnDirectAccess) {
- /* global Symbol */
- var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
- var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec.
-
- /**
- * Returns the iterator method function contained on the iterable object.
- *
- * Be sure to invoke the function with the iterable as context:
- *
- * var iteratorFn = getIteratorFn(myIterable);
- * if (iteratorFn) {
- * var iterator = iteratorFn.call(myIterable);
- * ...
- * }
- *
- * @param {?object} maybeIterable
- * @return {?function}
- */
- function getIteratorFn(maybeIterable) {
- var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);
- if (typeof iteratorFn === 'function') {
- return iteratorFn;
- }
- }
-
- /**
- * Collection of methods that allow declaration and validation of props that are
- * supplied to React components. Example usage:
- *
- * var Props = require('ReactPropTypes');
- * var MyArticle = React.createClass({
- * propTypes: {
- * // An optional string prop named "description".
- * description: Props.string,
- *
- * // A required enum prop named "category".
- * category: Props.oneOf(['News','Photos']).isRequired,
- *
- * // A prop named "dialog" that requires an instance of Dialog.
- * dialog: Props.instanceOf(Dialog).isRequired
- * },
- * render: function() { ... }
- * });
- *
- * A more formal specification of how these methods are used:
- *
- * type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...)
- * decl := ReactPropTypes.{type}(.isRequired)?
- *
- * Each and every declaration produces a function with the same signature. This
- * allows the creation of custom validation functions. For example:
- *
- * var MyLink = React.createClass({
- * propTypes: {
- * // An optional string or URI prop named "href".
- * href: function(props, propName, componentName) {
- * var propValue = props[propName];
- * if (propValue != null && typeof propValue !== 'string' &&
- * !(propValue instanceof URI)) {
- * return new Error(
- * 'Expected a string or an URI for ' + propName + ' in ' +
- * componentName
- * );
- * }
- * }
- * },
- * render: function() {...}
- * });
- *
- * @internal
- */
-
- var ANONYMOUS = '<>';
-
- // Important!
- // Keep this list in sync with production version in `./factoryWithThrowingShims.js`.
- var ReactPropTypes = {
- array: createPrimitiveTypeChecker('array'),
- bool: createPrimitiveTypeChecker('boolean'),
- func: createPrimitiveTypeChecker('function'),
- number: createPrimitiveTypeChecker('number'),
- object: createPrimitiveTypeChecker('object'),
- string: createPrimitiveTypeChecker('string'),
- symbol: createPrimitiveTypeChecker('symbol'),
-
- any: createAnyTypeChecker(),
- arrayOf: createArrayOfTypeChecker,
- element: createElementTypeChecker(),
- instanceOf: createInstanceTypeChecker,
- node: createNodeChecker(),
- objectOf: createObjectOfTypeChecker,
- oneOf: createEnumTypeChecker,
- oneOfType: createUnionTypeChecker,
- shape: createShapeTypeChecker
- };
-
- /**
- * inlined Object.is polyfill to avoid requiring consumers ship their own
- * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
- */
- /*eslint-disable no-self-compare*/
- function is(x, y) {
- // SameValue algorithm
- if (x === y) {
- // Steps 1-5, 7-10
- // Steps 6.b-6.e: +0 != -0
- return x !== 0 || 1 / x === 1 / y;
- } else {
- // Step 6.a: NaN == NaN
- return x !== x && y !== y;
- }
- }
- /*eslint-enable no-self-compare*/
-
- /**
- * We use an Error-like object for backward compatibility as people may call
- * PropTypes directly and inspect their output. However, we don't use real
- * Errors anymore. We don't inspect their stack anyway, and creating them
- * is prohibitively expensive if they are created too often, such as what
- * happens in oneOfType() for any type before the one that matched.
- */
- function PropTypeError(message) {
- this.message = message;
- this.stack = '';
- }
- // Make `instanceof Error` still work for returned errors.
- PropTypeError.prototype = Error.prototype;
-
- function createChainableTypeChecker(validate) {
- if (process.env.NODE_ENV !== 'production') {
- var manualPropTypeCallCache = {};
- var manualPropTypeWarningCount = 0;
- }
- function checkType(isRequired, props, propName, componentName, location, propFullName, secret) {
- componentName = componentName || ANONYMOUS;
- propFullName = propFullName || propName;
-
- if (secret !== ReactPropTypesSecret) {
- if (throwOnDirectAccess) {
- // New behavior only for users of `prop-types` package
- invariant(
- false,
- 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
- 'Use `PropTypes.checkPropTypes()` to call them. ' +
- 'Read more at http://fb.me/use-check-prop-types'
- );
- } else if (process.env.NODE_ENV !== 'production' && typeof console !== 'undefined') {
- // Old behavior for people using React.PropTypes
- var cacheKey = componentName + ':' + propName;
- if (
- !manualPropTypeCallCache[cacheKey] &&
- // Avoid spamming the console because they are often not actionable except for lib authors
- manualPropTypeWarningCount < 3
- ) {
- warning(
- false,
- 'You are manually calling a React.PropTypes validation ' +
- 'function for the `%s` prop on `%s`. This is deprecated ' +
- 'and will throw in the standalone `prop-types` package. ' +
- 'You may be seeing this warning due to a third-party PropTypes ' +
- 'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.',
- propFullName,
- componentName
- );
- manualPropTypeCallCache[cacheKey] = true;
- manualPropTypeWarningCount++;
- }
- }
- }
- if (props[propName] == null) {
- if (isRequired) {
- if (props[propName] === null) {
- return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.'));
- }
- return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.'));
- }
- return null;
- } else {
- return validate(props, propName, componentName, location, propFullName);
- }
- }
-
- var chainedCheckType = checkType.bind(null, false);
- chainedCheckType.isRequired = checkType.bind(null, true);
-
- return chainedCheckType;
- }
-
- function createPrimitiveTypeChecker(expectedType) {
- function validate(props, propName, componentName, location, propFullName, secret) {
- var propValue = props[propName];
- var propType = getPropType(propValue);
- if (propType !== expectedType) {
- // `propValue` being instance of, say, date/regexp, pass the 'object'
- // check, but we can offer a more precise error message here rather than
- // 'of type `object`'.
- var preciseType = getPreciseType(propValue);
-
- return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'));
- }
- return null;
- }
- return createChainableTypeChecker(validate);
- }
-
- function createAnyTypeChecker() {
- return createChainableTypeChecker(emptyFunction.thatReturnsNull);
- }
-
- function createArrayOfTypeChecker(typeChecker) {
- function validate(props, propName, componentName, location, propFullName) {
- if (typeof typeChecker !== 'function') {
- return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.');
- }
- var propValue = props[propName];
- if (!Array.isArray(propValue)) {
- var propType = getPropType(propValue);
- return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));
- }
- for (var i = 0; i < propValue.length; i++) {
- var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret);
- if (error instanceof Error) {
- return error;
- }
- }
- return null;
- }
- return createChainableTypeChecker(validate);
- }
-
- function createElementTypeChecker() {
- function validate(props, propName, componentName, location, propFullName) {
- var propValue = props[propName];
- if (!isValidElement(propValue)) {
- var propType = getPropType(propValue);
- return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.'));
- }
- return null;
- }
- return createChainableTypeChecker(validate);
- }
-
- function createInstanceTypeChecker(expectedClass) {
- function validate(props, propName, componentName, location, propFullName) {
- if (!(props[propName] instanceof expectedClass)) {
- var expectedClassName = expectedClass.name || ANONYMOUS;
- var actualClassName = getClassName(props[propName]);
- return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.'));
- }
- return null;
- }
- return createChainableTypeChecker(validate);
- }
-
- function createEnumTypeChecker(expectedValues) {
- if (!Array.isArray(expectedValues)) {
- process.env.NODE_ENV !== 'production' ? warning(false, 'Invalid argument supplied to oneOf, expected an instance of array.') : void 0;
- return emptyFunction.thatReturnsNull;
- }
-
- function validate(props, propName, componentName, location, propFullName) {
- var propValue = props[propName];
- for (var i = 0; i < expectedValues.length; i++) {
- if (is(propValue, expectedValues[i])) {
- return null;
- }
- }
-
- var valuesString = JSON.stringify(expectedValues);
- return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + propValue + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));
- }
- return createChainableTypeChecker(validate);
- }
-
- function createObjectOfTypeChecker(typeChecker) {
- function validate(props, propName, componentName, location, propFullName) {
- if (typeof typeChecker !== 'function') {
- return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.');
- }
- var propValue = props[propName];
- var propType = getPropType(propValue);
- if (propType !== 'object') {
- return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
- }
- for (var key in propValue) {
- if (propValue.hasOwnProperty(key)) {
- var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
- if (error instanceof Error) {
- return error;
- }
- }
- }
- return null;
- }
- return createChainableTypeChecker(validate);
- }
-
- function createUnionTypeChecker(arrayOfTypeCheckers) {
- if (!Array.isArray(arrayOfTypeCheckers)) {
- process.env.NODE_ENV !== 'production' ? warning(false, 'Invalid argument supplied to oneOfType, expected an instance of array.') : void 0;
- return emptyFunction.thatReturnsNull;
- }
-
- for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
- var checker = arrayOfTypeCheckers[i];
- if (typeof checker !== 'function') {
- warning(
- false,
- 'Invalid argument supplid to oneOfType. Expected an array of check functions, but ' +
- 'received %s at index %s.',
- getPostfixForTypeWarning(checker),
- i
- );
- return emptyFunction.thatReturnsNull;
- }
- }
-
- function validate(props, propName, componentName, location, propFullName) {
- for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
- var checker = arrayOfTypeCheckers[i];
- if (checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret) == null) {
- return null;
- }
- }
-
- return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`.'));
- }
- return createChainableTypeChecker(validate);
- }
-
- function createNodeChecker() {
- function validate(props, propName, componentName, location, propFullName) {
- if (!isNode(props[propName])) {
- return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));
- }
- return null;
- }
- return createChainableTypeChecker(validate);
- }
-
- function createShapeTypeChecker(shapeTypes) {
- function validate(props, propName, componentName, location, propFullName) {
- var propValue = props[propName];
- var propType = getPropType(propValue);
- if (propType !== 'object') {
- return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
- }
- for (var key in shapeTypes) {
- var checker = shapeTypes[key];
- if (!checker) {
- continue;
- }
- var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
- if (error) {
- return error;
- }
- }
- return null;
- }
- return createChainableTypeChecker(validate);
- }
-
- function isNode(propValue) {
- switch (typeof propValue) {
- case 'number':
- case 'string':
- case 'undefined':
- return true;
- case 'boolean':
- return !propValue;
- case 'object':
- if (Array.isArray(propValue)) {
- return propValue.every(isNode);
- }
- if (propValue === null || isValidElement(propValue)) {
- return true;
- }
-
- var iteratorFn = getIteratorFn(propValue);
- if (iteratorFn) {
- var iterator = iteratorFn.call(propValue);
- var step;
- if (iteratorFn !== propValue.entries) {
- while (!(step = iterator.next()).done) {
- if (!isNode(step.value)) {
- return false;
- }
- }
- } else {
- // Iterator will provide entry [k,v] tuples rather than values.
- while (!(step = iterator.next()).done) {
- var entry = step.value;
- if (entry) {
- if (!isNode(entry[1])) {
- return false;
- }
- }
- }
- }
- } else {
- return false;
- }
-
- return true;
- default:
- return false;
- }
- }
-
- function isSymbol(propType, propValue) {
- // Native Symbol.
- if (propType === 'symbol') {
- return true;
- }
-
- // 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol'
- if (propValue['@@toStringTag'] === 'Symbol') {
- return true;
- }
-
- // Fallback for non-spec compliant Symbols which are polyfilled.
- if (typeof Symbol === 'function' && propValue instanceof Symbol) {
- return true;
- }
-
- return false;
- }
-
- // Equivalent of `typeof` but with special handling for array and regexp.
- function getPropType(propValue) {
- var propType = typeof propValue;
- if (Array.isArray(propValue)) {
- return 'array';
- }
- if (propValue instanceof RegExp) {
- // Old webkits (at least until Android 4.0) return 'function' rather than
- // 'object' for typeof a RegExp. We'll normalize this here so that /bla/
- // passes PropTypes.object.
- return 'object';
- }
- if (isSymbol(propType, propValue)) {
- return 'symbol';
- }
- return propType;
- }
-
- // This handles more types than `getPropType`. Only used for error messages.
- // See `createPrimitiveTypeChecker`.
- function getPreciseType(propValue) {
- if (typeof propValue === 'undefined' || propValue === null) {
- return '' + propValue;
- }
- var propType = getPropType(propValue);
- if (propType === 'object') {
- if (propValue instanceof Date) {
- return 'date';
- } else if (propValue instanceof RegExp) {
- return 'regexp';
- }
- }
- return propType;
- }
-
- // Returns a string that is postfixed to a warning about an invalid type.
- // For example, "undefined" or "of type array"
- function getPostfixForTypeWarning(value) {
- var type = getPreciseType(value);
- switch (type) {
- case 'array':
- case 'object':
- return 'an ' + type;
- case 'boolean':
- case 'date':
- case 'regexp':
- return 'a ' + type;
- default:
- return type;
- }
- }
-
- // Returns class name of the object, if any.
- function getClassName(propValue) {
- if (!propValue.constructor || !propValue.constructor.name) {
- return ANONYMOUS;
- }
- return propValue.constructor.name;
- }
-
- ReactPropTypes.checkPropTypes = checkPropTypes;
- ReactPropTypes.PropTypes = ReactPropTypes;
-
- return ReactPropTypes;
-};
-
-}).call(this,require('_process'))
-},{"./checkPropTypes":7,"./lib/ReactPropTypesSecret":11,"_process":6,"fbjs/lib/emptyFunction":2,"fbjs/lib/invariant":3,"fbjs/lib/warning":4}],10:[function(require,module,exports){
-(function (process){
-/**
- * Copyright 2013-present, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
-
-if (process.env.NODE_ENV !== 'production') {
- var REACT_ELEMENT_TYPE = (typeof Symbol === 'function' &&
- Symbol.for &&
- Symbol.for('react.element')) ||
- 0xeac7;
-
- var isValidElement = function(object) {
- return typeof object === 'object' &&
- object !== null &&
- object.$$typeof === REACT_ELEMENT_TYPE;
- };
-
- // By explicitly using `prop-types` you are opting into new development behavior.
- // http://fb.me/prop-types-in-prod
- var throwOnDirectAccess = true;
- module.exports = require('./factoryWithTypeCheckers')(isValidElement, throwOnDirectAccess);
-} else {
- // By explicitly using `prop-types` you are opting into new production behavior.
- // http://fb.me/prop-types-in-prod
- module.exports = require('./factoryWithThrowingShims')();
-}
-
-}).call(this,require('_process'))
-},{"./factoryWithThrowingShims":8,"./factoryWithTypeCheckers":9,"_process":6}],11:[function(require,module,exports){
-/**
- * Copyright 2013-present, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
-
-'use strict';
-
-var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
-
-module.exports = ReactPropTypesSecret;
-
-},{}],12:[function(require,module,exports){
-"use strict";
-
-Object.defineProperty(exports, "__esModule", {
- value: true
-});
-
-var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
-
-exports.default = createPlotlyComponent;
-
-var _react = (window.React);
-
-var _react2 = _interopRequireDefault(_react);
-
-var _propTypes = require("prop-types");
-
-var _propTypes2 = _interopRequireDefault(_propTypes);
-
-var _fastIsnumeric = require("fast-isnumeric");
-
-var _fastIsnumeric2 = _interopRequireDefault(_fastIsnumeric);
-
-var _objectAssign = require("object-assign");
-
-var _objectAssign2 = _interopRequireDefault(_objectAssign);
-
-function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
-
-function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
-
-function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
-
-function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
-
-// The naming convention is:
-// - events are attached as `'plotly_' + eventName.toLowerCase()`
-// - react props are `'on' + eventName`
-var eventNames = ["AfterExport", "AfterPlot", "Animated", "AnimatingFrame", "AnimationInterrupted", "AutoSize", "BeforeExport", "ButtonClicked", "Click", "ClickAnnotation", "Deselect", "DoubleClick", "Framework", "Hover", "Relayout", "Restyle", "Redraw", "Selected", "Selecting", "SliderChange", "SliderEnd", "SliderStart", "Transitioning", "TransitionInterrupted", "Unhover"];
-
-// Check if a window is available since SSR (server-side rendering)
-// breaks unnecessarily if you try to use it server-side.
-var isBrowser = typeof window !== "undefined";
-
-function createPlotlyComponent(Plotly) {
- var hasReactAPIMethod = !!Plotly.react;
-
- var PlotlyComponent = function (_Component) {
- _inherits(PlotlyComponent, _Component);
-
- function PlotlyComponent(props) {
- _classCallCheck(this, PlotlyComponent);
-
- var _this = _possibleConstructorReturn(this, (PlotlyComponent.__proto__ || Object.getPrototypeOf(PlotlyComponent)).call(this, props));
-
- _this.p = Promise.resolve();
- _this.resizeHandler = null;
- _this.handlers = {};
-
- _this.syncWindowResize = _this.syncWindowResize.bind(_this);
- _this.syncEventHandlers = _this.syncEventHandlers.bind(_this);
- _this.getRef = _this.getRef.bind(_this);
- return _this;
- }
-
- _createClass(PlotlyComponent, [{
- key: "componentDidMount",
- value: function componentDidMount() {
- var _this2 = this;
-
- this.p = this.p.then(function () {
- return Plotly.plot(_this2.el, {
- data: _this2.props.data,
- layout: _this2.sizeAdjustedLayout(_this2.props.layout),
- config: _this2.props.config,
- frames: _this2.props.frames
- });
- }).then(function () {
- _this2.syncWindowResize();
- _this2.syncEventHandlers();
- });
- }
- }, {
- key: "componentWillReceiveProps",
- value: function componentWillReceiveProps(nextProps) {
- var _this3 = this;
-
- this.p = this.p.then(function () {
- return (hasReactAPIMethod ? Plotly.react : Plotly.newPlot)(_this3.el, {
- data: nextProps.data,
- layout: _this3.sizeAdjustedLayout(nextProps.layout),
- config: nextProps.config,
- frames: nextProps.frames
- }).then(function () {
- _this3.syncEventHandlers(nextProps);
- _this3.syncWindowResize(nextProps);
- });
- });
- }
- }, {
- key: "componentWillUnmount",
- value: function componentWillUnmount() {
- if (this.resizeHandler && isBrowser) {
- window.removeEventListener("resize", this.handleResize);
- this.resizeHandler = null;
- }
-
- Plotly.purge(this.el);
- }
- }, {
- key: "syncWindowResize",
- value: function syncWindowResize(props) {
- var _this4 = this;
-
- props = props || this.props;
- if (!isBrowser) return;
-
- if (props.fit && !this.resizeHandler) {
- if (!this.resizeHandler) {
- this.resizeHandler = function () {
- _this4.p = _this4.p.then(function () {
- return Plotly.relayout(_this4.el, _this4.getSize());
- });
- };
- window.addEventListener("resize", this.resizeHandler);
- this.resizeHandler();
- }
- } else if (!props.fit && this.resizeHandler) {
- window.removeEventListener('resize', this.resizeHandler);
- this.resizeHandler = null;
- }
- }
- }, {
- key: "getRef",
- value: function getRef(el) {
- this.el = el;
-
- if (this.props.debug && isBrowser) {
- window.gd = this.el;
- }
- }
-
- // Attach and remove event handlers as they're added or removed from props:
-
- }, {
- key: "syncEventHandlers",
- value: function syncEventHandlers(props) {
- // Allow use of nextProps if passed explicitly:
- props = props || this.props;
-
- for (var i = 0; i < eventNames.length; i++) {
- var eventName = eventNames[i];
- var prop = props["on" + eventName];
- var hasHandler = !!this.handlers[eventName];
-
- if (prop && !hasHandler) {
- var handler = this.handlers[eventName] = props["on" + eventName];
- this.el.on("plotly_" + eventName.toLowerCase(), handler);
- } else if (!prop && hasHandler) {
- // Needs to be removed:
- this.el.off("plotly_" + eventName.toLowerCase(), this.handlers[eventName]);
- delete this.handlers[eventName];
- }
- }
- }
- }, {
- key: "sizeAdjustedLayout",
- value: function sizeAdjustedLayout(layout) {
- var size = this.getSize();
-
- // Shallow-clone the layout so that we don't have to
- // modify the original object:
- layout = (0, _objectAssign2.default)({}, layout);
- (0, _objectAssign2.default)(layout, this.getSize());
- return layout;
- }
- }, {
- key: "getSize",
- value: function getSize() {
- var rect = void 0;
- var hasWidth = (0, _fastIsnumeric2.default)(this.props.width);
- var hasHeight = (0, _fastIsnumeric2.default)(this.props.height);
-
- if (!hasWidth || !hasHeight) {
- rect = this.el.parentElement.getBoundingClientRect();
- }
-
- return {
- width: hasWidth ? parseInt(this.props.width) : rect.width,
- height: hasHeight ? parseInt(this.props.height) : rect.height
- };
- }
- }, {
- key: "render",
- value: function render() {
- return _react2.default.createElement("div", { ref: this.getRef });
- }
- }]);
-
- return PlotlyComponent;
- }(_react.Component);
-
- PlotlyComponent.propTypes = {
- fit: _propTypes2.default.bool,
- width: _propTypes2.default.number,
- height: _propTypes2.default.number,
- data: _propTypes2.default.arrayOf(_propTypes2.default.object),
- config: _propTypes2.default.object,
- layout: _propTypes2.default.object,
- frames: _propTypes2.default.arrayOf(_propTypes2.default.object)
- };
-
- for (var i = 0; i < eventNames.length; i++) {
- PlotlyComponent.propTypes["on" + eventNames[i]] = _propTypes2.default.func;
- }
-
- PlotlyComponent.defaultProps = {
- fit: false,
- data: [],
- width: null,
- height: null
- };
-
- return PlotlyComponent;
-}
-
-},{"fast-isnumeric":1,"object-assign":5,"prop-types":10}]},{},[12])(12)
-});
\ No newline at end of file
diff --git a/build/plotlyjs-react.min.js b/build/plotlyjs-react.min.js
deleted file mode 100644
index f65025f..0000000
--- a/build/plotlyjs-react.min.js
+++ /dev/null
@@ -1 +0,0 @@
-!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).createPlotlyComponent=e()}}(function(){return function e(t,n,r){function o(a,u){if(!n[a]){if(!t[a]){var s="function"==typeof require&&require;if(!u&&s)return s(a,!0);if(i)return i(a,!0);var c=new Error("Cannot find module '"+a+"'");throw c.code="MODULE_NOT_FOUND",c}var f=n[a]={exports:{}};t[a][0].call(f.exports,function(e){var n=t[a][1][e];return o(n||e)},f,f.exports,e,t,n,r)}return n[a].exports}for(var i="function"==typeof require&&require,a=0;a13)&&32!==t&&133!==t&&160!==t&&5760!==t&&6158!==t&&(t<8192||t>8205)&&8232!==t&&8233!==t&&8239!==t&&8287!==t&&8288!==t&&12288!==t&&65279!==t)return!1;return!0}t.exports=function(e){var t=typeof e;if("string"===t){var n=e;if(0===(e=+e)&&r(n))return!1}else if("number"!==t)return!1;return e-e<1}},{}],2:[function(e,t,n){"use strict";function r(e){return function(){return e}}var o=function(){};o.thatReturns=r,o.thatReturnsFalse=r(!1),o.thatReturnsTrue=r(!0),o.thatReturnsNull=r(null),o.thatReturnsThis=function(){return this},o.thatReturnsArgument=function(e){return e},t.exports=o},{}],3:[function(e,t,n){(function(e){"use strict";var n=function(e){};"production"!==e.env.NODE_ENV&&(n=function(e){if(void 0===e)throw new Error("invariant requires an error message argument")}),t.exports=function(e,t,r,o,i,a,u,s){if(n(t),!e){var c;if(void 0===t)c=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var f=[r,o,i,a,u,s],l=0;(c=new Error(t.replace(/%s/g,function(){return f[l++]}))).name="Invariant Violation"}throw c.framesToPop=1,c}}}).call(this,e("_process"))},{_process:6}],4:[function(e,t,n){(function(n){"use strict";var r=e("./emptyFunction");if("production"!==n.env.NODE_ENV){var o=function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r2?n-2:0),i=2;i1)for(var n=1;n>",T={array:p("array"),bool:p("boolean"),func:p("function"),number:p("number"),object:p("object"),string:p("string"),symbol:p("symbol"),any:l(r.thatReturnsNull),arrayOf:function(e){return l(function(t,n,r,o,i){if("function"!=typeof e)return new f("Property `"+i+"` of component `"+r+"` has invalid PropType notation inside arrayOf.");var u=t[n];if(!Array.isArray(u))return new f("Invalid "+o+" `"+i+"` of type `"+h(u)+"` supplied to `"+r+"`, expected an array.");for(var s=0;s
-
- plotly.js-react
+ react-plotly.js
diff --git a/lib/plotly.js-react.js b/factory.js
similarity index 86%
rename from lib/plotly.js-react.js
rename to factory.js
index 851bf48..b177245 100644
--- a/lib/plotly.js-react.js
+++ b/factory.js
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
-exports.default = createPlotlyComponent;
+exports.default = plotComponentFactory;
var _react = require("react");
@@ -24,10 +24,6 @@ var _objectAssign = require("object-assign");
var _objectAssign2 = _interopRequireDefault(_objectAssign);
-var _throttle = require("throttle-debounce/throttle");
-
-var _throttle2 = _interopRequireDefault(_throttle);
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
@@ -36,9 +32,7 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
-function constructUpdate(diff) {
- var keys = Object.keys(diff);
-}
+// import throttle from "throttle-debounce/throttle";
// The naming convention is:
// - events are attached as `'plotly_' + eventName.toLowerCase()`
@@ -51,7 +45,7 @@ var updateEvents = ["plotly_restyle", "plotly_redraw", "plotly_relayout", "plotl
// breaks unnecessarily if you try to use it server-side.
var isBrowser = typeof window !== "undefined";
-function createPlotlyComponent(Plotly) {
+function plotComponentFactory(Plotly) {
var hasReactAPIMethod = !!Plotly.react;
var PlotlyComponent = function (_Component) {
@@ -77,6 +71,16 @@ function createPlotlyComponent(Plotly) {
}
_createClass(PlotlyComponent, [{
+ key: "shouldComponentUpdate",
+ value: function shouldComponentUpdate(nextProps) {
+ if ((0, _fastIsnumeric2.default)(nextProps.revision) && (0, _fastIsnumeric2.default)(this.props.revision)) {
+ // If revision is numeric, then increment only if revision has increased:
+ return nextProps.revision > this.props.revision;
+ } else {
+ return true;
+ }
+ }
+ }, {
key: "componentDidMount",
value: function componentDidMount() {
var _this2 = this;
@@ -88,22 +92,22 @@ function createPlotlyComponent(Plotly) {
config: _this2.props.config,
frames: _this2.props.frames
});
- }).then(this.attachUpdateEvents).then(function () {
- return _this2.syncWindowResize(null, false);
}).then(function () {
- return _this2.syncEventHandlers();
- }).then(this.handleUpdate, function () {
- _this2.props.onError && _this2.props.onError();
+ return _this2.syncWindowResize(null, false);
+ }).then(this.syncEventHandlers).then(this.attachUpdateEvents)
+ //.then(
+ //() => this.props.onInitialized && this.props.onInitialized(this.el)
+ //)
+ .catch(function (e) {
+ console.error("Error while plotting:", e);
+ return _this2.props.onError && _this2.props.onError();
});
}
}, {
- key: "componentWillReceiveProps",
- value: function componentWillReceiveProps(nextProps) {
+ key: "componentWillUpdate",
+ value: function componentWillUpdate(nextProps) {
var _this3 = this;
- var dataDiff = void 0,
- layoutDiff = void 0,
- configDiff = void 0;
var nextLayout = this.sizeAdjustedLayout(nextProps.layout);
this.p = this.p.then(function () {
@@ -126,11 +130,10 @@ function createPlotlyComponent(Plotly) {
return _this3.syncEventHandlers(nextProps);
}).then(function () {
return _this3.syncWindowResize(nextProps);
- }).then(function () {
- return function () {
- return _this3.handleUpdate(nextProps);
- };
+ }).then(this.attachUpdateEvents).then(function () {
+ return _this3.handleUpdate(nextProps);
}).catch(function (err) {
+ console.error("Error while plotting:", err);
_this3.props.onError && _this3.props.onError(err);
});
}
@@ -149,8 +152,12 @@ function createPlotlyComponent(Plotly) {
}, {
key: "attachUpdateEvents",
value: function attachUpdateEvents() {
+ var _this4 = this;
+
for (var i = 0; i < updateEvents.length; i++) {
- this.el.on(updateEvents[i], this.handleUpdate);
+ this.el.on(updateEvents[i], function () {
+ _this4.handleUpdate();
+ });
}
}
}, {
@@ -173,14 +180,14 @@ function createPlotlyComponent(Plotly) {
}, {
key: "syncWindowResize",
value: function syncWindowResize(props, invoke) {
- var _this4 = this;
+ var _this5 = this;
props = props || this.props;
if (!isBrowser) return;
if (props.fit && !this.resizeHandler) {
this.resizeHandler = function () {
- return Plotly.relayout(_this4.el, _this4.getSize());
+ return Plotly.relayout(_this5.el, _this5.getSize());
};
window.addEventListener("resize", this.resizeHandler);
@@ -195,6 +202,10 @@ function createPlotlyComponent(Plotly) {
value: function getRef(el) {
this.el = el;
+ if (this.props.onInitialized) {
+ this.props.onInitialized(el);
+ }
+
if (this.props.debug && isBrowser) {
window.gd = this.el;
}
@@ -279,7 +290,11 @@ function createPlotlyComponent(Plotly) {
config: _propTypes2.default.object,
layout: _propTypes2.default.object,
frames: _propTypes2.default.arrayOf(_propTypes2.default.object),
- onInitialized: _propTypes2.default.func
+ onInitialized: _propTypes2.default.func,
+ onError: _propTypes2.default.func,
+ onUpdate: _propTypes2.default.func,
+ debug: _propTypes2.default.bool
+ //onGraphDiv: PropTypes.func,
};
for (var i = 0; i < eventNames.length; i++) {
@@ -287,7 +302,7 @@ function createPlotlyComponent(Plotly) {
}
PlotlyComponent.defaultProps = {
- debug: true,
+ debug: false,
fit: false,
data: []
};
@@ -295,5 +310,4 @@ function createPlotlyComponent(Plotly) {
return PlotlyComponent;
}
module.exports = exports["default"];
-
-//# sourceMappingURL=plotly.js-react.js.map
\ No newline at end of file
+//# sourceMappingURL=factory.js.map
\ No newline at end of file
diff --git a/factory.js.map b/factory.js.map
new file mode 100644
index 0000000..ca071d2
--- /dev/null
+++ b/factory.js.map
@@ -0,0 +1 @@
+{"version":3,"sources":["../src/factory.js"],"names":["plotComponentFactory","eventNames","updateEvents","isBrowser","window","Plotly","hasReactAPIMethod","react","PlotlyComponent","props","p","Promise","resolve","resizeHandler","handlers","syncWindowResize","bind","syncEventHandlers","attachUpdateEvents","getRef","handleUpdate","nextProps","revision","then","newPlot","el","data","layout","sizeAdjustedLayout","config","frames","catch","console","error","e","onError","nextLayout","err","removeEventListener","handleResize","removeUpdateEvents","purge","i","length","on","off","onUpdate","invoke","fit","relayout","getSize","addEventListener","onInitialized","debug","gd","eventName","prop","hasHandler","handler","toLowerCase","parentElement","getBoundingClientRect","rect","layoutWidth","width","layoutHeight","height","hasWidth","hasHeight","getParentSize","parseInt","position","display","propTypes","bool","arrayOf","object","func","defaultProps"],"mappings":";;;;;;;;kBAiDwBA,oB;;AAjDxB;;;;AACA;;;;AACA;;;;AACA;;;;;;;;;;;;AACA;;AAEA;AACA;AACA;AACA,IAAMC,aAAa,CACjB,aADiB,EAEjB,WAFiB,EAGjB,UAHiB,EAIjB,gBAJiB,EAKjB,sBALiB,EAMjB,UANiB,EAOjB,cAPiB,EAQjB,eARiB,EASjB,OATiB,EAUjB,iBAViB,EAWjB,UAXiB,EAYjB,aAZiB,EAajB,WAbiB,EAcjB,OAdiB,EAejB,UAfiB,EAgBjB,SAhBiB,EAiBjB,QAjBiB,EAkBjB,UAlBiB,EAmBjB,WAnBiB,EAoBjB,cApBiB,EAqBjB,WArBiB,EAsBjB,aAtBiB,EAuBjB,eAvBiB,EAwBjB,uBAxBiB,EAyBjB,SAzBiB,CAAnB;;AA4BA,IAAMC,eAAe,CACnB,gBADmB,EAEnB,eAFmB,EAGnB,iBAHmB,EAInB,oBAJmB,EAKnB,iBALmB,CAArB;;AAQA;AACA;AACA,IAAMC,YAAY,OAAOC,MAAP,KAAkB,WAApC;;A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AAKO,aAAL,EAAP;AACD;;AAED,eAAO;AACLL,iBAAOG,WAAWG,SAASP,WAAT,CAAX,GAAmCD,KAAKE,KAD1C;AAELE,kBAAQE,YAAYE,SAASL,YAAT,CAAZ,GAAqCH,KAAKI;AAF7C,SAAP;AAID;AAtMgD;AAAA;AAAA,+BAwMxC;AACP,eACE;AACE,iBAAO;AACLK,sBAAU,UADL;AAELC,qBAAS;AAFJ,WADT;AAKE,eAAK,KAAKrD;AALZ,UADF;AASD;AAlNgD;;AAAA;AAAA;;AAqNnDX,kBAAgBiE,SAAhB,GAA4B;AAC1BzB,SAAK,oBAAU0B,IADW;AAE1BhD,UAAM,oBAAUiD,OAAV,CAAkB,oBAAUC,MAA5B,CAFoB;AAG1B/C,YAAQ,oBAAU+C,MAHQ;AAI1BjD,YAAQ,oBAAUiD,MAJQ;AAK1B9C,YAAQ,oBAAU6C,OAAV,CAAkB,oBAAUC,MAA5B,CALkB;AAM1BxB,mBAAe,oBAAUyB,IANC;AAO1B1C,aAAS,oBAAU0C,IAPO;AAQ1B/B,cAAU,oBAAU+B,IARM;AAS1BxB,WAAO,oBAAUqB;AACjB;AAV0B,GAA5B;;AAaA,OAAK,IAAIhC,IAAI,CAAb,EAAgBA,IAAIzC,WAAW0C,MAA/B,EAAuCD,GAAvC,EAA4C;AAC1ClC,oBAAgBiE,SAAhB,CAA0B,OAAOxE,WAAWyC,CAAX,CAAjC,IAAkD,oBAAUmC,IAA5D;AACD;;AAEDrE,kBAAgBsE,YAAhB,GAA+B;AAC7BzB,WAAO,KADsB;AAE7BL,SAAK,KAFwB;AAG7BtB,UAAM;AAHuB,GAA/B;;AAMA,SAAOlB,eAAP;AACD","file":"factory.js","sourcesContent":["import React, { Component } from \"react\";\nimport PropTypes from \"prop-types\";\nimport isNumeric from \"fast-isnumeric\";\nimport objectAssign from \"object-assign\";\n// import throttle from \"throttle-debounce/throttle\";\n\n// The naming convention is:\n// - events are attached as `'plotly_' + eventName.toLowerCase()`\n// - react props are `'on' + eventName`\nconst eventNames = [\n \"AfterExport\",\n \"AfterPlot\",\n \"Animated\",\n \"AnimatingFrame\",\n \"AnimationInterrupted\",\n \"AutoSize\",\n \"BeforeExport\",\n \"ButtonClicked\",\n \"Click\",\n \"ClickAnnotation\",\n \"Deselect\",\n \"DoubleClick\",\n \"Framework\",\n \"Hover\",\n \"Relayout\",\n \"Restyle\",\n \"Redraw\",\n \"Selected\",\n \"Selecting\",\n \"SliderChange\",\n \"SliderEnd\",\n \"SliderStart\",\n \"Transitioning\",\n \"TransitionInterrupted\",\n \"Unhover\",\n];\n\nconst updateEvents = [\n \"plotly_restyle\",\n \"plotly_redraw\",\n \"plotly_relayout\",\n \"plotly_doubleclick\",\n \"plotly_animated\",\n];\n\n// Check if a window is available since SSR (server-side rendering)\n// breaks unnecessarily if you try to use it server-side.\nconst isBrowser = typeof window !== \"undefined\";\n\nexport default function plotComponentFactory(Plotly) {\n const hasReactAPIMethod = !!Plotly.react;\n\n class PlotlyComponent extends Component {\n constructor(props) {\n super(props);\n\n this.p = Promise.resolve();\n this.resizeHandler = null;\n this.handlers = {};\n\n this.syncWindowResize = this.syncWindowResize.bind(this);\n this.syncEventHandlers = this.syncEventHandlers.bind(this);\n this.attachUpdateEvents = this.attachUpdateEvents.bind(this);\n this.getRef = this.getRef.bind(this);\n\n //this.handleUpdate = throttle(0, this.handleUpdate.bind(this));\n this.handleUpdate = this.handleUpdate.bind(this);\n }\n\n shouldComponentUpdate(nextProps) {\n if (isNumeric(nextProps.revision) && isNumeric(this.props.revision)) {\n // If revision is numeric, then increment only if revision has increased:\n return nextProps.revision > this.props.revision;\n } else {\n return true;\n }\n }\n\n componentDidMount() {\n this.p = this.p\n .then(() => {\n return Plotly.newPlot(this.el, {\n data: this.props.data,\n layout: this.sizeAdjustedLayout(this.props.layout),\n config: this.props.config,\n frames: this.props.frames,\n });\n })\n .then(() => this.syncWindowResize(null, false))\n .then(this.syncEventHandlers)\n .then(this.attachUpdateEvents)\n //.then(\n //() => this.props.onInitialized && this.props.onInitialized(this.el)\n //)\n .catch(e => {\n console.error(\"Error while plotting:\", e);\n return this.props.onError && this.props.onError();\n });\n }\n\n componentWillUpdate(nextProps) {\n let nextLayout = this.sizeAdjustedLayout(nextProps.layout);\n\n this.p = this.p\n .then(() => {\n if (hasReactAPIMethod) {\n return Plotly.react(this.el, {\n data: nextProps.data,\n layout: nextLayout,\n config: nextProps.config,\n frames: nextProps.frames,\n });\n } else {\n return Plotly.newPlot(this.el, {\n data: nextProps.data,\n layout: nextLayout,\n config: nextProps.config,\n frames: nextProps.frames,\n });\n }\n })\n .then(() => this.syncEventHandlers(nextProps))\n .then(() => this.syncWindowResize(nextProps))\n .then(this.attachUpdateEvents)\n .then(() => this.handleUpdate(nextProps))\n .catch(err => {\n console.error(\"Error while plotting:\", err);\n this.props.onError && this.props.onError(err);\n });\n }\n\n componentWillUnmount() {\n if (this.resizeHandler && isBrowser) {\n window.removeEventListener(\"resize\", this.handleResize);\n this.resizeHandler = null;\n }\n\n this.removeUpdateEvents();\n\n Plotly.purge(this.el);\n }\n\n attachUpdateEvents() {\n for (let i = 0; i < updateEvents.length; i++) {\n this.el.on(updateEvents[i], () => {\n this.handleUpdate();\n });\n }\n }\n\n removeUpdateEvents() {\n if (!this.el || !this.el.off) return;\n\n for (let i = 0; i < updateEvents.length; i++) {\n this.el.off(updateEvents[i], this.handleUpdate);\n }\n }\n\n handleUpdate(props) {\n props = props || this.props;\n if (props.onUpdate && typeof props.onUpdate === \"function\") {\n props.onUpdate(this.el);\n }\n }\n\n syncWindowResize(props, invoke) {\n props = props || this.props;\n if (!isBrowser) return;\n\n if (props.fit && !this.resizeHandler) {\n this.resizeHandler = () => {\n return Plotly.relayout(this.el, this.getSize());\n };\n window.addEventListener(\"resize\", this.resizeHandler);\n\n if (invoke) return this.resizeHandler();\n } else if (!props.fit && this.resizeHandler) {\n window.removeEventListener(\"resize\", this.resizeHandler);\n this.resizeHandler = null;\n }\n }\n\n getRef(el) {\n this.el = el;\n\n if (this.props.onInitialized) {\n this.props.onInitialized(el);\n }\n\n if (this.props.debug && isBrowser) {\n window.gd = this.el;\n }\n }\n\n // Attach and remove event handlers as they're added or removed from props:\n syncEventHandlers(props) {\n // Allow use of nextProps if passed explicitly:\n props = props || this.props;\n\n for (let i = 0; i < eventNames.length; i++) {\n const eventName = eventNames[i];\n const prop = props[\"on\" + eventName];\n const hasHandler = !!this.handlers[eventName];\n\n if (prop && !hasHandler) {\n let handler = (this.handlers[eventName] = props[\"on\" + eventName]);\n this.el.on(\"plotly_\" + eventName.toLowerCase(), handler);\n } else if (!prop && hasHandler) {\n // Needs to be removed:\n this.el.off(\n \"plotly_\" + eventName.toLowerCase(),\n this.handlers[eventName]\n );\n delete this.handlers[eventName];\n }\n }\n }\n\n sizeAdjustedLayout(layout) {\n if (this.props.fit) {\n layout = objectAssign({}, layout);\n objectAssign(layout, this.getSize(layout));\n }\n\n return layout;\n }\n\n getParentSize() {\n return this.el.parentElement.getBoundingClientRect();\n }\n\n getSize(layout) {\n let rect;\n layout = layout || this.props.layout;\n const layoutWidth = layout ? layout.width : null;\n const layoutHeight = layout ? layout.height : null;\n const hasWidth = isNumeric(layoutWidth);\n const hasHeight = isNumeric(layoutHeight);\n\n if (!hasWidth || !hasHeight) {\n rect = this.getParentSize();\n }\n\n return {\n width: hasWidth ? parseInt(layoutWidth) : rect.width,\n height: hasHeight ? parseInt(layoutHeight) : rect.height,\n };\n }\n\n render() {\n return (\n \n );\n }\n }\n\n PlotlyComponent.propTypes = {\n fit: PropTypes.bool,\n data: PropTypes.arrayOf(PropTypes.object),\n config: PropTypes.object,\n layout: PropTypes.object,\n frames: PropTypes.arrayOf(PropTypes.object),\n onInitialized: PropTypes.func,\n onError: PropTypes.func,\n onUpdate: PropTypes.func,\n debug: PropTypes.bool,\n //onGraphDiv: PropTypes.func,\n };\n\n for (let i = 0; i < eventNames.length; i++) {\n PlotlyComponent.propTypes[\"on\" + eventNames[i]] = PropTypes.func;\n }\n\n PlotlyComponent.defaultProps = {\n debug: false,\n fit: false,\n data: [],\n };\n\n return PlotlyComponent;\n}\n"]}
\ No newline at end of file
diff --git a/lib/plotly.js-react.js.map b/lib/plotly.js-react.js.map
deleted file mode 100644
index 6d73aae..0000000
--- a/lib/plotly.js-react.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"sources":["../src/plotly.js-react.js"],"names":[],"mappings":";;;;;;;;kBAqDwB,qB;;AArDxB;;;;AACA;;;;AACA;;;;AACA;;;;AACA;;;;;;;;;;;;AAEA,SAAS,eAAT,CAAyB,IAAzB,EAA+B;AAC7B,MAAI,OAAO,OAAO,IAAP,CAAY,IAAZ,CAAX;AACD;;AAED;AACA;AACA;AACA,IAAM,aAAa,CACjB,aADiB,EAEjB,WAFiB,EAGjB,UAHiB,EAIjB,gBAJiB,EAKjB,sBALiB,EAMjB,UANiB,EAOjB,cAPiB,EAQjB,eARiB,EASjB,OATiB,EAUjB,iBAViB,EAWjB,UAXiB,EAYjB,aAZiB,EAajB,WAbiB,EAcjB,OAdiB,EAejB,UAfiB,EAgBjB,SAhBiB,EAiBjB,QAjBiB,EAkBjB,UAlBiB,EAmBjB,WAnBiB,EAoBjB,cApBiB,EAqBjB,WArBiB,EAsBjB,aAtBiB,EAuBjB,eAvBiB,EAwBjB,uBAxBiB,EAyBjB,SAzBiB,CAAnB;;AA4BA,IAAM,eAAe,CACnB,gBADmB,EAEnB,eAFmB,EAGnB,iBAHmB,EAInB,oBAJmB,EAKnB,iBALmB,CAArB;;AAQA;AACA;AACA,IAAM,YAAY,OAAO,MAAP,KAAkB,WAApC;;AAEe,SAAS,qBAAT,CAA+B,MAA/B,EAAuC;AACpD,MAAM,oBAAoB,CAAC,CAAC,OAAO,KAAnC;;AADoD,MAG9C,eAH8C;AAAA;;AAIlD,6BAAY,KAAZ,EAAmB;AAAA;;AAAA,oIACX,KADW;;AAGjB,YAAK,CAAL,GAAS,QAAQ,OAAR,EAAT;AACA,YAAK,aAAL,GAAqB,IAArB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AAhB,GAAyB,IAA9C;AACA,YAAM,WAAW,6BAAU,WAAV,CAAjB;AACA,YAAM,YAAY,6BAAU,YAAV,CAAlB;;AAEA,YAAI,CAAC,QAAD,IAAa,CAAC,SAAlB,EAA6B;AAC3B,iBAAO,KAAK,aAAL,EAAP;AACD;;AAED,eAAO;AACL,iBAAO,WAAW,SAAS,WAAT,CAAX,GAAmC,KAAK,KAD1C;AAEL,kBAAQ,YAAY,SAAS,YAAT,CAAZ,GAAqC,KAAK;AAF7C,SAAP;AAID;AAlLiD;AAAA;AAAA,+BAoLzC;AACP,eACE;AACE,iBAAO;AACL,sBAAU,UADL;AAEL,qBAAS;AAFJ,WADT;AAKE,eAAK,KAAK;AALZ,UADF;AASD;AA9LiD;;AAAA;AAAA;;AAiMpD,kBAAgB,SAAhB,GAA4B;AAC1B,SAAK,oBAAU,IADW;AAE1B,UAAM,oBAAU,OAAV,CAAkB,oBAAU,MAA5B,CAFoB;AAG1B,YAAQ,oBAAU,MAHQ;AAI1B,YAAQ,oBAAU,MAJQ;AAK1B,YAAQ,oBAAU,OAAV,CAAkB,oBAAU,MAA5B,CALkB;AAM1B,mBAAe,oBAAU;AANC,GAA5B;;AASA,OAAK,IAAI,IAAI,CAAb,EAAgB,IAAI,WAAW,MAA/B,EAAuC,GAAvC,EAA4C;AAC1C,oBAAgB,SAAhB,CAA0B,OAAO,WAAW,CAAX,CAAjC,IAAkD,oBAAU,IAA5D;AACD;;AAED,kBAAgB,YAAhB,GAA+B;AAC7B,WAAO,IADsB;AAE7B,SAAK,KAFwB;AAG7B,UAAM;AAHuB,GAA/B;;AAMA,SAAO,eAAP;AACD","file":"plotly.js-react.js","sourcesContent":["import React, { Component } from \"react\";\nimport PropTypes from \"prop-types\";\nimport isNumeric from \"fast-isnumeric\";\nimport objectAssign from \"object-assign\";\nimport throttle from \"throttle-debounce/throttle\";\n\nfunction constructUpdate(diff) {\n var keys = Object.keys(diff);\n}\n\n// The naming convention is:\n// - events are attached as `'plotly_' + eventName.toLowerCase()`\n// - react props are `'on' + eventName`\nconst eventNames = [\n \"AfterExport\",\n \"AfterPlot\",\n \"Animated\",\n \"AnimatingFrame\",\n \"AnimationInterrupted\",\n \"AutoSize\",\n \"BeforeExport\",\n \"ButtonClicked\",\n \"Click\",\n \"ClickAnnotation\",\n \"Deselect\",\n \"DoubleClick\",\n \"Framework\",\n \"Hover\",\n \"Relayout\",\n \"Restyle\",\n \"Redraw\",\n \"Selected\",\n \"Selecting\",\n \"SliderChange\",\n \"SliderEnd\",\n \"SliderStart\",\n \"Transitioning\",\n \"TransitionInterrupted\",\n \"Unhover\",\n];\n\nconst updateEvents = [\n \"plotly_restyle\",\n \"plotly_redraw\",\n \"plotly_relayout\",\n \"plotly_doubleclick\",\n \"plotly_animated\",\n];\n\n// Check if a window is available since SSR (server-side rendering)\n// breaks unnecessarily if you try to use it server-side.\nconst isBrowser = typeof window !== \"undefined\";\n\nexport default function createPlotlyComponent(Plotly) {\n const hasReactAPIMethod = !!Plotly.react;\n\n class PlotlyComponent extends Component {\n constructor(props) {\n super(props);\n\n this.p = Promise.resolve();\n this.resizeHandler = null;\n this.handlers = {};\n\n this.syncWindowResize = this.syncWindowResize.bind(this);\n this.syncEventHandlers = this.syncEventHandlers.bind(this);\n this.attachUpdateEvents = this.attachUpdateEvents.bind(this);\n this.getRef = this.getRef.bind(this);\n\n //this.handleUpdate = throttle(0, this.handleUpdate.bind(this));\n this.handleUpdate = this.handleUpdate.bind(this);\n }\n\n componentDidMount() {\n this.p = this.p\n .then(() => {\n return Plotly.newPlot(this.el, {\n data: this.props.data,\n layout: this.sizeAdjustedLayout(this.props.layout),\n config: this.props.config,\n frames: this.props.frames,\n });\n })\n .then(this.attachUpdateEvents)\n .then(() => this.syncWindowResize(null, false))\n .then(() => this.syncEventHandlers())\n .then(this.handleUpdate, () => {\n this.props.onError && this.props.onError();\n });\n }\n\n componentWillReceiveProps(nextProps) {\n let dataDiff, layoutDiff, configDiff;\n let nextLayout = this.sizeAdjustedLayout(nextProps.layout);\n\n this.p = this.p\n .then(() => {\n if (hasReactAPIMethod) {\n return Plotly.react(this.el, {\n data: nextProps.data,\n layout: nextLayout,\n config: nextProps.config,\n frames: nextProps.frames,\n });\n } else {\n return Plotly.newPlot(this.el, {\n data: nextProps.data,\n layout: nextLayout,\n config: nextProps.config,\n frames: nextProps.frames,\n });\n }\n })\n .then(() => this.syncEventHandlers(nextProps))\n .then(() => this.syncWindowResize(nextProps))\n .then(() => () => this.handleUpdate(nextProps))\n .catch(err => {\n this.props.onError && this.props.onError(err);\n });\n }\n\n componentWillUnmount() {\n if (this.resizeHandler && isBrowser) {\n window.removeEventListener(\"resize\", this.handleResize);\n this.resizeHandler = null;\n }\n\n this.removeUpdateEvents();\n\n Plotly.purge(this.el);\n }\n\n attachUpdateEvents() {\n for (let i = 0; i < updateEvents.length; i++) {\n this.el.on(updateEvents[i], this.handleUpdate);\n }\n }\n\n removeUpdateEvents() {\n if (!this.el || !this.el.off) return;\n\n for (let i = 0; i < updateEvents.length; i++) {\n this.el.off(updateEvents[i], this.handleUpdate);\n }\n }\n\n handleUpdate(props) {\n props = props || this.props;\n if (props.onUpdate && typeof props.onUpdate === \"function\") {\n props.onUpdate(this.el);\n }\n }\n\n syncWindowResize(props, invoke) {\n props = props || this.props;\n if (!isBrowser) return;\n\n if (props.fit && !this.resizeHandler) {\n this.resizeHandler = () => {\n return Plotly.relayout(this.el, this.getSize());\n };\n window.addEventListener(\"resize\", this.resizeHandler);\n\n if (invoke) return this.resizeHandler();\n } else if (!props.fit && this.resizeHandler) {\n window.removeEventListener(\"resize\", this.resizeHandler);\n this.resizeHandler = null;\n }\n }\n\n getRef(el) {\n this.el = el;\n\n if (this.props.debug && isBrowser) {\n window.gd = this.el;\n }\n }\n\n // Attach and remove event handlers as they're added or removed from props:\n syncEventHandlers(props) {\n // Allow use of nextProps if passed explicitly:\n props = props || this.props;\n\n for (let i = 0; i < eventNames.length; i++) {\n const eventName = eventNames[i];\n const prop = props[\"on\" + eventName];\n const hasHandler = !!this.handlers[eventName];\n\n if (prop && !hasHandler) {\n let handler = (this.handlers[eventName] = props[\"on\" + eventName]);\n this.el.on(\"plotly_\" + eventName.toLowerCase(), handler);\n } else if (!prop && hasHandler) {\n // Needs to be removed:\n this.el.off(\n \"plotly_\" + eventName.toLowerCase(),\n this.handlers[eventName]\n );\n delete this.handlers[eventName];\n }\n }\n }\n\n sizeAdjustedLayout(layout) {\n if (this.props.fit) {\n layout = objectAssign({}, layout);\n objectAssign(layout, this.getSize(layout));\n }\n\n return layout;\n }\n\n getParentSize() {\n return this.el.parentElement.getBoundingClientRect();\n }\n\n getSize(layout) {\n let rect;\n layout = layout || this.props.layout;\n const layoutWidth = layout ? layout.width : null;\n const layoutHeight = layout ? layout.height : null;\n const hasWidth = isNumeric(layoutWidth);\n const hasHeight = isNumeric(layoutHeight);\n\n if (!hasWidth || !hasHeight) {\n rect = this.getParentSize();\n }\n\n return {\n width: hasWidth ? parseInt(layoutWidth) : rect.width,\n height: hasHeight ? parseInt(layoutHeight) : rect.height,\n };\n }\n\n render() {\n return (\n \n );\n }\n }\n\n PlotlyComponent.propTypes = {\n fit: PropTypes.bool,\n data: PropTypes.arrayOf(PropTypes.object),\n config: PropTypes.object,\n layout: PropTypes.object,\n frames: PropTypes.arrayOf(PropTypes.object),\n onInitialized: PropTypes.func,\n };\n\n for (let i = 0; i < eventNames.length; i++) {\n PlotlyComponent.propTypes[\"on\" + eventNames[i]] = PropTypes.func;\n }\n\n PlotlyComponent.defaultProps = {\n debug: true,\n fit: false,\n data: [],\n };\n\n return PlotlyComponent;\n}\n"]}
\ No newline at end of file
diff --git a/lib/plotlyjs-react.js b/lib/plotlyjs-react.js
deleted file mode 100644
index f9d91ce..0000000
--- a/lib/plotlyjs-react.js
+++ /dev/null
@@ -1,227 +0,0 @@
-"use strict";
-
-Object.defineProperty(exports, "__esModule", {
- value: true
-});
-
-var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
-
-exports.default = createPlotlyComponent;
-
-var _react = require("react");
-
-var _react2 = _interopRequireDefault(_react);
-
-var _propTypes = require("prop-types");
-
-var _propTypes2 = _interopRequireDefault(_propTypes);
-
-var _fastIsnumeric = require("fast-isnumeric");
-
-var _fastIsnumeric2 = _interopRequireDefault(_fastIsnumeric);
-
-var _objectAssign = require("object-assign");
-
-var _objectAssign2 = _interopRequireDefault(_objectAssign);
-
-function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
-
-function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
-
-function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
-
-function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
-
-// The naming convention is:
-// - events are attached as `'plotly_' + eventName.toLowerCase()`
-// - react props are `'on' + eventName`
-var eventNames = ["AfterExport", "AfterPlot", "Animated", "AnimatingFrame", "AnimationInterrupted", "AutoSize", "BeforeExport", "ButtonClicked", "Click", "ClickAnnotation", "Deselect", "DoubleClick", "Framework", "Hover", "Relayout", "Restyle", "Redraw", "Selected", "Selecting", "SliderChange", "SliderEnd", "SliderStart", "Transitioning", "TransitionInterrupted", "Unhover"];
-
-// Check if a window is available since SSR (server-side rendering)
-// breaks unnecessarily if you try to use it server-side.
-var isBrowser = typeof window !== "undefined";
-
-function createPlotlyComponent(Plotly) {
- var hasReactAPIMethod = !!Plotly.react;
-
- var PlotlyComponent = function (_Component) {
- _inherits(PlotlyComponent, _Component);
-
- function PlotlyComponent(props) {
- _classCallCheck(this, PlotlyComponent);
-
- var _this = _possibleConstructorReturn(this, (PlotlyComponent.__proto__ || Object.getPrototypeOf(PlotlyComponent)).call(this, props));
-
- _this.p = Promise.resolve();
- _this.resizeHandler = null;
- _this.handlers = {};
-
- _this.syncWindowResize = _this.syncWindowResize.bind(_this);
- _this.syncEventHandlers = _this.syncEventHandlers.bind(_this);
- _this.getRef = _this.getRef.bind(_this);
- return _this;
- }
-
- _createClass(PlotlyComponent, [{
- key: "componentDidMount",
- value: function componentDidMount() {
- var _this2 = this;
-
- this.p = this.p.then(function () {
- return Plotly.plot(_this2.el, {
- data: _this2.props.data,
- layout: _this2.sizeAdjustedLayout(_this2.props.layout),
- config: _this2.props.config,
- frames: _this2.props.frames
- });
- }).then(function () {
- _this2.syncWindowResize();
- _this2.syncEventHandlers();
- });
- }
- }, {
- key: "componentWillReceiveProps",
- value: function componentWillReceiveProps(nextProps) {
- var _this3 = this;
-
- this.p = this.p.then(function () {
- return (hasReactAPIMethod ? Plotly.react : Plotly.newPlot)(_this3.el, {
- data: nextProps.data,
- layout: _this3.sizeAdjustedLayout(nextProps.layout),
- config: nextProps.config,
- frames: nextProps.frames
- }).then(function () {
- _this3.syncEventHandlers(nextProps);
- _this3.syncWindowResize(nextProps);
- });
- });
- }
- }, {
- key: "componentWillUnmount",
- value: function componentWillUnmount() {
- if (this.resizeHandler && isBrowser) {
- window.removeEventListener("resize", this.handleResize);
- this.resizeHandler = null;
- }
-
- Plotly.purge(this.el);
- }
- }, {
- key: "syncWindowResize",
- value: function syncWindowResize(props) {
- var _this4 = this;
-
- props = props || this.props;
- if (!isBrowser) return;
-
- if (props.fit && !this.resizeHandler) {
- if (!this.resizeHandler) {
- this.resizeHandler = function () {
- _this4.p = _this4.p.then(function () {
- return Plotly.relayout(_this4.el, _this4.getSize());
- });
- };
- window.addEventListener("resize", this.resizeHandler);
- this.resizeHandler();
- }
- } else if (!props.fit && this.resizeHandler) {
- window.removeEventListener('resize', this.resizeHandler);
- this.resizeHandler = null;
- }
- }
- }, {
- key: "getRef",
- value: function getRef(el) {
- this.el = el;
-
- if (this.props.debug && isBrowser) {
- window.gd = this.el;
- }
- }
-
- // Attach and remove event handlers as they're added or removed from props:
-
- }, {
- key: "syncEventHandlers",
- value: function syncEventHandlers(props) {
- // Allow use of nextProps if passed explicitly:
- props = props || this.props;
-
- for (var i = 0; i < eventNames.length; i++) {
- var eventName = eventNames[i];
- var prop = props["on" + eventName];
- var hasHandler = !!this.handlers[eventName];
-
- if (prop && !hasHandler) {
- var handler = this.handlers[eventName] = props["on" + eventName];
- this.el.on("plotly_" + eventName.toLowerCase(), handler);
- } else if (!prop && hasHandler) {
- // Needs to be removed:
- this.el.off("plotly_" + eventName.toLowerCase(), this.handlers[eventName]);
- delete this.handlers[eventName];
- }
- }
- }
- }, {
- key: "sizeAdjustedLayout",
- value: function sizeAdjustedLayout(layout) {
- var size = this.getSize();
-
- // Shallow-clone the layout so that we don't have to
- // modify the original object:
- layout = (0, _objectAssign2.default)({}, layout);
- (0, _objectAssign2.default)(layout, this.getSize());
- return layout;
- }
- }, {
- key: "getSize",
- value: function getSize() {
- var rect = void 0;
- var hasWidth = (0, _fastIsnumeric2.default)(this.props.width);
- var hasHeight = (0, _fastIsnumeric2.default)(this.props.height);
-
- if (!hasWidth || !hasHeight) {
- rect = this.el.parentElement.getBoundingClientRect();
- }
-
- return {
- width: hasWidth ? parseInt(this.props.width) : rect.width,
- height: hasHeight ? parseInt(this.props.height) : rect.height
- };
- }
- }, {
- key: "render",
- value: function render() {
- return _react2.default.createElement("div", { ref: this.getRef });
- }
- }]);
-
- return PlotlyComponent;
- }(_react.Component);
-
- PlotlyComponent.propTypes = {
- fit: _propTypes2.default.bool,
- width: _propTypes2.default.number,
- height: _propTypes2.default.number,
- data: _propTypes2.default.arrayOf(_propTypes2.default.object),
- config: _propTypes2.default.object,
- layout: _propTypes2.default.object,
- frames: _propTypes2.default.arrayOf(_propTypes2.default.object)
- };
-
- for (var i = 0; i < eventNames.length; i++) {
- PlotlyComponent.propTypes["on" + eventNames[i]] = _propTypes2.default.func;
- }
-
- PlotlyComponent.defaultProps = {
- fit: false,
- data: [],
- width: null,
- height: null
- };
-
- return PlotlyComponent;
-}
-module.exports = exports["default"];
-
-//# sourceMappingURL=plotlyjs-react.js.map
\ No newline at end of file
diff --git a/lib/plotlyjs-react.js.map b/lib/plotlyjs-react.js.map
deleted file mode 100644
index 701dae5..0000000
--- a/lib/plotlyjs-react.js.map
+++ /dev/null
@@ -1 +0,0 @@
-{"version":3,"sources":["../src/plotlyjs-react.jsx"],"names":[],"mappings":";;;;;;;;kBAwCwB,qB;;AAxCxB;;;;AACA;;;;AACA;;;;AACA;;;;;;;;;;;;AAEA;AACA;AACA;AACA,IAAM,aAAa,CACjB,aADiB,EAEjB,WAFiB,EAGjB,UAHiB,EAIjB,gBAJiB,EAKjB,sBALiB,EAMjB,UANiB,EAOjB,cAPiB,EAQjB,eARiB,EASjB,OATiB,EAUjB,iBAViB,EAWjB,UAXiB,EAYjB,aAZiB,EAajB,WAbiB,EAcjB,OAdiB,EAejB,UAfiB,EAgBjB,SAhBiB,EAiBjB,QAjBiB,EAkBjB,UAlBiB,EAmBjB,WAnBiB,EAoBjB,cApBiB,EAqBjB,WArBiB,EAsBjB,aAtBiB,EAuBjB,eAvBiB,EAwBjB,uBAxBiB,EAyBjB,SAzBiB,CAAnB;;AA4BA;AACA;AACA,IAAM,YAAY,OAAO,MAAP,KAAkB,WAApC;;AAEe,SAAS,qBAAT,CAAgC,MAAhC,EAAwC;AACrD,MAAM,oBAAoB,CAAC,CAAC,OAAO,KAAnC;;AADqD,MAG/C,eAH+C;AAAA;;AAInD,6BAAY,KAAZ,EAAmB;AAAA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,KAAK,KAAK,MAAf,GAAP;AACD;AAxIkD;;AAAA;AAAA;;AA2IrD,kBAAgB,SAAhB,GAA4B;AAC1B,SAAK,oBAAU,IADW;AAE1B,WAAO,oBAAU,MAFS;AAG1B,YAAQ,oBAAU,MAHQ;AAI1B,UAAM,oBAAU,OAAV,CAAkB,oBAAU,MAA5B,CAJoB;AAK1B,YAAQ,oBAAU,MALQ;AAM1B,YAAQ,oBAAU,MANQ;AAO1B,YAAQ,oBAAU,OAAV,CAAkB,oBAAU,MAA5B;AAPkB,GAA5B;;AAUA,OAAK,IAAI,IAAI,CAAb,EAAgB,IAAI,WAAW,MAA/B,EAAuC,GAAvC,EAA4C;AAC1C,oBAAgB,SAAhB,CAA0B,OAAO,WAAW,CAAX,CAAjC,IAAkD,oBAAU,IAA5D;AACD;;AAED,kBAAgB,YAAhB,GAA+B;AAC7B,SAAK,KADwB;AAE7B,UAAM,EAFuB;AAG7B,WAAO,IAHsB;AAI7B,YAAQ;AAJqB,GAA/B;;AAOA,SAAO,eAAP;AACD","file":"plotlyjs-react.js","sourcesContent":["import React, { Component } from \"react\";\nimport PropTypes from \"prop-types\";\nimport isNumeric from \"fast-isnumeric\";\nimport objectAssign from \"object-assign\";\n\n// The naming convention is:\n// - events are attached as `'plotly_' + eventName.toLowerCase()`\n// - react props are `'on' + eventName`\nconst eventNames = [\n \"AfterExport\",\n \"AfterPlot\",\n \"Animated\",\n \"AnimatingFrame\",\n \"AnimationInterrupted\",\n \"AutoSize\",\n \"BeforeExport\",\n \"ButtonClicked\",\n \"Click\",\n \"ClickAnnotation\",\n \"Deselect\",\n \"DoubleClick\",\n \"Framework\",\n \"Hover\",\n \"Relayout\",\n \"Restyle\",\n \"Redraw\",\n \"Selected\",\n \"Selecting\",\n \"SliderChange\",\n \"SliderEnd\",\n \"SliderStart\",\n \"Transitioning\",\n \"TransitionInterrupted\",\n \"Unhover\",\n];\n\n// Check if a window is available since SSR (server-side rendering)\n// breaks unnecessarily if you try to use it server-side.\nconst isBrowser = typeof window !== \"undefined\";\n\nexport default function createPlotlyComponent (Plotly) {\n const hasReactAPIMethod = !!Plotly.react;\n\n class PlotlyComponent extends Component {\n constructor(props) {\n super(props);\n\n this.p = Promise.resolve();\n this.resizeHandler = null;\n this.handlers = {};\n\n this.syncWindowResize = this.syncWindowResize.bind(this);\n this.syncEventHandlers = this.syncEventHandlers.bind(this);\n this.getRef = this.getRef.bind(this);\n }\n\n componentDidMount() {\n this.p = this.p\n .then(() => {\n return Plotly.plot(this.el, {\n data: this.props.data,\n layout: this.sizeAdjustedLayout(this.props.layout),\n config: this.props.config,\n frames: this.props.frames,\n });\n })\n .then(() => {\n this.syncWindowResize()\n this.syncEventHandlers()\n });\n }\n\n componentWillReceiveProps(nextProps) {\n this.p = this.p.then(() => {\n return (hasReactAPIMethod ? Plotly.react : Plotly.newPlot)(this.el, {\n data: nextProps.data,\n layout: this.sizeAdjustedLayout(nextProps.layout),\n config: nextProps.config,\n frames: nextProps.frames,\n }).then(() => {\n this.syncEventHandlers(nextProps)\n this.syncWindowResize(nextProps)\n });\n });\n }\n\n componentWillUnmount() {\n if (this.resizeHandler && isBrowser) {\n window.removeEventListener(\"resize\", this.handleResize);\n this.resizeHandler = null;\n }\n\n Plotly.purge(this.el);\n }\n\n syncWindowResize (props) {\n props = props || this.props;\n if (!isBrowser) return;\n\n if (props.fit && !this.resizeHandler) {\n if (!this.resizeHandler) {\n this.resizeHandler = () => {\n this.p = this.p.then(() => {\n return Plotly.relayout(this.el, this.getSize());\n });\n };\n window.addEventListener(\"resize\", this.resizeHandler);\n this.resizeHandler();\n }\n } else if (!props.fit && this.resizeHandler) {\n window.removeEventListener('resize', this.resizeHandler);\n this.resizeHandler = null;\n }\n }\n\n getRef(el) {\n this.el = el;\n\n if (this.props.debug && isBrowser) {\n window.gd = this.el;\n }\n }\n\n // Attach and remove event handlers as they're added or removed from props:\n syncEventHandlers(props) {\n // Allow use of nextProps if passed explicitly:\n props = props || this.props;\n\n for (let i = 0; i < eventNames.length; i++) {\n const eventName = eventNames[i];\n const prop = props[\"on\" + eventName];\n const hasHandler = !!this.handlers[eventName];\n\n if (prop && !hasHandler) {\n let handler = (this.handlers[eventName] = props[\n \"on\" + eventName\n ]);\n this.el.on(\"plotly_\" + eventName.toLowerCase(), handler);\n } else if (!prop && hasHandler) {\n // Needs to be removed:\n this.el.off(\n \"plotly_\" + eventName.toLowerCase(),\n this.handlers[eventName]\n );\n delete this.handlers[eventName];\n }\n }\n }\n\n sizeAdjustedLayout(layout) {\n const size = this.getSize();\n\n // Shallow-clone the layout so that we don't have to\n // modify the original object:\n layout = objectAssign({}, layout);\n objectAssign(layout, this.getSize());\n return layout;\n }\n\n getSize() {\n let rect;\n const hasWidth = isNumeric(this.props.width);\n const hasHeight = isNumeric(this.props.height);\n\n if (!hasWidth || !hasHeight) {\n rect = this.el.parentElement.getBoundingClientRect();\n }\n\n return {\n width: hasWidth ? parseInt(this.props.width) : rect.width,\n height: hasHeight ? parseInt(this.props.height) : rect.height,\n };\n }\n\n render() {\n return ;\n }\n }\n\n PlotlyComponent.propTypes = {\n fit: PropTypes.bool,\n width: PropTypes.number,\n height: PropTypes.number,\n data: PropTypes.arrayOf(PropTypes.object),\n config: PropTypes.object,\n layout: PropTypes.object,\n frames: PropTypes.arrayOf(PropTypes.object),\n };\n\n for (let i = 0; i < eventNames.length; i++) {\n PlotlyComponent.propTypes[\"on\" + eventNames[i]] = PropTypes.func;\n }\n\n PlotlyComponent.defaultProps = {\n fit: false,\n data: [],\n width: null,\n height: null,\n };\n\n return PlotlyComponent;\n}\n"]}
\ No newline at end of file
diff --git a/package.json b/package.json
index 3180bdc..0128858 100644
--- a/package.json
+++ b/package.json
@@ -1,32 +1,32 @@
{
- "name": "plotly.js-react",
+ "name": "react-plotly.js",
"version": "1.0.0",
"license": "MIT",
- "description": "A React component for plotly.js charts",
+ "description": "A plotly.js react component from Plotly",
"author": "Plotly, Inc.",
- "main": "lib/plotly.js-react.js",
+ "main": "react-plotly.js",
"repository": {
"type": "git",
- "url": "https://github.com/plotly/plotly.js-react.git"
+ "url": "https://github.com/plotly/react-plotly.js.git"
},
"bugs": {
- "url": "https://github.com/plotly/plotly.js-react/issues"
+ "url": "https://github.com/plotly/react-plotly.js/issues"
},
"scripts": {
"start": "budo example/src/index.js --dir example/src --dir example --open --live --host localhost -- -p [ css-modulesify --after autoprefixer --autoprefixer.browsers \"> 5%\" -o example/assets/styles.css ] -t [ babelify --presets [ es2015 react ] --plugins transform-class-properties ] -t brfs",
"example:build:html": "cp example/src/index.html example/dist/index.html",
- "example:build:js": "browserify example/src/index.js -p [ css-modulesify --after autoprefixer --autoprefixer.browsers \"> 5%\" -o example/dist/styles.css ] -t [ babelify --presets [ es2015 react ] --plugins transform-class-properties ] -t brfs -g [ envify --NODE_ENV production ] -g uglifyify -p bundle-collapser/plugin | uglifyjs --compress --mangle > example/dist/index.js",
+ "example:build:js": "browserify example/src/index.js -p [ css-modulesify --after autoprefixer --autoprefixer.browsers \"> 5%\" -o example/dist/styles.css ] -t [ babelify --presets [ es2015 react ] --plugins transform-class-properties ] -t brfs -g [ envify --NODE_ENV production ] -p bundle-collapser/plugin | uglifyjs --compress --mangle > example/dist/index.js",
"example:build:assets": "rm -rf example/dist/assets && cp -r example/assets example/dist/assets",
"example:build": "rm -rf example/dist && mkdir -p example/dist && npm run example:build:html && npm run example:build:js && npm run example:build:assets",
- "example:deploy": "netlify deploy example/dist",
- "make:lib": "mkdir -p lib && babel src/plotly.js-react.js -o lib/plotly.js-react.js --presets=es2015,react --source-maps --plugins babel-plugin-add-module-exports",
- "make:build": "mkdir -p build && browserify src/plotly.js-react.js -o ./build/plotly.js-react.js -t [ babelify --presets [ es2015 react ] ] -t browserify-global-shim --standalone createPlotlyComponent && uglifyjs ./build/plotly.js-react.js --compress --mangle --output ./build/plotly.js-react.min.js --source-map filename=build/plotly.js-react.min.js.map",
- "prepublish": "npm run make:lib && npm run make:build",
- "lint": "prettier --trailing-comma es5 --write \"{src,example/src}/**/*.js\"",
+ "make:lib": "mkdir -p lib && babel src --out-dir=lib --ignore __tests__/*.js,__mocks__/*.js --presets=es2015,react --source-maps --plugins babel-plugin-add-module-exports && mv lib/* ./ && rmdir lib",
+ "clean": "rm -rf lib react-plotly.js react-plotly.js.map factory.js factory.js.map",
+ "prepublishOnly": "npm run make:lib",
+ "lint": "prettier --trailing-comma es5 --write \"{src,example/src}/**/*.js\" && eslint src",
"precommit": "lint-staged",
- "test": "jest",
+ "test": "npm run lint && npm run deps && jest",
"watch-test": "jest --watch",
- "watch": "nodemon --exec \"npm run make:lib\" -w src"
+ "watch": "nodemon --exec \"npm run make:lib\" -w src",
+ "deps": "./node_modules/.bin/dependency-check package.json --entry src/react-plotly.js --missing"
},
"keywords": [
"graphing",
@@ -50,8 +50,11 @@
"budo": "^10.0.4",
"bundle-collapser": "^1.2.1",
"css-modulesify": "^0.28.0",
+ "dependency-check": "^2.9.1",
"envify": "^4.1.0",
"enzyme": "^2.9.1",
+ "eslint": "^4.8.0",
+ "eslint-plugin-react": "^7.4.0",
"event-emitter": "^0.3.5",
"gl": "^4.0.4",
"husky": "^0.14.3",
@@ -59,10 +62,8 @@
"jest": "^20.0.4",
"json-beautify": "^1.0.1",
"lint-staged": "^4.0.2",
- "netlify-cli": "^1.2.2",
"nodemon": "^1.11.0",
"onetime": "^1.1.0",
- "plotly.js": "^1.29.2",
"prettier": "^1.5.3",
"react": "^15.6.1",
"react-addons-test-utils": "^15.6.0",
@@ -71,8 +72,10 @@
"react-dom": "^15.6.1",
"react-test-renderer": "^15.6.1",
"throttle-debounce": "^1.0.1",
- "uglify-js": "^3.0.26",
- "uglifyify": "^4.0.3"
+ "uglify-js": "^3.0.26"
+ },
+ "peerDependencies": {
+ "plotly.js": ">1.0.0"
},
"browserify-global-shim": {
"react": "React"
diff --git a/react-plotly.js b/react-plotly.js
new file mode 100644
index 0000000..4f9ca1e
--- /dev/null
+++ b/react-plotly.js
@@ -0,0 +1,21 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _factory = require("./factory");
+
+var _factory2 = _interopRequireDefault(_factory);
+
+var _plotly = require("plotly.js");
+
+var _plotly2 = _interopRequireDefault(_plotly);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+var PlotComponent = (0, _factory2.default)(_plotly2.default);
+
+exports.default = PlotComponent;
+module.exports = exports["default"];
+//# sourceMappingURL=react-plotly.js.map
\ No newline at end of file
diff --git a/react-plotly.js.map b/react-plotly.js.map
new file mode 100644
index 0000000..da8e627
--- /dev/null
+++ b/react-plotly.js.map
@@ -0,0 +1 @@
+{"version":3,"sources":["../src/react-plotly.js"],"names":["PlotComponent"],"mappings":";;;;;;AAAA;;;;AACA;;;;;;AAEA,IAAMA,gBAAgB,wCAAtB;;kBAEeA,a","file":"react-plotly.js","sourcesContent":["import plotComponentFactory from \"./factory\";\nimport Plotly from \"plotly.js\";\n\nconst PlotComponent = plotComponentFactory(Plotly);\n\nexport default PlotComponent;\n"]}
\ No newline at end of file
diff --git a/scripts/example-build-html.sh b/scripts/example-build-html.sh
deleted file mode 100755
index adb1571..0000000
--- a/scripts/example-build-html.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/usr/bin/env sh
-
-cp example/src/index.html example/dist/index.html
diff --git a/scripts/example-build-js.sh b/scripts/example-build-js.sh
deleted file mode 100755
index b42e198..0000000
--- a/scripts/example-build-js.sh
+++ /dev/null
@@ -1,14 +0,0 @@
-browserify example/src/index.js \
- -p [ \
- css-modulesify --after autoprefixer --autoprefixer.browsers "> 5%" -o example/dist/styles.css \
- ] \
- -t [ \
- babelify \
- --presets [ es2015 react ] \
- --plugins transform-class-properties ] \
- -t brfs \
- -g [ envify --NODE_ENV production ] \
- -g uglifyify \
- -p bundle-collapser/plugin \
- | uglifyjs --compress --mangle \
- > example/dist/index.js
diff --git a/scripts/start.sh b/scripts/start.sh
deleted file mode 100755
index 89e75ee..0000000
--- a/scripts/start.sh
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/usr/bin/env sh
-
-budo example/src/index.js \
- --dir example/src \
- --open \
- --live \
- --host localhost \
- -- \
- -p [ \
- css-modulesify --after autoprefixer --autoprefixer.browsers "> 5%" -o example/src/assets/styles.css \
- ] \
- -t [ \
- babelify \
- --presets [ es2015 react ] \
- --plugins transform-class-properties \
- ] \
- -t brfs
diff --git a/src/__mocks__/plotly.js b/src/__mocks__/plotly.js
index e01d02f..5bdc95e 100644
--- a/src/__mocks__/plotly.js
+++ b/src/__mocks__/plotly.js
@@ -31,7 +31,7 @@ export default {
}, ASYNC_DELAY);
}),
update: jest.fn(),
- purge: jest.fn(gd => {
+ purge: jest.fn(() => {
state.gd = nll;
}),
};
diff --git a/src/__tests__/plotlyjs-react.test.js b/src/__tests__/react-plotly.test.js
similarity index 90%
rename from src/__tests__/plotlyjs-react.test.js
rename to src/__tests__/react-plotly.test.js
index 2cb81ea..b7be993 100644
--- a/src/__tests__/plotlyjs-react.test.js
+++ b/src/__tests__/react-plotly.test.js
@@ -1,15 +1,21 @@
import React from "react";
-import { mount, shallow } from "enzyme";
-import createComponent from "../plotly.js-react";
+import { mount } from "enzyme";
+import createComponent from "../factory";
import once from "onetime";
describe("", () => {
- let Plotly, Plot;
+ let Plotly, PlotComponent;
function createPlot(props) {
return new Promise((resolve, reject) => {
const plot = mount(
- resolve(plot)} onError={reject} />
+ {
+ resolve(plot);
+ }}
+ onError={reject}
+ />
);
});
}
@@ -32,10 +38,13 @@ describe("", () => {
describe("with mocked plotly.js", () => {
beforeEach(() => {
Plotly = require.requireMock("../__mocks__/plotly.js").default;
- Plot = createComponent(Plotly);
+ PlotComponent = createComponent(Plotly);
// Override the parent element size:
- Plot.prototype.getParentSize = () => ({ width: 123, height: 456 });
+ PlotComponent.prototype.getParentSize = () => ({
+ width: 123,
+ height: 456,
+ });
});
describe("initialization", function() {
@@ -44,7 +53,9 @@ describe("", () => {
.then(() => {
expect(Plotly.newPlot).toHaveBeenCalled();
})
- .catch(err => done.fail(err))
+ .catch(err => {
+ done.fail(err);
+ })
.then(done);
});
@@ -130,7 +141,6 @@ describe("", () => {
describe("responding to window events", () => {
describe("with fit: true", () => {
test("does not call relayout on initialization", done => {
- let relayoutCnt = 0;
createPlot({
fit: true,
onRelayout: () => done.fail("Unexpected relayout event"),
@@ -161,7 +171,6 @@ describe("", () => {
describe("with fit: false", () => {
test("does not call relayout on init", done => {
- let relayoutCnt = 0;
createPlot({
fit: false,
onRelayout: () => done.fail("Unexpected relayout event"),
@@ -173,7 +182,6 @@ describe("", () => {
});
test("does not call relayout on window resize", done => {
- let relayoutCnt = 0;
createPlot({
fit: false,
onRelayout: () => done.fail("Unexpected relayout event"),
diff --git a/src/plotly.js-react.js b/src/factory.js
similarity index 84%
rename from src/plotly.js-react.js
rename to src/factory.js
index 41e5b8a..877b748 100644
--- a/src/plotly.js-react.js
+++ b/src/factory.js
@@ -2,11 +2,7 @@ import React, { Component } from "react";
import PropTypes from "prop-types";
import isNumeric from "fast-isnumeric";
import objectAssign from "object-assign";
-import throttle from "throttle-debounce/throttle";
-
-function constructUpdate(diff) {
- var keys = Object.keys(diff);
-}
+// import throttle from "throttle-debounce/throttle";
// The naming convention is:
// - events are attached as `'plotly_' + eventName.toLowerCase()`
@@ -51,7 +47,7 @@ const updateEvents = [
// breaks unnecessarily if you try to use it server-side.
const isBrowser = typeof window !== "undefined";
-export default function createPlotlyComponent(Plotly) {
+export default function plotComponentFactory(Plotly) {
const hasReactAPIMethod = !!Plotly.react;
class PlotlyComponent extends Component {
@@ -71,6 +67,15 @@ export default function createPlotlyComponent(Plotly) {
this.handleUpdate = this.handleUpdate.bind(this);
}
+ shouldComponentUpdate(nextProps) {
+ if (isNumeric(nextProps.revision) && isNumeric(this.props.revision)) {
+ // If revision is numeric, then increment only if revision has increased:
+ return nextProps.revision > this.props.revision;
+ } else {
+ return true;
+ }
+ }
+
componentDidMount() {
this.p = this.p
.then(() => {
@@ -81,16 +86,19 @@ export default function createPlotlyComponent(Plotly) {
frames: this.props.frames,
});
})
- .then(this.attachUpdateEvents)
.then(() => this.syncWindowResize(null, false))
- .then(() => this.syncEventHandlers())
- .then(this.handleUpdate, () => {
- this.props.onError && this.props.onError();
+ .then(this.syncEventHandlers)
+ .then(this.attachUpdateEvents)
+ //.then(
+ //() => this.props.onInitialized && this.props.onInitialized(this.el)
+ //)
+ .catch(e => {
+ console.error("Error while plotting:", e);
+ return this.props.onError && this.props.onError();
});
}
- componentWillReceiveProps(nextProps) {
- let dataDiff, layoutDiff, configDiff;
+ componentWillUpdate(nextProps) {
let nextLayout = this.sizeAdjustedLayout(nextProps.layout);
this.p = this.p
@@ -113,8 +121,10 @@ export default function createPlotlyComponent(Plotly) {
})
.then(() => this.syncEventHandlers(nextProps))
.then(() => this.syncWindowResize(nextProps))
- .then(() => () => this.handleUpdate(nextProps))
+ .then(this.attachUpdateEvents)
+ .then(() => this.handleUpdate(nextProps))
.catch(err => {
+ console.error("Error while plotting:", err);
this.props.onError && this.props.onError(err);
});
}
@@ -132,7 +142,9 @@ export default function createPlotlyComponent(Plotly) {
attachUpdateEvents() {
for (let i = 0; i < updateEvents.length; i++) {
- this.el.on(updateEvents[i], this.handleUpdate);
+ this.el.on(updateEvents[i], () => {
+ this.handleUpdate();
+ });
}
}
@@ -171,6 +183,10 @@ export default function createPlotlyComponent(Plotly) {
getRef(el) {
this.el = el;
+ if (this.props.onInitialized) {
+ this.props.onInitialized(el);
+ }
+
if (this.props.debug && isBrowser) {
window.gd = this.el;
}
@@ -251,6 +267,10 @@ export default function createPlotlyComponent(Plotly) {
layout: PropTypes.object,
frames: PropTypes.arrayOf(PropTypes.object),
onInitialized: PropTypes.func,
+ onError: PropTypes.func,
+ onUpdate: PropTypes.func,
+ debug: PropTypes.bool,
+ //onGraphDiv: PropTypes.func,
};
for (let i = 0; i < eventNames.length; i++) {
@@ -258,7 +278,7 @@ export default function createPlotlyComponent(Plotly) {
}
PlotlyComponent.defaultProps = {
- debug: true,
+ debug: false,
fit: false,
data: [],
};
diff --git a/src/react-plotly.js b/src/react-plotly.js
new file mode 100644
index 0000000..e4b9382
--- /dev/null
+++ b/src/react-plotly.js
@@ -0,0 +1,6 @@
+import plotComponentFactory from "./factory";
+import Plotly from "plotly.js";
+
+const PlotComponent = plotComponentFactory(Plotly);
+
+export default PlotComponent;