dash-core-components 2.2.0 → 2.5.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 (37) hide show
  1. package/README.md +1 -1
  2. package/dash_core_components/async-datepicker.js +1 -1
  3. package/dash_core_components/async-datepicker.js.map +1 -1
  4. package/dash_core_components/async-dropdown.js +1 -1
  5. package/dash_core_components/async-dropdown.js.map +1 -1
  6. package/dash_core_components/async-graph.js +1 -1
  7. package/dash_core_components/async-graph.js.map +1 -1
  8. package/dash_core_components/async-highlight.js +1 -1
  9. package/dash_core_components/async-highlight.js.map +1 -1
  10. package/dash_core_components/async-markdown.js +1 -1
  11. package/dash_core_components/async-markdown.js.map +1 -1
  12. package/dash_core_components/async-mathjax.js +1 -0
  13. package/dash_core_components/async-plotlyjs.js +1 -1
  14. package/dash_core_components/async-slider.js +1 -1
  15. package/dash_core_components/async-slider.js.map +1 -1
  16. package/dash_core_components/dash_core_components-shared.js +1 -1
  17. package/dash_core_components/dash_core_components-shared.js.map +1 -1
  18. package/dash_core_components/dash_core_components.js +1 -1
  19. package/dash_core_components/dash_core_components.js.map +1 -1
  20. package/dash_core_components/mathjax.js +1 -0
  21. package/dash_core_components/plotly.min.js +10 -10
  22. package/lib/components/Checklist.react.js +1 -1
  23. package/lib/components/Dropdown.react.js +1 -1
  24. package/lib/components/Graph.react.js +17 -3
  25. package/lib/components/Markdown.react.js +46 -4
  26. package/lib/components/RadioItems.react.js +1 -1
  27. package/lib/components/Tooltip.react.js +7 -5
  28. package/lib/fragments/DatePickerRange.react.js +20 -13
  29. package/lib/fragments/DatePickerSingle.react.js +38 -10
  30. package/lib/fragments/Dropdown.react.js +106 -115
  31. package/lib/fragments/Graph.react.js +118 -61
  32. package/lib/fragments/Markdown.react.js +36 -1
  33. package/lib/fragments/Math.react.js +101 -0
  34. package/lib/utils/LazyLoader/mathjax.js +22 -0
  35. package/lib/utils/computeSliderStyle.js +2 -2
  36. package/lib/utils/mathjax.js +5 -0
  37. package/package.json +23 -22
@@ -33,25 +33,17 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
33
33
 
34
34
  function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
35
35
 
36
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
36
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
37
37
 
38
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
38
+ 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."); }
39
39
 
40
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
40
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
41
41
 
42
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
42
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
43
43
 
44
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
44
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
45
45
 
46
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
47
-
48
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
49
-
50
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
51
-
52
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
53
-
54
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
46
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
55
47
 
56
48
  // Custom tokenizer, see https://github.com/bvaughn/js-search/issues/43
57
49
  // Split on spaces
@@ -64,114 +56,113 @@ var TOKENIZER = {
64
56
  });
65
57
  }
66
58
  };
