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.
- package/dash_core_components/async-datepicker.js +1 -1
- package/dash_core_components/async-datepicker.js.map +1 -1
- package/dash_core_components/async-dropdown.js +1 -1
- package/dash_core_components/async-dropdown.js.map +1 -1
- package/dash_core_components/async-graph.js +1 -1
- package/dash_core_components/async-graph.js.map +1 -1
- package/dash_core_components/async-highlight.js +1 -1
- package/dash_core_components/async-highlight.js.map +1 -1
- package/dash_core_components/async-markdown.js +1 -1
- package/dash_core_components/async-markdown.js.map +1 -1
- package/dash_core_components/async-slider.js +1 -1
- package/dash_core_components/async-slider.js.map +1 -1
- package/dash_core_components/async-upload.js +1 -1
- package/dash_core_components/async-upload.js.map +1 -1
- package/dash_core_components/dash_core_components.js +1 -1
- package/dash_core_components/dash_core_components.js.map +1 -1
- package/lib/components/Checklist.react.js +46 -63
- package/lib/components/Clipboard.react.js +172 -218
- package/lib/components/ConfirmDialog.react.js +34 -61
- package/lib/components/ConfirmDialogProvider.react.js +21 -44
- package/lib/components/DatePickerRange.react.js +7 -26
- package/lib/components/DatePickerSingle.react.js +7 -26
- package/lib/components/Download.react.js +22 -45
- package/lib/components/Dropdown.react.js +7 -26
- package/lib/components/Geolocation.react.js +64 -91
- package/lib/components/Graph.react.js +70 -97
- package/lib/components/Input.react.js +119 -162
- package/lib/components/Interval.react.js +55 -86
- package/lib/components/Link.react.js +4 -4
- package/lib/components/Loading.react.js +31 -35
- package/lib/components/Location.react.js +97 -126
- package/lib/components/Markdown.react.js +15 -35
- package/lib/components/RadioItems.react.js +45 -63
- package/lib/components/RangeSlider.react.js +7 -26
- package/lib/components/Slider.react.js +7 -26
- package/lib/components/Store.react.js +128 -176
- package/lib/components/Tab.react.js +1 -1
- package/lib/components/Tabs.react.js +97 -126
- package/lib/components/Textarea.react.js +4 -4
- package/lib/components/Tooltip.react.js +1 -1
- package/lib/components/Upload.react.js +7 -26
- package/lib/fragments/DatePickerRange.react.js +150 -181
- package/lib/fragments/DatePickerSingle.react.js +103 -134
- package/lib/fragments/Dropdown.react.js +11 -19
- package/lib/fragments/Graph.privateprops.js +3 -9
- package/lib/fragments/Graph.react.js +302 -370
- package/lib/fragments/Loading/spinners/CircleSpinner.js +2 -4
- package/lib/fragments/Loading/spinners/CubeSpinner.js +2 -4
- package/lib/fragments/Loading/spinners/DefaultSpinner.js +2 -4
- package/lib/fragments/Loading/spinners/DotSpinner.js +2 -4
- package/lib/fragments/Loading/spinners/GraphSpinner.js +2 -4
- package/lib/fragments/Markdown.react.js +119 -158
- package/lib/fragments/Math.react.js +23 -47
- package/lib/fragments/RangeSlider.react.js +110 -133
- package/lib/fragments/Slider.react.js +110 -133
- package/lib/fragments/Upload.react.js +82 -99
- package/lib/utils/DatePickerPersistence.js +2 -4
- package/lib/utils/LazyLoader/datePickerRange.js +2 -3
- package/lib/utils/LazyLoader/datePickerSingle.js +2 -3
- package/lib/utils/LazyLoader/dropdown.js +2 -3
- package/lib/utils/LazyLoader/graph.js +2 -3
- package/lib/utils/LazyLoader/hljs.js +2 -5
- package/lib/utils/LazyLoader/markdown.js +2 -3
- package/lib/utils/LazyLoader/mathjax.js +2 -5
- package/lib/utils/LazyLoader/plotly.js +7 -6
- package/lib/utils/LazyLoader/rangeSlider.js +2 -3
- package/lib/utils/LazyLoader/slider.js +2 -3
- package/lib/utils/LazyLoader/upload.js +2 -3
- package/lib/utils/MarkdownHighlighter.js +5 -6
- package/lib/utils/ResizeDetector.js +8 -12
- package/lib/utils/computeSliderMarkers.js +29 -49
- package/lib/utils/computeSliderStyle.js +4 -3
- package/lib/utils/convertToMoment.js +5 -6
- package/lib/utils/formatSliderTooltip.js +6 -8
- package/lib/utils/optionTypes.js +8 -9
- package/package.json +1 -1
|
@@ -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
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
className:
|
|
61
|
-
},
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
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
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
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(
|
|
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
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
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
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
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
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
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
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
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
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
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
|
-
|
|
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,
|