dash-core-components 3.0.3 → 3.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/dash_core_components/async-datepicker.js +1 -1
  2. package/dash_core_components/async-datepicker.js.map +1 -1
  3. package/dash_core_components/async-dropdown.js +1 -1
  4. package/dash_core_components/async-dropdown.js.map +1 -1
  5. package/dash_core_components/async-graph.js +1 -1
  6. package/dash_core_components/async-graph.js.map +1 -1
  7. package/dash_core_components/async-highlight.js +1 -1
  8. package/dash_core_components/async-highlight.js.map +1 -1
  9. package/dash_core_components/async-markdown.js +1 -1
  10. package/dash_core_components/async-markdown.js.map +1 -1
  11. package/dash_core_components/async-slider.js +1 -1
  12. package/dash_core_components/async-slider.js.map +1 -1
  13. package/dash_core_components/async-upload.js +1 -1
  14. package/dash_core_components/async-upload.js.map +1 -1
  15. package/dash_core_components/dash_core_components.js +1 -1
  16. package/dash_core_components/dash_core_components.js.map +1 -1
  17. package/lib/components/Checklist.react.js +46 -63
  18. package/lib/components/Clipboard.react.js +172 -218
  19. package/lib/components/ConfirmDialog.react.js +34 -61
  20. package/lib/components/ConfirmDialogProvider.react.js +21 -44
  21. package/lib/components/DatePickerRange.react.js +7 -26
  22. package/lib/components/DatePickerSingle.react.js +7 -26
  23. package/lib/components/Download.react.js +22 -45
  24. package/lib/components/Dropdown.react.js +7 -26
  25. package/lib/components/Geolocation.react.js +64 -91
  26. package/lib/components/Graph.react.js +70 -97
  27. package/lib/components/Input.react.js +119 -162
  28. package/lib/components/Interval.react.js +55 -86
  29. package/lib/components/Link.react.js +4 -4
  30. package/lib/components/Loading.react.js +31 -35
  31. package/lib/components/Location.react.js +97 -126
  32. package/lib/components/Markdown.react.js +15 -35
  33. package/lib/components/RadioItems.react.js +45 -63
  34. package/lib/components/RangeSlider.react.js +7 -26
  35. package/lib/components/Slider.react.js +7 -26
  36. package/lib/components/Store.react.js +128 -176
  37. package/lib/components/Tab.react.js +1 -1
  38. package/lib/components/Tabs.react.js +99 -134
  39. package/lib/components/Textarea.react.js +4 -4
  40. package/lib/components/Tooltip.react.js +7 -6
  41. package/lib/components/Upload.react.js +7 -26
  42. package/lib/fragments/DatePickerRange.react.js +150 -181
  43. package/lib/fragments/DatePickerSingle.react.js +103 -134
  44. package/lib/fragments/Dropdown.react.js +11 -19
  45. package/lib/fragments/Graph.privateprops.js +3 -9
  46. package/lib/fragments/Graph.react.js +302 -370
  47. package/lib/fragments/Loading/spinners/CircleSpinner.js +2 -4
  48. package/lib/fragments/Loading/spinners/CubeSpinner.js +2 -4
  49. package/lib/fragments/Loading/spinners/DefaultSpinner.js +2 -4
  50. package/lib/fragments/Loading/spinners/DotSpinner.js +2 -4
  51. package/lib/fragments/Loading/spinners/GraphSpinner.js +2 -4
  52. package/lib/fragments/Markdown.react.js +119 -158
  53. package/lib/fragments/Math.react.js +23 -47
  54. package/lib/fragments/RangeSlider.react.js +110 -133
  55. package/lib/fragments/Slider.react.js +110 -133
  56. package/lib/fragments/Upload.react.js +82 -99
  57. package/lib/utils/DatePickerPersistence.js +2 -4
  58. package/lib/utils/LazyLoader/datePickerRange.js +2 -3
  59. package/lib/utils/LazyLoader/datePickerSingle.js +2 -3
  60. package/lib/utils/LazyLoader/dropdown.js +2 -3
  61. package/lib/utils/LazyLoader/graph.js +2 -3
  62. package/lib/utils/LazyLoader/hljs.js +2 -5
  63. package/lib/utils/LazyLoader/markdown.js +2 -3
  64. package/lib/utils/LazyLoader/mathjax.js +2 -5
  65. package/lib/utils/LazyLoader/plotly.js +7 -6
  66. package/lib/utils/LazyLoader/rangeSlider.js +2 -3
  67. package/lib/utils/LazyLoader/slider.js +2 -3
  68. package/lib/utils/LazyLoader/upload.js +2 -3
  69. package/lib/utils/MarkdownHighlighter.js +5 -6
  70. package/lib/utils/ResizeDetector.js +9 -13
  71. package/lib/utils/computeSliderMarkers.js +29 -49
  72. package/lib/utils/computeSliderStyle.js +4 -3
  73. package/lib/utils/convertToMoment.js +5 -6
  74. package/lib/utils/formatSliderTooltip.js +6 -8
  75. package/lib/utils/optionTypes.js +8 -9
  76. package/package.json +1 -1
