dash-core-components 4.2.0 → 4.3.0

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 (44) 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-markdown.js +1 -1
  8. package/dash_core_components/async-markdown.js.map +1 -1
  9. package/dash_core_components/async-slider.js +1 -1
  10. package/dash_core_components/async-slider.js.map +1 -1
  11. package/dash_core_components/async-upload.js +1 -1
  12. package/dash_core_components/async-upload.js.map +1 -1
  13. package/dash_core_components/dash_core_components-shared.js +1 -1
  14. package/dash_core_components/dash_core_components-shared.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/dash_core_components/plotly.min.js +8 -0
  18. package/lib/components/Clipboard.react.js +220 -173
  19. package/lib/components/ConfirmDialog.react.js +62 -34
  20. package/lib/components/ConfirmDialogProvider.react.js +45 -21
  21. package/lib/components/Download.react.js +46 -22
  22. package/lib/components/Geolocation.react.js +92 -64
  23. package/lib/components/Graph.react.js +99 -71
  24. package/lib/components/Interval.react.js +88 -56
  25. package/lib/components/Link.react.js +6 -5
  26. package/lib/components/Location.react.js +127 -97
  27. package/lib/components/Markdown.react.js +37 -16
  28. package/lib/components/Store.react.js +177 -128
  29. package/lib/components/Upload.react.js +28 -8
  30. package/lib/fragments/Graph.privateprops.js +9 -3
  31. package/lib/fragments/Graph.react.js +411 -339
  32. package/lib/fragments/Markdown.react.js +160 -120
  33. package/lib/fragments/Math.react.js +49 -24
  34. package/lib/fragments/Upload.react.js +341 -302
  35. package/lib/utils/LazyLoader/graph.js +3 -2
  36. package/lib/utils/LazyLoader/hljs.js +5 -2
  37. package/lib/utils/LazyLoader/markdown.js +3 -2
  38. package/lib/utils/LazyLoader/mathjax.js +5 -2
  39. package/lib/utils/LazyLoader/plotly.js +6 -7
  40. package/lib/utils/LazyLoader/upload.js +3 -2
  41. package/lib/utils/LoadingElement.js +3 -2
  42. package/lib/utils/MarkdownHighlighter.js +6 -5
  43. package/lib/utils/ResizeDetector.js +14 -9
  44. package/package.json +3 -3
@@ -11,19 +11,30 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
11
11
  var _Graph = require("../components/Graph.react");
12
12
  var _ResizeDetector = _interopRequireDefault(require("../utils/ResizeDetector"));
13
13
  var _LoadingElement = _interopRequireDefault(require("../utils/LoadingElement"));
14
- function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
14
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
15
15
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
16
16
  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; }
17
17
  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; }
18
18
  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; }
19
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
20
- 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); }
21
19
  function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
22
20
  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."); }
23
21
  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; } }
24
22
  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; }
25
23
  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; } }
26
- function _arrayWithHoles(r) { if (Array.isArray(r)) return r; } /* global Plotly:true */
24
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
25
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
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
38
  /**
28
39
  * `autosize: true` causes Plotly.js to conform to the parent element size.
29
40
  * This is necessary for `dcc.Graph` call to `Plotly.Plots.resize(target)` to do something.
@@ -55,7 +66,7 @@ var AUTO_CONFIG = {};
55
66
  var UNRESPONSIVE_CONFIG = {
56
67
  responsive: false
57
68
  };
58
- var filterEventData = (gd, eventData, event) => {
69
+ var filterEventData = function filterEventData(gd, eventData, event) {
59
70
  var filteredEventData;
60
71
  if ((0, _ramda.includes)(event, ['click', 'hover', 'selected'])) {
61
72
  var points = [];
@@ -132,378 +143,439 @@ var filterEventData = (gd, eventData, event) => {
132
143
  * You can define callbacks based on user interaction with Graphs such as
133
144
  * hovering, clicking or selecting
134
145
  */
