dash-core-components 4.5.4 → 4.5.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) 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.map +1 -1
  4. package/dash_core_components/async-graph.js +1 -1
  5. package/dash_core_components/async-graph.js.map +1 -1
  6. package/dash_core_components/async-highlight.js.map +1 -1
  7. package/dash_core_components/async-markdown.js +1 -2
  8. package/dash_core_components/async-markdown.js.map +1 -1
  9. package/dash_core_components/async-slider.js +1 -1
  10. package/dash_core_components/async-slider.js.map +1 -1
  11. package/dash_core_components/async-upload.js +1 -1
  12. package/dash_core_components/async-upload.js.map +1 -1
  13. package/dash_core_components/dash_core_components-shared.js +1 -1
  14. package/dash_core_components/dash_core_components-shared.js.map +1 -1
  15. package/dash_core_components/dash_core_components.js +1 -1
  16. package/dash_core_components/dash_core_components.js.map +1 -1
  17. package/lib/components/Clipboard.react.js +1 -1
  18. package/lib/components/Input.tsx +2 -2
  19. package/lib/fragments/Graph.react.js +208 -18
  20. package/lib/fragments/Markdown.tsx +16 -2
  21. package/lib/fragments/Upload.react.js +1 -1
  22. package/lib/utils/markdown/components/Code.tsx +2 -2
  23. package/lib/utils/markdown/components/types.ts +1 -2
  24. package/lib/utils/markdown/plugins/index.ts +8 -0
  25. package/lib/utils/markdown/plugins/rehypeBlockCode.ts +25 -0
  26. package/lib/utils/markdown/plugins/rehypeDashMath.ts +15 -2
  27. package/lib/utils/markdown/plugins/rehypeLinkTarget.ts +15 -0
  28. package/lib/utils/markdown/polyfills.ts +24 -0
  29. package/package.json +6 -6
@@ -12,7 +12,7 @@ var _LoadingElement = _interopRequireDefault(require("../utils/LoadingElement"))
12
12
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
13
  var cache;
14
14
  function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var r, c, a = Object.defineProperty, n = { __proto__: null, default: e }; if (Object(e) !== e) return n; if (cache || "function" != typeof WeakMap || (cache = new WeakMap()), cache) { if (cache.has(e)) return cache.get(e); cache.set(e, n); } for (c in e) "default" !== c && {}.hasOwnProperty.call(e, c) && ((r = a && Object.getOwnPropertyDescriptor(e, c)) && (r.get || r.set) ? a(n, c, r) : n[c] = e[c]); return n; }
15
- function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
15
+ function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? (c > 1 && (G.n = c < 3 ? -1 : u), d(c, u)) : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
16
16
  function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
17
17
  function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
18
18
  function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
@@ -208,9 +208,9 @@ function Input({
208
208
 
209
209
  input.current.value = roundedValue.toString();
210
210
  setValue(roundedValue.toString());
211
- onEvent();
211
+ setPropValue(props.value, roundedValue);
212
212
  },
213
- [step, props.min, props.max, onEvent]
213
+ [step, props.min, props.max, props.value, setPropValue]
214
214
  );
215
215
 
216
216
  useEffect(() => {
@@ -16,11 +16,8 @@ function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e;
16
16
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
17
17
  function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
18
18
  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."); }
19
- 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; } }
20
- 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; }
21
19
  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; } }
22
20
  function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
23
- 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); }
24
21
  function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
25
22
  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); } }
26
23
  function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
@@ -31,6 +28,13 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
31
28
  function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
32
29
  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); }
33
30
  function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
31
+ 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); }
32
+ function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
33
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
34
+ 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; } }
35
+ function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
36
+ function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
37
+ 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; }
34
38
  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; }
35
39
  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; }
36
40
  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; }
@@ -176,6 +180,101 @@ var filterEventData = function filterEventData(gd, eventData, event) {
176
180
  return filteredEventData;
177
181
  };
178
182
 
