dash-core-components 3.0.2 → 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 (80) 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-mathjax.js +1 -1
  12. package/dash_core_components/async-slider.js +1 -1
  13. package/dash_core_components/async-slider.js.map +1 -1
  14. package/dash_core_components/async-upload.js +1 -1
  15. package/dash_core_components/async-upload.js.map +1 -1
  16. package/dash_core_components/dash_core_components-shared.js +1 -1
  17. package/dash_core_components/dash_core_components-shared.js.map +1 -1
  18. package/dash_core_components/dash_core_components.js +1 -1
  19. package/dash_core_components/dash_core_components.js.map +1 -1
  20. package/lib/components/Checklist.react.js +46 -63
  21. package/lib/components/Clipboard.react.js +172 -218
  22. package/lib/components/ConfirmDialog.react.js +34 -61
  23. package/lib/components/ConfirmDialogProvider.react.js +21 -44
  24. package/lib/components/DatePickerRange.react.js +7 -26
  25. package/lib/components/DatePickerSingle.react.js +7 -26
  26. package/lib/components/Download.react.js +22 -45
  27. package/lib/components/Dropdown.react.js +7 -26
  28. package/lib/components/Geolocation.react.js +64 -91
  29. package/lib/components/Graph.react.js +70 -97
  30. package/lib/components/Input.react.js +119 -162
  31. package/lib/components/Interval.react.js +55 -86
  32. package/lib/components/Link.react.js +6 -6
  33. package/lib/components/Loading.react.js +31 -35
  34. package/lib/components/Location.react.js +97 -126
  35. package/lib/components/Markdown.react.js +15 -35
  36. package/lib/components/RadioItems.react.js +45 -63
  37. package/lib/components/RangeSlider.react.js +7 -26
  38. package/lib/components/Slider.react.js +7 -26
  39. package/lib/components/Store.react.js +128 -176
  40. package/lib/components/Tab.react.js +1 -1
  41. package/lib/components/Tabs.react.js +97 -126
  42. package/lib/components/Textarea.react.js +6 -6
  43. package/lib/components/Tooltip.react.js +3 -3
  44. package/lib/components/Upload.react.js +7 -26
  45. package/lib/fragments/DatePickerRange.react.js +150 -181
  46. package/lib/fragments/DatePickerSingle.react.js +103 -134
  47. package/lib/fragments/Dropdown.react.js +11 -19
  48. package/lib/fragments/Graph.privateprops.js +3 -9
  49. package/lib/fragments/Graph.react.js +302 -370
  50. package/lib/fragments/Loading/spinners/CircleSpinner.js +2 -4
  51. package/lib/fragments/Loading/spinners/CubeSpinner.js +2 -4
  52. package/lib/fragments/Loading/spinners/DefaultSpinner.js +2 -4
  53. package/lib/fragments/Loading/spinners/DotSpinner.js +2 -4
  54. package/lib/fragments/Loading/spinners/GraphSpinner.js +2 -4
  55. package/lib/fragments/Markdown.react.js +119 -158
  56. package/lib/fragments/Math.react.js +23 -47
  57. package/lib/fragments/RangeSlider.react.js +110 -133
  58. package/lib/fragments/Slider.react.js +110 -133
  59. package/lib/fragments/Upload.react.js +82 -99
  60. package/lib/utils/DatePickerPersistence.js +2 -4
  61. package/lib/utils/LazyLoader/datePickerRange.js +2 -3
  62. package/lib/utils/LazyLoader/datePickerSingle.js +2 -3
  63. package/lib/utils/LazyLoader/dropdown.js +2 -3
  64. package/lib/utils/LazyLoader/graph.js +2 -3
  65. package/lib/utils/LazyLoader/hljs.js +2 -5
  66. package/lib/utils/LazyLoader/markdown.js +2 -3
  67. package/lib/utils/LazyLoader/mathjax.js +2 -5
  68. package/lib/utils/LazyLoader/plotly.js +7 -6
  69. package/lib/utils/LazyLoader/rangeSlider.js +2 -3
  70. package/lib/utils/LazyLoader/slider.js +2 -3
  71. package/lib/utils/LazyLoader/upload.js +2 -3
  72. package/lib/utils/LoadingElement.js +2 -2
  73. package/lib/utils/MarkdownHighlighter.js +5 -6
  74. package/lib/utils/ResizeDetector.js +8 -12
  75. package/lib/utils/computeSliderMarkers.js +29 -49
  76. package/lib/utils/computeSliderStyle.js +4 -3
  77. package/lib/utils/convertToMoment.js +5 -6
  78. package/lib/utils/formatSliderTooltip.js +6 -8
  79. package/lib/utils/optionTypes.js +8 -9
  80. package/package.json +7 -7
