dash-core-components 1.15.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/README.md +8 -44
  2. package/dash_core_components/async-datepicker.js +1 -1
  3. package/dash_core_components/async-datepicker.js.map +1 -1
  4. package/dash_core_components/async-dropdown.js +2 -2
  5. package/dash_core_components/async-dropdown.js.map +1 -1
  6. package/dash_core_components/async-graph.js +1 -1
  7. package/dash_core_components/async-graph.js.map +1 -1
  8. package/dash_core_components/async-highlight.js +1 -1
  9. package/dash_core_components/async-highlight.js.map +1 -1
  10. package/dash_core_components/async-markdown.js +2 -2
  11. package/dash_core_components/async-markdown.js.map +1 -1
  12. package/dash_core_components/async-plotlyjs.js +2 -2
  13. package/dash_core_components/async-slider.js +1 -2
  14. package/dash_core_components/async-slider.js.map +1 -1
  15. package/dash_core_components/async-upload.js +1 -1
  16. package/dash_core_components/async-upload.js.map +1 -1
  17. package/dash_core_components/dash_core_components-shared.js +2 -2
  18. package/dash_core_components/dash_core_components-shared.js.map +1 -1
  19. package/dash_core_components/dash_core_components.js +3 -0
  20. package/dash_core_components/dash_core_components.js.map +1 -0
  21. package/dash_core_components/plotly.min.js +30 -26
  22. package/lib/components/Checklist.react.js +77 -35
  23. package/lib/components/Clipboard.react.js +354 -0
  24. package/lib/components/ConfirmDialog.react.js +16 -12
  25. package/lib/components/ConfirmDialogProvider.react.js +19 -15
  26. package/lib/components/DatePickerRange.react.js +111 -97
  27. package/lib/components/DatePickerSingle.react.js +95 -81
  28. package/lib/components/Download.react.js +138 -0
  29. package/lib/components/Dropdown.react.js +69 -47
  30. package/lib/components/Graph.react.js +36 -24
  31. package/lib/components/Input.react.js +98 -92
  32. package/lib/components/Interval.react.js +18 -12
  33. package/lib/components/Link.react.js +36 -30
  34. package/lib/components/Loading.react.js +21 -15
  35. package/lib/components/Location.react.js +15 -13
  36. package/lib/components/LogoutButton.react.js +18 -14
  37. package/lib/components/Markdown.react.js +23 -17
  38. package/lib/components/RadioItems.react.js +77 -35
  39. package/lib/components/RangeSlider.react.js +61 -55
  40. package/lib/components/Slider.react.js +52 -46
  41. package/lib/components/Store.react.js +16 -16
  42. package/lib/components/Tab.react.js +6 -2
  43. package/lib/components/Tabs.react.js +32 -23
  44. package/lib/components/Textarea.react.js +19 -13
  45. package/lib/components/Tooltip.react.js +152 -0
  46. package/lib/components/Upload.react.js +25 -19
  47. package/lib/components/css/Dropdown.css +1 -1
  48. package/lib/fragments/DatePickerRange.react.js +63 -51
  49. package/lib/fragments/DatePickerSingle.react.js +28 -17
  50. package/lib/fragments/Dropdown.react.js +33 -22
  51. package/lib/fragments/Graph.privateprops.js +1 -1
  52. package/lib/fragments/Graph.react.js +44 -28
  53. package/lib/fragments/Loading/spinners/CircleSpinner.js +16 -16
  54. package/lib/fragments/Loading/spinners/CubeSpinner.js +11 -11
  55. package/lib/fragments/Loading/spinners/DefaultSpinner.js +9 -9
  56. package/lib/fragments/Loading/spinners/DotSpinner.js +7 -7
  57. package/lib/fragments/Loading/spinners/GraphSpinner.js +18 -18
  58. package/lib/fragments/Markdown.react.js +35 -32
  59. package/lib/fragments/RangeSlider.react.js +57 -22
  60. package/lib/fragments/Slider.react.js +40 -21
  61. package/lib/fragments/Upload.react.js +19 -13
  62. package/lib/index.js +77 -53
  63. package/lib/third-party/highlight.js +12 -0
  64. package/lib/utils/LazyLoader/datePickerRange.js +9 -3
  65. package/lib/utils/LazyLoader/datePickerSingle.js +9 -3
  66. package/lib/utils/LazyLoader/dropdown.js +9 -3
  67. package/lib/utils/LazyLoader/graph.js +9 -3
  68. package/lib/utils/LazyLoader/hljs.js +9 -3
  69. package/lib/utils/LazyLoader/markdown.js +9 -3
  70. package/lib/utils/LazyLoader/plotly.js +9 -3
  71. package/lib/utils/LazyLoader/rangeSlider.js +9 -3
  72. package/lib/utils/LazyLoader/slider.js +9 -3
  73. package/lib/utils/LazyLoader/upload.js +9 -3
  74. package/lib/utils/computeSliderMarkers.js +230 -0
  75. package/lib/utils/convertToMoment.js +4 -0
  76. package/lib/utils/optionTypes.js +52 -0
  77. package/package.json +68 -75
  78. package/CHANGELOG.md +0 -1034
  79. package/dash_core_components/dash_core_components.min.js +0 -2
  80. package/dash_core_components/dash_core_components.min.js.map +0 -1
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
2
 