183
+ // layoutUIControlPatterns in plotly.js src/plot_api/plot_api.js: the GUI
184
+ // edits plotly.js keeps across figure updates while their uirevision holds
185
+ var UIREVISION_PATTERNS = [{
186
+ pattern: /^hiddenlabels/,
187
+ attr: 'legend.uirevision'
188
+ }, {
189
+ pattern: /^((x|y)axis\d*)\.((auto)?range|title\.text)/
190
+ }, {
191
+ pattern: /axis\d*\.showspikes$/,
192
+ attr: 'modebar.uirevision'
193
+ }, {
194
+ pattern: /(hover|drag)mode$/,
195
+ attr: 'modebar.uirevision'
196
+ }, {
197
+ pattern: /^(scene\d*)\.camera/
198
+ }, {
199
+ pattern: /^(geo\d*)\.(projection|center|fitbounds)/
200
+ }, {
201
+ pattern: /^(ternary\d*\.[abc]axis)\.(min|title\.text)$/
202
+ }, {
203
+ pattern: /^(polar\d*\.radialaxis)\.((auto)?range|angle|title\.text)/
204
+ }, {
205
+ pattern: /^(polar\d*\.angularaxis)\.rotation/
206
+ }, {
207
+ pattern: /^(map\d*)\.(center|zoom|bearing|pitch)/
208
+ }, {
209
+ pattern: /^legend\.(x|y)$/,
210
+ attr: 'editrevision'
211
+ }, {
212
+ pattern: /^(shapes|annotations)/,
213
+ attr: 'editrevision'
214
+ }, {
215
+ pattern: /^selections/,
216
+ attr: 'selectionrevision'
217
+ }, {
218
+ pattern: /^title\.text$/,
219
+ attr: 'editrevision'
220
+ }];
221
+ var getRevisionAttr = function getRevisionAttr(attr) {
222
+ for (var _i = 0, _UIREVISION_PATTERNS = UIREVISION_PATTERNS; _i < _UIREVISION_PATTERNS.length; _i++) {
223
+ var _UIREVISION_PATTERNS$ = _UIREVISION_PATTERNS[_i],
224
+ pattern = _UIREVISION_PATTERNS$.pattern,
225
+ revisionAttr = _UIREVISION_PATTERNS$.attr;
226
+ var match = attr.match(pattern);
227
+ if (match) {
228
+ return revisionAttr || "".concat(match[1], ".uirevision");
229
+ }
230
+ }
231
+ return null;
232
+ };
233
+
234
+ // 'shapes[1].x0' -> ['shapes', 1, 'x0']
235
+ var toPath = function toPath(attr) {
236
+ return attr.split('.').flatMap(function (part) {
237
+ return part.split(/\[(\d+)\]/).filter(function (segment) {
238
+ return segment !== '';
239
+ }).map(function (segment, i) {
240
+ return i ? Number(segment) : segment;
241
+ });
242
+ });
243
+ };
244
+
245
+ // Same inheritance as getNewRev in plotly.js
246
+ var getNewRevision = function getNewRevision(layout, revisionAttr) {
247
+ var keys = toPath(revisionAttr);
248
+ var revision = (0, _ramda.path)(keys, layout);
249
+ if (revision !== undefined) {
250
+ return revision;
251
+ }
252
+ for (var depth = keys.length - 2; depth > 0; depth--) {
253
+ var inherited = (0, _ramda.path)([].concat(_toConsumableArray(keys.slice(0, depth)), ['uirevision']), layout);
254
+ if (inherited !== undefined) {
255
+ return inherited;
256
+ }
257
+ }
258
+ return layout.uirevision;
259
+ };
260
+
261
+ // Only sets inside existing containers, never creates them
262
+ var setPath = function setPath(container, keys, value) {
263
+ var parent = (0, _ramda.path)(keys.slice(0, -1), container);
264
+ if (_typeof(parent) !== 'object' || parent === null) {
265
+ return;
266
+ }
267
+ var last = keys[keys.length - 1];
268
+ if (Array.isArray(parent) && last >= parent.length) {
269
+ return;
270
+ }
271
+ if (value === undefined && !Array.isArray(parent)) {
272
+ delete parent[last];
273
+ } else {
274
+ parent[last] = value;
275
+ }
276
+ };
277
+
179
278
  /**
180
279
  * Graph can be used to render any plotly.js-powered data visualization.
181
280
  *
@@ -191,6 +290,7 @@ var PlotlyGraph = /*#__PURE__*/function (_Component) {
191
290
  _this2._hasPlotted = false;
192
291
  _this2._prevGd = null;
193
292
  _this2._queue = Promise.resolve();
293
+ _this2._pendingFigures = [];
194
294
  _this2.parentElement = /*#__PURE__*/_react.default.createRef();
195
295
  _this2.bindEvents = _this2.bindEvents.bind(_this2);
196
296
  _this2.getConfig = _this2.getConfig.bind(_this2);
@@ -204,6 +304,7 @@ var PlotlyGraph = /*#__PURE__*/function (_Component) {
204
304
  override: {},
205
305
  originals: {}
206
306
  };
307
+ _this2._syncedEdits = {};
207
308
  return _this2;
208
309
  }
