dash-core-components 3.0.2 → 3.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/dash_core_components/async-datepicker.js +1 -1
  2. package/dash_core_components/async-datepicker.js.map +1 -1
  3. package/dash_core_components/async-dropdown.js +1 -1
  4. package/dash_core_components/async-dropdown.js.map +1 -1
  5. package/dash_core_components/async-graph.js +1 -1
  6. package/dash_core_components/async-graph.js.map +1 -1
  7. package/dash_core_components/async-highlight.js +1 -1
  8. package/dash_core_components/async-highlight.js.map +1 -1
  9. package/dash_core_components/async-markdown.js +1 -1
  10. package/dash_core_components/async-markdown.js.map +1 -1
  11. package/dash_core_components/async-mathjax.js +1 -1
  12. package/dash_core_components/async-slider.js +1 -1
  13. package/dash_core_components/async-slider.js.map +1 -1
  14. package/dash_core_components/async-upload.js +1 -1
  15. package/dash_core_components/async-upload.js.map +1 -1
  16. package/dash_core_components/dash_core_components-shared.js +1 -1
  17. package/dash_core_components/dash_core_components-shared.js.map +1 -1
  18. package/dash_core_components/dash_core_components.js +1 -1
  19. package/dash_core_components/dash_core_components.js.map +1 -1
  20. package/lib/components/Checklist.react.js +46 -63
  21. package/lib/components/Clipboard.react.js +172 -218
  22. package/lib/components/ConfirmDialog.react.js +34 -61
  23. package/lib/components/ConfirmDialogProvider.react.js +21 -44
  24. package/lib/components/DatePickerRange.react.js +7 -26
  25. package/lib/components/DatePickerSingle.react.js +7 -26
  26. package/lib/components/Download.react.js +22 -45
  27. package/lib/components/Dropdown.react.js +7 -26
  28. package/lib/components/Geolocation.react.js +64 -91
  29. package/lib/components/Graph.react.js +70 -97
  30. package/lib/components/Input.react.js +119 -162
  31. package/lib/components/Interval.react.js +55 -86
  32. package/lib/components/Link.react.js +6 -6
  33. package/lib/components/Loading.react.js +31 -35
  34. package/lib/components/Location.react.js +97 -126
  35. package/lib/components/Markdown.react.js +15 -35
  36. package/lib/components/RadioItems.react.js +45 -63
  37. package/lib/components/RangeSlider.react.js +7 -26
  38. package/lib/components/Slider.react.js +7 -26
  39. package/lib/components/Store.react.js +128 -176
  40. package/lib/components/Tab.react.js +1 -1
  41. package/lib/components/Tabs.react.js +97 -126
  42. package/lib/components/Textarea.react.js +6 -6
  43. package/lib/components/Tooltip.react.js +3 -3
  44. package/lib/components/Upload.react.js +7 -26
  45. package/lib/fragments/DatePickerRange.react.js +150 -181
  46. package/lib/fragments/DatePickerSingle.react.js +103 -134
  47. package/lib/fragments/Dropdown.react.js +11 -19
  48. package/lib/fragments/Graph.privateprops.js +3 -9
  49. package/lib/fragments/Graph.react.js +302 -370
  50. package/lib/fragments/Loading/spinners/CircleSpinner.js +2 -4
  51. package/lib/fragments/Loading/spinners/CubeSpinner.js +2 -4
  52. package/lib/fragments/Loading/spinners/DefaultSpinner.js +2 -4
  53. package/lib/fragments/Loading/spinners/DotSpinner.js +2 -4
  54. package/lib/fragments/Loading/spinners/GraphSpinner.js +2 -4
  55. package/lib/fragments/Markdown.react.js +119 -158
  56. package/lib/fragments/Math.react.js +23 -47
  57. package/lib/fragments/RangeSlider.react.js +110 -133
  58. package/lib/fragments/Slider.react.js +110 -133
  59. package/lib/fragments/Upload.react.js +82 -99
  60. package/lib/utils/DatePickerPersistence.js +2 -4
  61. package/lib/utils/LazyLoader/datePickerRange.js +2 -3
  62. package/lib/utils/LazyLoader/datePickerSingle.js +2 -3
  63. package/lib/utils/LazyLoader/dropdown.js +2 -3
  64. package/lib/utils/LazyLoader/graph.js +2 -3
  65. package/lib/utils/LazyLoader/hljs.js +2 -5
  66. package/lib/utils/LazyLoader/markdown.js +2 -3
  67. package/lib/utils/LazyLoader/mathjax.js +2 -5
  68. package/lib/utils/LazyLoader/plotly.js +7 -6
  69. package/lib/utils/LazyLoader/rangeSlider.js +2 -3
  70. package/lib/utils/LazyLoader/slider.js +2 -3
  71. package/lib/utils/LazyLoader/upload.js +2 -3
  72. package/lib/utils/LoadingElement.js +2 -2
  73. package/lib/utils/MarkdownHighlighter.js +5 -6
  74. package/lib/utils/ResizeDetector.js +8 -12
  75. package/lib/utils/computeSliderMarkers.js +29 -49
  76. package/lib/utils/computeSliderStyle.js +4 -3
  77. package/lib/utils/convertToMoment.js +5 -6
  78. package/lib/utils/formatSliderTooltip.js +6 -8
  79. package/lib/utils/optionTypes.js +8 -9
  80. package/package.json +7 -7