135
- class PlotlyGraph extends _react.Component {
136
- constructor(props) {
137
- super(props);
138
- this.gd = /*#__PURE__*/_react.default.createRef();
139
- this._hasPlotted = false;
140
- this._prevGd = null;
141
- this._queue = Promise.resolve();
142
- this.parentElement = /*#__PURE__*/_react.default.createRef();
143
- this.bindEvents = this.bindEvents.bind(this);
144
- this.getConfig = this.getConfig.bind(this);
145
- this.getConfigOverride = this.getConfigOverride.bind(this);
146
- this.getLayout = this.getLayout.bind(this);
147
- this.getLayoutOverride = this.getLayoutOverride.bind(this);
148
- this.graphResize = this.graphResize.bind(this);
149
- this.isResponsive = this.isResponsive.bind(this);
150
- this.amendTraces = this.amendTraces.bind(this);
151
- this.state = {
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 = {
152
165
  override: {},
153
166
  originals: {}
154
167
  };
168
+ return _this2;
155
169
  }
156
- plot(props) {
157
- var _figure, _figure2, _figure3;
158
- var figure = props.figure,
159
- config = props.config;
160
- var animate = props.animate,
161
- animation_options = props.animation_options,
162
- responsive = props.responsive,
163
- mathjax = props.mathjax;
164
- var gd = this.gd.current;
165
- figure = props._dashprivate_transformFigure(figure, gd);
166
- config = props._dashprivate_transformConfig(config, gd);
167
- var configClone = this.getConfig(config, responsive);
168
- // add typesetMath | not exposed to the dash API
169
- configClone.typesetMath = mathjax;
170
- var figureClone = {
171
- data: (_figure = figure) === null || _figure === void 0 ? void 0 : _figure.data,
172
- layout: this.getLayout((_figure2 = figure) === null || _figure2 === void 0 ? void 0 : _figure2.layout, responsive),
173
- frames: (_figure3 = figure) === null || _figure3 === void 0 ? void 0 : _figure3.frames,
174
- config: configClone
175
- };
176
- if (animate && this._hasPlotted && figure.data.length === gd.data.length) {
177
- // in case we've have figure frames,
178
- // we need to recreate frames before animation
179
- if (figure.frames) {
180
- return Plotly.deleteFrames(gd).then(() => Plotly.addFrames(gd, figure.frames)).then(() => Plotly.animate(gd, figureClone, animation_options));
181
- }
182
- return Plotly.animate(gd, figureClone, animation_options);
183
- }
184
- gd.classList.add('dash-graph--pending');
185
- return (0, _mathjax.default)(mathjax).then(() => {
186
- var gd = this.gd.current;
187
- return gd && Plotly.react(gd, figureClone);
188
- }).then(() => {
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;
189
184
  var gd = this.gd.current;
190
-
191
- // double-check gd hasn't been unmounted
192
- if (!gd) {
193
- return;
194
- }
195
- gd.classList.remove('dash-graph--pending');
196
-
197
- // in case we've made a new DOM element, transfer events
198
- if (this._hasPlotted && gd !== this._prevGd) {
199
- if (this._prevGd && this._prevGd.removeAllListeners) {
200
- this._prevGd.removeAllListeners();
201
- Plotly.purge(this._prevGd);
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
+ });
202
205
  }
203
- this._hasPlotted = false;
206
+ return Plotly.animate(gd, figureClone, animation_options);
204
207
  }
205
- if (!this._hasPlotted) {
206
- this.bindEvents();
207
- this.graphResize(true);
208
- this._hasPlotted = true;
209
- this._prevGd = gd;
210
- }
211
- });
212
- }
213
- amendTraces(p, oldProps, newProps) {
214
- var oldPrepend = oldProps.prependData,
215
- oldExtend = oldProps.extendData;
216
- var newPrepend = newProps.prependData,
217
- newExtend = newProps.extendData;
218
- var _this = this;
219
- function mergeTraces(props, dataKey, plotlyFnKey) {
220
- var clearState = props.clearState;
221
- var dataArray = props[dataKey];
222
- var _p = Promise.resolve();
223
- dataArray.forEach(data => {
224
- var updateData, traceIndices, maxPoints;
225
- if (Array.isArray(data) && typeof data[0] === 'object') {
226
- var _data = _slicedToArray(data, 3);
227
- updateData = _data[0];
228
- traceIndices = _data[1];
229
- maxPoints = _data[2];
230
- } else {
231
- updateData = data;
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;
214
+
215
+ // double-check gd hasn't been unmounted
216
+ if (!gd) {
217
+ return;
232
218
  }
233
- if (!traceIndices) {
234
- function getFirstProp(data) {
235
- return data[Object.keys(data)[0]];
236
- }
237
- function generateIndices(data) {
238
- return Array.from(Array(getFirstProp(data).length).keys());
219
+ gd.classList.remove('dash-graph--pending');
220
+
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);
239
226
  }
240
- traceIndices = generateIndices(updateData);
227
+ _this3._hasPlotted = false;
228
+ }
229
+ if (!_this3._hasPlotted) {
230
+ _this3.bindEvents();
231
+ _this3.graphResize(true);
232
+ _this3._hasPlotted = true;
233
+ _this3._prevGd = gd;
241
234
  }
242
- _p = _p.then(() => {
243
- var gd = _this.gd.current;
244
- return gd && Plotly[plotlyFnKey](gd, updateData, traceIndices, maxPoints);
245
- });
246
235
  });
247
- return _p.then(() => clearState(dataKey));
248
- }
249
- var modified = false;
250
- if (newPrepend !== null && newPrepend !== void 0 && newPrepend.length && oldPrepend !== newPrepend) {
251
- modified = true;
252
- p = p.then(() => mergeTraces(newProps, 'prependData', 'prependTraces'));
253
- }
254
- if (newExtend !== null && newExtend !== void 0 && newExtend.length && oldExtend !== newExtend) {
255
- modified = true;
256
- p = p.then(() => mergeTraces(newProps, 'extendData', 'extendTraces'));
257
- }
258
- if (modified) {
259
- p = p.then(() => newProps._dashprivate_onFigureModified(newProps.figure));
260
- }
261
- return p;
262
- }
263
- getConfig(config, responsive) {
264
- return (0, _ramda.mergeDeepRight)(config, this.getConfigOverride(responsive));
265
- }
266
- getLayout(originalLayout, responsive) {
267
- if (!originalLayout) {
268
- return originalLayout;
269
236
  }
270
- // Clone layout to avoid mutating the original (important for Patch)
271
- var layout = (0, _ramda.clone)(originalLayout);
272
- var override = this.getLayoutOverride(responsive);
273
- var _this$state = this.state,
274
- prev_override = _this$state.override,
275
- prev_originals = _this$state.originals;
276
- // Store the original data that we're about to override
277
- var originals = {};
278
- for (var key in override) {
279
- if (layout[key] !== prev_override[key]) {
280
- originals[key] = layout[key];
281
- } else if (prev_originals.hasOwnProperty(key)) {
282
- originals[key] = prev_originals[key];
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;
258
+ }
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);
267
+ }
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
+ });
283
276
  }
