dash-core-components 3.0.3 → 3.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/dash_core_components/async-datepicker.js +1 -1
  2. package/dash_core_components/async-datepicker.js.map +1 -1
  3. package/dash_core_components/async-dropdown.js +1 -1
  4. package/dash_core_components/async-dropdown.js.map +1 -1
  5. package/dash_core_components/async-graph.js +1 -1
  6. package/dash_core_components/async-graph.js.map +1 -1
  7. package/dash_core_components/async-highlight.js +1 -1
  8. package/dash_core_components/async-highlight.js.map +1 -1
  9. package/dash_core_components/async-markdown.js +1 -1
  10. package/dash_core_components/async-markdown.js.map +1 -1
  11. package/dash_core_components/async-slider.js +1 -1
  12. package/dash_core_components/async-slider.js.map +1 -1
  13. package/dash_core_components/async-upload.js +1 -1
  14. package/dash_core_components/async-upload.js.map +1 -1
  15. package/dash_core_components/dash_core_components.js +1 -1
  16. package/dash_core_components/dash_core_components.js.map +1 -1
  17. package/lib/components/Checklist.react.js +46 -63
  18. package/lib/components/Clipboard.react.js +172 -218
  19. package/lib/components/ConfirmDialog.react.js +34 -61
  20. package/lib/components/ConfirmDialogProvider.react.js +21 -44
  21. package/lib/components/DatePickerRange.react.js +7 -26
  22. package/lib/components/DatePickerSingle.react.js +7 -26
  23. package/lib/components/Download.react.js +22 -45
  24. package/lib/components/Dropdown.react.js +7 -26
  25. package/lib/components/Geolocation.react.js +64 -91
  26. package/lib/components/Graph.react.js +70 -97
  27. package/lib/components/Input.react.js +119 -162
  28. package/lib/components/Interval.react.js +55 -86
  29. package/lib/components/Link.react.js +4 -4
  30. package/lib/components/Loading.react.js +31 -35
  31. package/lib/components/Location.react.js +97 -126
  32. package/lib/components/Markdown.react.js +15 -35
  33. package/lib/components/RadioItems.react.js +45 -63
  34. package/lib/components/RangeSlider.react.js +7 -26
  35. package/lib/components/Slider.react.js +7 -26
  36. package/lib/components/Store.react.js +128 -176
  37. package/lib/components/Tab.react.js +1 -1
  38. package/lib/components/Tabs.react.js +99 -134
  39. package/lib/components/Textarea.react.js +4 -4
  40. package/lib/components/Tooltip.react.js +7 -6
  41. package/lib/components/Upload.react.js +7 -26
  42. package/lib/fragments/DatePickerRange.react.js +150 -181
  43. package/lib/fragments/DatePickerSingle.react.js +103 -134
  44. package/lib/fragments/Dropdown.react.js +11 -19
  45. package/lib/fragments/Graph.privateprops.js +3 -9
  46. package/lib/fragments/Graph.react.js +302 -370
  47. package/lib/fragments/Loading/spinners/CircleSpinner.js +2 -4
  48. package/lib/fragments/Loading/spinners/CubeSpinner.js +2 -4
  49. package/lib/fragments/Loading/spinners/DefaultSpinner.js +2 -4
  50. package/lib/fragments/Loading/spinners/DotSpinner.js +2 -4
  51. package/lib/fragments/Loading/spinners/GraphSpinner.js +2 -4
  52. package/lib/fragments/Markdown.react.js +119 -158
  53. package/lib/fragments/Math.react.js +23 -47
  54. package/lib/fragments/RangeSlider.react.js +110 -133
  55. package/lib/fragments/Slider.react.js +110 -133
  56. package/lib/fragments/Upload.react.js +82 -99
  57. package/lib/utils/DatePickerPersistence.js +2 -4
  58. package/lib/utils/LazyLoader/datePickerRange.js +2 -3
  59. package/lib/utils/LazyLoader/datePickerSingle.js +2 -3
  60. package/lib/utils/LazyLoader/dropdown.js +2 -3
  61. package/lib/utils/LazyLoader/graph.js +2 -3
  62. package/lib/utils/LazyLoader/hljs.js +2 -5
  63. package/lib/utils/LazyLoader/markdown.js +2 -3
  64. package/lib/utils/LazyLoader/mathjax.js +2 -5
  65. package/lib/utils/LazyLoader/plotly.js +7 -6
  66. package/lib/utils/LazyLoader/rangeSlider.js +2 -3
  67. package/lib/utils/LazyLoader/slider.js +2 -3
  68. package/lib/utils/LazyLoader/upload.js +2 -3
  69. package/lib/utils/MarkdownHighlighter.js +5 -6
  70. package/lib/utils/ResizeDetector.js +9 -13
  71. package/lib/utils/computeSliderMarkers.js +29 -49
  72. package/lib/utils/computeSliderStyle.js +4 -3
  73. package/lib/utils/convertToMoment.js +5 -6
  74. package/lib/utils/formatSliderTooltip.js +6 -8
  75. package/lib/utils/optionTypes.js +8 -9
  76. package/package.json +1 -1
