dash-core-components 3.0.3 → 3.0.4

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 (76) 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.js +1 -1
  16. package/dash_core_components/dash_core_components.js.map +1 -1
  17. package/lib/components/Checklist.react.js +46 -63
  18. package/lib/components/Clipboard.react.js +172 -218
  19. package/lib/components/ConfirmDialog.react.js +34 -61
  20. package/lib/components/ConfirmDialogProvider.react.js +21 -44
  21. package/lib/components/DatePickerRange.react.js +7 -26
  22. package/lib/components/DatePickerSingle.react.js +7 -26
  23. package/lib/components/Download.react.js +22 -45
  24. package/lib/components/Dropdown.react.js +7 -26
  25. package/lib/components/Geolocation.react.js +64 -91
  26. package/lib/components/Graph.react.js +70 -97
  27. package/lib/components/Input.react.js +119 -162
  28. package/lib/components/Interval.react.js +55 -86
  29. package/lib/components/Link.react.js +4 -4
  30. package/lib/components/Loading.react.js +31 -35
  31. package/lib/components/Location.react.js +97 -126
  32. package/lib/components/Markdown.react.js +15 -35
  33. package/lib/components/RadioItems.react.js +45 -63
  34. package/lib/components/RangeSlider.react.js +7 -26
  35. package/lib/components/Slider.react.js +7 -26
  36. package/lib/components/Store.react.js +128 -176
  37. package/lib/components/Tab.react.js +1 -1
  38. package/lib/components/Tabs.react.js +97 -126
  39. package/lib/components/Textarea.react.js +4 -4
  40. package/lib/components/Tooltip.react.js +1 -1
  41. package/lib/components/Upload.react.js +7 -26
  42. package/lib/fragments/DatePickerRange.react.js +150 -181
  43. package/lib/fragments/DatePickerSingle.react.js +103 -134
  44. package/lib/fragments/Dropdown.react.js +11 -19
  45. package/lib/fragments/Graph.privateprops.js +3 -9
  46. package/lib/fragments/Graph.react.js +302 -370
  47. package/lib/fragments/Loading/spinners/CircleSpinner.js +2 -4
  48. package/lib/fragments/Loading/spinners/CubeSpinner.js +2 -4
  49. package/lib/fragments/Loading/spinners/DefaultSpinner.js +2 -4
  50. package/lib/fragments/Loading/spinners/DotSpinner.js +2 -4
  51. package/lib/fragments/Loading/spinners/GraphSpinner.js +2 -4
  52. package/lib/fragments/Markdown.react.js +119 -158
  53. package/lib/fragments/Math.react.js +23 -47
  54. package/lib/fragments/RangeSlider.react.js +110 -133
  55. package/lib/fragments/Slider.react.js +110 -133
  56. package/lib/fragments/Upload.react.js +82 -99
  57. package/lib/utils/DatePickerPersistence.js +2 -4
  58. package/lib/utils/LazyLoader/datePickerRange.js +2 -3
  59. package/lib/utils/LazyLoader/datePickerSingle.js +2 -3
  60. package/lib/utils/LazyLoader/dropdown.js +2 -3
  61. package/lib/utils/LazyLoader/graph.js +2 -3
  62. package/lib/utils/LazyLoader/hljs.js +2 -5
  63. package/lib/utils/LazyLoader/markdown.js +2 -3
  64. package/lib/utils/LazyLoader/mathjax.js +2 -5
  65. package/lib/utils/LazyLoader/plotly.js +7 -6
  66. package/lib/utils/LazyLoader/rangeSlider.js +2 -3
  67. package/lib/utils/LazyLoader/slider.js +2 -3
  68. package/lib/utils/LazyLoader/upload.js +2 -3
  69. package/lib/utils/MarkdownHighlighter.js +5 -6
  70. package/lib/utils/ResizeDetector.js +8 -12
  71. package/lib/utils/computeSliderMarkers.js +29 -49
  72. package/lib/utils/computeSliderStyle.js +4 -3
  73. package/lib/utils/convertToMoment.js +5 -6
  74. package/lib/utils/formatSliderTooltip.js +6 -8
  75. package/lib/utils/optionTypes.js +8 -9
  76. package/package.json +1 -1
@@ -9,105 +9,74 @@ var _react = _interopRequireWildcard(require("react"));
9
9
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
10
10
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
11
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); }
24
12
  // eslint-disable-line no-unused-vars