284
- }
285
- this.setState({
286
- override,
287
- originals
288
- });
289
- // Undo the previous override, but only for keys that the user did not change
290
- for (var _key in prev_originals) {
291
- if (layout[_key] === prev_override[_key]) {
292
- layout[_key] = prev_originals[_key];
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
+ });
293
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);
293
+ });
294
+ }
295
+ return p;
294
296
  }
295
- // Apply the current override
296
- for (var _key2 in override) {
297
- layout[_key2] = override[_key2];
298
- }
299
- return layout;
300
- }
301
- getConfigOverride(responsive) {
302
- switch (responsive) {
303
- case false:
304
- return UNRESPONSIVE_CONFIG;
305
- case true:
306
- return RESPONSIVE_CONFIG;
307
- default:
308
- return AUTO_CONFIG;
297
+ }, {
298
+ key: "getConfig",
299
+ value: function getConfig(config, responsive) {
300
+ return (0, _ramda.mergeDeepRight)(config, this.getConfigOverride(responsive));
309
301
  }
310
- }
311
- getLayoutOverride(responsive) {
312
- switch (responsive) {
313
- case false:
314
- return UNRESPONSIVE_LAYOUT;
315
- case true:
316
- return RESPONSIVE_LAYOUT;
317
- default:
318
- return AUTO_LAYOUT;
302
+ }, {
303
+ key: "getLayout",
304
+ value: function getLayout(originalLayout, responsive) {
305
+ if (!originalLayout) {
306
+ return originalLayout;
307
+ }
308
+ // Clone layout to avoid mutating the original (important for Patch)
309
+ var layout = (0, _ramda.clone)(originalLayout);
310
+ var override = this.getLayoutOverride(responsive);
311
+ var _this$state = this.state,
312
+ prev_override = _this$state.override,
313
+ prev_originals = _this$state.originals;
314
+ // Store the original data that we're about to override
315
+ var originals = {};
316
+ for (var key in override) {
317
+ if (layout[key] !== prev_override[key]) {
318
+ originals[key] = layout[key];
319
+ } else if (prev_originals.hasOwnProperty(key)) {
320
+ originals[key] = prev_originals[key];
321
+ }
322
+ }
323
+ this.setState({
324
+ override,
325
+ originals
326
+ });
327
+ // Undo the previous override, but only for keys that the user did not change
328
+ for (var _key in prev_originals) {
329
+ if (layout[_key] === prev_override[_key]) {
330
+ layout[_key] = prev_originals[_key];
331
+ }
332
+ }
333
+ // Apply the current override
334
+ for (var _key2 in override) {
335
+ layout[_key2] = override[_key2];
336
+ }
337
+ return layout;
319
338
  }
320
- }
321
- isResponsive(props) {
322
- var config = props.config,
323
- figure = props.figure,
324
- responsive = props.responsive;
325
- if ((0, _ramda.type)(responsive) === 'Boolean') {
326
- return responsive;
339
+ }, {
340
+ key: "getConfigOverride",
341
+ value: function getConfigOverride(responsive) {
342
+ switch (responsive) {
343
+ case false:
344
+ return UNRESPONSIVE_CONFIG;
345
+ case true:
346
+ return RESPONSIVE_CONFIG;
347
+ default:
348
+ return AUTO_CONFIG;
349
+ }
327
350
  }
328
- 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))));
329
- }
330
- graphResize() {
331
- var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
332
- if (!force && !this.isResponsive(this.props)) {
333
- return;
351
+ }, {
352
+ key: "getLayoutOverride",
353
+ value: function getLayoutOverride(responsive) {
354
+ switch (responsive) {
355
+ case false:
356
+ return UNRESPONSIVE_LAYOUT;
357
+ case true:
358
+ return RESPONSIVE_LAYOUT;
359
+ default:
360
+ return AUTO_LAYOUT;
361
+ }
334
362
  }
335
- var gd = this.gd.current;
336
- if (!gd) {
337
- return;
363
+ }, {
364
+ key: "isResponsive",
365
+ value: function isResponsive(props) {
366
+ var config = props.config,
367
+ figure = props.figure,
368
+ responsive = props.responsive;
369
+ if ((0, _ramda.type)(responsive) === 'Boolean') {
370
+ return responsive;
371
+ }
372
+ 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))));
338
373
  }