3
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
+
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
@@ -11,27 +13,33 @@ var _ramda = require("ramda");
11
13
 
12
14
  var _react = _interopRequireWildcard(require("react"));
13
15
 
14
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
16
+ var _optionTypes = require("../utils/optionTypes");
15
17
 
16
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
17
19
 
18
- function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
20
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
21
+
22
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
23
 
20
24
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
21
25
 
22
26
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
23
27
 
24
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
28
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
25
29
 
26
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
30
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } Object.defineProperty(subClass, "prototype", { value: Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }), writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
27
31
 
28
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
32
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
29
33
 
30
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
34
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
31
35
 
32
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
36
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
33
37
 
34
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
38
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
39
+
40
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
41
+
42
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
35
43
 
36
44
  /**
37
45
  * Checklist is a component that encapsulates several checkboxes.
@@ -39,15 +47,15 @@ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || func
39
47
  * property and the checked items are specified with the `value` property.
40
48
  * Each checkbox is rendered as an input with a surrounding label.
41
49
  */
42
- var Checklist =
43
- /*#__PURE__*/
44
- function (_Component) {
50
+ var Checklist = /*#__PURE__*/function (_Component) {
45
51
  _inherits(Checklist, _Component);
46
52
 
53
+ var _super = _createSuper(Checklist);
54
+
47
55
  function Checklist() {
48
56
  _classCallCheck(this, Checklist);
49
57
 
50
- return _possibleConstructorReturn(this, _getPrototypeOf(Checklist).apply(this, arguments));
58
+ return _super.apply(this, arguments);
51
59
  }
52
60
 
53
61
  _createClass(Checklist, [{
@@ -64,18 +72,21 @@ function (_Component) {
64
72
  setProps = _this$props.setProps,
65
73
  style = _this$props.style,
66
74
  loading_state = _this$props.loading_state,
67
- value = _this$props.value;
68
- return _react.default.createElement("div", {
75
+ value = _this$props.value,
76
+ inline = _this$props.inline;
77
+ return /*#__PURE__*/_react.default.createElement("div", {
69
78
  "data-dash-is-loading": loading_state && loading_state.is_loading || undefined,
70
79
  id: id,
71
80
  style: style,
72
81
  className: className
73
- }, options.map(function (option) {
74
- return _react.default.createElement("label", {
82
+ }, (0, _optionTypes.sanitizeOptions)(options).map(function (option) {
83
+ return /*#__PURE__*/_react.default.createElement("label", {
75
84
  key: option.value,
76
- style: labelStyle,
85
+ style: Object.assign({}, labelStyle, inline ? {
86
+ display: 'inline-block'
87
+ } : {}),
77
88
  className: labelClassName
78
- }, _react.default.createElement("input", {
89
+ }, /*#__PURE__*/_react.default.createElement("input", {
79
90
  checked: (0, _ramda.includes)(option.value, value),
80
91
  className: inputClassName,
81
92
  disabled: Boolean(option.disabled),
@@ -105,38 +116,61 @@ function (_Component) {
105
116
  exports.default = Checklist;
106
117
  Checklist.propTypes = {
107
118
  /**
108
- * The ID of this component, used to identify dash components
109
- * in callbacks. The ID needs to be unique across all of the
110
- * components in an app.
119
+ * An array of options
111
120
  */
112
- id: _propTypes.default.string,
113
-
121
+ options: _propTypes.default.oneOfType([
114
122
  /**
115
- * An array of options
123
+ * Array of options where the label and the value are the same thing - [string|number|bool]
124
+ */
125
+ _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number, _propTypes.default.bool])),
126
+ /**
127
+ * Simpler `options` representation in dictionary format. The order is not guaranteed.
128
+ * {`value1`: `label1`, `value2`: `label2`, ... }
129
+ * which is equal to
130
+ * [{label: `label1`, value: `value1`}, {label: `label2`, value: `value2`}, ...]
131
+ */
132
+ _propTypes.default.object,
133
+ /**
134
+ * An array of options {label: [string|number], value: [string|number]},
135
+ * an optional disabled field can be used for each option
116
136
  */
117
- options: _propTypes.default.arrayOf(_propTypes.default.exact({
137
+ _propTypes.default.arrayOf(_propTypes.default.exact({
118
138
  /**
119
- * The checkbox's label
139
+ * The option's label
120
140
  */
121
- label: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]).isRequired,
141
+ label: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number, _propTypes.default.bool]).isRequired,
122
142
 
123
143
  /**
124
- * The value of the checkbox. This value
144
+ * The value of the option. This value
125
145
  * corresponds to the items specified in the
126
146
  * `value` property.
127
147
  */
128
- value: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]).isRequired,
148
+ value: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number, _propTypes.default.bool]).isRequired,
129
149
 
130
150
  /**
131
- * If true, this checkbox is disabled and can't be clicked on.
151
+ * If true, this option is disabled and cannot be selected.
132
152
  */
133
- disabled: _propTypes.default.bool
134
- })),
153
+ disabled: _propTypes.default.bool,
154
+
155
+ /**
156
+ * The HTML 'title' attribute for the option. Allows for
157
+ * information on hover. For more information on this attribute,
158
+ * see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/title
159
+ */
160
+ title: _propTypes.default.string
161
+ }))]),
135
162
 
136
163
  /**
137
164
  * The currently selected value
138
165
  */
139
- value: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number])),
166
+ value: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number, _propTypes.default.bool])),
167
+
168
+ /**
169
+ * Indicates whether labelStyle should be inline or not
170
+ * True: Automatically set { 'display': 'inline-block' } to labelStyle
171
+ * False: No additional styles are passed into labelStyle.
172
+ */
173
+ inline: _propTypes.default.bool,
140
174
 
141
175
  /**
142
176
  * The class of the container (div)
@@ -170,6 +204,13 @@ Checklist.propTypes = {
170
204
  */
171
205
  labelClassName: _propTypes.default.string,
172
206
 
207
+ /**
208
+ * The ID of this component, used to identify dash components
209
+ * in callbacks. The ID needs to be unique across all of the
210
+ * components in an app.
211
+ */
212
+ id: _propTypes.default.string,
213
+
173
214
  /**
174
215
  * Dash-assigned callback that gets fired when the value changes.
175
216
  */
@@ -228,5 +269,6 @@ Checklist.defaultProps = {
228
269
  options: [],
229
270
  value: [],
230
271
  persisted_props: ['value'],
231
- persistence_type: 'local'
272
+ persistence_type: 'local',
273
+ inline: false
232
274
  };
@@ -0,0 +1,354 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _react = _interopRequireWildcard(require("react"));
9
+
10
+ var _propTypes = _interopRequireDefault(require("prop-types"));
11
+
12
+ var _reactFontawesome = require("@fortawesome/react-fontawesome");
13
+
14
+ var _freeRegularSvgIcons = require("@fortawesome/free-regular-svg-icons");
15
+
16
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
+
18
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
19
+
20
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
21
+
22
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
23
+
24
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
25
+
26
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
27
+
28
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
29
+
30
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
31
+
32
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
33
+
34
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } Object.defineProperty(subClass, "prototype", { value: Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }), writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
35
+
36
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
37
+
38
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
39
+
40
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
41
+
42
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
43
+
44
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
45
+
46
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
47
+
48
+ var clipboardAPI = navigator.clipboard;
49
+
50
+ function wait(ms) {
51
+ return new Promise(function (r) {
52
+ return setTimeout(r, ms);
53
+ });
54
+ }
55
+ /**
56
+ * The Clipboard component copies text to the clipboard
57
+ */
58
+
59
+
60
+ var Clipboard = /*#__PURE__*/function (_React$Component) {
61
+ _inherits(Clipboard, _React$Component);
62
+
63
+ var _super = _createSuper(Clipboard);
64
+
65
+ function Clipboard(props) {
66
+ var _this;
67
+
68
+ _classCallCheck(this, Clipboard);
69
+
70
+ _this = _super.call(this, props);
71
+ _this.copyToClipboard = _this.copyToClipboard.bind(_assertThisInitialized(_this));
72
+ _this.copySuccess = _this.copySuccess.bind(_assertThisInitialized(_this));
73
+ _this.getTargetText = _this.getTargetText.bind(_assertThisInitialized(_this));
74
+ _this.loading = _this.loading.bind(_assertThisInitialized(_this));
75
+ _this.stringifyId = _this.stringifyId.bind(_assertThisInitialized(_this));
76
+ _this.state = {
77
+ copied: false
78
+ };
79
+ return _this;
80
+ } // stringifies object ids used in pattern matching callbacks
81
+
82
+
83
+ _createClass(Clipboard, [{
84
+ key: "stringifyId",
85
+ value: function stringifyId(id) {
86
+ if (_typeof(id) !== 'object') {
87
+ return id;
88
+ }
89
+
90
+ var stringifyVal = function stringifyVal(v) {
91
+ return v && v.wild || JSON.stringify(v);
92
+ };
93
+
94
+ var parts = Object.keys(id).sort().map(function (k) {
95
+ return JSON.stringify(k) + ':' + stringifyVal(id[k]);
96
+ });
97
+ return '{' + parts.join(',') + '}';
98
+ }
99
+ }, {
100
+ key: "copySuccess",
101
+ value: function () {
102
+ var _copySuccess = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(content) {
103
+ var showCopiedIcon;
104
+ return regeneratorRuntime.wrap(function _callee$(_context) {
105
+ while (1) {
106
+ switch (_context.prev = _context.next) {
107
+ case 0:
108
+ showCopiedIcon = 1000;
109
+ _context.next = 3;
110
+ return clipboardAPI.writeText(content);
111
+
112
+ case 3:
113
+ this.setState({
114
+ copied: true
115
+ });
116
+ _context.next = 6;
117
+ return wait(showCopiedIcon);
118
+
119
+ case 6:
120
+ this.setState({
121
+ copied: false
122
+ });
123
+
124
+ case 7:
125
+ case "end":
126
+ return _context.stop();
127
+ }
128
+ }
129
+ }, _callee, this);
130
+ }));
131
+
132
+ function copySuccess(_x) {
133
+ return _copySuccess.apply(this, arguments);
134
+ }
135
+
136
+ return copySuccess;
137
+ }()
138
+ }, {
139
+ key: "getTargetText",
140
+ value: function getTargetText() {
141
+ // get the inner text. If none, use the content of the value param
142
+ var id = this.stringifyId(this.props.target_id);
143
+ var target = document.getElementById(id);
144
+
145
+ if (!target) {
146
+ throw new Error('Clipboard copy failed: no element found for target_id ' + this.props.target_id);
147
+ }
148
+
149
+ var content = target.innerText;
150
+
151
+ if (!content) {
152
+ content = target.value;
153
+ content = content === undefined ? null : content;
154
+ }
155
+
156
+ return content;
157
+ }
158
+ }, {
159
+ key: "loading",
160
+ value: function () {
161
+ var _loading = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
162
+ var _this$props$loading_s;
163
+
164
+ return regeneratorRuntime.wrap(function _callee2$(_context2) {
165
+ while (1) {
166
+ switch (_context2.prev = _context2.next) {
167
+ case 0:
168
+ if (!((_this$props$loading_s = this.props.loading_state) !== null && _this$props$loading_s !== void 0 && _this$props$loading_s.is_loading)) {
169
+ _context2.next = 5;
170
+ break;
171
+ }
172
+
173
+ _context2.next = 3;
174
+ return wait(100);
175
+
176
+ case 3:
177
+ _context2.next = 0;
178
+ break;
179
+
180
+ case 5:
181
+ case "end":
182
+ return _context2.stop();
183
+ }
184
+ }
185
+ }, _callee2, this);
186
+ }));
187
+
188
+ function loading() {
189
+ return _loading.apply(this, arguments);
190
+ }
191
+
192
+ return loading;
193
+ }()
194
+ }, {
195
+ key: "copyToClipboard",
196
+ value: function () {
197
+ var _copyToClipboard = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {
198
+ var content;
199
+ return regeneratorRuntime.wrap(function _callee3$(_context3) {
200
+ while (1) {
201
+ switch (_context3.prev = _context3.next) {
202
+ case 0:
203
+ this.props.setProps({
204
+ n_clicks: this.props.n_clicks + 1
205
+ });
206
+
207
+ if (!this.props.target_id) {
208
+ _context3.next = 5;
209
+ break;
210
+ }
211
+
212
+ content = this.getTargetText();
213
+ _context3.next = 10;
214
+ break;
215
+
216
+ case 5:
217
+ _context3.next = 7;
218
+ return wait(100);
219
+
220
+ case 7:
221
+ _context3.next = 9;
222
+ return this.loading();
223
+
224
+ case 9:
225
+ content = this.props.content;
226
+
227
+ case 10:
228
+ if (content) {
229
+ this.copySuccess(content);
230
+ }
231
+
232
+ case 11:
233
+ case "end":
234
+ return _context3.stop();
235
+ }
236
+ }
237
+ }, _callee3, this);
238
+ }));
239
+
240
+ function copyToClipboard() {
241
+ return _copyToClipboard.apply(this, arguments);
242
+ }
243
+
244
+ return copyToClipboard;
245
+ }()
246
+ }, {
247
+ key: "componentDidMount",
248
+ value: function componentDidMount() {
249
+ if (!clipboardAPI) {
250
+ console.warn('Copy to clipboard not available with this browser'); // eslint-disable-line no-console
251
+ }
252
+ }
253
+ }, {
254
+ key: "render",
255
+ value: function render() {
256
+ var _this$props = this.props,
257
+ id = _this$props.id,
258
+ title = _this$props.title,
259
+ className = _this$props.className,
260
+ style = _this$props.style,
261
+ loading_state = _this$props.loading_state;
262
+
263
+ var copyIcon = /*#__PURE__*/_react.default.createElement(_reactFontawesome.FontAwesomeIcon, {
264
+ icon: _freeRegularSvgIcons.faCopy
265
+ });
266
+
267
+ var copiedIcon = /*#__PURE__*/_react.default.createElement(_reactFontawesome.FontAwesomeIcon, {
268
+ icon: _freeRegularSvgIcons.faCheckCircle
269
+ });
270
+
271
+ var btnIcon = this.state.copied ? copiedIcon : copyIcon;
272
+ return clipboardAPI ? /*#__PURE__*/_react.default.createElement("div", {
273
+ id: id,
274
+ title: title,
275
+ style: style,
276
+ className: className,
277
+ onClick: this.copyToClipboard,
278
+ "data-dash-is-loading": loading_state && loading_state.is_loading || undefined
279
+ }, /*#__PURE__*/_react.default.createElement("i", null, " ", btnIcon)) : null;
280
+ }
281
+ }]);
282
+
283
+ return Clipboard;
284
+ }(_react.default.Component);
285
+
286
+ exports.default = Clipboard;
287
+ Clipboard.defaultProps = {
288
+ content: null,
289
+ target_id: null,
290
+ n_clicks: 0
291
+ };
292
+ Clipboard.propTypes = {
293
+ /**
294
+ * The ID used to identify this component.
295
+ */
296
+ id: _propTypes.default.string,
297
+
298
+ /**
299
+ * The id of target component containing text to copy to the clipboard.
300
+ * The inner text of the `children` prop will be copied to the clipboard. If none, then the text from the
301
+ * `value` prop will be copied.
302
+ */
303
+ target_id: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.object]),
304
+
305
+ /**
306
+ * The text to be copied to the clipboard if the `target_id` is None.
307
+ */
308
+ content: _propTypes.default.string,
309
+
310
+ /**
311
+ * The number of times copy button was clicked
312
+ */
313
+ n_clicks: _propTypes.default.number,
314
+
315
+ /**
316
+ * The text shown as a tooltip when hovering over the copy icon.
317
+ */
318
+ title: _propTypes.default.string,
319
+
320
+ /**
321
+ * The icon's styles
322
+ */
323
+ style: _propTypes.default.object,
324
+
325
+ /**
326
+ * The class name of the icon element
327
+ */
328
+ className: _propTypes.default.string,
329
+
330
+ /**
331
+ * Object that holds the loading state object coming from dash-renderer
332
+ */
333
+ loading_state: _propTypes.default.shape({
334
+ /**
335
+ * Determines if the component is loading or not
336
+ */
337
+ is_loading: _propTypes.default.bool,
338
+
339
+ /**
340
+ * Holds which property is loading
341
+ */
342
+ prop_name: _propTypes.default.string,
343
+
344
+ /**
345
+ * Holds the name of the component that is loading
346
+ */
347
+ component_name: _propTypes.default.string
348
+ }),
349
+
350
+ /**
351
+ * Dash-assigned callback that gets fired when the value changes.
352
+ */
353
+ setProps: _propTypes.default.func
354
+ };
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
2
 