13
+
25
14
  /**
26
15
  * A component that repeatedly increments a counter `n_intervals`
27
16
  * with a fixed time delay between each increment.
28
17
  * Interval is good for triggering a component on a recurring basis.
29
18
  * The time delay is set with the property "interval" in milliseconds.
30
19
  */
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;
20
+ class Interval extends _react.Component {
21
+ constructor(props) {
22
+ super(props);
23
+ this.intervalId = null;
24
+ this.reportInterval = this.reportInterval.bind(this);
25
+ this.handleTimer = this.handleTimer.bind(this);
40
26
  }
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
27
+ handleTimer(props) {
28
+ // Check if timer should stop or shouldn't even start
29
+ if (props.max_intervals === 0 || props.disabled || props.n_intervals >= props.max_intervals && props.max_intervals !== -1) {
30
+ // stop existing timer
56
31
  if (this.intervalId) {
57
- return;
58
- }
59
-
60
- // it hasn't started yet (& it should start)
61
- this.intervalId = window.setInterval(this.reportInterval, props.interval);
62
- }
63
- }, {
64
- key: "resetTimer",
65
- value: function resetTimer(props) {
66
- this.clearTimer();
67
- this.handleTimer(props);
68
- }
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);
32
+ this.clearTimer();
97
33
  }
34
+ // and don't start a timer
35
+ return;
98
36
  }