67
- var DELIMITER = ',';
68
-
69
- var Dropdown = /*#__PURE__*/function (_Component) {
70
- _inherits(Dropdown, _Component);
71
-
72
- var _super = _createSuper(Dropdown);
73
-
74
- function Dropdown(props) {
75
- var _this;
76
-
77
- _classCallCheck(this, Dropdown);
59
+ var RDProps = ['multi', 'clearable', 'searchable', 'search_value', 'placeholder', 'disabled', 'optionHeight', 'style', 'className'];
60
+
61
+ var Dropdown = function Dropdown(props) {
62
+ var id = props.id,
63
+ clearable = props.clearable,
64
+ multi = props.multi,
65
+ options = props.options,
66
+ setProps = props.setProps,
67
+ style = props.style,
68
+ loading_state = props.loading_state,
69
+ value = props.value;
70
+
71
+ var _useState = (0, _react.useState)(null),
72
+ _useState2 = _slicedToArray(_useState, 2),
73
+ optionsCheck = _useState2[0],
74
+ setOptionsCheck = _useState2[1];
75
+
76
+ var _useMemo = (0, _react.useMemo)(function () {
77
+ var sanitized = (0, _optionTypes.sanitizeOptions)(options);
78
+ return [sanitized, (0, _reactSelectFastFilterOptions.default)({
79
+ options: sanitized,
80
+ tokenizer: TOKENIZER
81
+ })];
82
+ }, [options]),
83
+ _useMemo2 = _slicedToArray(_useMemo, 2),
84
+ sanitizedOptions = _useMemo2[0],
85
+ filterOptions = _useMemo2[1];
86
+
87
+ var onChange = (0, _react.useCallback)(function (selectedOption) {
88
+ if (multi) {
89
+ var _value;
90
+
91
+ if ((0, _ramda.isNil)(selectedOption)) {
92
+ _value = [];
93
+ } else {
94
+ _value = (0, _ramda.pluck)('value', selectedOption);
95
+ }
78
96
 
79
- _this = _super.call(this, props);
80
- _this.state = {
81
- filterOptions: (0, _reactSelectFastFilterOptions.default)({
82
- options: (0, _optionTypes.sanitizeOptions)(props.options),
83
- tokenizer: TOKENIZER
84
- })
85
- };
86
- return _this;
87
- }
97
+ setProps({
98
+ value: _value
99
+ });
100
+ } else {
101
+ var _value2;
88
102
 
89
- _createClass(Dropdown, [{
90
- key: "UNSAFE_componentWillReceiveProps",
91
- value: function UNSAFE_componentWillReceiveProps(newProps) {
92
- if (newProps.options !== this.props.options) {
93
- this.setState({
94
- filterOptions: (0, _reactSelectFastFilterOptions.default)({
95
- options: (0, _optionTypes.sanitizeOptions)(newProps.options),
96
- tokenizer: TOKENIZER
97
- })
98
- });
99
- }
100
- }
101
- }, {
102
- key: "render",
103
- value: function render() {
104
- var _this$props = this.props,
105
- id = _this$props.id,
106
- clearable = _this$props.clearable,
107
- multi = _this$props.multi,
108
- options = _this$props.options,
109
- setProps = _this$props.setProps,
110
- style = _this$props.style,
111
- loading_state = _this$props.loading_state,
112
- value = _this$props.value;
113
- var filterOptions = this.state.filterOptions;
114
- var selectedValue;
115
-
116
- if ((0, _ramda.type)(value) === 'Array') {
117
- selectedValue = value.join(DELIMITER);
103
+ if ((0, _ramda.isNil)(selectedOption)) {
104
+ _value2 = null;
118
105
  } else {
119
- selectedValue = value;
106
+ _value2 = selectedOption.value;
120
107
  }
121
108
 
122
- return /*#__PURE__*/_react.default.createElement("div", {
123
- id: id,
124
- className: "dash-dropdown",
125
- style: style,
126
- "data-dash-is-loading": loading_state && loading_state.is_loading || undefined
127
- }, /*#__PURE__*/_react.default.createElement(_reactVirtualizedSelect.default, _extends({
128
- filterOptions: filterOptions,
129
- options: (0, _optionTypes.sanitizeOptions)(options),
130
- value: selectedValue,
131
- onChange: function onChange(selectedOption) {
132
- if (multi) {
133
- var _value;
134
-
135
- if ((0, _ramda.isNil)(selectedOption)) {
136
- _value = [];
137
- } else {
138
- _value = (0, _ramda.pluck)('value', selectedOption);
139
- }
140
-
141
- setProps({
142
- value: _value
143
- });
144
- } else {
145
- var _value2;
146
-
147
- if ((0, _ramda.isNil)(selectedOption)) {
148
- _value2 = null;
149
- } else {
150
- _value2 = selectedOption.value;
151
- }
152
-
153
- setProps({
154
- value: _value2
155
- });
156
- }
157
- },
158
- onInputChange: function onInputChange(search_value) {
159
- return setProps({
160
- search_value: search_value
109
+ setProps({
110
+ value: _value2
111
+ });
112
+ }
113
+ }, [multi]);
114
+ var onInputChange = (0, _react.useCallback)(function (search_value) {
115
+ return setProps({
116
+ search_value: search_value
117
+ });
118
+ }, []);
119
+ (0, _react.useEffect)(function () {
120
+ if (!(0, _ramda.isNil)(sanitizedOptions) && optionsCheck !== sanitizedOptions && !(0, _ramda.isNil)(value)) {
121
+ var values = sanitizedOptions.map(function (option) {
122
+ return option.value;
123
+ });
124
+
125
+ if (multi && Array.isArray(value)) {
126
+ var invalids = value.filter(function (v) {
127
+ return !values.includes(v);
128
+ });
129
+
130
+ if (invalids.length) {
131
+ setProps({
132
+ value: (0, _ramda.without)(invalids, value)
161
133
  });
162
- },
163
- backspaceRemoves: clearable,
164
- deleteRemoves: clearable,
165
- inputProps: {
166
- autoComplete: 'off'
167
134
  }
168
- }, (0, _ramda.omit)(['setProps', 'value', 'options'], this.props))));
169
- }
170
- }]);
135
+ } else {
136
+ if (!values.includes(value)) {
137
+ setProps({
138
+ value: null
139
+ });
140
+ }
141
+ }
171
142
 
172
- return Dropdown;
173
- }(_react.Component);
143
+ setOptionsCheck(sanitizedOptions);
144
+ }
145
+ }, [sanitizedOptions, optionsCheck, multi, value]);
146
+ return /*#__PURE__*/_react.default.createElement("div", {
147
+ id: id,
148
+ className: "dash-dropdown",
149
+ style: style,
150
+ "data-dash-is-loading": loading_state && loading_state.is_loading || undefined
151
+ }, /*#__PURE__*/_react.default.createElement(_reactVirtualizedSelect.default, _extends({
152
+ filterOptions: filterOptions,
153
+ options: (0, _optionTypes.sanitizeOptions)(options),
154
+ value: value,
155
+ onChange: onChange,
156
+ onInputChange: onInputChange,
157
+ backspaceRemoves: clearable,
158
+ deleteRemoves: clearable,
159
+ inputProps: {
160
+ autoComplete: 'off'
161
+ }
162
+ }, (0, _ramda.pick)(RDProps, props))));
163
+ };
174
164
 
175
- exports.default = Dropdown;
176
165
  Dropdown.propTypes = _Dropdown2.propTypes;
177
- Dropdown.defaultProps = _Dropdown2.defaultProps;
166
+ Dropdown.defaultProps = _Dropdown2.defaultProps;
167
+ var _default = Dropdown;
168
+ exports.default = _default;
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
+ var _mathjax = _interopRequireDefault(require("../utils/LazyLoader/mathjax"));
9
+
8
10
  var _react = _interopRequireWildcard(require("react"));
9
11
 
10
12
  var _withPolyfill = _interopRequireDefault(require("react-resize-detector/build/withPolyfill"));
@@ -15,12 +17,12 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
15
17
 
16
18
  var _Graph = require("../components/Graph.react");
17
19
 
18
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
-
20
20
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
21
21
 
22
22
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
23
23
 
24
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
+
24
26
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
25
27
 
26
28
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
@@ -39,8 +41,6 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
39
41
 
40
42
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
41
43
 
42
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
43
-
44
44
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
45
45
 
46
46
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
@@ -61,6 +61,8 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
61
61
 
62
62
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
63
63
 
64
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
65
+
64
66
  /* global Plotly:true */
65
67
 
66
68
  /**
@@ -99,48 +101,64 @@ var filterEventData = function filterEventData(gd, eventData, event) {
99
101
  var filteredEventData;
100
102
 
101
103
  if ((0, _ramda.includes)(event, ['click', 'hover', 'selected'])) {
102
- var points = [];
104
+ var _ret = function () {
105
+ var points = [];
103
106
 
104
- if ((0, _ramda.isNil)(eventData)) {
105
- return null;
106
- }
107
- /*
108
- * remove `data`, `layout`, `xaxis`, etc
109
- * objects from the event data since they're so big
110
- * and cause JSON stringify ciricular structure errors.
111
- *
112
- * also, pull down the `customdata` point from the data array
113
- * into the event object
114
- */
115
-
116
-
117
- var data = gd.data;
107
+ if ((0, _ramda.isNil)(eventData)) {
108
+ return {
109
+ v: null
110
+ };
111
+ }
112
+ /*
113
+ * remove `data`, `layout`, `xaxis`, etc
114
+ * objects from the event data since they're so big
115
+ * and cause JSON stringify ciricular structure errors.
116
+ *
117
+ * also, pull down the `customdata` point from the data array
118
+ * into the event object
119
+ */
120
+
121
+
122
+ var data = gd.data;
123
+
124
+ var _loop = function _loop(i) {
125
+ var fullPoint = eventData.points[i];
126
+ var pointData = (0, _ramda.filter)(function (o) {
127
+ return !(0, _ramda.includes)((0, _ramda.type)(o), ['Object', 'Array']);
128
+ }, fullPoint); // permit a bounding box to pass through, if present
129
+
130
+ if ((0, _ramda.has)('bbox', fullPoint)) {
131
+ pointData.bbox = fullPoint.bbox;
132
+ }
118
133
 
119
- for (var i = 0; i < eventData.points.length; i++) {
120
- var fullPoint = eventData.points[i];
121
- var pointData = (0, _ramda.filter)(function (o) {
122
- return !(0, _ramda.includes)((0, _ramda.type)(o), ['Object', 'Array']);
123
- }, fullPoint); // permit a bounding box to pass through, if present
134
+ if ((0, _ramda.has)('curveNumber', fullPoint) && (0, _ramda.has)('customdata', data[pointData.curveNumber])) {
135
+ if ((0, _ramda.has)('pointNumber', fullPoint)) {
136
+ pointData.customdata = data[pointData.curveNumber].customdata[fullPoint.pointNumber];
137
+ } else if ((0, _ramda.has)('pointNumbers', fullPoint)) {
138
+ pointData.customdata = fullPoint.pointNumbers.map(function (point) {
139
+ return data[pointData.curveNumber].customdata[point];
140
+ });
141
+ }
142
+ } // specific to histogram. see https://github.com/plotly/plotly.js/pull/2113/
124
143
 
125
- if ((0, _ramda.has)('bbox', fullPoint)) {
126
- pointData.bbox = fullPoint.bbox;
127
- }
128
144
 
129
- if ((0, _ramda.has)('curveNumber', fullPoint) && (0, _ramda.has)('pointNumber', fullPoint) && (0, _ramda.has)('customdata', data[pointData.curveNumber])) {
130
- pointData.customdata = data[pointData.curveNumber].customdata[fullPoint.pointNumber];
131
- } // specific to histogram. see https://github.com/plotly/plotly.js/pull/2113/
145
+ if ((0, _ramda.has)('pointNumbers', fullPoint)) {
146
+ pointData.pointNumbers = fullPoint.pointNumbers;
147
+ }
132
148
 
149
+ points[i] = pointData;
150
+ };
133
151
 
134
- if ((0, _ramda.has)('pointNumbers', fullPoint)) {
135
- pointData.pointNumbers = fullPoint.pointNumbers;
152
+ for (var i = 0; i < eventData.points.length; i++) {
153
+ _loop(i);
136
154
  }
137
155
 
138
- points[i] = pointData;
139
- }
156
+ filteredEventData = {
157
+ points: points
158
+ };
159
+ }();
140
160
 
141
- filteredEventData = {
142
- points: points
143
- };
161
+ if (_typeof(_ret) === "object") return _ret.v;
144
162
  } else if (event === 'relayout' || event === 'restyle') {
145
163
  /*
146
164
  * relayout shouldn't include any big objects
@@ -206,23 +224,39 @@ var PlotlyGraph = /*#__PURE__*/function (_Component) {
206
224
  config = props.config;
207
225
  var animate = props.animate,
208
226
  animation_options = props.animation_options,
209
- responsive = props.responsive;
227
+ responsive = props.responsive,
228
+ mathjax = props.mathjax;
210
229
  var gd = this.gd.current;
211
230
  figure = props._dashprivate_transformFigure(figure, gd);
212
231
  config = props._dashprivate_transformConfig(config, gd);
232
+ var configClone = this.getConfig(config, responsive); // add typesetMath | not exposed to the dash API
233
+
234
+ configClone.typesetMath = mathjax;
235
+ var figureClone = {
236
+ data: figure.data,
237
+ layout: this.getLayout(figure.layout, responsive),
238
+ frames: figure.frames,
239
+ config: configClone
240
+ };
213
241
 
214
242
  if (animate && this._hasPlotted && figure.data.length === gd.data.length) {
215
- return Plotly.animate(gd, figure, animation_options);
243
+ // in case we've have figure frames,
244
+ // we need to recreate frames before animation
245
+ if (figure.frames) {
246
+ return Plotly.deleteFrames(gd).then(function () {
247
+ return Plotly.addFrames(gd, figure.frames);
248
+ }).then(function () {
249
+ return Plotly.animate(gd, figureClone, animation_options);
250
+ });
251
+ }
252
+
253
+ return Plotly.animate(gd, figureClone, animation_options);
216
254
  }
217
255
 
218
- var configClone = this.getConfig(config, responsive);
219
- var layoutClone = this.getLayout(figure.layout, responsive);
220
256
  gd.classList.add('dash-graph--pending');
221
- return Plotly.react(gd, {
222
- data: figure.data,
223
- layout: layoutClone,
224
- frames: figure.frames,
225
- config: configClone
257
+ return (0, _mathjax.default)(mathjax).then(function () {
258
+ var gd = _this2.gd.current;
259
+ return gd && Plotly.react(gd, figureClone);
226
260
  }).then(function () {
227
261
  var gd = _this2.gd.current; // double-check gd hasn't been unmounted
228
262
 
@@ -259,6 +293,7 @@ var PlotlyGraph = /*#__PURE__*/function (_Component) {
259
293
 
260
294
  var clearState = props.clearState;
261
295
  var dataArray = props[dataKey];
296
+ var p = Promise.resolve();
262
297
  dataArray.forEach(function (data) {
263
298
  var updateData, traceIndices, maxPoints;
264
299
 
@@ -284,10 +319,14 @@ var PlotlyGraph = /*#__PURE__*/function (_Component) {
284
319
  traceIndices = generateIndices(updateData);
285
320
  }
286
321
 
287
- var gd = _this3.gd.current;
288
- return Plotly[plotlyFnKey](gd, updateData, traceIndices, maxPoints);
322
+ p = p.then(function () {
323
+ var gd = _this3.gd.current;
324
+ return gd && Plotly[plotlyFnKey](gd, updateData, traceIndices, maxPoints);
325
+ });
326
+ });
327
+ p.then(function () {
328
+ return clearState(dataKey);
289
329
  });
290
- clearState(dataKey);
291
330
  }
292
331
  }, {
293
332
  key: "getConfig",
@@ -473,20 +512,28 @@ var PlotlyGraph = /*#__PURE__*/function (_Component) {
473
512
  }, {
474
513
  key: "componentDidMount",
475
514
  value: function componentDidMount() {
476
- var _this$props$prependDa, _this$props$extendDat;
515
+ var _this4 = this,
516
+ _this$props$prependDa,
517
+ _this$props$extendDat;
477
518
 
478
- this.plot(this.props);
519
+ var p = this.plot(this.props);
479
520
 
480
521
  if (this.props.prependData) {
481
- this.mergeTraces(this.props, 'prependData', 'prependTraces');
522
+ p = p.then(function () {
523
+ return _this4.mergeTraces(_this4.props, 'prependData', 'prependTraces');
524
+ });
482
525
  }
483
526
 
484
527
  if (this.props.extendData) {
485
- this.mergeTraces(this.props, 'extendData', 'extendTraces');
528
+ p = p.then(function () {
529
+ return _this4.mergeTraces(_this4.props, 'extendData', 'extendTraces');
530
+ });
486
531
  }
487
532
 
488
533
  if ((_this$props$prependDa = this.props.prependData) !== null && _this$props$prependDa !== void 0 && _this$props$prependDa.length || (_this$props$extendDat = this.props.extendData) !== null && _this$props$extendDat !== void 0 && _this$props$extendDat.length) {
489
- this.props._dashprivate_onFigureModified(this.props.figure);
534
+ p.then(function () {
535
+ return _this4.props._dashprivate_onFigureModified(_this4.props.figure);
536
+ });
490
537
  }
491
538
  }
492
539
  }, {
@@ -510,7 +557,9 @@ var PlotlyGraph = /*#__PURE__*/function (_Component) {
510
557
  }, {
511
558
  key: "UNSAFE_componentWillReceiveProps",
512
559
  value: function UNSAFE_componentWillReceiveProps(nextProps) {
513
- var _this$props$prependDa2, _this$props$extendDat2;
560
+ var _this5 = this,
561
+ _this$props$prependDa2,
562
+ _this$props$extendDat2;
514
563
 
515
564
  var idChanged = this.props.id !== nextProps.id;
516
565
 
@@ -522,26 +571,34 @@ var PlotlyGraph = /*#__PURE__*/function (_Component) {
522
571
  return;
523
572
  }
524
573
 
525
- if (this.props.figure !== nextProps.figure || this.props._dashprivate_transformConfig !== nextProps._dashprivate_transformConfig || this.props._dashprivate_transformFigure !== nextProps._dashprivate_transformFigure) {
526
- this.plot(nextProps);
574
+ var p = Promise.resolve();
575
+
576
+ 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) {
577
+ p = this.plot(nextProps);
527
578
  }
528
579
 
529
580
  if (this.props.prependData !== nextProps.prependData) {
530
- this.mergeTraces(nextProps, 'prependData', 'prependTraces');
581
+ p = p.then(function () {
582
+ return _this5.mergeTraces(nextProps, 'prependData', 'prependTraces');
583
+ });
531
584
  }
532
585
 
533
586
  if (this.props.extendData !== nextProps.extendData) {
534
- this.mergeTraces(nextProps, 'extendData', 'extendTraces');
587
+ p = p.then(function () {
588
+ return _this5.mergeTraces(nextProps, 'extendData', 'extendTraces');
589
+ });
535
590
  }
536
591
 
537
592
  if ((_this$props$prependDa2 = this.props.prependData) !== null && _this$props$prependDa2 !== void 0 && _this$props$prependDa2.length || (_this$props$extendDat2 = this.props.extendData) !== null && _this$props$extendDat2 !== void 0 && _this$props$extendDat2.length) {
538
- this.props._dashprivate_onFigureModified(this.props.figure);
593
+ p.then(function () {
594
+ return _this5.props._dashprivate_onFigureModified(_this5.props.figure);
595
+ });
539
596
  }
540
597
  }
541
598
  }, {
542
599
  key: "componentDidUpdate",
543
600
  value: function componentDidUpdate(prevProps) {
544
- if (prevProps.id !== this.props.id) {
601
+ if (prevProps.id !== this.props.id || prevProps.mathjax !== this.props.mathjax) {
545
602
  this.plot(this.props);
546
603
  }
547
604
  }
@@ -15,6 +15,10 @@ var _reactJsxParser = _interopRequireDefault(require("react-jsx-parser"));
15
15
 
16
16
  var _reactMarkdown = _interopRequireDefault(require("react-markdown"));
17
17
 
18
+ var _remarkMath = _interopRequireDefault(require("remark-math"));
19
+
20
+ var _Math = _interopRequireDefault(require("./Math.react"));
21
+
18
22
  var _MarkdownHighlighter = _interopRequireDefault(require("../utils/MarkdownHighlighter"));
19
23
 
20
24
  var _Markdown = require("../components/Markdown.react");
@@ -159,6 +163,8 @@ var DashMarkdown = /*#__PURE__*/function (_Component) {
159
163
  highlight_config = _this$props.highlight_config,
160
164
  loading_state = _this$props.loading_state,
161
165
  dangerously_allow_html = _this$props.dangerously_allow_html,
166
+ link_target = _this$props.link_target,
167
+ mathjax = _this$props.mathjax,
162
168
  children = _this$props.children,
163
169
  dedent = _this$props.dedent;
164
170
  var textProp = (0, _ramda.type)(children) === 'Array' ? children.join('\n') : children;
@@ -169,8 +175,23 @@ var DashMarkdown = /*#__PURE__*/function (_Component) {
169
175
  },
170
176
  dccMarkdown: function dccMarkdown(props) {
171
177
  return /*#__PURE__*/_react.default.createElement(_reactMarkdown.default, (0, _ramda.mergeDeepRight)((0, _ramda.pick)(['dangerously_allow_html', 'dedent'], _this2.props), (0, _ramda.pick)(['children'], props)));
178
+ },
179
+ dashMathjax: function dashMathjax(props) {
180
+ return /*#__PURE__*/_react.default.createElement(_Math.default, {
181
+ tex: props.value,
182
+ inline: props.inline
183
+ });
172
184
  }
173
185
  };
186
+
187
+ var regexMath = function regexMath(value) {
188
+ var newValue = value.replace(/(\${1,2})((?:\\.|[^$])+)\1/g, function (m, tag, src) {
189
+ var inline = tag.length === 1 || src.indexOf('\n') === -1;
190
+ return "<dashMathjax value='".concat(src, "' inline='").concat(inline, "'/>");
191
+ });
192
+ return newValue;
193
+ };
194
+
174
195
  return /*#__PURE__*/_react.default.createElement("div", {
175
196
  id: id,
176
197
  ref: function ref(node) {
@@ -182,10 +203,24 @@ var DashMarkdown = /*#__PURE__*/function (_Component) {
182
203
  }, /*#__PURE__*/_react.default.createElement(_reactMarkdown.default, {
183
204
  source: displayText,
184
205
  escapeHtml: !dangerously_allow_html,
206
+ linkTarget: link_target,
207
+ plugins: mathjax ? [_remarkMath.default] : [],
185
208
  renderers: {
209
+ math: function math(props) {
210
+ return /*#__PURE__*/_react.default.createElement(_Math.default, {
211
+ tex: props.value,
212
+ inline: false
213
+ });
214
+ },
215
+ inlineMath: function inlineMath(props) {
216
+ return /*#__PURE__*/_react.default.createElement(_Math.default, {
217
+ tex: props.value,
218
+ inline: true
219
+ });
220
+ },
186
221
  html: function html(props) {
187
222
  return props.escapeHtml ? props.value : /*#__PURE__*/_react.default.createElement(_reactJsxParser.default, {
188
- jsx: props.value,
223
+ jsx: mathjax ? regexMath(props.value) : props.value,
189
224
  components: componentTransforms,
190
225
  renderInWrapper: false
191
226
  });