339
- gd.classList.add('dash-graph--pending');
374
+ }, {
375
+ key: "graphResize",
376
+ value: function graphResize() {
377
+ var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
378
+ if (!force && !this.isResponsive(this.props)) {
379
+ return;
380
+ }
381
+ var gd = this.gd.current;
382
+ if (!gd) {
383
+ return;
384
+ }
385
+ gd.classList.add('dash-graph--pending');
340
386
 
341
- // Calling resize enables layout.autosize in plotly.js
342
- Plotly.Plots.resize(gd).catch(() => {}).finally(() => gd.classList.remove('dash-graph--pending'));
343
- }
344
- bindEvents() {
345
- var _this$props = this.props,
346
- setProps = _this$props.setProps,
347
- clear_on_unhover = _this$props.clear_on_unhover,
348
- relayoutData = _this$props.relayoutData,
349
- restyleData = _this$props.restyleData,
350
- hoverData = _this$props.hoverData,
351
- selectedData = _this$props.selectedData;
352
- var gd = this.gd.current;
353
- gd.on('plotly_click', eventData => {
354
- var clickData = filterEventData(gd, eventData, 'click');
355
- if (!(0, _ramda.isNil)(clickData)) {
387
+ // Calling resize enables layout.autosize in plotly.js
388
+ Plotly.Plots.resize(gd).catch(function () {}).finally(function () {
389
+ return gd.classList.remove('dash-graph--pending');
390
+ });
391
+ }
392
+ }, {
393
+ key: "bindEvents",
394
+ value: function bindEvents() {
395
+ var _this4 = this;
396
+ var _this$props = this.props,
397
+ setProps = _this$props.setProps,
398
+ clear_on_unhover = _this$props.clear_on_unhover,
399
+ relayoutData = _this$props.relayoutData,
400
+ restyleData = _this$props.restyleData,
401
+ hoverData = _this$props.hoverData,
402
+ selectedData = _this$props.selectedData;
403
+ var gd = this.gd.current;
404
+ gd.on('plotly_click', function (eventData) {
405
+ var clickData = filterEventData(gd, eventData, 'click');
406
+ if (!(0, _ramda.isNil)(clickData)) {
407
+ // Add timestamp to ensure each click is unique (for DashWrapper deduplication)
408
+ clickData.timestamp = Date.now();
409
+ setProps({
410
+ clickData
411
+ });
412
+ }
413
+ });
414
+ gd.on('plotly_clickannotation', function (eventData) {
415
+ var clickAnnotationData = (0, _ramda.omit)(['event', 'fullAnnotation'], eventData);
356
416
  // Add timestamp to ensure each click is unique (for DashWrapper deduplication)
357
- clickData.timestamp = Date.now();
417
+ clickAnnotationData.timestamp = Date.now();
358
418
  setProps({
359
- clickData
419
+ clickAnnotationData
360
420
  });
361
- }
362
- });
363
- gd.on('plotly_clickannotation', eventData => {
364
- var clickAnnotationData = (0, _ramda.omit)(['event', 'fullAnnotation'], eventData);
365
- // Add timestamp to ensure each click is unique (for DashWrapper deduplication)
366
- clickAnnotationData.timestamp = Date.now();
367
- setProps({
368
- clickAnnotationData
369
421
  });
370
- });
371
- gd.on('plotly_hover', eventData => {
372
- var hover = filterEventData(gd, eventData, 'hover');
373
- if (!(0, _ramda.isNil)(hover) && !(0, _ramda.equals)(hover, hoverData)) {
374
- setProps({
375
- hoverData: hover
376
- });
377
- }
378
- });
379
- gd.on('plotly_selected', eventData => {
380
- var selected = filterEventData(gd, eventData, 'selected');
381
- if (!(0, _ramda.isNil)(selected) && !(0, _ramda.equals)(selected, selectedData)) {
382
- setProps({
383
- selectedData: selected
384
- });
385
- }
386
- });
387
- gd.on('plotly_deselect', () => {
388
- setProps({
389
- selectedData: null
422
+ gd.on('plotly_hover', function (eventData) {
423
+ var hover = filterEventData(gd, eventData, 'hover');
424
+ if (!(0, _ramda.isNil)(hover) && !(0, _ramda.equals)(hover, hoverData)) {
425
+ setProps({
426
+ hoverData: hover
427
+ });
428
+ }
390
429
  });
391
- });
392
- gd.on('plotly_relayout', eventData => {
393
- var relayout = filterEventData(gd, eventData, 'relayout');
394
- if (!(0, _ramda.isNil)(relayout) && !(0, _ramda.equals)(relayout, relayoutData)) {
430
+ gd.on('plotly_selected', function (eventData) {
431
+ var selected = filterEventData(gd, eventData, 'selected');
432
+ if (!(0, _ramda.isNil)(selected) && !(0, _ramda.equals)(selected, selectedData)) {
433
+ setProps({
434
+ selectedData: selected
435
+ });
436
+ }
437
+ });
438
+ gd.on('plotly_deselect', function () {
395
439
  setProps({
396
- relayoutData: relayout
440
+ selectedData: null
397
441
  });
398
- }
399
- // Sync shapes from gd.layout to figure when shapes are modified by user
400
- // This is needed because getLayout() clones layout to prevent mutation issues
401
- if (eventData && gd.layout) {
402
- var hasShapeChanges = Object.keys(eventData).some(key => key === 'shapes' || key.startsWith('shapes['));
403
- if (hasShapeChanges) {
404
- var _figure$layout;
405
- var _this$props$figure = this.props.figure,
406
- figure = _this$props$figure === void 0 ? {} : _this$props$figure;
407
- var currentShapes = figure === null || figure === void 0 || (_figure$layout = figure.layout) === null || _figure$layout === void 0 ? void 0 : _figure$layout.shapes;
408
- var newShapes = gd.layout.shapes;
409
- if (!(0, _ramda.equals)(currentShapes, newShapes)) {
410
- setProps({
411
- figure: _objectSpread(_objectSpread({}, figure), {}, {
412
- layout: _objectSpread(_objectSpread({}, figure === null || figure === void 0 ? void 0 : figure.layout), {}, {
413
- shapes: newShapes
442
+ });
443
+ gd.on('plotly_relayout', function (eventData) {
444
+ var relayout = filterEventData(gd, eventData, 'relayout');
445
+ if (!(0, _ramda.isNil)(relayout) && !(0, _ramda.equals)(relayout, relayoutData)) {
446
+ setProps({
447
+ relayoutData: relayout
448
+ });
449
+ }
450
+ // Sync shapes from gd.layout to figure when shapes are modified by user
451
+ // This is needed because getLayout() clones layout to prevent mutation issues
452
+ if (eventData && gd.layout) {
453
+ var hasShapeChanges = Object.keys(eventData).some(function (key) {
454
+ return key === 'shapes' || key.startsWith('shapes[');
455
+ });
456
+ if (hasShapeChanges) {
457
+ var _figure$layout;
458
+ var _this4$props$figure = _this4.props.figure,
459
+ figure = _this4$props$figure === void 0 ? {} : _this4$props$figure;
460
+ var currentShapes = figure === null || figure === void 0 || (_figure$layout = figure.layout) === null || _figure$layout === void 0 ? void 0 : _figure$layout.shapes;
461
+ var newShapes = gd.layout.shapes;
462
+ if (!(0, _ramda.equals)(currentShapes, newShapes)) {
463
+ setProps({
464
+ figure: _objectSpread(_objectSpread({}, figure), {}, {
465
+ layout: _objectSpread(_objectSpread({}, figure === null || figure === void 0 ? void 0 : figure.layout), {}, {
466
+ shapes: newShapes
467
+ })
414
468
  })
415
- })
416
- });
469
+ });
470
+ }
417
471
  }
418
472
  }
419
- }
420
- });
421
- gd.on('plotly_restyle', eventData => {
422
- var restyle = filterEventData(gd, eventData, 'restyle');
423
- if (!(0, _ramda.isNil)(restyle) && !(0, _ramda.equals)(restyle, restyleData)) {
424
- setProps({
425
- restyleData: restyle
426
- });
427
- }
428
- });
429
- gd.on('plotly_unhover', () => {
430
- if (clear_on_unhover) {
431
- setProps({
432
- hoverData: null
433
- });
434
- }
435
- });
436
- }
437
- componentDidMount() {
438
- var p = this.plot(this.props);
439
- this._queue = this.amendTraces(p, {}, this.props);
440
- }
441
- componentWillUnmount() {
442
- var gd = this.gd.current;
443
- if (gd && gd.removeAllListeners) {
444
- gd.removeAllListeners();
445
- if (this._hasPlotted) {
446
- Plotly.purge(gd);
447
- }
473
+ });
474
+ gd.on('plotly_restyle', function (eventData) {
475
+ var restyle = filterEventData(gd, eventData, 'restyle');
476
+ if (!(0, _ramda.isNil)(restyle) && !(0, _ramda.equals)(restyle, restyleData)) {
477
+ setProps({
478
+ restyleData: restyle
479
+ });
480
+ }
481
+ });
482
+ gd.on('plotly_unhover', function () {
483
+ if (clear_on_unhover) {
484
+ setProps({
485
+ hoverData: null
486
+ });
487
+ }
488
+ });
448
489
  }
449
- }
450
- shouldComponentUpdate(nextProps) {
451
- return this.props.id !== nextProps.id || JSON.stringify(this.props.style) !== JSON.stringify(nextProps.style);
452
- }
453
- UNSAFE_componentWillReceiveProps(nextProps) {
454
- var idChanged = this.props.id !== nextProps.id;
455
- if (idChanged) {
456
- /*
457
- * then the dom needs to get re-rendered with a new ID.
458
- * the graph will get updated in componentDidUpdate
459
- */
460
- return;
490
+ }, {
491
+ key: "componentDidMount",
492
+ value: function componentDidMount() {
493
+ var p = this.plot(this.props);
494
+ this._queue = this.amendTraces(p, {}, this.props);
461
495
  }
462
- var p = this._queue;
463
- 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) {
464
- p = p.then(() => this.plot(nextProps));
496
+ }, {
497
+ key: "componentWillUnmount",
498
+ value: function componentWillUnmount() {
499
+ var gd = this.gd.current;
500
+ if (gd && gd.removeAllListeners) {
501
+ gd.removeAllListeners();
502
+ if (this._hasPlotted) {
503
+ Plotly.purge(gd);
504
+ }
505
+ }
465
506
  }
466
- this._queue = this.amendTraces(p, this.props, nextProps);
467
- }
468
- componentDidUpdate(prevProps) {
469
- if (prevProps.id !== this.props.id || prevProps.mathjax !== this.props.mathjax) {
470
- this._queue = this._queue.then(() => this.plot(this.props));
507
+ }, {
508
+ key: "shouldComponentUpdate",
509
+ value: function shouldComponentUpdate(nextProps) {
510
+ return this.props.id !== nextProps.id || JSON.stringify(this.props.style) !== JSON.stringify(nextProps.style);
471
511
  }
472
- }
473
- render() {
474
- var _this$props2 = this.props,
475
- className = _this$props2.className,
476
- id = _this$props2.id,
477
- loading_state = _this$props2.loading_state,
478
- _this$props2$style = _this$props2.style,
479
- style = _this$props2$style === void 0 ? {} : _this$props2$style;
480
- if (this.isResponsive(this.props)) {
481
- style.height || (style.height = '100%');
512
+ }, {
513
+ key: "UNSAFE_componentWillReceiveProps",
514
+ value: function UNSAFE_componentWillReceiveProps(nextProps) {
515
+ var _this5 = this;
516
+ var idChanged = this.props.id !== nextProps.id;
517
+ if (idChanged) {
518
+ /*
519
+ * then the dom needs to get re-rendered with a new ID.
520
+ * the graph will get updated in componentDidUpdate
521
+ */
522
+ return;
523
+ }
524
+ var p = this._queue;
525
+ 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) {
526
+ p = p.then(function () {
527
+ return _this5.plot(nextProps);
528
+ });
529
+ }
530
+ this._queue = this.amendTraces(p, this.props, nextProps);
482
531
  }
483
- var Container = _LoadingElement.default;
484
- var containerProps = {
485
- className,
486
- id,
487
- key: id,
488
- ref: this.parentElement,
489
- style
490
- };
491
- if (!window.dash_component_api) {
492
- Container = 'div';
493
- containerProps['data-dash-is-loading'] = (loading_state === null || loading_state === void 0 ? void 0 : loading_state.is_loading) || undefined;
532
+ }, {
533
+ key: "componentDidUpdate",
534
+ value: function componentDidUpdate(prevProps) {
535
+ var _this6 = this;
536
+ if (prevProps.id !== this.props.id || prevProps.mathjax !== this.props.mathjax) {
537
+ this._queue = this._queue.then(function () {
538
+ return _this6.plot(_this6.props);
539
+ });
540
+ }
494
541
  }
495
- return /*#__PURE__*/_react.default.createElement(Container, containerProps, /*#__PURE__*/_react.default.createElement(_ResizeDetector.default, {
496
- onResize: this.graphResize,
497
- targets: [this.parentElement, this.gd]
498
- }), /*#__PURE__*/_react.default.createElement("div", {
499
- ref: this.gd,
500
- style: {
501
- height: '100%',
502
- width: '100%'
542
+ }, {
543
+ key: "render",
544
+ value: function render() {
545
+ var _this$props2 = this.props,
546
+ className = _this$props2.className,
547
+ id = _this$props2.id,
548
+ loading_state = _this$props2.loading_state,
549
+ _this$props2$style = _this$props2.style,
550
+ style = _this$props2$style === void 0 ? {} : _this$props2$style;
551
+ if (this.isResponsive(this.props)) {
552
+ style.height || (style.height = '100%');
503
553
  }
504
- }));
505
- }
506
- }
554
+ var Container = _LoadingElement.default;
555
+ var containerProps = {
556
+ className,
557
+ id,
558
+ key: id,
559
+ ref: this.parentElement,
560
+ style
561
+ };
562
+ if (!window.dash_component_api) {
563
+ Container = 'div';
564
+ containerProps['data-dash-is-loading'] = (loading_state === null || loading_state === void 0 ? void 0 : loading_state.is_loading) || undefined;
565
+ }
566
+ return /*#__PURE__*/_react.default.createElement(Container, containerProps, /*#__PURE__*/_react.default.createElement(_ResizeDetector.default, {
567
+ onResize: this.graphResize,
568
+ targets: [this.parentElement, this.gd]
569
+ }), /*#__PURE__*/_react.default.createElement("div", {
570
+ ref: this.gd,
571
+ style: {
572
+ height: '100%',
573
+ width: '100%'
574
+ }
575
+ }));
576
+ }
577
+ }]);
578
+ }(_react.Component);
507
579
  PlotlyGraph.propTypes = _objectSpread(_objectSpread({}, _Graph.graphPropTypes), {}, {
508
580
  prependData: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object])),
509
581
  extendData: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.object])),