@@ -15,78 +15,61 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
15
15
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
16
16
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
17
17
  function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
18
- function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
19
- 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); } }
20
- function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
21
18
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
22
19
  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); }
23
- function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
24
- 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); }
25
- function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
26
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
27
- function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
28
- 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); }
29
- function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
30
20
  /**
31
21
  * Checklist is a component that encapsulates several checkboxes.
32
22
  * The values and labels of the checklist are specified in the `options`
33
23
  * property and the checked items are specified with the `value` property.
34
24
  * Each checkbox is rendered as an input with a surrounding label.
35
25
  */
36
- var Checklist = exports.default = /*#__PURE__*/function (_Component) {
37
- function Checklist() {
38
- _classCallCheck(this, Checklist);
39
- return _callSuper(this, Checklist, arguments);
40
- }
41
- _inherits(Checklist, _Component);
42
- return _createClass(Checklist, [{
43
- key: "render",
44
- value: function render() {
45
- var _this$props = this.props,
46
- className = _this$props.className,
47
- id = _this$props.id,
48
- inputClassName = _this$props.inputClassName,
49
- inputStyle = _this$props.inputStyle,
50
- labelClassName = _this$props.labelClassName,
51
- labelStyle = _this$props.labelStyle,
52
- options = _this$props.options,
53
- setProps = _this$props.setProps,
54
- style = _this$props.style,
55
- value = _this$props.value,
56
- inline = _this$props.inline;
57
- return /*#__PURE__*/_react.default.createElement(_LoadingElement.default, {
58
- id: id,
59
- style: style,
60
- className: className
61
- }, (0, _optionTypes.sanitizeOptions)(options).map(function (option) {
62
- return /*#__PURE__*/_react.default.createElement("label", {
63
- key: option.value,
64
- style: _objectSpread({
65
- display: inline ? 'inline-block' : 'block'
66
- }, labelStyle),
67
- className: labelClassName
68
- }, /*#__PURE__*/_react.default.createElement("input", {
69
- checked: (0, _ramda.includes)(option.value, value),
70
- className: inputClassName,
71
- disabled: Boolean(option.disabled),
72
- style: inputStyle,
73
- type: "checkbox",
74
- onChange: function onChange() {
75
- var newValue;
76
- if ((0, _ramda.includes)(option.value, value)) {
77
- newValue = (0, _ramda.without)([option.value], value);
78
- } else {
79
- newValue = (0, _ramda.append)(option.value, value);
80
- }
81
- setProps({
82
- value: newValue
83
- });
26
+ class Checklist extends _react.Component {
27
+ render() {
28
+ var _this$props = this.props,
29
+ className = _this$props.className,
30
+ id = _this$props.id,
31
+ inputClassName = _this$props.inputClassName,
32
+ inputStyle = _this$props.inputStyle,
33
+ labelClassName = _this$props.labelClassName,
34
+ labelStyle = _this$props.labelStyle,
35
+ options = _this$props.options,
36
+ setProps = _this$props.setProps,
37
+ style = _this$props.style,
38
+ value = _this$props.value,
39
+ inline = _this$props.inline;
40
+ return /*#__PURE__*/_react.default.createElement(_LoadingElement.default, {
41
+ id: id,
42
+ style: style,
43
+ className: className
44
+ }, (0, _optionTypes.sanitizeOptions)(options).map(option => {
45
+ return /*#__PURE__*/_react.default.createElement("label", {
46
+ key: option.value,
47
+ style: _objectSpread({
48
+ display: inline ? 'inline-block' : 'block'
49
+ }, labelStyle),
50
+ className: labelClassName
51
+ }, /*#__PURE__*/_react.default.createElement("input", {
52
+ checked: (0, _ramda.includes)(option.value, value),
53
+ className: inputClassName,
54
+ disabled: Boolean(option.disabled),
55
+ style: inputStyle,
56
+ type: "checkbox",
57
+ onChange: () => {
58
+ var newValue;
59
+ if ((0, _ramda.includes)(option.value, value)) {
60
+ newValue = (0, _ramda.without)([option.value], value);
61
+ } else {
62
+ newValue = (0, _ramda.append)(option.value, value);
84
63
  }
85
- }), option.label);
86
- }));
87
- }
88
- }]);
89
- }(_react.Component);
64
+ setProps({
65
+ value: newValue
66
+ });
67
+ }
68
+ }), option.label);
69
+ }));
70
+ }
71
+ }
72
+ exports.default = Checklist;
90
73
  Checklist.propTypes = {
91
74
  /**
92
75
  * An array of options
@@ -15,245 +15,199 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
15
15
  function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(typeof e + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
16
16
  function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
17
17
  function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
18
- function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
19
- 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); } }
20
- function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
21
- function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
22
- 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); }
23
- function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
24
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
25
- function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
26
- 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); }
27
- function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
28
18
  function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
29
19
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
30
20
  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); } // eslint-disable-line no-unused-vars
31
21
  var clipboardAPI = navigator.clipboard;
32
22
  function wait(ms) {
33
- return new Promise(function (r) {
34
- return setTimeout(r, ms);
35
- });
23
+ return new Promise(r => setTimeout(r, ms));
36
24
  }
37
25
 
38
26
  /**
39
27
  * The Clipboard component copies text to the clipboard
40
28
  */
41
- var Clipboard = exports.default = /*#__PURE__*/function (_React$Component) {
42
- function Clipboard(props) {
43
- var _this;
44
- _classCallCheck(this, Clipboard);
45
- _this = _callSuper(this, Clipboard, [props]);
46
- _this.copyToClipboard = _this.copyToClipboard.bind(_this);
47
- _this.onClickHandler = _this.onClickHandler.bind(_this);
48
- _this.copySuccess = _this.copySuccess.bind(_this);
49
- _this.getTargetText = _this.getTargetText.bind(_this);
50
- _this.loading = _this.loading.bind(_this);
51
- _this.stringifyId = _this.stringifyId.bind(_this);
52
- _this.state = {
29
+
30
+ class Clipboard extends _react.default.Component {
31
+ constructor(props) {
32
+ super(props);
33
+ this.copyToClipboard = this.copyToClipboard.bind(this);
34
+ this.onClickHandler = this.onClickHandler.bind(this);
35
+ this.copySuccess = this.copySuccess.bind(this);
36
+ this.getTargetText = this.getTargetText.bind(this);
37
+ this.loading = this.loading.bind(this);
38
+ this.stringifyId = this.stringifyId.bind(this);
39
+ this.state = {
53
40
  copied: false
54
41
  };
55
- return _this;
56
42
  }
57
- _inherits(Clipboard, _React$Component);
58
- return _createClass(Clipboard, [{
59
- key: "onClickHandler",
60
- value: function onClickHandler() {
61
- this.props.setProps({
62
- n_clicks: this.props.n_clicks + 1
63
- });
64
- }
65
- }, {
66
- key: "componentDidUpdate",
67
- value: function componentDidUpdate(prevProps) {
68
- // If the clicks has not changed, do nothing
69
- if (!this.props.n_clicks || this.props.n_clicks === prevProps.n_clicks) {
70
- return;
71
- }
72
- // If the clicks has changed, copy to clipboard
73
- this.copyToClipboard();
43
+ onClickHandler() {
44
+ this.props.setProps({
45
+ n_clicks: this.props.n_clicks + 1
46
+ });
47
+ }
48
+ componentDidUpdate(prevProps) {
49
+ // If the clicks has not changed, do nothing
50
+ if (!this.props.n_clicks || this.props.n_clicks === prevProps.n_clicks) {
51
+ return;
74
52
  }
53
+ // If the clicks has changed, copy to clipboard
54
+ this.copyToClipboard();
55
+ }
75
56
 
76
- // stringifies object ids used in pattern matching callbacks
77
- }, {
78
- key: "stringifyId",
79
- value: function stringifyId(id) {
80
- if (typeof id !== 'object') {
81
- return id;
82
- }
83
- var stringifyVal = function stringifyVal(v) {
84
- return v && v.wild || JSON.stringify(v);
85
- };
86
- var parts = Object.keys(id).sort().map(function (k) {
87
- return JSON.stringify(k) + ':' + stringifyVal(id[k]);
88
- });
89
- return '{' + parts.join(',') + '}';
57
+ // stringifies object ids used in pattern matching callbacks
58
+ stringifyId(id) {
59
+ if (typeof id !== 'object') {
60
+ return id;
90
61
  }
91
- }, {
92
- key: "copySuccess",
93
- value: function () {
94
- var _copySuccess = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(content, htmlContent) {
95
- var showCopiedIcon, blobHtml, blobText, data;
96
- return _regeneratorRuntime().wrap(function _callee$(_context) {
97
- while (1) switch (_context.prev = _context.next) {
98
- case 0:
99
- showCopiedIcon = 1000;
100
- if (!htmlContent) {
101
- _context.next = 9;
102
- break;
103
- }
104
- blobHtml = new Blob([htmlContent], {
105
- type: 'text/html'
106
- });
107
- blobText = new Blob([content !== null && content !== void 0 ? content : htmlContent], {
108
- type: 'text/plain'
109
- });
110
- data = [new ClipboardItem({
111
- ['text/plain']: blobText,
112
- ['text/html']: blobHtml
113
- })];
114
- _context.next = 7;
115
- return navigator.clipboard.write(data);
116
- case 7:
117
- _context.next = 11;
62
+ var stringifyVal = v => v && v.wild || JSON.stringify(v);
63
+ var parts = Object.keys(id).sort().map(k => JSON.stringify(k) + ':' + stringifyVal(id[k]));
64
+ return '{' + parts.join(',') + '}';
65
+ }
66
+ copySuccess(content, htmlContent) {
67
+ var _this = this;
68
+ return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
69
+ var showCopiedIcon, blobHtml, blobText, data;
70
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
71
+ while (1) switch (_context.prev = _context.next) {
72
+ case 0:
73
+ showCopiedIcon = 1000;
74
+ if (!htmlContent) {
75
+ _context.next = 9;
118
76
  break;
119
- case 9:
120
- _context.next = 11;
121
- return clipboardAPI.writeText(content);
122
- case 11:
123
- this.setState({
124
- copied: true
125
- });
126
- _context.next = 14;
127
- return wait(showCopiedIcon);
128
- case 14:
129
- this.setState({
130
- copied: false
131
- });
132
- case 15:
133
- case "end":
134
- return _context.stop();
135
- }
136
- }, _callee, this);
137
- }));
138
- function copySuccess(_x, _x2) {
139
- return _copySuccess.apply(this, arguments);
140
- }
141
- return copySuccess;
142
- }()
143
- }, {
144
- key: "getTargetText",
145
- value: function getTargetText() {
146
- // get the inner text. If none, use the content of the value param
147
- var id = this.stringifyId(this.props.target_id);
148
- var target = document.getElementById(id);
149
- if (!target) {
150
- throw new Error('Clipboard copy failed: no element found for target_id ' + this.props.target_id);
151
- }
152
- var content = target.innerText;
153
- if (!content) {
154
- content = target.value;
155
- content = content === undefined ? null : content;
156
- }
157
- return content;
77
+ }
78
+ blobHtml = new Blob([htmlContent], {
79
+ type: 'text/html'
80
+ });
81
+ blobText = new Blob([content !== null && content !== void 0 ? content : htmlContent], {
82
+ type: 'text/plain'
83
+ });
84
+ data = [new ClipboardItem({
85
+ ['text/plain']: blobText,
86
+ ['text/html']: blobHtml
87
+ })];
88
+ _context.next = 7;
89
+ return navigator.clipboard.write(data);
90
+ case 7:
91
+ _context.next = 11;
92
+ break;
93
+ case 9:
94
+ _context.next = 11;
95
+ return clipboardAPI.writeText(content);
96
+ case 11:
97
+ _this.setState({
98
+ copied: true
99
+ });
100
+ _context.next = 14;
101
+ return wait(showCopiedIcon);
102
+ case 14:
103
+ _this.setState({
104
+ copied: false
105
+ });
106
+ case 15:
107
+ case "end":
108
+ return _context.stop();
109
+ }
110
+ }, _callee);
111
+ }))();
112
+ }
113
+ getTargetText() {
114
+ // get the inner text. If none, use the content of the value param
115
+ var id = this.stringifyId(this.props.target_id);
116
+ var target = document.getElementById(id);
117
+ if (!target) {
118
+ throw new Error('Clipboard copy failed: no element found for target_id ' + this.props.target_id);
119
+ }
120
+ var content = target.innerText;
121
+ if (!content) {
122
+ content = target.value;
123
+ content = content === undefined ? null : content;
158
124
  }
159
- }, {
160
- key: "loading",
161
- value: function () {
162
- var _loading = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
163
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
164
- while (1) switch (_context2.prev = _context2.next) {
165
- case 0:
166
- if (!this.context.isLoading()) {
167
- _context2.next = 5;
168
- break;
169
- }
170
- _context2.next = 3;
171
- return wait(100);
172
- case 3:
173
- _context2.next = 0;
125
+ return content;
126
+ }
127
+ loading() {
128
+ var _this2 = this;
129
+ return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
130
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
131
+ while (1) switch (_context2.prev = _context2.next) {
132
+ case 0:
133
+ if (!_this2.context.isLoading()) {
134
+ _context2.next = 5;
174
135
  break;
175
- case 5:
176
- case "end":
177
- return _context2.stop();
178
- }
179
- }, _callee2, this);
180
- }));
181
- function loading() {
182
- return _loading.apply(this, arguments);
183
- }
184
- return loading;
185
- }()
186
- }, {
187
- key: "copyToClipboard",
188
- value: function () {
189
- var _copyToClipboard = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
190
- var content, htmlContent;
191
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
192
- while (1) switch (_context3.prev = _context3.next) {
193
- case 0:
194
- if (!this.props.target_id) {
195
- _context3.next = 4;
196
- break;
197
- }
198
- content = this.getTargetText();
199
- _context3.next = 10;
136
+ }
137
+ _context2.next = 3;
138
+ return wait(100);
139
+ case 3:
140
+ _context2.next = 0;
141
+ break;
142
+ case 5:
143
+ case "end":
144
+ return _context2.stop();
145
+ }
146
+ }, _callee2);
147
+ }))();
148
+ }
149
+ copyToClipboard() {
150
+ var _this3 = this;
151
+ return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
152
+ var content, htmlContent;
153
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
154
+ while (1) switch (_context3.prev = _context3.next) {
155
+ case 0:
156
+ if (!_this3.props.target_id) {
157
+ _context3.next = 4;
200
158
  break;
201
- case 4:
202
- _context3.next = 6;
203
- return wait(100);
204
- case 6:
205
- _context3.next = 8;
206
- return this.loading();
207
- case 8:
208
- content = this.props.content;
209
- htmlContent = this.props.html_content;
210
- case 10:
211
- if (content || htmlContent) {
212
- this.copySuccess(content, htmlContent);
213
- }
214
- case 11:
215
- case "end":
216
- return _context3.stop();
217
- }
218
- }, _callee3, this);
219
- }));
220
- function copyToClipboard() {
221
- return _copyToClipboard.apply(this, arguments);
222
- }
223
- return copyToClipboard;
224
- }()
225
- }, {
226
- key: "componentDidMount",
227
- value: function componentDidMount() {
228
- if (!clipboardAPI) {
229
- console.warn('Copy to clipboard not available with this browser'); // eslint-disable-line no-console
230
- }
231
- }
232
- }, {
233
- key: "render",
234
- value: function render() {
235
- var _this$props = this.props,
236
- id = _this$props.id,
237
- title = _this$props.title,
238
- className = _this$props.className,
239
- style = _this$props.style;
240
- var copyIcon = /*#__PURE__*/_react.default.createElement(_reactFontawesome.FontAwesomeIcon, {
241
- icon: _freeRegularSvgIcons.faCopy
242
- });
243
- var copiedIcon = /*#__PURE__*/_react.default.createElement(_reactFontawesome.FontAwesomeIcon, {
244
- icon: _freeRegularSvgIcons.faCheckCircle
245
- });
246
- var btnIcon = this.state.copied ? copiedIcon : copyIcon;
247
- return clipboardAPI ? /*#__PURE__*/_react.default.createElement(_LoadingElement.default, {
248
- id: id,
249
- title: title,
250
- style: style,
251
- className: className,
252
- onClick: this.onClickHandler
253
- }, /*#__PURE__*/_react.default.createElement("i", null, " ", btnIcon)) : null;
159
+ }
160
+ content = _this3.getTargetText();
161
+ _context3.next = 10;
162
+ break;
163
+ case 4:
164
+ _context3.next = 6;
165
+ return wait(100);
166
+ case 6:
167
+ _context3.next = 8;
168
+ return _this3.loading();
169
+ case 8:
170
+ content = _this3.props.content;
171
+ htmlContent = _this3.props.html_content;
172
+ case 10:
173
+ if (content || htmlContent) {
174
+ _this3.copySuccess(content, htmlContent);
175
+ }
176
+ case 11:
177
+ case "end":
178
+ return _context3.stop();
179
+ }
180
+ }, _callee3);
181
+ }))();
182
+ }
183
+ componentDidMount() {
184
+ if (!clipboardAPI) {
185
+ console.warn('Copy to clipboard not available with this browser'); // eslint-disable-line no-console
254
186
  }
255
- }]);
256
- }(_react.default.Component);
187
+ }
188
+ render() {
189
+ var _this$props = this.props,
190
+ id = _this$props.id,
191
+ title = _this$props.title,
192
+ className = _this$props.className,
193
+ style = _this$props.style;
194
+ var copyIcon = /*#__PURE__*/_react.default.createElement(_reactFontawesome.FontAwesomeIcon, {
195
+ icon: _freeRegularSvgIcons.faCopy
196
+ });
197
+ var copiedIcon = /*#__PURE__*/_react.default.createElement(_reactFontawesome.FontAwesomeIcon, {
198
+ icon: _freeRegularSvgIcons.faCheckCircle
199
+ });
200
+ var btnIcon = this.state.copied ? copiedIcon : copyIcon;
201
+ return clipboardAPI ? /*#__PURE__*/_react.default.createElement(_LoadingElement.default, {
202
+ id: id,
203
+ title: title,
204
+ style: style,
205
+ className: className,
206
+ onClick: this.onClickHandler
207
+ }, /*#__PURE__*/_react.default.createElement("i", null, " ", btnIcon)) : null;
208
+ }
209
+ }
210
+ exports.default = Clipboard;
257
211
  _defineProperty(Clipboard, "contextType", window.dash_component_api.DashContext);
258
212
  Clipboard.defaultProps = {
259
213
  content: null,