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