dash-core-components 4.1.0 → 4.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/dash_core_components/async-datepicker.js +1 -1
  2. package/dash_core_components/async-datepicker.js.map +1 -1
  3. package/dash_core_components/async-dropdown.js +1 -1
  4. package/dash_core_components/async-dropdown.js.map +1 -1
  5. package/dash_core_components/async-graph.js +1 -1
  6. package/dash_core_components/async-graph.js.map +1 -1
  7. package/dash_core_components/async-highlight.js +1 -1
  8. package/dash_core_components/async-highlight.js.map +1 -1
  9. package/dash_core_components/async-markdown.js +1 -1
  10. package/dash_core_components/async-markdown.js.map +1 -1
  11. package/dash_core_components/async-slider.js +1 -1
  12. package/dash_core_components/async-slider.js.map +1 -1
  13. package/dash_core_components/async-upload.js +2 -1
  14. package/dash_core_components/async-upload.js.map +1 -1
  15. package/dash_core_components/dash_core_components-shared.js +1 -1
  16. package/dash_core_components/dash_core_components-shared.js.map +1 -1
  17. package/dash_core_components/dash_core_components.js +1 -1
  18. package/dash_core_components/dash_core_components.js.map +1 -1
  19. package/dash_core_components/proptypes.js +1 -0
  20. package/lib/components/Clipboard.react.js +220 -126
  21. package/lib/components/ConfirmDialog.react.js +62 -35
  22. package/lib/components/ConfirmDialogProvider.react.js +45 -22
  23. package/lib/components/Download.react.js +46 -24
  24. package/lib/components/Geolocation.react.js +92 -64
  25. package/lib/components/Graph.react.js +112 -75
  26. package/lib/components/Input.tsx +2 -2
  27. package/lib/components/Interval.react.js +88 -57
  28. package/lib/components/Link.react.js +16 -18
  29. package/lib/components/Location.react.js +127 -101
  30. package/lib/components/Markdown.react.js +43 -15
  31. package/lib/components/Store.react.js +177 -131
  32. package/lib/components/Upload.react.js +28 -8
  33. package/lib/components/css/dropdown.css +6 -0
  34. package/lib/components/css/sliders.css +1 -0
  35. package/lib/fragments/DatePickerRange.tsx +147 -148
  36. package/lib/fragments/DatePickerSingle.tsx +115 -116
  37. package/lib/fragments/Dropdown.tsx +42 -2
  38. package/lib/fragments/Graph.privateprops.js +9 -3
  39. package/lib/fragments/Graph.react.js +418 -322
  40. package/lib/fragments/Markdown.react.js +163 -112
  41. package/lib/fragments/Math.react.js +49 -24
  42. package/lib/fragments/Upload.react.js +344 -220
  43. package/lib/types.ts +7 -0
  44. package/lib/utils/LazyLoader/graph.js +3 -2
  45. package/lib/utils/LazyLoader/hljs.js +5 -2
  46. package/lib/utils/LazyLoader/markdown.js +3 -2
  47. package/lib/utils/LazyLoader/mathjax.js +5 -2
  48. package/lib/utils/LazyLoader/plotly.js +6 -7
  49. package/lib/utils/LazyLoader/upload.js +3 -2
  50. package/lib/utils/LoadingElement.js +5 -5
  51. package/lib/utils/MarkdownHighlighter.js +6 -5
  52. package/lib/utils/ResizeDetector.js +17 -14
  53. package/lib/utils/dropdownSearch.ts +32 -12
  54. package/lib/utils/optionRendering.tsx +3 -0
  55. package/package.json +3 -3
