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.
- package/dash_core_components/async-datepicker.js +1 -1
- package/dash_core_components/async-datepicker.js.map +1 -1
- package/dash_core_components/async-dropdown.js +1 -1
- package/dash_core_components/async-dropdown.js.map +1 -1
- package/dash_core_components/async-graph.js +1 -1
- package/dash_core_components/async-graph.js.map +1 -1
- package/dash_core_components/async-highlight.js +1 -1
- package/dash_core_components/async-highlight.js.map +1 -1
- package/dash_core_components/async-markdown.js +1 -1
- package/dash_core_components/async-markdown.js.map +1 -1
- package/dash_core_components/async-slider.js +1 -1
- package/dash_core_components/async-slider.js.map +1 -1
- package/dash_core_components/async-upload.js +1 -1
- package/dash_core_components/async-upload.js.map +1 -1
- package/dash_core_components/dash_core_components.js +1 -1
- package/dash_core_components/dash_core_components.js.map +1 -1
- package/lib/components/Checklist.react.js +46 -63
- package/lib/components/Clipboard.react.js +172 -218
- package/lib/components/ConfirmDialog.react.js +34 -61
- package/lib/components/ConfirmDialogProvider.react.js +21 -44
- package/lib/components/DatePickerRange.react.js +7 -26
- package/lib/components/DatePickerSingle.react.js +7 -26
- package/lib/components/Download.react.js +22 -45
- package/lib/components/Dropdown.react.js +7 -26
- package/lib/components/Geolocation.react.js +64 -91
- package/lib/components/Graph.react.js +70 -97
- package/lib/components/Input.react.js +119 -162
- package/lib/components/Interval.react.js +55 -86
- package/lib/components/Link.react.js +4 -4
- package/lib/components/Loading.react.js +31 -35
- package/lib/components/Location.react.js +97 -126
- package/lib/components/Markdown.react.js +15 -35
- package/lib/components/RadioItems.react.js +45 -63
- package/lib/components/RangeSlider.react.js +7 -26
- package/lib/components/Slider.react.js +7 -26
- package/lib/components/Store.react.js +128 -176
- package/lib/components/Tab.react.js +1 -1
- package/lib/components/Tabs.react.js +99 -134
- package/lib/components/Textarea.react.js +4 -4
- package/lib/components/Tooltip.react.js +7 -6
- package/lib/components/Upload.react.js +7 -26
- package/lib/fragments/DatePickerRange.react.js +150 -181
- package/lib/fragments/DatePickerSingle.react.js +103 -134
- package/lib/fragments/Dropdown.react.js +11 -19
- package/lib/fragments/Graph.privateprops.js +3 -9
- package/lib/fragments/Graph.react.js +302 -370
- package/lib/fragments/Loading/spinners/CircleSpinner.js +2 -4
- package/lib/fragments/Loading/spinners/CubeSpinner.js +2 -4
- package/lib/fragments/Loading/spinners/DefaultSpinner.js +2 -4
- package/lib/fragments/Loading/spinners/DotSpinner.js +2 -4
- package/lib/fragments/Loading/spinners/GraphSpinner.js +2 -4
- package/lib/fragments/Markdown.react.js +119 -158
- package/lib/fragments/Math.react.js +23 -47
- package/lib/fragments/RangeSlider.react.js +110 -133
- package/lib/fragments/Slider.react.js +110 -133
- package/lib/fragments/Upload.react.js +82 -99
- package/lib/utils/DatePickerPersistence.js +2 -4
- package/lib/utils/LazyLoader/datePickerRange.js +2 -3
- package/lib/utils/LazyLoader/datePickerSingle.js +2 -3
- package/lib/utils/LazyLoader/dropdown.js +2 -3
- package/lib/utils/LazyLoader/graph.js +2 -3
- package/lib/utils/LazyLoader/hljs.js +2 -5
- package/lib/utils/LazyLoader/markdown.js +2 -3
- package/lib/utils/LazyLoader/mathjax.js +2 -5
- package/lib/utils/LazyLoader/plotly.js +7 -6
- package/lib/utils/LazyLoader/rangeSlider.js +2 -3
- package/lib/utils/LazyLoader/slider.js +2 -3
- package/lib/utils/LazyLoader/upload.js +2 -3
- package/lib/utils/MarkdownHighlighter.js +5 -6
- package/lib/utils/ResizeDetector.js +9 -13
- package/lib/utils/computeSliderMarkers.js +29 -49
- package/lib/utils/computeSliderStyle.js +4 -3
- package/lib/utils/convertToMoment.js +5 -6
- package/lib/utils/formatSliderTooltip.js +6 -8
- package/lib/utils/optionTypes.js +8 -9
- package/package.json +1 -1
|
@@ -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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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
|
-
|
|
80
|
+
}
|
|
81
|
+
if (end_date && !end_date.isSame(oldMomentDates.end_date)) {
|
|
82
|
+
if (updatemode === 'singledate') {
|
|
116
83
|
setProps({
|
|
117
|
-
|
|
118
|
-
|
|
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
|
-
|
|
124
|
-
|
|
125
|
-
|
|
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
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
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
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
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
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
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
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
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;
|