dash-core-components 4.2.0 → 4.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dash_core_components/async-datepicker.js +1 -1
  2. package/dash_core_components/async-datepicker.js.map +1 -1
  3. package/dash_core_components/async-dropdown.js +1 -1
  4. package/dash_core_components/async-dropdown.js.map +1 -1
  5. package/dash_core_components/async-graph.js +1 -1
  6. package/dash_core_components/async-graph.js.map +1 -1
  7. package/dash_core_components/async-highlight.js +1 -1
  8. package/dash_core_components/async-highlight.js.map +1 -1
  9. package/dash_core_components/async-markdown.js +1 -1
  10. package/dash_core_components/async-markdown.js.map +1 -1
  11. package/dash_core_components/async-slider.js +1 -1
  12. package/dash_core_components/async-slider.js.map +1 -1
  13. package/dash_core_components/async-upload.js +1 -1
  14. package/dash_core_components/async-upload.js.map +1 -1
  15. package/dash_core_components/dash_core_components-shared.js +1 -1
  16. package/dash_core_components/dash_core_components-shared.js.map +1 -1
  17. package/dash_core_components/dash_core_components.js +1 -1
  18. package/dash_core_components/dash_core_components.js.map +1 -1
  19. package/lib/components/Clipboard.react.js +220 -173
  20. package/lib/components/ConfirmDialog.react.js +62 -34
  21. package/lib/components/ConfirmDialogProvider.react.js +45 -21
  22. package/lib/components/Download.react.js +46 -22
  23. package/lib/components/Geolocation.react.js +92 -64
  24. package/lib/components/Graph.react.js +99 -71
  25. package/lib/components/Interval.react.js +88 -56
  26. package/lib/components/Link.react.js +6 -5
  27. package/lib/components/Location.react.js +127 -97
  28. package/lib/components/Markdown.react.js +37 -16
  29. package/lib/components/Store.react.js +177 -128
  30. package/lib/components/Upload.react.js +28 -8
  31. package/lib/fragments/DatePickerRange.tsx +11 -9
  32. package/lib/fragments/Dropdown.tsx +1 -1
  33. package/lib/fragments/Graph.privateprops.js +9 -3
  34. package/lib/fragments/Graph.react.js +426 -339
  35. package/lib/fragments/Markdown.react.js +160 -120
  36. package/lib/fragments/Math.react.js +49 -24
  37. package/lib/fragments/Upload.react.js +341 -302
  38. package/lib/utils/LazyLoader/graph.js +3 -2
  39. package/lib/utils/LazyLoader/hljs.js +5 -2
  40. package/lib/utils/LazyLoader/markdown.js +3 -2
  41. package/lib/utils/LazyLoader/mathjax.js +5 -2
  42. package/lib/utils/LazyLoader/plotly.js +6 -7
  43. package/lib/utils/LazyLoader/upload.js +3 -2
  44. package/lib/utils/LoadingElement.js +3 -2
  45. package/lib/utils/MarkdownHighlighter.js +6 -5
  46. package/lib/utils/ResizeDetector.js +14 -9
  47. package/package.json +16 -15
@@ -1,81 +1,113 @@
1
1
  "use strict";
2
2
 
3
+ 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); }
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  exports.default = void 0;
7
8
  var _propTypes = _interopRequireDefault(require("prop-types"));
8
9
  var _react = _interopRequireWildcard(require("react"));
9
- 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); }
10
+ 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); }
10
11
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
13
+ 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); } }
14
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
15
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
16
+ 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); }
17
+ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
18
+ 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); }
19
+ function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
20
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
21
+ function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
22
+ 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); }
23
+ function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
11
24
  // eslint-disable-line no-unused-vars
12
-
13
25
  /**
14
26
  * A component that repeatedly increments a counter `n_intervals`
15
27
  * with a fixed time delay between each increment.
16
28
  * Interval is good for triggering a component on a recurring basis.
17
29
  * The time delay is set with the property "interval" in milliseconds.
18
30
  */