@@ -17,24 +17,14 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
17
17
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
18
18
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
19
19
  function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
20
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
21
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
20
22
  function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
21
23
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
22
24
  function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
23
25
  function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
24
26
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
25
- function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
26
- function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
27
- function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
28
- function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
29
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
30
- function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
31
- function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
32
- function _possibleConstructorReturn(t, e) { if (e && ("object" == typeof e || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
33
- function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
34
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
35
- function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
36
- function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
37
- function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); } /* global Plotly:true */
27
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; } /* global Plotly:true */
38
28
  /**
39
29
  * `autosize: true` causes Plotly.js to conform to the parent element size.
40
30
  * This is necessary for `dcc.Graph` call to `Plotly.Plots.resize(target)` to do something.
@@ -66,7 +56,7 @@ var AUTO_CONFIG = {};
66
56
  var UNRESPONSIVE_CONFIG = {
67
57
  responsive: false
68
58
  };
69
- var filterEventData = function filterEventData(gd, eventData, event) {
59
+ var filterEventData = (gd, eventData, event) => {
70
60
  var filteredEventData;
71
61
  if ((0, _ramda.includes)(event, ['click', 'hover', 'selected'])) {
72
62
  var points = [];
@@ -143,396 +133,338 @@ var filterEventData = function filterEventData(gd, eventData, event) {
143
133
  * You can define callbacks based on user interaction with Graphs such as
144
134
  * hovering, clicking or selecting
145
135
  */