99
- }, {
100
- key: "componentWillUnmount",
101
- value: function componentWillUnmount() {
102
- this.clearTimer();
37
+
38
+ // keep the existing timer running
39
+ if (this.intervalId) {
40
+ return;
103
41
  }
104
- }, {
105
- key: "render",
106
- value: function render() {
107
- return null;
42
+
43
+ // it hasn't started yet (& it should start)
44
+ this.intervalId = window.setInterval(this.reportInterval, props.interval);
45
+ }
46
+ resetTimer(props) {
47
+ this.clearTimer();
48
+ this.handleTimer(props);
49
+ }
50
+ clearTimer() {
51
+ window.clearInterval(this.intervalId);
52
+ this.intervalId = null;
53
+ }
54
+ reportInterval() {
55
+ var _this$props = this.props,
56
+ setProps = _this$props.setProps,
57
+ n_intervals = _this$props.n_intervals;
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);
108
70
  }
109
- }]);
110
- }(_react.Component);
71
+ }
72
+ componentWillUnmount() {
73
+ this.clearTimer();
74
+ }
75
+ render() {
76
+ return null;
77
+ }
78
+ }
79
+ exports.default = Interval;
111
80
  Interval.propTypes = {
112
81
  /**
113
82
  * The ID of this component, used to identify dash components
@@ -37,7 +37,7 @@ CustomEvent.prototype = window.Event.prototype;
37
37
  * For links with destinations outside the current app, `html.A` is a better
38
38
  * component to use.
39
39
  */
40
- var Link = function Link(_ref) {
40
+ var Link = _ref => {
41
41
  var _ref$refresh = _ref.refresh,
42
42
  refresh = _ref$refresh === void 0 ? false : _ref$refresh,
43
43
  props = _objectWithoutProperties(_ref, _excluded);
@@ -50,12 +50,12 @@ var Link = function Link(_ref) {
50
50
  target = props.target,
51
51
  setProps = props.setProps;
52
52
  var cleanUrl = window.dash_clientside.clean_url;
53
- var sanitizedUrl = (0, _react.useMemo)(function () {
53
+ var sanitizedUrl = (0, _react.useMemo)(() => {
54
54
  return href ? cleanUrl(href) : undefined;
55
55
  }, [href]);
56
56
  var ctx = window.dash_component_api.useDashContext();
57
57
  var loading = ctx.useLoading();
58
- var updateLocation = function updateLocation(e) {
58
+ var updateLocation = e => {
59
59
  var hasModifiers = e.metaKey || e.shiftKey || e.altKey || e.ctrlKey;
60
60
  if (hasModifiers) {
61
61
  return;
@@ -74,7 +74,7 @@ var Link = function Link(_ref) {
74
74
  // scroll back to top
75
75
  window.scrollTo(0, 0);
76
76
  };
77
- (0, _react.useEffect)(function () {
77
+ (0, _react.useEffect)(() => {
78
78
  if (sanitizedUrl && sanitizedUrl !== href) {
79
79
  setProps({
80
80
  _dash_error: new Error("Dangerous link detected:: ".concat(href))
@@ -32,9 +32,7 @@ var spinnerComponentOptions = {
32
32
  circle: _CircleSpinner.default,
33
33
  dot: _DotSpinner.default
34
34
  };
35
- var getSpinner = function getSpinner(spinnerType) {
36
- return spinnerComponentOptions[spinnerType] || _DefaultSpinner.default;
37
- };
35
+ var getSpinner = spinnerType => spinnerComponentOptions[spinnerType] || _DefaultSpinner.default;
38
36
  var coveringSpinner = {
39
37
  visibility: 'visible',
40
38
  position: 'absolute',
@@ -45,37 +43,35 @@ var coveringSpinner = {
45
43
  justifyContent: 'center',
46
44
  alignItems: 'center'
47
45
  };
48
- var loadingSelector = function loadingSelector(componentPath, targetComponents) {
49
- return function (state) {
50
- var stringPath = JSON.stringify(componentPath);
51
- // Remove the last ] for easy match
52
- stringPath = stringPath.substring(0, stringPath.length - 1);
53
- var loadingChildren = (0, _ramda.toPairs)(state.loading).reduce(function (acc, _ref) {
54
- var _ref2 = _slicedToArray(_ref, 2),
55
- path = _ref2[0],
56
- load = _ref2[1];
57
- if (path.startsWith(stringPath) && load.length) {
58
- if (targetComponents && !(0, _ramda.any)(function (l) {
59
- var target = targetComponents[l.id];
60
- if (!target) {
61
- return false;
62
- }
63
- if (Array.isArray(target)) {
64
- return (0, _ramda.includes)(l.property, target);
65
- }
66
- return l.property === target;
67
- }, load)) {
68
- return acc;
46
+ var loadingSelector = (componentPath, targetComponents) => state => {
47
+ var stringPath = JSON.stringify(componentPath);
48
+ // Remove the last ] for easy match
49
+ stringPath = stringPath.substring(0, stringPath.length - 1);
50
+ var loadingChildren = (0, _ramda.toPairs)(state.loading).reduce((acc, _ref) => {
51
+ var _ref2 = _slicedToArray(_ref, 2),
52
+ path = _ref2[0],
53
+ load = _ref2[1];
54
+ if (path.startsWith(stringPath) && load.length) {
55
+ if (targetComponents && !(0, _ramda.any)(l => {
56
+ var target = targetComponents[l.id];
57
+ if (!target) {
58
+ return false;
59
+ }
60
+ if (Array.isArray(target)) {
61
+ return (0, _ramda.includes)(l.property, target);
69
62
  }
70
- return (0, _ramda.concat)(acc, load);
63
+ return l.property === target;
64
+ }, load)) {
65
+ return acc;
71
66
  }
72
- return acc;
73
- }, []);
74
- if (loadingChildren.length) {
75
- return loadingChildren;
67
+ return (0, _ramda.concat)(acc, load);
76
68
  }
77
- return null;
78
- };
69
+ return acc;
70
+ }, []);
71
+ if (loadingChildren.length) {
72
+ return loadingChildren;
73
+ }
74
+ return null;
79
75
  };
80
76
  function Loading(_ref3) {
81
77
  var children = _ref3.children,
@@ -108,7 +104,7 @@ function Loading(_ref3) {
108
104
  setShowSpinner = _useState2[1];
109
105
  var dismissTimer = (0, _react.useRef)();
110
106
  var showTimer = (0, _react.useRef)();
111
- var containerStyle = (0, _react.useMemo)(function () {
107
+ var containerStyle = (0, _react.useMemo)(() => {
112
108
  if (showSpinner) {
113
109
  return _objectSpread(_objectSpread({
114
110
  visibility: 'hidden'
@@ -116,7 +112,7 @@ function Loading(_ref3) {
116
112
  }
117
113
  return parent_style;
118
114
  }, [showSpinner, parent_style]);
119
- (0, _react.useEffect)(function () {
115
+ (0, _react.useEffect)(() => {
120
116
  if (display === 'show' || display === 'hide') {
121
117
  setShowSpinner(display === 'show');
122
118
  return;
@@ -130,7 +126,7 @@ function Loading(_ref3) {
130
126
  // if component is currently loading but the spinner is not showing and
131
127
  // there is no timer set to show, then set a timeout to show
132
128
  if (!showSpinner && !showTimer.current) {
133
- showTimer.current = setTimeout(function () {
129
+ showTimer.current = setTimeout(() => {
134
130
  setShowSpinner(true);
135
131
  showTimer.current = null;
136
132
  }, delay_show);
@@ -144,7 +140,7 @@ function Loading(_ref3) {
144
140
  // if component is not currently loading and the spinner is showing and
145
141
  // there's no timer set to dismiss it, then set a timeout to hide it
146
142
  if (showSpinner && !dismissTimer.current) {
147
- dismissTimer.current = setTimeout(function () {
143
+ dismissTimer.current = setTimeout(() => {
148
144
  setShowSpinner(false);
149
145
  dismissTimer.current = null;
150
146
  }, delay_hide);
@@ -9,150 +9,121 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
9
9
  var _ramda = require("ramda");
10
10
  var _dashComponentPlugins = require("@plotly/dash-component-plugins");
11
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); }
24
12
  /**
25
13
  * Update and track the current window.location object through the window.history state.
26
14
  * Use in conjunction with the `dash_core_components.Link` component to make apps with multiple pages.
27
15
  */
28
- var Location = exports.default = /*#__PURE__*/function (_Component) {
29
- function Location(props) {
30
- var _this;
31
- _classCallCheck(this, Location);
32
- _this = _callSuper(this, Location, [props]);
33
- _this.updateLocation = _this.updateLocation.bind(_this);
34
- _this.onLocationChange = _this.onLocationChange.bind(_this);
35
- return _this;
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);
36
21
  }
37
- _inherits(Location, _Component);
38
- return _createClass(Location, [{
39
- key: "updateLocation",
40
- value: function updateLocation(props) {
41
- var _this2 = this;
42
- var hash = props.hash,
43
- href = props.href,
44
- pathname = props.pathname,
45
- refresh = props.refresh,
46
- search = props.search,
47
- setProps = props.setProps;
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;
48
29
 
49
- // Keep track of props relating to window.location that may need to be updated via setProps
50
- var propsToSet = {};
30
+ // Keep track of props relating to window.location that may need to be updated via setProps
31
+ var propsToSet = {};
51
32
 
52
- /**
53
- * Check if the field exists in props. If the prop with "fieldName" is not defined,
54
- * then it was not set by the user and needs to be equal to the value in window.location.
55
- * This only happens on page load (since props will no longer be undefined after componentDidMount).
56
- *
57
- * @param {string} fieldName
58
- * The name of the prop in window.location and in the component's prop
59
- *
60
- * @returns {boolean}
61
- * Returns true if the prop with fieldName is different and the window state needs to be updated
62
- */
63
- var checkExistsUpdateWindowLocation = function checkExistsUpdateWindowLocation(fieldName) {
64
- var propVal = props[fieldName];
65
- if (((0, _ramda.type)(propVal) === 'Undefined' || propVal === null) && (0, _ramda.type)(window.location[fieldName]) !== 'Undefined') {
66
- // propVal is undefined or null, but window.location has this fieldName defined
67
- propsToSet[fieldName] = window.location[fieldName];
68
- } else if (propVal !== window.location[fieldName]) {
69
- // Prop has changed?
70
- if (refresh === true) {
71
- // Refresh the page?
72
- window.location[fieldName] = propVal;
73
- } else if (_this2.props[fieldName] !== propVal) {
74
- // If this prop has changed, need to setProps
75
- propsToSet[fieldName] = propVal;
76
- // This (`${fieldName}`: propVal) needs to be pushed in the window.history
77
- return true;
78
- }
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;
79
59
  }
80
- // This (`${fieldName}`: propVal) DOES NOT need to be pushed in the window.history
81
- return false;
82
- };
83
-
84
- // Check if the prop value needs to be updated (note that this mutates propsToSet)
85
- var pathnameUpdated = checkExistsUpdateWindowLocation('pathname');
86
- var hrefUpdated = checkExistsUpdateWindowLocation('href');
87
- var hashUpdated = checkExistsUpdateWindowLocation('hash');
88
- var searchUpdated = checkExistsUpdateWindowLocation('search');
89
-
90
- // propsToSet has been updated -- batch update to Dash
91
- if (Object.keys(propsToSet).length > 0) {
92
- setProps(propsToSet);
93
60
  }
61
+ // This (`${fieldName}`: propVal) DOES NOT need to be pushed in the window.history
62
+ return false;
63
+ };
94
64
 
95
- // Special case -- overrides everything!
96
- if (hrefUpdated) {
97
- window.history.pushState({}, '', href);
98
- if (refresh === 'callback-nav') {
99
- window.dispatchEvent(new CustomEvent('_dashprivate_pushstate'));
100
- }
101
- } else if (pathnameUpdated || hashUpdated || searchUpdated) {
102
- // Otherwise, we can mash everything together
103
- var searchVal = (0, _ramda.type)(search) !== 'Undefined' ? search : '';
104
- var hashVal = (0, _ramda.type)(hash) !== 'Undefined' ? hash : '';
105
- window.history.pushState({}, '', "".concat(pathname).concat(searchVal).concat(hashVal));
106
- if (refresh === 'callback-nav') {
107
- window.dispatchEvent(new CustomEvent('_dashprivate_pushstate'));
108
- }
109
- }
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');
70
+
71
+ // propsToSet has been updated -- batch update to Dash
72
+ if (Object.keys(propsToSet).length > 0) {
73
+ setProps(propsToSet);
110
74
  }
111
- }, {
112
- key: "onLocationChange",
113
- value: function onLocationChange() {
114
- var setProps = this.props.setProps;
115
- var propsToChange = {};
116
- if (this.props.pathname !== window.location.pathname) {
117
- propsToChange.pathname = window.location.pathname;
118
- }
119
- if (this.props.href !== window.location.href) {
120
- propsToChange.href = window.location.href;
121
- }
122
- if (this.props.hash !== window.location.hash) {
123
- propsToChange.hash = window.location.hash;
75
+
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'));
124
81
  }
125
- if (this.props.search !== window.location.search) {
126
- propsToChange.search = window.location.search;
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'));
127
89
  }
128
- setProps(propsToChange);
129
- _dashComponentPlugins.History.dispatchChangeEvent();
130
90
  }
131
- }, {
132
- key: "componentDidMount",
133
- value: function componentDidMount() {
134
- window.addEventListener('popstate', this.onLocationChange);
135
- window.addEventListener('_dashprivate_pushstate', this.onLocationChange);
136
- this.updateLocation(this.props);
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;
137
97
  }
138
- }, {
139
- key: "componentWillUnmount",
140
- value: function componentWillUnmount() {
141
- window.removeEventListener('popstate', this.onLocationChange);
142
- window.removeEventListener('_dashprivate_pushstate', this.onLocationChange);
98
+ if (this.props.href !== window.location.href) {
99
+ propsToChange.href = window.location.href;
143
100
  }
144
- }, {
145
- key: "UNSAFE_componentWillReceiveProps",
146
- value: function UNSAFE_componentWillReceiveProps(nextProps) {
147
- this.updateLocation(nextProps);
101
+ if (this.props.hash !== window.location.hash) {
102
+ propsToChange.hash = window.location.hash;
148
103
  }
149
- }, {
150
- key: "render",
151
- value: function render() {
152
- return null;
104
+ if (this.props.search !== window.location.search) {
105
+ propsToChange.search = window.location.search;
153
106
  }
154
- }]);
155
- }(_react.Component);
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;
156
127
  Location.propTypes = {
157
128
  /**
158
129
  * The ID of this component, used to identify dash components
@@ -18,44 +18,26 @@ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r)
18
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
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
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); }
33
21
  // eslint-disable-next-line valid-jsdoc
34
22
  /**
35
23
  * A component that renders Markdown text as specified by the
36
24
  * GitHub Markdown spec. These component uses
37
25
  * [react-markdown](https://rexxars.github.io/react-markdown/) under the hood.
38
26
  */
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]);
27
+ class DashMarkdown extends _react.Component {
28
+ constructor(props) {
29
+ super(props);
44
30
  if (props.mathjax) {
45
31
  DashMarkdown._loadMathjax = true;
46
32
  }
47
- return _this;
48
33
  }
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
+ render() {
35
+ return /*#__PURE__*/_react.default.createElement(_react.Suspense, {
36
+ fallback: null
37
+ }, /*#__PURE__*/_react.default.createElement(RealDashMarkdown, this.props));
38
+ }
39
+ }
40
+ exports.default = DashMarkdown;
59
41
  DashMarkdown.propTypes = {
60
42
  /**
61
43
  * The ID of this component, used to identify dash components
@@ -113,12 +95,10 @@ DashMarkdown.defaultProps = {
113
95
  highlight_config: {},
114
96
  dedent: true
115
97
  };
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
- });
98
+ var RealDashMarkdown = (0, _dashComponentPlugins.asyncDecorator)(DashMarkdown, () => Promise.all([(0, _markdown.default)(), DashMarkdown._loadMathjax ? (0, _mathjax.default)() : undefined]).then(_ref => {
99
+ var _ref2 = _slicedToArray(_ref, 1),
100
+ md = _ref2[0];
101
+ return md;
102
+ }));
123
103
  var propTypes = exports.propTypes = DashMarkdown.propTypes;
124
104
  var defaultProps = exports.defaultProps = DashMarkdown.defaultProps;