209
310
  _inherits(PlotlyGraph, _Component);
@@ -226,13 +327,16 @@ var PlotlyGraph = /*#__PURE__*/function (_Component) {
226
327
  var configClone = this.getConfig(config, responsive);
227
328
  // add typesetMath | not exposed to the dash API
228
329
  configClone.typesetMath = mathjax;
330
+ var animating = animate && this._hasPlotted && figure.data.length === gd.data.length;
331
+ var layout = this.getLayout((_figure = figure) === null || _figure === void 0 ? void 0 : _figure.layout, responsive);
332
+ this.applySyncedEdits(layout, animating);
229
333
  var figureClone = {
230
- data: (_figure = figure) === null || _figure === void 0 ? void 0 : _figure.data,
231
- layout: this.getLayout((_figure2 = figure) === null || _figure2 === void 0 ? void 0 : _figure2.layout, responsive),
334
+ data: (_figure2 = figure) === null || _figure2 === void 0 ? void 0 : _figure2.data,
335
+ layout,
232
336
  frames: (_figure3 = figure) === null || _figure3 === void 0 ? void 0 : _figure3.frames,
233
337
  config: configClone
234
338
  };
235
- if (animate && this._hasPlotted && figure.data.length === gd.data.length) {
339
+ if (animating) {
236
340
  // in case we've have figure frames,
237
341
  // we need to recreate frames before animation
238
342
  if (figure.frames) {
@@ -375,6 +479,79 @@ var PlotlyGraph = /*#__PURE__*/function (_Component) {
375
479
  }
376
480
  return layout;
377
481
  }
482
+
483
+ /*
484
+ * The plotly_relayout handler copies GUI edits (zoom, pan, ...) into the
485
+ * figure prop. If Plotly.react gets them as input, plotly.js takes them as
486
+ * the new starting point and drops them from its uirevision bookkeeping
487
+ * (_preGUI), so a later figure without them resets the view. While a
488
+ * synced value is still in the figure and its uirevision is unchanged,
489
+ * give plotly.js the value from before the edit so it keeps the edit
490
+ * itself. Plotly.animate does not apply uirevision, so there the value
491
+ * from before the edit is replaced by the edit instead.
492
+ */
493
+ }, {
494
+ key: "applySyncedEdits",
495
+ value: function applySyncedEdits(layout, animating) {
496
+ var _this$gd$current,
497
+ _this4 = this;
498
+ var fullLayout = (_this$gd$current = this.gd.current) === null || _this$gd$current === void 0 ? void 0 : _this$gd$current._fullLayout;
499
+ var preGUI = fullLayout === null || fullLayout === void 0 ? void 0 : fullLayout._preGUI;
500
+ if (!layout || !preGUI) {
501
+ return;
502
+ }
503
+ var _loop2 = function _loop2() {
504
+ var _preGUI$attr;
505
+ var _Object$entries$_i = _slicedToArray(_Object$entries[_i2], 2),
506
+ attr = _Object$entries$_i[0],
507
+ syncedValues = _Object$entries$_i[1];
508
+ if (!(attr in preGUI)) {
509
+ delete _this4._syncedEdits[attr];
510
+ return 0; // continue
511
+ }
512
+ var revisionAttr = getRevisionAttr(attr);
513
+ var oldRevision = (0, _ramda.path)(toPath(revisionAttr), fullLayout);
514
+ if (!oldRevision || getNewRevision(layout, revisionAttr) !== oldRevision) {
515
+ return 0; // continue
516
+ }
517
+ var keys = toPath(attr);
518
+ var value = (0, _ramda.path)(keys, layout);
519
+ var original = (_preGUI$attr = preGUI[attr]) !== null && _preGUI$attr !== void 0 ? _preGUI$attr : undefined;
520
+ if (animating) {
521
+ if ((0, _ramda.equals)(value, original)) {
522
+ setPath(layout, keys, (0, _ramda.clone)(syncedValues[syncedValues.length - 1]));
523
+ }
524
+ return 0; // continue
525
+ }
526
+ // Earlier syncs may still be queued for plotting
527
+ var index = syncedValues.findIndex(function (synced) {
528
+ return (0, _ramda.equals)(value, synced);
529
+ });
530
+ if (index !== -1) {
531
+ _this4._syncedEdits[attr] = syncedValues.slice(index);
532
+ setPath(layout, keys, original);
533
+ }
534
+ },
535
+ _ret;
536
+ for (var _i2 = 0, _Object$entries = Object.entries(this._syncedEdits); _i2 < _Object$entries.length; _i2++) {
537
+ _ret = _loop2();
538
+ if (_ret === 0) continue;
539
+ }
540
+ }
541
+ }, {
542
+ key: "trackSyncedEdits",
543
+ value: function trackSyncedEdits(updates) {
544
+ var _this$gd$current$_ful, _this$gd$current2;
545
+ var preGUI = (_this$gd$current$_ful = (_this$gd$current2 = this.gd.current) === null || _this$gd$current2 === void 0 || (_this$gd$current2 = _this$gd$current2._fullLayout) === null || _this$gd$current2 === void 0 ? void 0 : _this$gd$current2._preGUI) !== null && _this$gd$current$_ful !== void 0 ? _this$gd$current$_ful : {};
546
+ for (var _i3 = 0, _Object$keys = Object.keys(preGUI); _i3 < _Object$keys.length; _i3++) {
547
+ var attr = _Object$keys[_i3];
548
+ var keys = toPath(attr);
549
+ if (keys[0] in updates && getRevisionAttr(attr)) {
550
+ var _this$_syncedEdits$at;
551
+ this._syncedEdits[attr] = [].concat(_toConsumableArray((_this$_syncedEdits$at = this._syncedEdits[attr]) !== null && _this$_syncedEdits$at !== void 0 ? _this$_syncedEdits$at : []), [(0, _ramda.path)(keys, updates)]);
552
+ }
553
+ }
554
+ }
378
555
  }, {
379
556
  key: "getConfigOverride",
380
557
  value: function getConfigOverride(responsive) {
@@ -431,7 +608,7 @@ var PlotlyGraph = /*#__PURE__*/function (_Component) {
431
608
  }, {
432
609
  key: "bindEvents",
433
610
  value: function bindEvents() {
434
- var _this4 = this;
611
+ var _this5 = this;
435
612
  var _this$props = this.props,
436
613
  setProps = _this$props.setProps,
437
614
  clear_on_unhover = _this$props.clear_on_unhover,
@@ -493,12 +670,14 @@ var PlotlyGraph = /*#__PURE__*/function (_Component) {
493
670
  // copy and the figure prop (used as the base for Patch
494
671
  // updates) would otherwise go stale.
495
672
  if (eventData && gd.layout) {
496
- var _this4$props$figure = _this4.props.figure,
497
- figure = _this4$props$figure === void 0 ? {} : _this4$props$figure;
673
+ var _ref, _this5$_pendingFigure;
674
+ // React may batch several relayouts before delivering props.
675
+ // Build on the latest sync rather than losing its changes.
676
+ var figure = (_ref = (_this5$_pendingFigure = _this5._pendingFigures[_this5._pendingFigures.length - 1]) !== null && _this5$_pendingFigure !== void 0 ? _this5$_pendingFigure : _this5.props.figure) !== null && _ref !== void 0 ? _ref : {};
498
677
  var updates = {};
499
- for (var _i = 0, _Object$keys = Object.keys(eventData); _i < _Object$keys.length; _i++) {
678
+ for (var _i4 = 0, _Object$keys2 = Object.keys(eventData); _i4 < _Object$keys2.length; _i4++) {
500
679
  var _figure$layout;
501
- var eventKey = _Object$keys[_i];
680
+ var eventKey = _Object$keys2[_i4];
502
681
  // 'xaxis.range[0]' -> 'xaxis', 'shapes[1].x0' -> 'shapes'
503
682
  var key = eventKey.split('.')[0].split('[')[0];
504
683
  if (
@@ -509,10 +688,13 @@ var PlotlyGraph = /*#__PURE__*/function (_Component) {
509
688
  }
510
689
  }
511
690
  if (Object.keys(updates).length) {
691
+ _this5.trackSyncedEdits(updates);
692
+ var syncedFigure = _objectSpread(_objectSpread({}, figure), {}, {
693
+ layout: _objectSpread(_objectSpread({}, figure === null || figure === void 0 ? void 0 : figure.layout), updates)
694
+ });
695
+ _this5._pendingFigures.push(syncedFigure);
512
696
  setProps({
513
- figure: _objectSpread(_objectSpread({}, figure), {}, {
514
- layout: _objectSpread(_objectSpread({}, figure === null || figure === void 0 ? void 0 : figure.layout), updates)
515
- })
697
+ figure: syncedFigure
516
698
  });
517
699
  }
518
700
  }
@@ -558,19 +740,27 @@ var PlotlyGraph = /*#__PURE__*/function (_Component) {
558
740
  }, {
559
741
  key: "UNSAFE_componentWillReceiveProps",
560
742
  value: function UNSAFE_componentWillReceiveProps(nextProps) {
561
- var _this5 = this;
743
+ var _this6 = this;
562
744
  var idChanged = this.props.id !== nextProps.id;
563
745
  if (idChanged) {
746
+ this._pendingFigures = [];
747
+ this._syncedEdits = {};
564
748
  /*
565
749
  * then the dom needs to get re-rendered with a new ID.
566
750
  * the graph will get updated in componentDidUpdate
567
751
  */
568
752
  return;
569
753
  }
754
+ if (this.props.figure !== nextProps.figure) {
755
+ // An acknowledgement may skip batched figures or arrive before
756
+ // a later sync. An external figure supersedes all pending syncs.
757
+ var syncedIndex = this._pendingFigures.indexOf(nextProps.figure);
758
+ this._pendingFigures = syncedIndex === -1 ? [] : this._pendingFigures.slice(syncedIndex + 1);
759
+ }
570
760
  var p = this._queue;
571
761
  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) {
572
762
  p = p.then(function () {
573
- return _this5.plot(nextProps);
763
+ return _this6.plot(nextProps);
574
764
  });
575
765
  }
576
766
  this._queue = this.amendTraces(p, this.props, nextProps);
@@ -578,10 +768,10 @@ var PlotlyGraph = /*#__PURE__*/function (_Component) {
578
768
  }, {
579
769
  key: "componentDidUpdate",
580
770
  value: function componentDidUpdate(prevProps) {
581
- var _this6 = this;
771
+ var _this7 = this;
582
772
  if (prevProps.id !== this.props.id || prevProps.mathjax !== this.props.mathjax) {
583
773
  this._queue = this._queue.then(function () {
584
- return _this6.plot(_this6.props);
774
+ return _this7.plot(_this7.props);
585
775
  });
586
776
  }
587
777
  }
@@ -1,5 +1,9 @@
1
+ import '../utils/markdown/polyfills';
1
2
  import React, {useCallback, useMemo} from 'react';
2
- import ReactMarkdown from 'react-markdown';
3
+ import ReactMarkdown, {
4
+ defaultUrlTransform,
5
+ type UrlTransform,
6
+ } from 'react-markdown';
3
7
  import type {PluggableList} from 'unified';
4
8
 
5
9
  import LoadingElement from '../utils/_LoadingElement';
@@ -7,13 +11,19 @@ import {MarkdownContentProps, MarkdownProps} from '../types';
7
11
  import {components} from '../utils/markdown/components';
8
12
  import {MarkdownContext} from '../utils/markdown/context';
9
13
  import {
14
+ linkTargetPlugins,
10
15
  rawHtmlPlugins,
16
+ rehypeBlockCodePlugins,
11
17
  rehypeMathPlugins,
12
18
  remarkMathPlugins,
13
19
  remarkGfmPlugins,
14
20
  } from '../utils/markdown/plugins';
15
21
  import {dedentText} from '../utils/markdown/text';
16
22
 
23
+ // react-markdown 9 dropped `tel:` from its safe protocols; v8 allowed it.
24
+ const urlTransform: UrlTransform = url =>
25
+ /^tel:/i.test(url) ? url : defaultUrlTransform(url);
26
+
17
27
  const MarkdownContent = React.memo(function MarkdownContent({
18
28
  children,
19
29
  dedent,
@@ -32,11 +42,15 @@ const MarkdownContent = React.memo(function MarkdownContent({
32
42
  if (dangerously_allow_html) {
33
43
  rehypePlugins.push(...rawHtmlPlugins);
34
44
  }
45
+ rehypePlugins.push(...rehypeBlockCodePlugins);
46
+ if (link_target) {
47
+ rehypePlugins.push(...linkTargetPlugins(link_target));
48
+ }
35
49
 
36
50
  return (
37
51
  <ReactMarkdown
38
- linkTarget={link_target}
39
52
  remarkPlugins={remarkPlugins}
53
+ urlTransform={urlTransform}
40
54
  rehypePlugins={rehypePlugins}
41
55
  components={components}
42
56
  >
@@ -12,7 +12,7 @@ var _LoadingElement = _interopRequireDefault(require("../utils/LoadingElement"))
12
12
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
13
  var cache;
14
14
  function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var r, c, a = Object.defineProperty, n = { __proto__: null, default: e }; if (Object(e) !== e) return n; if (cache || "function" != typeof WeakMap || (cache = new WeakMap()), cache) { if (cache.has(e)) return cache.get(e); cache.set(e, n); } for (c in e) "default" !== c && {}.hasOwnProperty.call(e, c) && ((r = a && Object.getOwnPropertyDescriptor(e, c)) && (r.get || r.set) ? a(n, c, r) : n[c] = e[c]); return n; }
15
- function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
15
+ function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? (c > 1 && (G.n = c < 3 ? -1 : u), d(c, u)) : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
16
16
  function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
17
17
  function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
18
18
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
@@ -26,11 +26,11 @@ function HighlightedCode({className, children}: ReactMarkdownCodeProps) {
26
26
  }
27
27
 
28
28
  export default function CodeRenderer({
29
- inline,
29
+ node,
30
30
  className,
31
31
  children,
32
32
  }: ReactMarkdownCodeProps) {
33
- if (inline) {
33
+ if (!node?.data?.block) {
34
34
  return <code className={className}>{children}</code>;
35
35
  }
36
36
  return <HighlightedCode className={className}>{children}</HighlightedCode>;
@@ -3,13 +3,12 @@ import type {Element} from 'hast';
3
3
 
4
4
  // Here we declare react-markdown's internal types that it will pass to our
5
5
  // components. See:
6
- // https://github.com/remarkjs/react-markdown/tree/8.0.7#appendix-b-components
6
+ // https://github.com/remarkjs/react-markdown/tree/10.1.0#appendix-b-components
7
7
  export type ReactMarkdownGenericProps = {
8
8
  node?: Element;
9
9
  children?: ReactNode;
10
10
  };
11
11
 
12
12
  export type ReactMarkdownCodeProps = ReactMarkdownGenericProps & {
13
- inline?: boolean;
14
13
  className?: string;
15
14
  };
@@ -3,8 +3,10 @@ import remarkGfm from 'remark-gfm';
3
3
  import remarkMath from 'remark-math';
4
4
  import rehypeRaw from 'rehype-raw';
5
5
 
6
+ import rehypeBlockCode from './rehypeBlockCode';
6
7
  import rehypeDashMath from './rehypeDashMath';
7
8
  import rehypeDccComponents from './rehypeDccComponents';
9
+ import rehypeLinkTarget from './rehypeLinkTarget';
8
10
  import rehypeStripTags from './rehypeStripTags';
9
11
 
10
12
  // remark plugin for GitHub Flavored Markdown: tables, strikethrough,
@@ -26,3 +28,9 @@ export const rawHtmlPlugins: PluggableList = [
26
28
  rehypeStripTags,
27
29
  rehypeDccComponents,
28
30
  ];
31
+
32
+ // Always last, so they also see elements that rehype-raw parsed from raw HTML.
33
+ export const rehypeBlockCodePlugins: PluggableList = [rehypeBlockCode];
34
+ export const linkTargetPlugins = (target: string): PluggableList => [
35
+ [rehypeLinkTarget, target],
36
+ ];
@@ -0,0 +1,25 @@
1
+ import type {Plugin} from 'unified';
2
+ import type {Root} from 'hast';
3
+ import {visit} from 'unist-util-visit';
4
+
5
+ declare module 'hast' {
6
+ interface ElementData {
7
+ block?: boolean;
8
+ }
9
+ }
10
+
11
+ // Flags `<code>` inside `<pre>` so the code renderer knows to highlight it.
12
+ // Replaces the `inline` prop react-markdown dropped in v9.
13
+ const rehypeBlockCode: Plugin<[], Root> = () => tree => {
14
+ visit(tree, 'element', (node, _index, parent) => {
15
+ if (
16
+ node.tagName === 'code' &&
17
+ parent?.type === 'element' &&
18
+ parent.tagName === 'pre'
19
+ ) {
20
+ node.data = {...node.data, block: true};
21
+ }
22
+ });
23
+ };
24
+
25
+ export default rehypeBlockCode;
@@ -24,8 +24,9 @@ function rewriteRawMath(value: string): string {
24
24
  });
25
25
  }
26
26
 
27
- // remark-math emits `<span class="math math-inline">` / `<div class="math
28
- // math-display">`; report which (if either) an element is.
27
+ // remark-math emits `<code class="language-math math-inline">` and
28
+ // `<pre><code class="language-math math-display">`; report which (if either)
29
+ // an element is.
29
30
  function mathKind(node: Element): 'inline' | 'display' | null {
30
31
  const className = node.properties?.className;
31
32
  if (Array.isArray(className)) {
@@ -55,6 +56,18 @@ const rehypeDashMath: Plugin<[], Root> = () => tree => {
55
56
  return;
56
57
  }
57
58
  if (node.type === 'element') {
59
+ const [first] = node.children;
60
+ if (
61
+ node.tagName === 'pre' &&
62
+ node.children.length === 1 &&
63
+ first.type === 'element' &&
64
+ mathKind(first) === 'display'
65
+ ) {
66
+ node.tagName = 'dashmathjax';
67
+ node.properties = {inline: 'false'};
68
+ node.children = first.children;
69
+ return;
70
+ }
58
71
  const kind = mathKind(node);
59
72
  if (kind) {
60
73
  node.tagName = 'dashmathjax';
@@ -0,0 +1,15 @@
1
+ import type {Plugin} from 'unified';
2
+ import type {Root} from 'hast';
3
+ import {visit} from 'unist-util-visit';
4
+
5
+ // Sets `target` on every link, including raw-HTML ones. Replaces the
6
+ // `linkTarget` option react-markdown dropped in v9.
7
+ const rehypeLinkTarget: Plugin<[string], Root> = target => tree => {
8
+ visit(tree, 'element', node => {
9
+ if (node.tagName === 'a') {
10
+ node.properties.target = target;
11
+ }
12
+ });
13
+ };
14
+
15
+ export default rehypeLinkTarget;
@@ -0,0 +1,24 @@
1
+ // The react-markdown 10 stack calls these at render time. They need Safari 15.4
2
+ // / Chrome 93, newer than our browserslist floor, and babel does not polyfill
3
+ // builtins.
4
+ const ObjectWithHasOwn = Object as ObjectConstructor & {
5
+ hasOwn?: (obj: object, key: PropertyKey) => boolean;
6
+ };
7
+ if (!ObjectWithHasOwn.hasOwn) {
8
+ ObjectWithHasOwn.hasOwn = (obj, key) =>
9
+ Object.prototype.hasOwnProperty.call(obj, key);
10
+ }
11
+
12
+ if (!('at' in Array.prototype)) {
13
+ // eslint-disable-next-line no-extend-native
14
+ Object.defineProperty(Array.prototype, 'at', {
15
+ configurable: true,
16
+ writable: true,
17
+ value: function at<T>(this: T[], index: number) {
18
+ const i = Math.trunc(index) || 0;
19
+ return this[i < 0 ? this.length + i : i];
20
+ },
21
+ });
22
+ }
23
+
24
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dash-core-components",
3
- "version": "4.5.4",
3
+ "version": "4.5.5",
4
4
  "description": "Core component suite for Dash",
5
5
  "repository": {
6
6
  "type": "git",
@@ -61,13 +61,13 @@
61
61
  "react-dropzone": "^4.1.2",
62
62
  "react-fast-compare": "^3.2.2",
63
63
  "react-input-autosize": "^3.0.0",
64
- "react-markdown": "^8.0.7",
64
+ "react-markdown": "^10.1.0",
65
65
  "react-window": "^1.8.11",
66
- "rehype-raw": "^6.1.1",
67
- "remark-math": "^5.1.1",
68
- "remark-gfm": "^3.0.1",
66
+ "rehype-raw": "^7.0.0",
67
+ "remark-gfm": "^4.0.1",
68
+ "remark-math": "^6.0.0",
69
69
  "uniqid": "^5.4.0",
70
- "unist-util-visit": "^4.1.2"
70
+ "unist-util-visit": "^5.2.0"
71
71
  },
72
72
  "devDependencies": {
73
73
  "@babel/cli": "^7.28.6",