@@ -17,6 +17,8 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
17
17
  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; }
18
18
  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; }
19
19
  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; }
20
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
21
+ 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); }
20
22
  function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
21
23
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
22
24
  function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
@@ -24,18 +26,6 @@ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length)
24
26
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
25
27
  function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
26
28
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
27
- function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
28
- 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); } }
29
- function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
30
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
31
- 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); }
32
- function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
33
- 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); }
34
- function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
35
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
36
- function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
37
- 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); }
38
- function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
39
29
  var EMPTY_DATA = [];
40
30
 
41
31
  /**
@@ -44,106 +34,89 @@ var EMPTY_DATA = [];
44
34
  * You can define callbacks based on user interaction with Graphs such as
45
35
  * hovering, clicking or selecting
46
36
  */
47
- var PlotlyGraph = /*#__PURE__*/function (_Component) {
48
- function PlotlyGraph(props) {
49
- var _this;
50
- _classCallCheck(this, PlotlyGraph);
51
- _this = _callSuper(this, PlotlyGraph, [props]);
37
+ class PlotlyGraph extends _react.Component {
38
+ constructor(props) {
39
+ super(props);
52
40
  if (props.mathjax) {
53
41
  PlotlyGraph._loadMathjax = true;
54
42
  }
55
- _this.state = {
43
+ this.state = {
56
44
  prependData: [],
57
45
  extendData: []
58
46
  };
59
- _this.clearState = _this.clearState.bind(_this);
60
- return _this;
47
+ this.clearState = this.clearState.bind(this);
61
48
  }
62
- _inherits(PlotlyGraph, _Component);
63
- return _createClass(PlotlyGraph, [{
64
- key: "componentDidMount",
65
- value: function componentDidMount() {
66
- if (this.props.prependData) {
67
- this.setState({
68
- prependData: [this.props.prependData]
69
- });
70
- }
71
- if (this.props.extendData) {
72
- this.setState({
73
- extendData: [this.props.extendData]
74
- });
75
- }
49
+ componentDidMount() {
50
+ if (this.props.prependData) {
51
+ this.setState({
52
+ prependData: [this.props.prependData]
53
+ });
76
54
  }
77
- }, {
78
- key: "componentWillUnmount",
79
- value: function componentWillUnmount() {
55
+ if (this.props.extendData) {
80
56
  this.setState({
81
- prependData: [],
82
- extendData: []
57
+ extendData: [this.props.extendData]
83
58
  });
84
59
  }
85
- }, {
86
- key: "UNSAFE_componentWillReceiveProps",
87
- value: function UNSAFE_componentWillReceiveProps(nextProps) {
88
- var prependData = this.state.prependData.slice(0);
89
- if (this.props.figure !== nextProps.figure) {
90
- prependData = EMPTY_DATA;
91
- }
92
- if (nextProps.prependData && this.props.prependData !== nextProps.prependData) {
93
- prependData.push(nextProps.prependData);
94
- } else {
95
- prependData = EMPTY_DATA;
96
- }
97
- if (prependData !== EMPTY_DATA) {
98
- this.setState({
99
- prependData
100
- });
101
- }
102
- var extendData = this.state.extendData.slice(0);
103
- if (this.props.figure !== nextProps.figure) {
104
- extendData = EMPTY_DATA;
105
- }
106
- if (nextProps.extendData && this.props.extendData !== nextProps.extendData) {
107
- extendData.push(nextProps.extendData);
108
- } else {
109
- extendData = EMPTY_DATA;
110
- }
111
- if (extendData !== EMPTY_DATA) {
112
- this.setState({
113
- extendData
114
- });
115
- }
60
+ }
61
+ componentWillUnmount() {
62
+ this.setState({
63
+ prependData: [],
64
+ extendData: []
65
+ });
66
+ }
67
+ UNSAFE_componentWillReceiveProps(nextProps) {
68
+ var prependData = this.state.prependData.slice(0);
69
+ if (this.props.figure !== nextProps.figure) {
70
+ prependData = EMPTY_DATA;
71
+ }
72
+ if (nextProps.prependData && this.props.prependData !== nextProps.prependData) {
73
+ prependData.push(nextProps.prependData);
74
+ } else {
75
+ prependData = EMPTY_DATA;
116
76
  }
117
- }, {
118
- key: "clearState",
119
- value: function clearState(dataKey) {
120
- this.setState(function (props) {
121
- var data = props[dataKey];
122
- var res = data && data.length ? {
123
- [dataKey]: EMPTY_DATA
124
- } : undefined;
125
- return res;
77
+ if (prependData !== EMPTY_DATA) {
78
+ this.setState({
79
+ prependData
126
80
  });
127
81
  }
128
- }, {
129
- key: "render",
130
- value: function render() {
131
- return /*#__PURE__*/_react.default.createElement(ControlledPlotlyGraph, _extends({}, this.props, {
132
- prependData: this.state.prependData,
133
- extendData: this.state.extendData,
134
- clearState: this.clearState
135
- }));
82
+ var extendData = this.state.extendData.slice(0);
83
+ if (this.props.figure !== nextProps.figure) {
84
+ extendData = EMPTY_DATA;
136
85
  }
137
- }]);
138
- }(_react.Component);
139
- var RealPlotlyGraph = (0, _dashComponentPlugins.asyncDecorator)(PlotlyGraph, function () {
140
- return Promise.all([(0, _graph.default)(), (0, _plotly.default)(), PlotlyGraph._loadMathjax ? (0, _mathjax.default)() : undefined]).then(function (_ref) {
141
- var _ref2 = _slicedToArray(_ref, 1),
142
- graph = _ref2[0];
143
- return graph;
144
- });
145
- });
146
- var ControlledPlotlyGraph = /*#__PURE__*/(0, _react.memo)(function (props) {
86
+ if (nextProps.extendData && this.props.extendData !== nextProps.extendData) {
87
+ extendData.push(nextProps.extendData);
88
+ } else {
89
+ extendData = EMPTY_DATA;
90
+ }
91
+ if (extendData !== EMPTY_DATA) {
92
+ this.setState({
93
+ extendData
94
+ });
95
+ }
96
+ }
97
+ clearState(dataKey) {
98
+ this.setState(props => {
99
+ var data = props[dataKey];
100
+ var res = data && data.length ? {
101
+ [dataKey]: EMPTY_DATA
102
+ } : undefined;
103
+ return res;
104
+ });
105
+ }
106
+ render() {
107
+ return /*#__PURE__*/_react.default.createElement(ControlledPlotlyGraph, _extends({}, this.props, {
108
+ prependData: this.state.prependData,
109
+ extendData: this.state.extendData,
110
+ clearState: this.clearState
111
+ }));
112
+ }
113
+ }
114
+ var RealPlotlyGraph = (0, _dashComponentPlugins.asyncDecorator)(PlotlyGraph, () => Promise.all([(0, _graph.default)(), (0, _plotly.default)(), PlotlyGraph._loadMathjax ? (0, _mathjax.default)() : undefined]).then(_ref => {
115
+ var _ref2 = _slicedToArray(_ref, 1),
116
+ graph = _ref2[0];
117
+ return graph;
118
+ }));
119
+ var ControlledPlotlyGraph = /*#__PURE__*/(0, _react.memo)(props => {
147
120
  var className = props.className,
148
121
  id = props.id;
149
122
  var extendedClassName = className ? 'dash-graph ' + className : 'dash-graph';
@@ -14,25 +14,9 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
14
14
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
15
15
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
16
16
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
17
- function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
18
- 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); } }
19
- function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
20
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
21
- 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); }
22
- function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
23
- 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); }
24
- function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
25
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
26
- function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
27
- 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); }
28
- function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
29
17
  // eslint-disable-next-line no-implicit-coercion
30
- var convert = function convert(val) {
31
- return (0, _fastIsnumeric.default)(val) ? +val : NaN;
32
- };
33
- var isEquivalent = function isEquivalent(v1, v2) {
34
- return v1 === v2 || isNaN(v1) && isNaN(v2);
35
- };
18
+ var convert = val => (0, _fastIsnumeric.default)(val) ? +val : NaN;
19
+ var isEquivalent = (v1, v2) => v1 === v2 || isNaN(v1) && isNaN(v2);
36
20
  var inputProps = ['type', 'placeholder', 'inputMode', 'autoComplete', 'readOnly', 'required', 'autoFocus', 'disabled', 'list', 'multiple', 'spellCheck', 'name', 'min', 'max', 'step', 'minLength', 'maxLength', 'pattern', 'size', 'style', 'id'];
37
21
 
38
22
  /**
@@ -42,169 +26,142 @@ var inputProps = ['type', 'placeholder', 'inputMode', 'autoComplete', 'readOnly'
42
26
  * the Checklist and RadioItems component. Dates, times, and file uploads
43
27
  * are also supported through separate components.
44
28
  */
45
- var Input = exports.default = /*#__PURE__*/function (_PureComponent) {
46
- function Input(props) {
47
- var _this;
48
- _classCallCheck(this, Input);
49
- _this = _callSuper(this, Input, [props]);
50
- _this.state = {
29
+ class Input extends _react.PureComponent {
30
+ constructor(props) {
31
+ super(props);
32
+ this.state = {
51
33
  pendingEvent: undefined,
52
34
  value: ''
53
35
  };
54
- _this.input = /*#__PURE__*/_react.default.createRef();
55
- _this.onBlur = _this.onBlur.bind(_this);
56
- _this.onChange = _this.onChange.bind(_this);
57
- _this.onEvent = _this.onEvent.bind(_this);
58
- _this.onKeyPress = _this.onKeyPress.bind(_this);
59
- _this.debounceEvent = _this.debounceEvent.bind(_this);
60
- _this.setInputValue = _this.setInputValue.bind(_this);
61
- _this.setPropValue = _this.setPropValue.bind(_this);
62
- return _this;
36
+ this.input = /*#__PURE__*/_react.default.createRef();
37
+ this.onBlur = this.onBlur.bind(this);
38
+ this.onChange = this.onChange.bind(this);
39
+ this.onEvent = this.onEvent.bind(this);
40
+ this.onKeyPress = this.onKeyPress.bind(this);
41
+ this.debounceEvent = this.debounceEvent.bind(this);
42
+ this.setInputValue = this.setInputValue.bind(this);
43
+ this.setPropValue = this.setPropValue.bind(this);
63
44
  }
64
- _inherits(Input, _PureComponent);
65
- return _createClass(Input, [{
66
- key: "UNSAFE_componentWillReceiveProps",
67
- value: function UNSAFE_componentWillReceiveProps(nextProps) {
68
- var value = this.input.current.value;
69
- if (this.state.pendingEvent) {
70
- // avoid updating the input while awaiting a debounced event
71
- return;
72
- }
73
- var valueAsNumber = convert(value);
74
- this.setInputValue((0, _ramda.isNil)(valueAsNumber) ? value : valueAsNumber, nextProps.value);
75
- if (this.props.type !== 'number') {
76
- this.setState({
77
- value: nextProps.value
78
- });
79
- }
80
- }
81
- }, {
82
- key: "componentDidMount",
83
- value: function componentDidMount() {
84
- var value = this.input.current.value;
85
- var valueAsNumber = convert(value);
86
- this.setInputValue((0, _ramda.isNil)(valueAsNumber) ? value : valueAsNumber, this.props.value);
87
- }
88
- }, {
89
- key: "UNSAFE_componentWillMount",
90
- value: function UNSAFE_componentWillMount() {
91
- if (this.props.type !== 'number') {
92
- this.setState({
93
- value: this.props.value
94
- });
95
- }
45
+ UNSAFE_componentWillReceiveProps(nextProps) {
46
+ var value = this.input.current.value;
47
+ if (this.state.pendingEvent) {
48
+ // avoid updating the input while awaiting a debounced event
49
+ return;
96
50
  }
97
- }, {
98
- key: "render",
99
- value: function render() {
100
- var valprops = this.props.type === 'number' ? {} : {
101
- value: this.state.value
102
- };
103
- var className = this.props.className;
104
- className = 'dash-input' + (className ? " ".concat(className) : '');
105
- return /*#__PURE__*/_react.default.createElement(_LoadingElement.default, _extends({
106
- elementType: 'input',
107
- className: className,
108
- ref: this.input,
109
- onBlur: this.onBlur,
110
- onChange: this.onChange,
111
- onKeyPress: this.onKeyPress
112
- }, valprops, (0, _ramda.pick)(inputProps, this.props)));
51
+ var valueAsNumber = convert(value);
52
+ this.setInputValue((0, _ramda.isNil)(valueAsNumber) ? value : valueAsNumber, nextProps.value);
53
+ if (this.props.type !== 'number') {
54
+ this.setState({
55
+ value: nextProps.value
56
+ });
113
57
  }
114
- }, {
115
- key: "setInputValue",
116
- value: function setInputValue(base, value) {
117
- var __value = value;
118
- base = this.input.current.checkValidity() ? convert(base) : NaN;
119
- value = convert(value);
120
- if (!isEquivalent(base, value)) {
121
- this.input.current.value = (0, _fastIsnumeric.default)(value) ? value : __value;
122
- }
58
+ }
59
+ componentDidMount() {
60
+ var value = this.input.current.value;
61
+ var valueAsNumber = convert(value);
62
+ this.setInputValue((0, _ramda.isNil)(valueAsNumber) ? value : valueAsNumber, this.props.value);
63
+ }
64
+ UNSAFE_componentWillMount() {
65
+ if (this.props.type !== 'number') {
66
+ this.setState({
67
+ value: this.props.value
68
+ });
123
69
  }
124
- }, {
125
- key: "setPropValue",
126
- value: function setPropValue(base, value) {
127
- base = convert(base);
128
- value = this.input.current.checkValidity() ? convert(value) : NaN;
129
- if (!isEquivalent(base, value)) {
130
- this.props.setProps({
131
- value
132
- });
133
- }
70
+ }
71
+ render() {
72
+ var valprops = this.props.type === 'number' ? {} : {
73
+ value: this.state.value
74
+ };
75
+ var className = this.props.className;
76
+ className = 'dash-input' + (className ? " ".concat(className) : '');
77
+ return /*#__PURE__*/_react.default.createElement(_LoadingElement.default, _extends({
78
+ elementType: 'input',
79
+ className: className,
80
+ ref: this.input,
81
+ onBlur: this.onBlur,
82
+ onChange: this.onChange,
83
+ onKeyPress: this.onKeyPress
84
+ }, valprops, (0, _ramda.pick)(inputProps, this.props)));
85
+ }
86
+ setInputValue(base, value) {
87
+ var __value = value;
88
+ base = this.input.current.checkValidity() ? convert(base) : NaN;
89
+ value = convert(value);
90
+ if (!isEquivalent(base, value)) {
91
+ this.input.current.value = (0, _fastIsnumeric.default)(value) ? value : __value;
134
92
  }
135
- }, {
136
- key: "onEvent",
137
- value: function onEvent() {
138
- var value = this.input.current.value;
139
- var valueAsNumber = convert(value);
140
- if (this.props.type === 'number') {
141
- this.setPropValue(this.props.value, (0, _ramda.isNil)(valueAsNumber) ? value : valueAsNumber);
142
- } else {
143
- this.props.setProps({
144
- value
145
- });
146
- }
147
- this.setState({
148
- pendingEvent: undefined
93
+ }
94
+ setPropValue(base, value) {
95
+ base = convert(base);
96
+ value = this.input.current.checkValidity() ? convert(value) : NaN;
97
+ if (!isEquivalent(base, value)) {
98
+ this.props.setProps({
99
+ value
149
100
  });
150
101
  }
151
- }, {
152
- key: "debounceEvent",
153
- value: function debounceEvent() {
154
- var _this$state,
155
- _this2 = this;
156
- var seconds = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0.5;
157
- var value = this.input.current.value;
158
- window.clearTimeout((_this$state = this.state) === null || _this$state === void 0 ? void 0 : _this$state.pendingEvent);
159
- var pendingEvent = window.setTimeout(function () {
160
- _this2.onEvent();
161
- }, seconds * 1000);
162
- this.setState({
163
- value,
164
- pendingEvent
102
+ }
103
+ onEvent() {
104
+ var value = this.input.current.value;
105
+ var valueAsNumber = convert(value);
106
+ if (this.props.type === 'number') {
107
+ this.setPropValue(this.props.value, (0, _ramda.isNil)(valueAsNumber) ? value : valueAsNumber);
108
+ } else {
109
+ this.props.setProps({
110
+ value
165
111
  });
166
112
  }
167
- }, {
168
- key: "onBlur",
169
- value: function onBlur() {
113
+ this.setState({
114
+ pendingEvent: undefined
115
+ });
116
+ }
117
+ debounceEvent() {
118
+ var _this$state;
119
+ var seconds = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0.5;
120
+ var value = this.input.current.value;
121
+ window.clearTimeout((_this$state = this.state) === null || _this$state === void 0 ? void 0 : _this$state.pendingEvent);
122
+ var pendingEvent = window.setTimeout(() => {
123
+ this.onEvent();
124
+ }, seconds * 1000);
125
+ this.setState({
126
+ value,
127
+ pendingEvent
128
+ });
129
+ }
130
+ onBlur() {
131
+ this.props.setProps({
132
+ n_blur: this.props.n_blur + 1,
133
+ n_blur_timestamp: Date.now()
134
+ });
135
+ this.input.current.checkValidity();
136
+ return this.props.debounce === true && this.onEvent();
137
+ }
138
+ onKeyPress(e) {
139
+ if (e.key === 'Enter') {
170
140
  this.props.setProps({
171
- n_blur: this.props.n_blur + 1,
172
- n_blur_timestamp: Date.now()
141
+ n_submit: this.props.n_submit + 1,
142
+ n_submit_timestamp: Date.now()
173
143
  });
174
144
  this.input.current.checkValidity();
175
- return this.props.debounce === true && this.onEvent();
176
145
  }
177
- }, {
178
- key: "onKeyPress",
179
- value: function onKeyPress(e) {
180
- if (e.key === 'Enter') {
181
- this.props.setProps({
182
- n_submit: this.props.n_submit + 1,
183
- n_submit_timestamp: Date.now()
184
- });
185
- this.input.current.checkValidity();
146
+ return this.props.debounce === true && e.key === 'Enter' && this.onEvent();
147
+ }
148
+ onChange() {
149
+ var debounce = this.props.debounce;
150
+ if (debounce) {
151
+ if (Number.isFinite(debounce)) {
152
+ this.debounceEvent(debounce);
186
153
  }
187
- return this.props.debounce === true && e.key === 'Enter' && this.onEvent();
188
- }
189
- }, {
190
- key: "onChange",
191
- value: function onChange() {
192
- var debounce = this.props.debounce;
193
- if (debounce) {
194
- if (Number.isFinite(debounce)) {
195
- this.debounceEvent(debounce);
196
- }
197
- if (this.props.type !== 'number') {
198
- this.setState({
199
- value: this.input.current.value
200
- });
201
- }
202
- } else {
203
- this.onEvent();
154
+ if (this.props.type !== 'number') {
155
+ this.setState({
156
+ value: this.input.current.value
157
+ });
204
158
  }
159
+ } else {
160
+ this.onEvent();
205
161
  }
206
- }]);
207
- }(_react.PureComponent);
162
+ }
163
+ }
164
+ exports.default = Input;
208
165
  Input.defaultProps = {
209
166
  type: 'text',
210
167
  n_blur: 0,