@@ -1,82 +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 {
55
- setProps,
56
- n_intervals
57
- } = this.props;
58
- setProps({
59
- n_intervals: n_intervals + 1
60
- });
61
- }
62
- componentDidMount() {
63
- this.handleTimer(this.props);
64
- }
65
- UNSAFE_componentWillReceiveProps(nextProps) {
66
- if (nextProps.interval !== this.props.interval) {
67
- this.resetTimer(nextProps);
68
- } else {
69
- this.handleTimer(nextProps);
63
+ }, {
64
+ key: "resetTimer",
65
+ value: function resetTimer(props) {
66
+ this.clearTimer();
67
+ this.handleTimer(props);
70
68
  }
71
- }
72
- componentWillUnmount() {
73
- this.clearTimer();
74
- }
75
- render() {
76
- return null;
77
- }
78
- }
79
- 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);
80
111
  Interval.propTypes = {
81
112
  /**
82
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,28 +37,25 @@ 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 {
41
- refresh = false
42
- } = _ref,
40
+ var Link = function Link(_ref) {
41
+ var _ref$refresh = _ref.refresh,
42
+ refresh = _ref$refresh === void 0 ? false : _ref$refresh,
43
43
  props = _objectWithoutProperties(_ref, _excluded);
44
- var {
45
- className,
46
- style,
47
- id,
48
- href,
49
- children,
50
- title,
51
- target,
52
- setProps
53
- } = props;
44
+ var className = props.className,
45
+ style = props.style,
46
+ id = props.id,
47
+ href = props.href,
48
+ children = props.children,
49
+ title = props.title,
50
+ target = props.target,
51
+ setProps = props.setProps;
54
52
  var cleanUrl = window.dash_clientside.clean_url;
55
- var sanitizedUrl = (0, _react.useMemo)(() => {
53
+ var sanitizedUrl = (0, _react.useMemo)(function () {
56
54
  return href ? cleanUrl(href) : undefined;
57
55
  }, [href]);
58
56
  var ctx = window.dash_component_api.useDashContext();
59
57
  var loading = ctx.useLoading();
60
- var updateLocation = e => {
58
+ var updateLocation = function updateLocation(e) {
61
59
  var hasModifiers = e.metaKey || e.shiftKey || e.altKey || e.ctrlKey;
62
60
  if (hasModifiers) {
63
61
  return;
@@ -76,7 +74,7 @@ var Link = _ref => {
76
74
  // scroll back to top
77
75
  window.scrollTo(0, 0);
78
76
  };
79
- (0, _react.useEffect)(() => {
77
+ (0, _react.useEffect)(function () {
80
78
  if (sanitizedUrl && sanitizedUrl !== href) {
81
79
  setProps({
82
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,125 +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 {
24
- hash,
25
- href,
26
- pathname,
27
- refresh,
28
- search,
29
- setProps
30
- } = props;
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;
31
49
 
32
- // Keep track of props relating to window.location that may need to be updated via setProps
33
- var propsToSet = {};
50
+ // Keep track of props relating to window.location that may need to be updated via setProps
51
+ var propsToSet = {};
34
52
 
35
- /**
36
- * Check if the field exists in props. If the prop with "fieldName" is not defined,
37
- * then it was not set by the user and needs to be equal to the value in window.location.
38
- * This only happens on page load (since props will no longer be undefined after componentDidMount).
39
- *
40
- * @param {string} fieldName
41
- * The name of the prop in window.location and in the component's prop
42
- *
43
- * @returns {boolean}
44
- * Returns true if the prop with fieldName is different and the window state needs to be updated
45
- */
46
- var checkExistsUpdateWindowLocation = fieldName => {
47
- var propVal = props[fieldName];
48
- if (((0, _ramda.type)(propVal) === 'Undefined' || propVal === null) && (0, _ramda.type)(window.location[fieldName]) !== 'Undefined') {
49
- // propVal is undefined or null, but window.location has this fieldName defined
50
- propsToSet[fieldName] = window.location[fieldName];
51
- } else if (propVal !== window.location[fieldName]) {
52
- // Prop has changed?
53
- if (refresh === true) {
54
- // Refresh the page?
55
- window.location[fieldName] = propVal;
56
- } else if (this.props[fieldName] !== propVal) {
57
- // If this prop has changed, need to setProps
58
- propsToSet[fieldName] = propVal;
59
- // This (`${fieldName}`: propVal) needs to be pushed in the window.history
60
- 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
+ }
61
80
  }
62
- }
63
- // This (`${fieldName}`: propVal) DOES NOT need to be pushed in the window.history
64
- return false;
65
- };
81
+ // This (`${fieldName}`: propVal) DOES NOT need to be pushed in the window.history
82
+ return false;
83
+ };
66
84
 
67
- // Check if the prop value needs to be updated (note that this mutates propsToSet)
68
- var pathnameUpdated = checkExistsUpdateWindowLocation('pathname');
69
- var hrefUpdated = checkExistsUpdateWindowLocation('href');
70
- var hashUpdated = checkExistsUpdateWindowLocation('hash');
71
- 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');
72
90
 
73
- // propsToSet has been updated -- batch update to Dash
74
- if (Object.keys(propsToSet).length > 0) {
75
- setProps(propsToSet);
76
- }
91
+ // propsToSet has been updated -- batch update to Dash
92
+ if (Object.keys(propsToSet).length > 0) {
93
+ setProps(propsToSet);
94
+ }
77
95
 