19
- class Interval extends _react.Component {
20
- constructor(props) {
21
- super(props);
22
- this.intervalId = null;
23
- this.reportInterval = this.reportInterval.bind(this);
24
- this.handleTimer = this.handleTimer.bind(this);
31
+ var Interval = exports.default = /*#__PURE__*/function (_Component) {
32
+ function Interval(props) {
33
+ var _this;
34
+ _classCallCheck(this, Interval);
35
+ _this = _callSuper(this, Interval, [props]);
36
+ _this.intervalId = null;
37
+ _this.reportInterval = _this.reportInterval.bind(_this);
38
+ _this.handleTimer = _this.handleTimer.bind(_this);
39
+ return _this;
25
40
  }
26
- handleTimer(props) {
27
- // Check if timer should stop or shouldn't even start
28
- if (props.max_intervals === 0 || props.disabled || props.n_intervals >= props.max_intervals && props.max_intervals !== -1) {
29
- // stop existing timer
41
+ _inherits(Interval, _Component);
42
+ return _createClass(Interval, [{
43
+ key: "handleTimer",
44
+ value: function handleTimer(props) {
45
+ // Check if timer should stop or shouldn't even start
46
+ if (props.max_intervals === 0 || props.disabled || props.n_intervals >= props.max_intervals && props.max_intervals !== -1) {
47
+ // stop existing timer
48
+ if (this.intervalId) {
49
+ this.clearTimer();
50
+ }
51
+ // and don't start a timer
52
+ return;
53
+ }
54
+
55
+ // keep the existing timer running
30
56
  if (this.intervalId) {
31
- this.clearTimer();
57
+ return;
32
58
  }
33
- // and don't start a timer
34
- return;
35
- }
36
59
 
37
- // keep the existing timer running
38
- if (this.intervalId) {
39
- return;
60
+ // it hasn't started yet (& it should start)
61
+ this.intervalId = window.setInterval(this.reportInterval, props.interval);
40
62
  }
41
-
42
- // it hasn't started yet (& it should start)
43
- this.intervalId = window.setInterval(this.reportInterval, props.interval);
44
- }
45
- resetTimer(props) {
46
- this.clearTimer();
47
- this.handleTimer(props);
48
- }
49
- clearTimer() {
50
- window.clearInterval(this.intervalId);
51
- this.intervalId = null;
52
- }
53
- reportInterval() {
54
- var _this$props = this.props,
55
- setProps = _this$props.setProps,
56
- n_intervals = _this$props.n_intervals;
57
- setProps({
58
- n_intervals: n_intervals + 1
59
- });
60
- }
61
- componentDidMount() {
62
- this.handleTimer(this.props);
63
- }
64
- UNSAFE_componentWillReceiveProps(nextProps) {
65
- if (nextProps.interval !== this.props.interval) {
66
- this.resetTimer(nextProps);
67
- } else {
68
- this.handleTimer(nextProps);
63
+ }, {
64
+ key: "resetTimer",
65
+ value: function resetTimer(props) {
66
+ this.clearTimer();
67
+ this.handleTimer(props);
69
68
  }
70
- }
71
- componentWillUnmount() {
72
- this.clearTimer();
73
- }
74
- render() {
75
- return null;
76
- }
77
- }
78
- exports.default = Interval;
69
+ }, {
70
+ key: "clearTimer",
71
+ value: function clearTimer() {
72
+ window.clearInterval(this.intervalId);
73
+ this.intervalId = null;
74
+ }
75
+ }, {
76
+ key: "reportInterval",
77
+ value: function reportInterval() {
78
+ var _this$props = this.props,
79
+ setProps = _this$props.setProps,
80
+ n_intervals = _this$props.n_intervals;
81
+ setProps({
82
+ n_intervals: n_intervals + 1
83
+ });
84
+ }
85
+ }, {
86
+ key: "componentDidMount",
87
+ value: function componentDidMount() {
88
+ this.handleTimer(this.props);
89
+ }
90
+ }, {
91
+ key: "UNSAFE_componentWillReceiveProps",
92
+ value: function UNSAFE_componentWillReceiveProps(nextProps) {
93
+ if (nextProps.interval !== this.props.interval) {
94
+ this.resetTimer(nextProps);
95
+ } else {
96
+ this.handleTimer(nextProps);
97
+ }
98
+ }
99
+ }, {
100
+ key: "componentWillUnmount",
101
+ value: function componentWillUnmount() {
102
+ this.clearTimer();
103
+ }
104
+ }, {
105
+ key: "render",
106
+ value: function render() {
107
+ return null;
108
+ }
109
+ }]);
110
+ }(_react.Component);
79
111
  Interval.propTypes = {
80
112
  /**
81
113
  * The ID of this component, used to identify dash components
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
 
3
+ 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); }
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
@@ -8,7 +9,7 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
8
9
  var _react = _interopRequireWildcard(require("react"));
9
10
  var _ramda = require("ramda");
10
11
  var _excluded = ["refresh"];
11
- 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); }
12
+ 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); }
12
13
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
14
  function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
14
15
  function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
@@ -36,7 +37,7 @@ CustomEvent.prototype = window.Event.prototype;
36
37
  * For links with destinations outside the current app, `html.A` is a better
37
38
  * component to use.
38
39
  */
39
- var Link = _ref => {
40
+ var Link = function Link(_ref) {
40
41
  var _ref$refresh = _ref.refresh,
41
42
  refresh = _ref$refresh === void 0 ? false : _ref$refresh,
42
43
  props = _objectWithoutProperties(_ref, _excluded);
@@ -49,12 +50,12 @@ var Link = _ref => {
49
50
  target = props.target,
50
51
  setProps = props.setProps;
51
52
  var cleanUrl = window.dash_clientside.clean_url;
52
- var sanitizedUrl = (0, _react.useMemo)(() => {
53
+ var sanitizedUrl = (0, _react.useMemo)(function () {
53
54
  return href ? cleanUrl(href) : undefined;
54
55
  }, [href]);
55
56
  var ctx = window.dash_component_api.useDashContext();
56
57
  var loading = ctx.useLoading();
57
- var updateLocation = e => {
58
+ var updateLocation = function updateLocation(e) {
58
59
  var hasModifiers = e.metaKey || e.shiftKey || e.altKey || e.ctrlKey;
59
60
  if (hasModifiers) {
60
61
  return;
@@ -73,7 +74,7 @@ var Link = _ref => {
73
74
  // scroll back to top
74
75
  window.scrollTo(0, 0);
75
76
  };
76
- (0, _react.useEffect)(() => {
77
+ (0, _react.useEffect)(function () {
77
78
  if (sanitizedUrl && sanitizedUrl !== href) {
78
79
  setProps({
79
80
  _dash_error: new Error("Dangerous link detected:: ".concat(href))
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
 
3
+ 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); }
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
@@ -9,121 +10,150 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
9
10
  var _ramda = require("ramda");
10
11
  var _dashComponentPlugins = require("@plotly/dash-component-plugins");
11
12
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
14
+ 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); } }
15
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
16
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
17
+ 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); }
18
+ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
19
+ 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); }
20
+ function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
21
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
22
+ function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
23
+ 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); }
24
+ function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
12
25
  /**
13
26
  * Update and track the current window.location object through the window.history state.
14
27
  * Use in conjunction with the `dash_core_components.Link` component to make apps with multiple pages.
15
28
  */
16
- class Location extends _react.Component {
17
- constructor(props) {
18
- super(props);
19
- this.updateLocation = this.updateLocation.bind(this);
20
- this.onLocationChange = this.onLocationChange.bind(this);
29
+ var Location = exports.default = /*#__PURE__*/function (_Component) {
30
+ function Location(props) {
31
+ var _this;
32
+ _classCallCheck(this, Location);
33
+ _this = _callSuper(this, Location, [props]);
34
+ _this.updateLocation = _this.updateLocation.bind(_this);
35
+ _this.onLocationChange = _this.onLocationChange.bind(_this);
36
+ return _this;
21
37
  }
22
- updateLocation(props) {
23
- var hash = props.hash,
24
- href = props.href,
25
- pathname = props.pathname,
26
- refresh = props.refresh,
27
- search = props.search,
28
- setProps = props.setProps;
38
+ _inherits(Location, _Component);
39
+ return _createClass(Location, [{
40
+ key: "updateLocation",
41
+ value: function updateLocation(props) {
42
+ var _this2 = this;
43
+ var hash = props.hash,
44
+ href = props.href,
45
+ pathname = props.pathname,
46
+ refresh = props.refresh,
47
+ search = props.search,
48
+ setProps = props.setProps;
29
49
 
30
- // Keep track of props relating to window.location that may need to be updated via setProps
31
- var propsToSet = {};
50
+ // Keep track of props relating to window.location that may need to be updated via setProps
51
+ var propsToSet = {};
32
52
 
33
- /**
34
- * Check if the field exists in props. If the prop with "fieldName" is not defined,
35
- * then it was not set by the user and needs to be equal to the value in window.location.
36
- * This only happens on page load (since props will no longer be undefined after componentDidMount).
37
- *
38
- * @param {string} fieldName
39
- * The name of the prop in window.location and in the component's prop
40
- *
41
- * @returns {boolean}
42
- * Returns true if the prop with fieldName is different and the window state needs to be updated
43
- */
44
- var checkExistsUpdateWindowLocation = fieldName => {
45
- var propVal = props[fieldName];
46
- if (((0, _ramda.type)(propVal) === 'Undefined' || propVal === null) && (0, _ramda.type)(window.location[fieldName]) !== 'Undefined') {
47
- // propVal is undefined or null, but window.location has this fieldName defined
48
- propsToSet[fieldName] = window.location[fieldName];
49
- } else if (propVal !== window.location[fieldName]) {
50
- // Prop has changed?
51
- if (refresh === true) {
52
- // Refresh the page?
53
- window.location[fieldName] = propVal;
54
- } else if (this.props[fieldName] !== propVal) {
55
- // If this prop has changed, need to setProps
56
- propsToSet[fieldName] = propVal;
57
- // This (`${fieldName}`: propVal) needs to be pushed in the window.history
58
- return true;
53
+ /**
54
+ * Check if the field exists in props. If the prop with "fieldName" is not defined,
55
+ * then it was not set by the user and needs to be equal to the value in window.location.
56
+ * This only happens on page load (since props will no longer be undefined after componentDidMount).
57
+ *
58
+ * @param {string} fieldName
59
+ * The name of the prop in window.location and in the component's prop
60
+ *
61
+ * @returns {boolean}
62
+ * Returns true if the prop with fieldName is different and the window state needs to be updated
63
+ */
64
+ var checkExistsUpdateWindowLocation = function checkExistsUpdateWindowLocation(fieldName) {
65
+ var propVal = props[fieldName];
66
+ if (((0, _ramda.type)(propVal) === 'Undefined' || propVal === null) && (0, _ramda.type)(window.location[fieldName]) !== 'Undefined') {
67
+ // propVal is undefined or null, but window.location has this fieldName defined
68
+ propsToSet[fieldName] = window.location[fieldName];
69
+ } else if (propVal !== window.location[fieldName]) {
70
+ // Prop has changed?
71
+ if (refresh === true) {
72
+ // Refresh the page?
73
+ window.location[fieldName] = propVal;
74
+ } else if (_this2.props[fieldName] !== propVal) {
75
+ // If this prop has changed, need to setProps
76
+ propsToSet[fieldName] = propVal;
77
+ // This (`${fieldName}`: propVal) needs to be pushed in the window.history
78
+ return true;
79
+ }
59
80
  }
60
- }
61
- // This (`${fieldName}`: propVal) DOES NOT need to be pushed in the window.history
62
- return false;
63
- };
81
+ // This (`${fieldName}`: propVal) DOES NOT need to be pushed in the window.history
82
+ return false;
83
+ };
64
84
 
65
- // Check if the prop value needs to be updated (note that this mutates propsToSet)
66
- var pathnameUpdated = checkExistsUpdateWindowLocation('pathname');
67
- var hrefUpdated = checkExistsUpdateWindowLocation('href');
68
- var hashUpdated = checkExistsUpdateWindowLocation('hash');
69
- var searchUpdated = checkExistsUpdateWindowLocation('search');
85
+ // Check if the prop value needs to be updated (note that this mutates propsToSet)
86
+ var pathnameUpdated = checkExistsUpdateWindowLocation('pathname');
87
+ var hrefUpdated = checkExistsUpdateWindowLocation('href');
88
+ var hashUpdated = checkExistsUpdateWindowLocation('hash');
89
+ var searchUpdated = checkExistsUpdateWindowLocation('search');
70
90
 
71
- // propsToSet has been updated -- batch update to Dash
72
- if (Object.keys(propsToSet).length > 0) {
73
- setProps(propsToSet);
74
- }
91
+ // propsToSet has been updated -- batch update to Dash
92
+ if (Object.keys(propsToSet).length > 0) {
93
+ setProps(propsToSet);
94
+ }
75
95
 
76
- // Special case -- overrides everything!
77
- if (hrefUpdated) {
78
- window.history.pushState({}, '', href);
79
- if (refresh === 'callback-nav') {
80
- window.dispatchEvent(new CustomEvent('_dashprivate_pushstate'));
96
+ // Special case -- overrides everything!
97
+ if (hrefUpdated) {
98
+ window.history.pushState({}, '', href);
99
+ if (refresh === 'callback-nav') {
100
+ window.dispatchEvent(new CustomEvent('_dashprivate_pushstate'));
101
+ }
102
+ } else if (pathnameUpdated || hashUpdated || searchUpdated) {
103
+ // Otherwise, we can mash everything together
104
+ var searchVal = (0, _ramda.type)(search) !== 'Undefined' ? search : '';
105
+ var hashVal = (0, _ramda.type)(hash) !== 'Undefined' ? hash : '';
106
+ window.history.pushState({}, '', "".concat(pathname).concat(searchVal).concat(hashVal));
107
+ if (refresh === 'callback-nav') {
108
+ window.dispatchEvent(new CustomEvent('_dashprivate_pushstate'));
109
+ }
110
+ }
111
+ }
112
+ }, {
113
+ key: "onLocationChange",
114
+ value: function onLocationChange() {
115
+ var setProps = this.props.setProps;
116
+ var propsToChange = {};
117
+ if (this.props.pathname !== window.location.pathname) {
118
+ propsToChange.pathname = window.location.pathname;
119
+ }
120
+ if (this.props.href !== window.location.href) {
121
+ propsToChange.href = window.location.href;
81
122
  }
82
- } else if (pathnameUpdated || hashUpdated || searchUpdated) {
83
- // Otherwise, we can mash everything together
84
- var searchVal = (0, _ramda.type)(search) !== 'Undefined' ? search : '';
85
- var hashVal = (0, _ramda.type)(hash) !== 'Undefined' ? hash : '';
86
- window.history.pushState({}, '', "".concat(pathname).concat(searchVal).concat(hashVal));
87
- if (refresh === 'callback-nav') {
88
- window.dispatchEvent(new CustomEvent('_dashprivate_pushstate'));
123
+ if (this.props.hash !== window.location.hash) {
124
+ propsToChange.hash = window.location.hash;
89
125
  }
126
+ if (this.props.search !== window.location.search) {
127
+ propsToChange.search = window.location.search;
128
+ }
129
+ setProps(propsToChange);
130
+ _dashComponentPlugins.History.dispatchChangeEvent();
90
131
  }
91
- }
92
- onLocationChange() {
93
- var setProps = this.props.setProps;
94
- var propsToChange = {};
95
- if (this.props.pathname !== window.location.pathname) {
96
- propsToChange.pathname = window.location.pathname;
132
+ }, {
133
+ key: "componentDidMount",
134
+ value: function componentDidMount() {
135
+ window.addEventListener('popstate', this.onLocationChange);
136
+ window.addEventListener('_dashprivate_pushstate', this.onLocationChange);
137
+ this.updateLocation(this.props);
97
138
  }
98
- if (this.props.href !== window.location.href) {
99
- propsToChange.href = window.location.href;
139
+ }, {
140
+ key: "componentWillUnmount",
141
+ value: function componentWillUnmount() {
142
+ window.removeEventListener('popstate', this.onLocationChange);
143
+ window.removeEventListener('_dashprivate_pushstate', this.onLocationChange);
100
144
  }
101
- if (this.props.hash !== window.location.hash) {
102
- propsToChange.hash = window.location.hash;
145
+ }, {
146
+ key: "UNSAFE_componentWillReceiveProps",
147
+ value: function UNSAFE_componentWillReceiveProps(nextProps) {
148
+ this.updateLocation(nextProps);
103
149
  }
104
- if (this.props.search !== window.location.search) {
105
- propsToChange.search = window.location.search;
150
+ }, {
151
+ key: "render",
152
+ value: function render() {
153
+ return null;
106
154
  }
107
- setProps(propsToChange);
108
- _dashComponentPlugins.History.dispatchChangeEvent();
109
- }
110
- componentDidMount() {
111
- window.addEventListener('popstate', this.onLocationChange);
112
- window.addEventListener('_dashprivate_pushstate', this.onLocationChange);
113
- this.updateLocation(this.props);
114
- }
115
- componentWillUnmount() {
116
- window.removeEventListener('popstate', this.onLocationChange);
117
- window.removeEventListener('_dashprivate_pushstate', this.onLocationChange);
118
- }
119
- UNSAFE_componentWillReceiveProps(nextProps) {
120
- this.updateLocation(nextProps);
121
- }
122
- render() {
123
- return null;
124
- }
125
- }
126
- exports.default = Location;
155
+ }]);
156
+ }(_react.Component);
127
157
  Location.propTypes = {
128
158
  /**
129
159
  * The ID of this component, used to identify dash components
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
 
3
+ 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); }
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
@@ -9,7 +10,7 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
9
10
  var _react = _interopRequireWildcard(require("react"));
10
11
  var _markdown = _interopRequireDefault(require("../utils/LazyLoader/markdown"));
11
12
  var _mathjax = _interopRequireDefault(require("../utils/LazyLoader/mathjax"));
12
- 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); }
13
+ 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); }
13
14
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
15
  function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
15
16
  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."); }
@@ -17,26 +18,44 @@ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r)
17
18
  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; }
18
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; } }
19
20
  function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
21
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
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); } }
23
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
24
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
25
+ 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); }
26
+ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
27
+ 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); }
28
+ function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
29
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
30
+ function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
31
+ 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); }
32
+ function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
20
33
  // eslint-disable-next-line valid-jsdoc
21
34
  /**
22
35
  * A component that renders Markdown text as specified by the
23
36
  * GitHub Markdown spec. These component uses
24
37
  * [react-markdown](https://rexxars.github.io/react-markdown/) under the hood.
25
38
  */
26
- class DashMarkdown extends _react.Component {
27
- constructor(props) {
28
- super(props);
39
+ var DashMarkdown = exports.default = /*#__PURE__*/function (_Component) {
40
+ function DashMarkdown(props) {
41
+ var _this;
42
+ _classCallCheck(this, DashMarkdown);
43
+ _this = _callSuper(this, DashMarkdown, [props]);
29
44
  if (props.mathjax) {
30
45
  DashMarkdown._loadMathjax = true;
31
46
  }
47
+ return _this;
32
48
  }
33
- render() {
34
- return /*#__PURE__*/_react.default.createElement(_react.Suspense, {
35
- fallback: null
36
- }, /*#__PURE__*/_react.default.createElement(RealDashMarkdown, this.props));
37
- }
38
- }
39
- exports.default = DashMarkdown;
49
+ _inherits(DashMarkdown, _Component);
50
+ return _createClass(DashMarkdown, [{
51
+ key: "render",
52
+ value: function render() {
53
+ return /*#__PURE__*/_react.default.createElement(_react.Suspense, {
54
+ fallback: null
55
+ }, /*#__PURE__*/_react.default.createElement(RealDashMarkdown, this.props));
56
+ }
57
+ }]);
58
+ }(_react.Component);
40
59
  DashMarkdown.propTypes = {
41
60
  /**
42
61
  * The ID of this component, used to identify dash components
@@ -94,10 +113,12 @@ DashMarkdown.defaultProps = {
94
113
  highlight_config: {},
95
114
  dedent: true
96
115
  };
97
- var RealDashMarkdown = (0, _dashComponentPlugins.asyncDecorator)(DashMarkdown, () => Promise.all([(0, _markdown.default)(), DashMarkdown._loadMathjax ? (0, _mathjax.default)() : undefined]).then(_ref => {
98
- var _ref2 = _slicedToArray(_ref, 1),
99
- md = _ref2[0];
100
- return md;
101
- }));
116
+ var RealDashMarkdown = (0, _dashComponentPlugins.asyncDecorator)(DashMarkdown, function () {
117
+ return Promise.all([(0, _markdown.default)(), DashMarkdown._loadMathjax ? (0, _mathjax.default)() : undefined]).then(function (_ref) {
118
+ var _ref2 = _slicedToArray(_ref, 1),
119
+ md = _ref2[0];
120
+ return md;
121
+ });
122
+ });
102
123
  var propTypes = exports.propTypes = DashMarkdown.propTypes;
103
124
  var defaultProps = exports.defaultProps = DashMarkdown.defaultProps;