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