78
- // Special case -- overrides everything!
79
- if (hrefUpdated) {
80
- window.history.pushState({}, '', href);
81
- if (refresh === 'callback-nav') {
82
- 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;
83
122
  }
84
- } else if (pathnameUpdated || hashUpdated || searchUpdated) {
85
- // Otherwise, we can mash everything together
86
- var searchVal = (0, _ramda.type)(search) !== 'Undefined' ? search : '';
87
- var hashVal = (0, _ramda.type)(hash) !== 'Undefined' ? hash : '';
88
- window.history.pushState({}, '', "".concat(pathname).concat(searchVal).concat(hashVal));
89
- if (refresh === 'callback-nav') {
90
- window.dispatchEvent(new CustomEvent('_dashprivate_pushstate'));
123
+ if (this.props.hash !== window.location.hash) {
124
+ propsToChange.hash = window.location.hash;
91
125
  }
126
+ if (this.props.search !== window.location.search) {
127
+ propsToChange.search = window.location.search;
128
+ }
129
+ setProps(propsToChange);
130
+ _dashComponentPlugins.History.dispatchChangeEvent();
92
131
  }
93
- }
94
- onLocationChange() {
95
- var {
96
- setProps
97
- } = this.props;
98
- var propsToChange = {};
99
- if (this.props.pathname !== window.location.pathname) {
100
- 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);
101
138
  }
102
- if (this.props.href !== window.location.href) {
103
- 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);
104
144
  }
105
- if (this.props.hash !== window.location.hash) {
106
- propsToChange.hash = window.location.hash;
145
+ }, {
146
+ key: "UNSAFE_componentWillReceiveProps",
147
+ value: function UNSAFE_componentWillReceiveProps(nextProps) {
148
+ this.updateLocation(nextProps);
107
149
  }
108
- if (this.props.search !== window.location.search) {
109
- propsToChange.search = window.location.search;
150
+ }, {
151
+ key: "render",
152
+ value: function render() {
153
+ return null;
110
154
  }
111
- setProps(propsToChange);
112
- _dashComponentPlugins.History.dispatchChangeEvent();
113
- }
114
- componentDidMount() {
115
- window.addEventListener('popstate', this.onLocationChange);
116
- window.addEventListener('_dashprivate_pushstate', this.onLocationChange);
117
- this.updateLocation(this.props);
118
- }
119
- componentWillUnmount() {
120
- window.removeEventListener('popstate', this.onLocationChange);
121
- window.removeEventListener('_dashprivate_pushstate', this.onLocationChange);
122
- }
123
- UNSAFE_componentWillReceiveProps(nextProps) {
124
- this.updateLocation(nextProps);
125
- }
126
- render() {
127
- return null;
128
- }
129
- }
130
- exports.default = Location;
155
+ }]);
156
+ }(_react.Component);
131
157
  Location.propTypes = {
132
158
  /**
133
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,28 +10,52 @@ 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 }; }
15
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
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
+ 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; } }
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; }
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; } }
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); }
14
33
  // eslint-disable-next-line valid-jsdoc
15
34
  /**
16
35
  * A component that renders Markdown text as specified by the
17
36
  * GitHub Markdown spec. These component uses
18
37
  * [react-markdown](https://rexxars.github.io/react-markdown/) under the hood.
19
38
  */
20
- class DashMarkdown extends _react.Component {
21
- constructor(props) {
22
- 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]);
23
44
  if (props.mathjax) {
24
45
  DashMarkdown._loadMathjax = true;
25
46
  }
47
+ return _this;
26
48
  }
27
- render() {
28
- return /*#__PURE__*/_react.default.createElement(_react.Suspense, {
29
- fallback: null
30
- }, /*#__PURE__*/_react.default.createElement(RealDashMarkdown, this.props));
31
- }
32
- }
33
- 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);
34
59
  DashMarkdown.propTypes = {
35
60
  /**
36
61
  * The ID of this component, used to identify dash components
@@ -88,9 +113,12 @@ DashMarkdown.defaultProps = {
88
113
  highlight_config: {},
89
114
  dedent: true
90
115
  };
91
- var RealDashMarkdown = (0, _dashComponentPlugins.asyncDecorator)(DashMarkdown, () => Promise.all([(0, _markdown.default)(), DashMarkdown._loadMathjax ? (0, _mathjax.default)() : undefined]).then(_ref => {
92
- var [md] = _ref;
93
- return md;
94
- }));
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
+ });
95
123
  var propTypes = exports.propTypes = DashMarkdown.propTypes;
96
124
  var defaultProps = exports.defaultProps = DashMarkdown.defaultProps;