3
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
+
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
@@ -11,23 +13,25 @@ var _react = require("react");
11
13
 
12
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
15
 
14
- function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
15
-
16
16
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
17
17
 
18
18
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
19
19
 
20
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
20
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
21
21
 
22
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
22
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } Object.defineProperty(subClass, "prototype", { value: Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }), writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
23
23
 
24
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
24
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
25
25
 
26
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
26
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
27
27
 
28
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
28
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
29
29
 
30
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
30
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
31
+
32
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
33
+
34
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
31
35
 
32
36
  /**
33
37
  * ConfirmDialog is used to display the browser's native "confirm" modal,
@@ -35,15 +39,15 @@ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || func
35
39
  * This ConfirmDialog can be used in conjunction with buttons when the user
36
40
  * is performing an action that should require an extra step of verification.
37
41
  */
38
- var ConfirmDialog =
39
- /*#__PURE__*/
40
- function (_Component) {
42
+ var ConfirmDialog = /*#__PURE__*/function (_Component) {
41
43
  _inherits(ConfirmDialog, _Component);
42
44
 
45
+ var _super = _createSuper(ConfirmDialog);
46
+
43
47
  function ConfirmDialog() {
44
48
  _classCallCheck(this, ConfirmDialog);
45
49
 
46
- return _possibleConstructorReturn(this, _getPrototypeOf(ConfirmDialog).apply(this, arguments));
50
+ return _super.apply(this, arguments);
47
51
  }
48
52
 
49
53
  _createClass(ConfirmDialog, [{