146
- var PlotlyGraph = /*#__PURE__*/function (_Component) {
147
- function PlotlyGraph(props) {
148
- var _this2;
149
- _classCallCheck(this, PlotlyGraph);
150
- _this2 = _callSuper(this, PlotlyGraph, [props]);
151
- _this2.gd = /*#__PURE__*/_react.default.createRef();
152
- _this2._hasPlotted = false;
153
- _this2._prevGd = null;
154
- _this2._queue = Promise.resolve();
155
- _this2.parentElement = /*#__PURE__*/_react.default.createRef();
156
- _this2.bindEvents = _this2.bindEvents.bind(_this2);
157
- _this2.getConfig = _this2.getConfig.bind(_this2);
158
- _this2.getConfigOverride = _this2.getConfigOverride.bind(_this2);
159
- _this2.getLayout = _this2.getLayout.bind(_this2);
160
- _this2.getLayoutOverride = _this2.getLayoutOverride.bind(_this2);
161
- _this2.graphResize = _this2.graphResize.bind(_this2);
162
- _this2.isResponsive = _this2.isResponsive.bind(_this2);
163
- _this2.amendTraces = _this2.amendTraces.bind(_this2);
164
- _this2.state = {
136
+ class PlotlyGraph extends _react.Component {
137
+ constructor(props) {
138
+ super(props);
139
+ this.gd = /*#__PURE__*/_react.default.createRef();
140
+ this._hasPlotted = false;
141
+ this._prevGd = null;
142
+ this._queue = Promise.resolve();
143
+ this.parentElement = /*#__PURE__*/_react.default.createRef();
144
+ this.bindEvents = this.bindEvents.bind(this);
145
+ this.getConfig = this.getConfig.bind(this);
146
+ this.getConfigOverride = this.getConfigOverride.bind(this);
147
+ this.getLayout = this.getLayout.bind(this);
148
+ this.getLayoutOverride = this.getLayoutOverride.bind(this);
149
+ this.graphResize = this.graphResize.bind(this);
150
+ this.isResponsive = this.isResponsive.bind(this);
151
+ this.amendTraces = this.amendTraces.bind(this);
152
+ this.state = {
165
153
  override: {},
166
154
  originals: {}
167
155
  };
168
- return _this2;
169
156
  }
170
- _inherits(PlotlyGraph, _Component);
171
- return _createClass(PlotlyGraph, [{
172
- key: "plot",
173
- value: function plot(props) {
174
- var _figure,
175
- _figure2,
176
- _figure3,
177
- _this3 = this;
178
- var figure = props.figure,
179
- config = props.config;
180
- var animate = props.animate,
181
- animation_options = props.animation_options,
182
- responsive = props.responsive,
183
- mathjax = props.mathjax;
184
- var gd = this.gd.current;
185
- figure = props._dashprivate_transformFigure(figure, gd);
186
- config = props._dashprivate_transformConfig(config, gd);
187
- var configClone = this.getConfig(config, responsive);
188
- // add typesetMath | not exposed to the dash API
189
- configClone.typesetMath = mathjax;
190
- var figureClone = {
191
- data: (_figure = figure) === null || _figure === void 0 ? void 0 : _figure.data,
192
- layout: this.getLayout((_figure2 = figure) === null || _figure2 === void 0 ? void 0 : _figure2.layout, responsive),
193
- frames: (_figure3 = figure) === null || _figure3 === void 0 ? void 0 : _figure3.frames,
194
- config: configClone
195
- };
196
- if (animate && this._hasPlotted && figure.data.length === gd.data.length) {
197
- // in case we've have figure frames,
198
- // we need to recreate frames before animation
199
- if (figure.frames) {
200
- return Plotly.deleteFrames(gd).then(function () {
201
- return Plotly.addFrames(gd, figure.frames);
202
- }).then(function () {
203
- return Plotly.animate(gd, figureClone, animation_options);
204
- });
205
- }
206
- return Plotly.animate(gd, figureClone, animation_options);
157
+ plot(props) {
158
+ var _figure, _figure2, _figure3;
159
+ var figure = props.figure,
160
+ config = props.config;
161
+ var animate = props.animate,
162
+ animation_options = props.animation_options,
163
+ responsive = props.responsive,
164
+ mathjax = props.mathjax;
165
+ var gd = this.gd.current;
166
+ figure = props._dashprivate_transformFigure(figure, gd);
167
+ config = props._dashprivate_transformConfig(config, gd);
168
+ var configClone = this.getConfig(config, responsive);
169
+ // add typesetMath | not exposed to the dash API
170
+ configClone.typesetMath = mathjax;
171
+ var figureClone = {
172
+ data: (_figure = figure) === null || _figure === void 0 ? void 0 : _figure.data,
173
+ layout: this.getLayout((_figure2 = figure) === null || _figure2 === void 0 ? void 0 : _figure2.layout, responsive),
174
+ frames: (_figure3 = figure) === null || _figure3 === void 0 ? void 0 : _figure3.frames,
175
+ config: configClone
176
+ };
177
+ if (animate && this._hasPlotted && figure.data.length === gd.data.length) {
178
+ // in case we've have figure frames,
179
+ // we need to recreate frames before animation
180
+ if (figure.frames) {
181
+ return Plotly.deleteFrames(gd).then(() => Plotly.addFrames(gd, figure.frames)).then(() => Plotly.animate(gd, figureClone, animation_options));
207
182
  }
208
- gd.classList.add('dash-graph--pending');
209
- return (0, _mathjax.default)(mathjax).then(function () {
210
- var gd = _this3.gd.current;
211
- return gd && Plotly.react(gd, figureClone);
212
- }).then(function () {
213
- var gd = _this3.gd.current;
183
+ return Plotly.animate(gd, figureClone, animation_options);
184
+ }
185
+ gd.classList.add('dash-graph--pending');
186
+ return (0, _mathjax.default)(mathjax).then(() => {
187
+ var gd = this.gd.current;
188
+ return gd && Plotly.react(gd, figureClone);
189
+ }).then(() => {
190
+ var gd = this.gd.current;
214
191
 
215
- // double-check gd hasn't been unmounted
216
- if (!gd) {
217
- return;
218
- }
219
- gd.classList.remove('dash-graph--pending');
192
+ // double-check gd hasn't been unmounted
193
+ if (!gd) {
194
+ return;
195
+ }
196
+ gd.classList.remove('dash-graph--pending');
220
197
 
221
- // in case we've made a new DOM element, transfer events
222
- if (_this3._hasPlotted && gd !== _this3._prevGd) {
223
- if (_this3._prevGd && _this3._prevGd.removeAllListeners) {
224
- _this3._prevGd.removeAllListeners();
225
- Plotly.purge(_this3._prevGd);
226
- }
227
- _this3._hasPlotted = false;
198
+ // in case we've made a new DOM element, transfer events
199
+ if (this._hasPlotted && gd !== this._prevGd) {
200
+ if (this._prevGd && this._prevGd.removeAllListeners) {
201
+ this._prevGd.removeAllListeners();
202
+ Plotly.purge(this._prevGd);
228
203
  }
229
- if (!_this3._hasPlotted) {
230
- _this3.bindEvents();
231
- _this3.graphResize(true);
232
- _this3._hasPlotted = true;
233
- _this3._prevGd = gd;
204
+ this._hasPlotted = false;
205
+ }
206
+ if (!this._hasPlotted) {
207
+ this.bindEvents();
208
+ this.graphResize(true);
209
+ this._hasPlotted = true;
210
+ this._prevGd = gd;
211
+ }
212
+ });
213
+ }
214
+ amendTraces(p, oldProps, newProps) {
215
+ var oldPrepend = oldProps.prependData,
216
+ oldExtend = oldProps.extendData;
217
+ var newPrepend = newProps.prependData,
218
+ newExtend = newProps.extendData;
219
+ var _this = this;
220
+ function mergeTraces(props, dataKey, plotlyFnKey) {
221
+ var clearState = props.clearState;
222
+ var dataArray = props[dataKey];
223
+ var _p = Promise.resolve();
224
+ dataArray.forEach(data => {
225
+ var updateData, traceIndices, maxPoints;
226
+ if (Array.isArray(data) && typeof data[0] === 'object') {
227
+ var _data = _slicedToArray(data, 3);
228
+ updateData = _data[0];
229
+ traceIndices = _data[1];
230
+ maxPoints = _data[2];
231
+ } else {
232
+ updateData = data;
234
233
  }
235
- });
236
- }
237
- }, {
238
- key: "amendTraces",
239
- value: function amendTraces(p, oldProps, newProps) {
240
- var oldPrepend = oldProps.prependData,
241
- oldExtend = oldProps.extendData;
242
- var newPrepend = newProps.prependData,
243
- newExtend = newProps.extendData;
244
- var _this = this;
245
- function mergeTraces(props, dataKey, plotlyFnKey) {
246
- var clearState = props.clearState;
247
- var dataArray = props[dataKey];
248
- var _p = Promise.resolve();
249
- dataArray.forEach(function (data) {
250
- var updateData, traceIndices, maxPoints;
251
- if (Array.isArray(data) && typeof data[0] === 'object') {
252
- var _data = _slicedToArray(data, 3);
253
- updateData = _data[0];
254
- traceIndices = _data[1];
255
- maxPoints = _data[2];
256
- } else {
257
- updateData = data;
234
+ if (!traceIndices) {
235
+ function getFirstProp(data) {
236
+ return data[Object.keys(data)[0]];
258
237
  }
259
- if (!traceIndices) {
260
- var getFirstProp = function getFirstProp(data) {
261
- return data[Object.keys(data)[0]];
262
- };
263
- var generateIndices = function generateIndices(data) {
264
- return Array.from(Array(getFirstProp(data).length).keys());
265
- };
266
- traceIndices = generateIndices(updateData);
238
+ function generateIndices(data) {
239
+ return Array.from(Array(getFirstProp(data).length).keys());
267
240
  }
268
- _p = _p.then(function () {
269
- var gd = _this.gd.current;
270
- return gd && Plotly[plotlyFnKey](gd, updateData, traceIndices, maxPoints);
271
- });
272
- });
273
- return _p.then(function () {
274
- return clearState(dataKey);
275
- });
276
- }
277
- var modified = false;
278
- if (newPrepend !== null && newPrepend !== void 0 && newPrepend.length && oldPrepend !== newPrepend) {
279
- modified = true;
280
- p = p.then(function () {
281
- return mergeTraces(newProps, 'prependData', 'prependTraces');
282
- });
283
- }
284
- if (newExtend !== null && newExtend !== void 0 && newExtend.length && oldExtend !== newExtend) {
285
- modified = true;
286
- p = p.then(function () {
287
- return mergeTraces(newProps, 'extendData', 'extendTraces');
288
- });
289
- }
290
- if (modified) {
291
- p = p.then(function () {
292
- return newProps._dashprivate_onFigureModified(newProps.figure);
241
+ traceIndices = generateIndices(updateData);
242
+ }
243
+ _p = _p.then(() => {
244
+ var gd = _this.gd.current;
245
+ return gd && Plotly[plotlyFnKey](gd, updateData, traceIndices, maxPoints);
293
246
  });
294
- }
295
- return p;
247
+ });
248
+ return _p.then(() => clearState(dataKey));
296
249
  }
297
- }, {
298
- key: "getConfig",
299
- value: function getConfig(config, responsive) {
300
- return (0, _ramda.mergeDeepRight)(config, this.getConfigOverride(responsive));
250
+ var modified = false;
251
+ if (newPrepend !== null && newPrepend !== void 0 && newPrepend.length && oldPrepend !== newPrepend) {
252
+ modified = true;
253
+ p = p.then(() => mergeTraces(newProps, 'prependData', 'prependTraces'));
301
254
  }
302
- }, {
303
- key: "getLayout",
304
- value: function getLayout(layout, responsive) {
305
- if (!layout) {
306
- return layout;
307
- }
308
- var override = this.getLayoutOverride(responsive);
309
- var _this$state = this.state,
310
- prev_override = _this$state.override,
311
- prev_originals = _this$state.originals;
312
- // Store the original data that we're about to override
313
- var originals = {};
314
- for (var key in override) {
315
- if (layout[key] !== prev_override[key]) {
316
- originals[key] = layout[key];
317
- } else if (prev_originals.hasOwnProperty(key)) {
318
- originals[key] = prev_originals[key];
319
- }
320
- }
321
- this.setState({
322
- override,
323
- originals
324
- });
325
- // Undo the previous override, but only for keys that the user did not change
326
- for (var _key in prev_originals) {
327
- if (layout[_key] === prev_override[_key]) {
328
- layout[_key] = prev_originals[_key];
329
- }
330
- }
331
- // Apply the current override
332
- for (var _key2 in override) {
333
- layout[_key2] = override[_key2];
334
- }
335
- return layout; // not really a clone
255
+ if (newExtend !== null && newExtend !== void 0 && newExtend.length && oldExtend !== newExtend) {
256
+ modified = true;
257
+ p = p.then(() => mergeTraces(newProps, 'extendData', 'extendTraces'));
336
258
  }
337
- }, {
338
- key: "getConfigOverride",
339
- value: function getConfigOverride(responsive) {
340
- switch (responsive) {
341
- case false:
342
- return UNRESPONSIVE_CONFIG;
343
- case true:
344
- return RESPONSIVE_CONFIG;
345
- default:
346
- return AUTO_CONFIG;
347
- }
259
+ if (modified) {
260
+ p = p.then(() => newProps._dashprivate_onFigureModified(newProps.figure));
348
261
  }
349
- }, {
350
- key: "getLayoutOverride",
351
- value: function getLayoutOverride(responsive) {
352
- switch (responsive) {
353
- case false:
354
- return UNRESPONSIVE_LAYOUT;
355
- case true:
356
- return RESPONSIVE_LAYOUT;
357
- default:
358
- return AUTO_LAYOUT;
359
- }
262
+ return p;
263
+ }
264
+ getConfig(config, responsive) {
265
+ return (0, _ramda.mergeDeepRight)(config, this.getConfigOverride(responsive));
266
+ }
267
+ getLayout(layout, responsive) {
268
+ if (!layout) {
269
+ return layout;
360
270
  }
361
- }, {
362
- key: "isResponsive",
363
- value: function isResponsive(props) {
364
- var config = props.config,
365
- figure = props.figure,
366
- responsive = props.responsive;
367
- if ((0, _ramda.type)(responsive) === 'Boolean') {
368
- return responsive;
271
+ var override = this.getLayoutOverride(responsive);
272
+ var _this$state = this.state,
273
+ prev_override = _this$state.override,
274
+ prev_originals = _this$state.originals;
275
+ // Store the original data that we're about to override
276
+ var originals = {};
277
+ for (var key in override) {
278
+ if (layout[key] !== prev_override[key]) {
279
+ originals[key] = layout[key];
280
+ } else if (prev_originals.hasOwnProperty(key)) {
281
+ originals[key] = prev_originals[key];
369
282
  }
370
- return Boolean(config.responsive && (!figure.layout || (figure.layout.autosize || (0, _ramda.isNil)(figure.layout.autosize)) && ((0, _ramda.isNil)(figure.layout.height) || (0, _ramda.isNil)(figure.layout.width))));
371
283
  }
372
- }, {
373
- key: "graphResize",
374
- value: function graphResize() {
375
- var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
376
- if (!force && !this.isResponsive(this.props)) {
377
- return;
284
+ this.setState({
285
+ override,
286
+ originals
287
+ });
288
+ // Undo the previous override, but only for keys that the user did not change
289
+ for (var _key in prev_originals) {
290
+ if (layout[_key] === prev_override[_key]) {
291
+ layout[_key] = prev_originals[_key];
378
292
  }
379
- var gd = this.gd.current;
380
- if (!gd) {
381
- return;
382
- }
383
- gd.classList.add('dash-graph--pending');
384
- Plotly.Plots.resize(gd).catch(function () {}).finally(function () {
385
- return gd.classList.remove('dash-graph--pending');
386
- });
387
293
  }
388
- }, {
389
- key: "bindEvents",
390
- value: function bindEvents() {
391
- var _this$props = this.props,
392
- setProps = _this$props.setProps,
393
- clear_on_unhover = _this$props.clear_on_unhover,
394
- relayoutData = _this$props.relayoutData,
395
- restyleData = _this$props.restyleData,
396
- hoverData = _this$props.hoverData,
397
- selectedData = _this$props.selectedData;
398
- var gd = this.gd.current;
399
- gd.on('plotly_click', function (eventData) {
400
- var clickData = filterEventData(gd, eventData, 'click');
401
- if (!(0, _ramda.isNil)(clickData)) {
402
- setProps({
403
- clickData
404
- });
405
- }
406
- });
407
- gd.on('plotly_clickannotation', function (eventData) {
408
- var clickAnnotationData = (0, _ramda.omit)(['event', 'fullAnnotation'], eventData);
294
+ // Apply the current override
295
+ for (var _key2 in override) {
296
+ layout[_key2] = override[_key2];
297
+ }
298
+ return layout; // not really a clone
299
+ }
300
+ getConfigOverride(responsive) {
301
+ switch (responsive) {
302
+ case false:
303
+ return UNRESPONSIVE_CONFIG;
304
+ case true:
305
+ return RESPONSIVE_CONFIG;
306
+ default:
307
+ return AUTO_CONFIG;
308
+ }
309
+ }
310
+ getLayoutOverride(responsive) {
311
+ switch (responsive) {
312
+ case false:
313
+ return UNRESPONSIVE_LAYOUT;
314
+ case true:
315
+ return RESPONSIVE_LAYOUT;
316
+ default:
317
+ return AUTO_LAYOUT;
318
+ }
319
+ }
320
+ isResponsive(props) {
321
+ var config = props.config,
322
+ figure = props.figure,
323
+ responsive = props.responsive;
324
+ if ((0, _ramda.type)(responsive) === 'Boolean') {
325
+ return responsive;
326
+ }
327
+ return Boolean(config.responsive && (!figure.layout || (figure.layout.autosize || (0, _ramda.isNil)(figure.layout.autosize)) && ((0, _ramda.isNil)(figure.layout.height) || (0, _ramda.isNil)(figure.layout.width))));
328
+ }
329
+ graphResize() {
330
+ var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
331
+ if (!force && !this.isResponsive(this.props)) {
332
+ return;
333
+ }
334
+ var gd = this.gd.current;
335
+ if (!gd) {
336
+ return;
337
+ }
338
+ gd.classList.add('dash-graph--pending');
339
+ Plotly.Plots.resize(gd).catch(() => {}).finally(() => gd.classList.remove('dash-graph--pending'));
340
+ }
341
+ bindEvents() {
342
+ var _this$props = this.props,
343
+ setProps = _this$props.setProps,
344
+ clear_on_unhover = _this$props.clear_on_unhover,
345
+ relayoutData = _this$props.relayoutData,
346
+ restyleData = _this$props.restyleData,
347
+ hoverData = _this$props.hoverData,
348
+ selectedData = _this$props.selectedData;
349
+ var gd = this.gd.current;
350
+ gd.on('plotly_click', eventData => {
351
+ var clickData = filterEventData(gd, eventData, 'click');
352
+ if (!(0, _ramda.isNil)(clickData)) {
409
353
  setProps({
410
- clickAnnotationData
354
+ clickData
411
355
  });
356
+ }
357
+ });
358
+ gd.on('plotly_clickannotation', eventData => {
359
+ var clickAnnotationData = (0, _ramda.omit)(['event', 'fullAnnotation'], eventData);
360
+ setProps({
361
+ clickAnnotationData
412
362
  });
413
- gd.on('plotly_hover', function (eventData) {
414
- var hover = filterEventData(gd, eventData, 'hover');
415
- if (!(0, _ramda.isNil)(hover) && !(0, _ramda.equals)(hover, hoverData)) {
416
- setProps({
417
- hoverData: hover
418
- });
419
- }
420
- });
421
- gd.on('plotly_selected', function (eventData) {
422
- var selected = filterEventData(gd, eventData, 'selected');
423
- if (!(0, _ramda.isNil)(selected) && !(0, _ramda.equals)(selected, selectedData)) {
424
- setProps({
425
- selectedData: selected
426
- });
427
- }
428
- });
429
- gd.on('plotly_deselect', function () {
363
+ });
364
+ gd.on('plotly_hover', eventData => {
365
+ var hover = filterEventData(gd, eventData, 'hover');
366
+ if (!(0, _ramda.isNil)(hover) && !(0, _ramda.equals)(hover, hoverData)) {
430
367
  setProps({
431
- selectedData: null
368
+ hoverData: hover
432
369
  });
433
- });
434
- gd.on('plotly_relayout', function (eventData) {
435
- var relayout = filterEventData(gd, eventData, 'relayout');
436
- if (!(0, _ramda.isNil)(relayout) && !(0, _ramda.equals)(relayout, relayoutData)) {
437
- setProps({
438
- relayoutData: relayout
439
- });
440
- }
441
- });
442
- gd.on('plotly_restyle', function (eventData) {
443
- var restyle = filterEventData(gd, eventData, 'restyle');
444
- if (!(0, _ramda.isNil)(restyle) && !(0, _ramda.equals)(restyle, restyleData)) {
445
- setProps({
446
- restyleData: restyle
447
- });
448
- }
449
- });
450
- gd.on('plotly_unhover', function () {
451
- if (clear_on_unhover) {
452
- setProps({
453
- hoverData: null
454
- });
455
- }
456
- });
457
- }
458
- }, {
459
- key: "componentDidMount",
460
- value: function componentDidMount() {
461
- var p = this.plot(this.props);
462
- this._queue = this.amendTraces(p, {}, this.props);
463
- }
464
- }, {
465
- key: "componentWillUnmount",
466
- value: function componentWillUnmount() {
467
- var gd = this.gd.current;
468
- if (gd && gd.removeAllListeners) {
469
- gd.removeAllListeners();
470
- if (this._hasPlotted) {
471
- Plotly.purge(gd);
472
- }
473
370
  }
474
- }
475
- }, {
476
- key: "shouldComponentUpdate",
477
- value: function shouldComponentUpdate(nextProps) {
478
- return this.props.id !== nextProps.id || JSON.stringify(this.props.style) !== JSON.stringify(nextProps.style);
479
- }
480
- }, {
481
- key: "UNSAFE_componentWillReceiveProps",
482
- value: function UNSAFE_componentWillReceiveProps(nextProps) {
483
- var _this4 = this;
484
- var idChanged = this.props.id !== nextProps.id;
485
- if (idChanged) {
486
- /*
487
- * then the dom needs to get re-rendered with a new ID.
488
- * the graph will get updated in componentDidUpdate
489
- */
490
- return;
371
+ });
372
+ gd.on('plotly_selected', eventData => {
373
+ var selected = filterEventData(gd, eventData, 'selected');
374
+ if (!(0, _ramda.isNil)(selected) && !(0, _ramda.equals)(selected, selectedData)) {
375
+ setProps({
376
+ selectedData: selected
377
+ });
491
378
  }
492
- var p = this._queue;
493
- if (this.props.mathjax !== nextProps.mathjax || this.props.figure !== nextProps.figure || this.props._dashprivate_transformConfig !== nextProps._dashprivate_transformConfig || this.props._dashprivate_transformFigure !== nextProps._dashprivate_transformFigure) {
494
- p = p.then(function () {
495
- return _this4.plot(nextProps);
379
+ });
380
+ gd.on('plotly_deselect', () => {
381
+ setProps({
382
+ selectedData: null
383
+ });
384
+ });
385
+ gd.on('plotly_relayout', eventData => {
386
+ var relayout = filterEventData(gd, eventData, 'relayout');
387
+ if (!(0, _ramda.isNil)(relayout) && !(0, _ramda.equals)(relayout, relayoutData)) {
388
+ setProps({
389
+ relayoutData: relayout
496
390
  });
497
391
  }
498
- this._queue = this.amendTraces(p, this.props, nextProps);
499
- }
500
- }, {
501
- key: "componentDidUpdate",
502
- value: function componentDidUpdate(prevProps) {
503
- var _this5 = this;
504
- if (prevProps.id !== this.props.id || prevProps.mathjax !== this.props.mathjax) {
505
- this._queue = this._queue.then(function () {
506
- return _this5.plot(_this5.props);
392
+ });
393
+ gd.on('plotly_restyle', eventData => {
394
+ var restyle = filterEventData(gd, eventData, 'restyle');
395
+ if (!(0, _ramda.isNil)(restyle) && !(0, _ramda.equals)(restyle, restyleData)) {
396
+ setProps({
397
+ restyleData: restyle
507
398
  });
508
399
  }
400
+ });
401
+ gd.on('plotly_unhover', () => {
402
+ if (clear_on_unhover) {
403
+ setProps({
404
+ hoverData: null
405
+ });
406
+ }
407
+ });
408
+ }
409
+ componentDidMount() {
410
+ var p = this.plot(this.props);
411
+ this._queue = this.amendTraces(p, {}, this.props);
412
+ }
413
+ componentWillUnmount() {
414
+ var gd = this.gd.current;
415
+ if (gd && gd.removeAllListeners) {
416
+ gd.removeAllListeners();
417
+ if (this._hasPlotted) {
418
+ Plotly.purge(gd);
419
+ }
509
420
  }
510
- }, {
511
- key: "render",
512
- value: function render() {
513
- var _this$props2 = this.props,
514
- className = _this$props2.className,
515
- id = _this$props2.id,
516
- style = _this$props2.style;
517
- return /*#__PURE__*/_react.default.createElement(_LoadingElement.default, {
518
- id: id,
519
- key: id,
520
- className: className,
521
- style: style,
522
- ref: this.parentElement
523
- }, /*#__PURE__*/_react.default.createElement(_ResizeDetector.default, {
524
- onResize: this.graphResize,
525
- targets: [this.parentElement, this.gd]
526
- }), /*#__PURE__*/_react.default.createElement("div", {
527
- ref: this.gd,
528
- style: {
529
- height: '100%',
530
- width: '100%'
531
- }
532
- }));
421
+ }
422
+ shouldComponentUpdate(nextProps) {
423
+ return this.props.id !== nextProps.id || JSON.stringify(this.props.style) !== JSON.stringify(nextProps.style);
424
+ }
425
+ UNSAFE_componentWillReceiveProps(nextProps) {
426
+ var idChanged = this.props.id !== nextProps.id;
427
+ if (idChanged) {
428
+ /*
429
+ * then the dom needs to get re-rendered with a new ID.
430
+ * the graph will get updated in componentDidUpdate
431
+ */
432
+ return;
533
433
  }
534
- }]);
535
- }(_react.Component);
434
+ var p = this._queue;
435
+ if (this.props.mathjax !== nextProps.mathjax || this.props.figure !== nextProps.figure || this.props._dashprivate_transformConfig !== nextProps._dashprivate_transformConfig || this.props._dashprivate_transformFigure !== nextProps._dashprivate_transformFigure) {
436
+ p = p.then(() => this.plot(nextProps));
437
+ }
438
+ this._queue = this.amendTraces(p, this.props, nextProps);
439
+ }
440
+ componentDidUpdate(prevProps) {
441
+ if (prevProps.id !== this.props.id || prevProps.mathjax !== this.props.mathjax) {
442
+ this._queue = this._queue.then(() => this.plot(this.props));
443
+ }
444
+ }
445
+ render() {
446
+ var _this$props2 = this.props,
447
+ className = _this$props2.className,
448
+ id = _this$props2.id,
449
+ style = _this$props2.style;
450
+ return /*#__PURE__*/_react.default.createElement(_LoadingElement.default, {
451
+ id: id,
452
+ key: id,
453
+ className: className,
454
+ style: style,
455
+ ref: this.parentElement
456
+ }, /*#__PURE__*/_react.default.createElement(_ResizeDetector.default, {
457
+ onResize: this.graphResize,
458
+ targets: [this.parentElement, this.gd]
459
+ }), /*#__PURE__*/_react.default.createElement("div", {
460
+ ref: this.gd,
461
+ style: {
462
+ height: '100%',
463
+ width: '100%'
464
+ }
465
+ }));
466
+ }
467
+ }
536
468
  PlotlyGraph.propTypes = _objectSpread(_objectSpread({}, _Graph.graphPropTypes), {}, {
537
469
  prependData: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object])),
538
470
  extendData: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object])),