@@ -17,204 +17,173 @@ 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 _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
21
- 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); } }
22
- function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
23
20
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
24
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); }
25
- function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
26
- 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); }
27
- function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
28
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
29
- function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
30
- 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); }
31
- function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
32
- var DatePickerRange = exports.default = /*#__PURE__*/function (_Component) {
33
- function DatePickerRange(props) {
34
- var _this;
35
- _classCallCheck(this, DatePickerRange);
36
- _this = _callSuper(this, DatePickerRange, [props]);
37
- _this.propsToState = _this.propsToState.bind(_this);
38
- _this.onDatesChange = _this.onDatesChange.bind(_this);
39
- _this.isOutsideRange = _this.isOutsideRange.bind(_this);
40
- _this.state = {
22
+ class DatePickerRange extends _react.Component {
23
+ constructor(props) {
24
+ super(props);
25
+ this.propsToState = this.propsToState.bind(this);
26
+ this.onDatesChange = this.onDatesChange.bind(this);
27
+ this.isOutsideRange = this.isOutsideRange.bind(this);
28
+ this.state = {
41
29
  focused: false,
42
30
  start_date_id: props.start_date_id || (0, _uniqid.default)(),
43
31
  end_date_id: props.end_date_id || (0, _uniqid.default)()
44
32
  };
45
- return _this;
46
33
  }
47
- _inherits(DatePickerRange, _Component);
48
- return _createClass(DatePickerRange, [{
49
- key: "propsToState",
50
- value: function propsToState(newProps) {
51
- var force = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
52
- var state = {};
53
- if (force || newProps.start_date !== this.props.start_date) {
54
- state.start_date = newProps.start_date;
55
- }
56
- if (force || newProps.end_date !== this.props.end_date) {
57
- state.end_date = newProps.end_date;
58
- }
59
- if (force || newProps.max_date_allowed !== this.props.max_date_allowed) {
60
- state.max_date_allowed = (0, _convertToMoment3.default)(newProps, ['max_date_allowed']).max_date_allowed;
61
- }
62
- if (force || newProps.min_date_allowed !== this.props.min_date_allowed) {
63
- state.min_date_allowed = (0, _convertToMoment3.default)(newProps, ['min_date_allowed']).min_date_allowed;
64
- }
65
- if (force || newProps.disabled_days !== this.props.disabled_days) {
66
- state.disabled_days = (0, _convertToMoment3.default)(newProps, ['disabled_days']).disabled_days;
67
- }
68
- if (Object.keys(state).length) {
69
- this.setState(state);
70
- }
34
+ propsToState(newProps) {
35
+ var force = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
36
+ var state = {};
37
+ if (force || newProps.start_date !== this.props.start_date) {
38
+ state.start_date = newProps.start_date;
71
39
  }
72
- }, {
73
- key: "UNSAFE_componentWillReceiveProps",
74
- value: function UNSAFE_componentWillReceiveProps(newProps) {
75
- this.propsToState(newProps);
40
+ if (force || newProps.end_date !== this.props.end_date) {
41
+ state.end_date = newProps.end_date;
76
42
  }
77
- }, {
78
- key: "UNSAFE_componentWillMount",
79
- value: function UNSAFE_componentWillMount() {
80
- this.propsToState(this.props, true);
43
+ if (force || newProps.max_date_allowed !== this.props.max_date_allowed) {
44
+ state.max_date_allowed = (0, _convertToMoment3.default)(newProps, ['max_date_allowed']).max_date_allowed;
81
45
  }
82
- }, {
83
- key: "onDatesChange",
84
- value: function onDatesChange(_ref) {
85
- var start_date = _ref.startDate,
86
- end_date = _ref.endDate;
87
- var _this$props = this.props,
88
- setProps = _this$props.setProps,
89
- updatemode = _this$props.updatemode,
90
- clearable = _this$props.clearable;
91
- var oldMomentDates = (0, _convertToMoment3.default)(this.state, ['start_date', 'end_date']);
92
- if (start_date && !start_date.isSame(oldMomentDates.start_date)) {
93
- if (updatemode === 'singledate') {
94
- setProps({
95
- start_date: start_date.format('YYYY-MM-DD')
96
- });
97
- } else {
98
- this.setState({
99
- start_date: start_date.format('YYYY-MM-DD')
100
- });
101
- }
102
- }
103
- if (end_date && !end_date.isSame(oldMomentDates.end_date)) {
104
- if (updatemode === 'singledate') {
105
- setProps({
106
- end_date: end_date.format('YYYY-MM-DD')
107
- });
108
- } else if (updatemode === 'bothdates') {
109
- setProps({
110
- start_date: this.state.start_date,
111
- end_date: end_date.format('YYYY-MM-DD')
112
- });
113
- }
46
+ if (force || newProps.min_date_allowed !== this.props.min_date_allowed) {
47
+ state.min_date_allowed = (0, _convertToMoment3.default)(newProps, ['min_date_allowed']).min_date_allowed;
48
+ }
49
+ if (force || newProps.disabled_days !== this.props.disabled_days) {
50
+ state.disabled_days = (0, _convertToMoment3.default)(newProps, ['disabled_days']).disabled_days;
51
+ }
52
+ if (Object.keys(state).length) {
53
+ this.setState(state);
54
+ }
55
+ }
56
+ UNSAFE_componentWillReceiveProps(newProps) {
57
+ this.propsToState(newProps);
58
+ }
59
+ UNSAFE_componentWillMount() {
60
+ this.propsToState(this.props, true);
61
+ }
62
+ onDatesChange(_ref) {
63
+ var start_date = _ref.startDate,
64
+ end_date = _ref.endDate;
65
+ var _this$props = this.props,
66
+ setProps = _this$props.setProps,
67
+ updatemode = _this$props.updatemode,
68
+ clearable = _this$props.clearable;
69
+ var oldMomentDates = (0, _convertToMoment3.default)(this.state, ['start_date', 'end_date']);
70
+ if (start_date && !start_date.isSame(oldMomentDates.start_date)) {
71
+ if (updatemode === 'singledate') {
72
+ setProps({
73
+ start_date: start_date.format('YYYY-MM-DD')
74
+ });
75
+ } else {
76
+ this.setState({
77
+ start_date: start_date.format('YYYY-MM-DD')
78
+ });
114
79
  }
115
- if (clearable && !start_date && !end_date && (oldMomentDates.start_date !== start_date || oldMomentDates.end_date !== end_date)) {
80
+ }
81
+ if (end_date && !end_date.isSame(oldMomentDates.end_date)) {
82
+ if (updatemode === 'singledate') {
116
83
  setProps({
117
- start_date: null,
118
- end_date: null
84
+ end_date: end_date.format('YYYY-MM-DD')
85
+ });
86
+ } else if (updatemode === 'bothdates') {
87
+ setProps({
88
+ start_date: this.state.start_date,
89
+ end_date: end_date.format('YYYY-MM-DD')
119
90
  });
120
91
  }
121
92
  }
122
- }, {
123
- key: "isOutsideRange",
124
- value: function isOutsideRange(date) {
125
- return this.state.min_date_allowed && date.isBefore(this.state.min_date_allowed) || this.state.max_date_allowed && date.isAfter(this.state.max_date_allowed) || this.state.disabled_days && this.state.disabled_days.some(function (d) {
126
- return date.isSame(d, 'day');
93
+ if (clearable && !start_date && !end_date && (oldMomentDates.start_date !== start_date || oldMomentDates.end_date !== end_date)) {
94
+ setProps({
95
+ start_date: null,
96
+ end_date: null
127
97
  });
128
98
  }
129
- }, {
130
- key: "render",
131
- value: function render() {
132
- var _this2 = this;
133
- var focusedInput = this.state.focusedInput;
134
- var _this$props2 = this.props,
135
- calendar_orientation = _this$props2.calendar_orientation,
136
- clearable = _this$props2.clearable,
137
- day_size = _this$props2.day_size,
138
- disabled = _this$props2.disabled,
139
- display_format = _this$props2.display_format,
140
- end_date_placeholder_text = _this$props2.end_date_placeholder_text,
141
- first_day_of_week = _this$props2.first_day_of_week,
142
- is_RTL = _this$props2.is_RTL,
143
- minimum_nights = _this$props2.minimum_nights,
144
- month_format = _this$props2.month_format,
145
- number_of_months_shown = _this$props2.number_of_months_shown,
146
- reopen_calendar_on_clear = _this$props2.reopen_calendar_on_clear,
147
- show_outside_days = _this$props2.show_outside_days,
148
- start_date_placeholder_text = _this$props2.start_date_placeholder_text,
149
- stay_open_on_select = _this$props2.stay_open_on_select,
150
- with_full_screen_portal = _this$props2.with_full_screen_portal,
151
- with_portal = _this$props2.with_portal,
152
- id = _this$props2.id,
153
- style = _this$props2.style,
154
- className = _this$props2.className,
155
- start_date_id = _this$props2.start_date_id,
156
- end_date_id = _this$props2.end_date_id;
157
- var _convertToMoment = (0, _convertToMoment3.default)(this.props, ['initial_visible_month']),
158
- initial_visible_month = _convertToMoment.initial_visible_month;
159
- var _convertToMoment2 = (0, _convertToMoment3.default)(this.state, ['start_date', 'end_date']),
160
- start_date = _convertToMoment2.start_date,
161
- end_date = _convertToMoment2.end_date;
162
- var verticalFlag = calendar_orientation !== 'vertical';
163
- var DatePickerWrapperStyles = _objectSpread({
164
- position: 'relative',
165
- display: 'inline-block'
166
- }, style);
99
+ }
100
+ isOutsideRange(date) {
101
+ return this.state.min_date_allowed && date.isBefore(this.state.min_date_allowed) || this.state.max_date_allowed && date.isAfter(this.state.max_date_allowed) || this.state.disabled_days && this.state.disabled_days.some(d => date.isSame(d, 'day'));
102
+ }
103
+ render() {
104
+ var focusedInput = this.state.focusedInput;
105
+ var _this$props2 = this.props,
106
+ calendar_orientation = _this$props2.calendar_orientation,
107
+ clearable = _this$props2.clearable,
108
+ day_size = _this$props2.day_size,
109
+ disabled = _this$props2.disabled,
110
+ display_format = _this$props2.display_format,
111
+ end_date_placeholder_text = _this$props2.end_date_placeholder_text,
112
+ first_day_of_week = _this$props2.first_day_of_week,
113
+ is_RTL = _this$props2.is_RTL,
114
+ minimum_nights = _this$props2.minimum_nights,
115
+ month_format = _this$props2.month_format,
116
+ number_of_months_shown = _this$props2.number_of_months_shown,
117
+ reopen_calendar_on_clear = _this$props2.reopen_calendar_on_clear,
118
+ show_outside_days = _this$props2.show_outside_days,
119
+ start_date_placeholder_text = _this$props2.start_date_placeholder_text,
120
+ stay_open_on_select = _this$props2.stay_open_on_select,
121
+ with_full_screen_portal = _this$props2.with_full_screen_portal,
122
+ with_portal = _this$props2.with_portal,
123
+ id = _this$props2.id,
124
+ style = _this$props2.style,
125
+ className = _this$props2.className,
126
+ start_date_id = _this$props2.start_date_id,
127
+ end_date_id = _this$props2.end_date_id;
128
+ var _convertToMoment = (0, _convertToMoment3.default)(this.props, ['initial_visible_month']),
129
+ initial_visible_month = _convertToMoment.initial_visible_month;
130
+ var _convertToMoment2 = (0, _convertToMoment3.default)(this.state, ['start_date', 'end_date']),
131
+ start_date = _convertToMoment2.start_date,
132
+ end_date = _convertToMoment2.end_date;
133
+ var verticalFlag = calendar_orientation !== 'vertical';
134
+ var DatePickerWrapperStyles = _objectSpread({
135
+ position: 'relative',
136
+ display: 'inline-block'
137
+ }, style);
167
138
 
168
- // the height in px of the top part of the calendar (that holds
169
- // the name of the month)
170
- var baselineHeight = 145;
171
- return /*#__PURE__*/_react.default.createElement(_LoadingElement.default, {
172
- id: id,
173
- style: DatePickerWrapperStyles,
174
- className: className
175
- }, /*#__PURE__*/_react.default.createElement(_reactDates.DateRangePicker, {
176
- daySize: day_size,
177
- disabled: disabled,
178
- displayFormat: display_format,
179
- enableOutsideDays: show_outside_days,
180
- endDate: end_date,
181
- endDatePlaceholderText: end_date_placeholder_text,
182
- firstDayOfWeek: first_day_of_week,
183
- focusedInput: focusedInput,
184
- initialVisibleMonth: function initialVisibleMonth() {
185
- if (initial_visible_month) {
186
- return initial_visible_month;
187
- } else if (end_date && focusedInput === 'endDate') {
188
- return end_date;
189
- } else if (start_date && focusedInput === 'startDate') {
190
- return start_date;
191
- }
139
+ // the height in px of the top part of the calendar (that holds
140
+ // the name of the month)
141
+ var baselineHeight = 145;
142
+ return /*#__PURE__*/_react.default.createElement(_LoadingElement.default, {
143
+ id: id,
144
+ style: DatePickerWrapperStyles,
145
+ className: className
146
+ }, /*#__PURE__*/_react.default.createElement(_reactDates.DateRangePicker, {
147
+ daySize: day_size,
148
+ disabled: disabled,
149
+ displayFormat: display_format,
150
+ enableOutsideDays: show_outside_days,
151
+ endDate: end_date,
152
+ endDatePlaceholderText: end_date_placeholder_text,
153
+ firstDayOfWeek: first_day_of_week,
154
+ focusedInput: focusedInput,
155
+ initialVisibleMonth: () => {
156
+ if (initial_visible_month) {
157
+ return initial_visible_month;
158
+ } else if (end_date && focusedInput === 'endDate') {
159
+ return end_date;
160
+ } else if (start_date && focusedInput === 'startDate') {
192
161
  return start_date;
193
- },
194
- isOutsideRange: this.isOutsideRange,
195
- isRTL: is_RTL,
196
- keepOpenOnDateSelect: stay_open_on_select,
197
- minimumNights: minimum_nights,
198
- monthFormat: month_format,
199
- numberOfMonths: number_of_months_shown,
200
- onDatesChange: this.onDatesChange,
201
- onFocusChange: function onFocusChange(focusedInput) {
202
- return _this2.setState({
203
- focusedInput
204
- });
205
- },
206
- orientation: calendar_orientation,
207
- reopenPickerOnClearDates: reopen_calendar_on_clear,
208
- showClearDates: clearable,
209
- startDate: start_date,
210
- startDatePlaceholderText: start_date_placeholder_text,
211
- withFullScreenPortal: with_full_screen_portal && verticalFlag,
212
- withPortal: with_portal && verticalFlag,
213
- startDateId: start_date_id || this.state.start_date_id,
214
- endDateId: end_date_id || this.state.end_date_id,
215
- verticalHeight: baselineHeight + day_size * 6 + 'px'
216
- }));
217
- }
218
- }]);
219
- }(_react.Component);
162
+ }
163
+ return start_date;
164
+ },
165
+ isOutsideRange: this.isOutsideRange,
166
+ isRTL: is_RTL,
167
+ keepOpenOnDateSelect: stay_open_on_select,
168
+ minimumNights: minimum_nights,
169
+ monthFormat: month_format,
170
+ numberOfMonths: number_of_months_shown,
171
+ onDatesChange: this.onDatesChange,
172
+ onFocusChange: focusedInput => this.setState({
173
+ focusedInput
174
+ }),
175
+ orientation: calendar_orientation,
176
+ reopenPickerOnClearDates: reopen_calendar_on_clear,
177
+ showClearDates: clearable,
178
+ startDate: start_date,
179
+ startDatePlaceholderText: start_date_placeholder_text,
180
+ withFullScreenPortal: with_full_screen_portal && verticalFlag,
181
+ withPortal: with_portal && verticalFlag,
182
+ startDateId: start_date_id || this.state.start_date_id,
183
+ endDateId: end_date_id || this.state.end_date_id,
184
+ verticalHeight: baselineHeight + day_size * 6 + 'px'
185
+ }));
186
+ }
187
+ }
188
+ exports.default = DatePickerRange;
220
189
  DatePickerRange.propTypes = _DatePickerRange.propTypes;
@@ -17,148 +17,117 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: 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 _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
21
- 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); } }
22
- function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
23
20
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
24
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); }
25
- function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
26
- 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); }
27
- function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
28
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
29
- function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
30
- 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); }
31
- function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
32
- var DatePickerSingle = exports.default = /*#__PURE__*/function (_Component) {
33
- function DatePickerSingle() {
34
- var _this;
35
- _classCallCheck(this, DatePickerSingle);
36
- _this = _callSuper(this, DatePickerSingle);
37
- _this.propsToState = _this.propsToState.bind(_this);
38
- _this.isOutsideRange = _this.isOutsideRange.bind(_this);
39
- _this.onDateChange = _this.onDateChange.bind(_this);
40
- _this.state = {
22
+ class DatePickerSingle extends _react.Component {
23
+ constructor() {
24
+ super();
25
+ this.propsToState = this.propsToState.bind(this);
26
+ this.isOutsideRange = this.isOutsideRange.bind(this);
27
+ this.onDateChange = this.onDateChange.bind(this);
28
+ this.state = {
41
29
  focused: false
42
30
  };
43
- return _this;
44
31
  }
45
- _inherits(DatePickerSingle, _Component);
46
- return _createClass(DatePickerSingle, [{
47
- key: "propsToState",
48
- value: function propsToState(newProps) {
49
- var force = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
50
- var state = {};
51
- if (force || newProps.max_date_allowed !== this.props.max_date_allowed) {
52
- state.max_date_allowed = (0, _convertToMoment2.default)(newProps, ['max_date_allowed']).max_date_allowed;
53
- }
54
- if (force || newProps.min_date_allowed !== this.props.min_date_allowed) {
55
- state.min_date_allowed = (0, _convertToMoment2.default)(newProps, ['min_date_allowed']).min_date_allowed;
56
- }
57
- if (force || newProps.disabled_days !== this.props.disabled_days) {
58
- state.disabled_days = (0, _convertToMoment2.default)(newProps, ['disabled_days']).disabled_days;
59
- }
60
- if (Object.keys(state).length) {
61
- this.setState(state);
62
- }
32
+ propsToState(newProps) {
33
+ var force = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
34
+ var state = {};
35
+ if (force || newProps.max_date_allowed !== this.props.max_date_allowed) {
36
+ state.max_date_allowed = (0, _convertToMoment2.default)(newProps, ['max_date_allowed']).max_date_allowed;
63
37
  }
64
- }, {
65
- key: "UNSAFE_componentWillReceiveProps",
66
- value: function UNSAFE_componentWillReceiveProps(newProps) {
67
- this.propsToState(newProps);
38
+ if (force || newProps.min_date_allowed !== this.props.min_date_allowed) {
39
+ state.min_date_allowed = (0, _convertToMoment2.default)(newProps, ['min_date_allowed']).min_date_allowed;
68
40
  }
69
- }, {
70
- key: "UNSAFE_componentWillMount",
71
- value: function UNSAFE_componentWillMount() {
72
- this.propsToState(this.props, true);
41
+ if (force || newProps.disabled_days !== this.props.disabled_days) {
42
+ state.disabled_days = (0, _convertToMoment2.default)(newProps, ['disabled_days']).disabled_days;
73
43
  }
74
- }, {
75
- key: "isOutsideRange",
76
- value: function isOutsideRange(date) {
77
- return this.state.min_date_allowed && date.isBefore(this.state.min_date_allowed) || this.state.max_date_allowed && date.isAfter(this.state.max_date_allowed) || this.state.disabled_days && this.state.disabled_days.some(function (d) {
78
- return date.isSame(d, 'day');
79
- });
44
+ if (Object.keys(state).length) {
45
+ this.setState(state);
80
46
  }
81
- }, {
82
- key: "onDateChange",
83
- value: function onDateChange(date) {
84
- var setProps = this.props.setProps;
85
- var payload = {
86
- date: date ? date.format('YYYY-MM-DD') : null
87
- };
88
- setProps(payload);
89
- }
90
- }, {
91
- key: "render",
92
- value: function render() {
93
- var _this2 = this;
94
- var focused = this.state.focused;
95
- var _this$props = this.props,
96
- calendar_orientation = _this$props.calendar_orientation,
97
- clearable = _this$props.clearable,
98
- day_size = _this$props.day_size,
99
- disabled = _this$props.disabled,
100
- display_format = _this$props.display_format,
101
- first_day_of_week = _this$props.first_day_of_week,
102
- is_RTL = _this$props.is_RTL,
103
- month_format = _this$props.month_format,
104
- number_of_months_shown = _this$props.number_of_months_shown,
105
- placeholder = _this$props.placeholder,
106
- reopen_calendar_on_clear = _this$props.reopen_calendar_on_clear,
107
- show_outside_days = _this$props.show_outside_days,
108
- stay_open_on_select = _this$props.stay_open_on_select,
109
- with_full_screen_portal = _this$props.with_full_screen_portal,
110
- with_portal = _this$props.with_portal,
111
- id = _this$props.id,
112
- style = _this$props.style,
113
- className = _this$props.className;
114
- var _convertToMoment = (0, _convertToMoment2.default)(this.props, ['date', 'initial_visible_month']),
115
- date = _convertToMoment.date,
116
- initial_visible_month = _convertToMoment.initial_visible_month;
117
- var verticalFlag = calendar_orientation !== 'vertical';
118
- var DatePickerWrapperStyles = _objectSpread({
119
- position: 'relative',
120
- display: 'inline-block'
121
- }, style);
47
+ }
48
+ UNSAFE_componentWillReceiveProps(newProps) {
49
+ this.propsToState(newProps);
50
+ }
51
+ UNSAFE_componentWillMount() {
52
+ this.propsToState(this.props, true);
53
+ }
54
+ isOutsideRange(date) {
55
+ return this.state.min_date_allowed && date.isBefore(this.state.min_date_allowed) || this.state.max_date_allowed && date.isAfter(this.state.max_date_allowed) || this.state.disabled_days && this.state.disabled_days.some(d => date.isSame(d, 'day'));
56
+ }
57
+ onDateChange(date) {
58
+ var setProps = this.props.setProps;
59
+ var payload = {
60
+ date: date ? date.format('YYYY-MM-DD') : null
61
+ };
62
+ setProps(payload);
63
+ }
64
+ render() {
65
+ var focused = this.state.focused;
66
+ var _this$props = this.props,
67
+ calendar_orientation = _this$props.calendar_orientation,
68
+ clearable = _this$props.clearable,
69
+ day_size = _this$props.day_size,
70
+ disabled = _this$props.disabled,
71
+ display_format = _this$props.display_format,
72
+ first_day_of_week = _this$props.first_day_of_week,
73
+ is_RTL = _this$props.is_RTL,
74
+ month_format = _this$props.month_format,
75
+ number_of_months_shown = _this$props.number_of_months_shown,
76
+ placeholder = _this$props.placeholder,
77
+ reopen_calendar_on_clear = _this$props.reopen_calendar_on_clear,
78
+ show_outside_days = _this$props.show_outside_days,
79
+ stay_open_on_select = _this$props.stay_open_on_select,
80
+ with_full_screen_portal = _this$props.with_full_screen_portal,
81
+ with_portal = _this$props.with_portal,
82
+ id = _this$props.id,
83
+ style = _this$props.style,
84
+ className = _this$props.className;
85
+ var _convertToMoment = (0, _convertToMoment2.default)(this.props, ['date', 'initial_visible_month']),
86
+ date = _convertToMoment.date,
87
+ initial_visible_month = _convertToMoment.initial_visible_month;
88
+ var verticalFlag = calendar_orientation !== 'vertical';
89
+ var DatePickerWrapperStyles = _objectSpread({
90
+ position: 'relative',
91
+ display: 'inline-block'
92
+ }, style);
122
93
 
123
- // the height in px of the top part of the calendar (that holds
124
- // the name of the month)
125
- var baselineHeight = 145;
126
- return /*#__PURE__*/_react.default.createElement(_LoadingElement.default, {
127
- id: id,
128
- style: DatePickerWrapperStyles,
129
- className: className
130
- }, /*#__PURE__*/_react.default.createElement(_reactDates.SingleDatePicker, {
131
- date: date,
132
- onDateChange: this.onDateChange,
133
- focused: focused,
134
- onFocusChange: function onFocusChange(_ref) {
135
- var focused = _ref.focused;
136
- return _this2.setState({
137
- focused
138
- });
139
- },
140
- initialVisibleMonth: function initialVisibleMonth() {
141
- return date || initial_visible_month || (0, _moment.default)();
142
- },
143
- isOutsideRange: this.isOutsideRange,
144
- numberOfMonths: number_of_months_shown,
145
- withPortal: with_portal && verticalFlag,
146
- withFullScreenPortal: with_full_screen_portal && verticalFlag,
147
- firstDayOfWeek: first_day_of_week,
148
- enableOutsideDays: show_outside_days,
149
- monthFormat: month_format,
150
- displayFormat: display_format,
151
- placeholder: placeholder,
152
- showClearDate: clearable,
153
- disabled: disabled,
154
- keepOpenOnDateSelect: stay_open_on_select,
155
- reopenPickerOnClearDate: reopen_calendar_on_clear,
156
- isRTL: is_RTL,
157
- orientation: calendar_orientation,
158
- daySize: day_size,
159
- verticalHeight: baselineHeight + day_size * 6 + 'px'
160
- }));
161
- }
162
- }]);
163
- }(_react.Component);
94
+ // the height in px of the top part of the calendar (that holds
95
+ // the name of the month)
96
+ var baselineHeight = 145;
97
+ return /*#__PURE__*/_react.default.createElement(_LoadingElement.default, {
98
+ id: id,
99
+ style: DatePickerWrapperStyles,
100
+ className: className
101
+ }, /*#__PURE__*/_react.default.createElement(_reactDates.SingleDatePicker, {
102
+ date: date,
103
+ onDateChange: this.onDateChange,
104
+ focused: focused,
105
+ onFocusChange: _ref => {
106
+ var focused = _ref.focused;
107
+ return this.setState({
108
+ focused
109
+ });
110
+ },
111
+ initialVisibleMonth: () => date || initial_visible_month || (0, _moment.default)(),
112
+ isOutsideRange: this.isOutsideRange,
113
+ numberOfMonths: number_of_months_shown,
114
+ withPortal: with_portal && verticalFlag,
115
+ withFullScreenPortal: with_full_screen_portal && verticalFlag,
116
+ firstDayOfWeek: first_day_of_week,
117
+ enableOutsideDays: show_outside_days,
118
+ monthFormat: month_format,
119
+ displayFormat: display_format,
120
+ placeholder: placeholder,
121
+ showClearDate: clearable,
122
+ disabled: disabled,
123
+ keepOpenOnDateSelect: stay_open_on_select,
124
+ reopenPickerOnClearDate: reopen_calendar_on_clear,
125
+ isRTL: is_RTL,
126
+ orientation: calendar_orientation,
127
+ daySize: day_size,
128
+ verticalHeight: baselineHeight + day_size * 6 + 'px'
129
+ }));
130
+ }
131
+ }
132
+ exports.default = DatePickerSingle;
164
133
  DatePickerSingle.propTypes = _DatePickerSingle.propTypes;