@jetbrains/ring-ui-built 6.0.32 → 6.0.33
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/components/_helpers/_rollupPluginBabelHelpers.js +567 -1
- package/components/_helpers/anchor.js +6 -7
- package/components/_helpers/button__classes.js +14 -16
- package/components/_helpers/caption.js +20 -14
- package/components/_helpers/card.js +105 -95
- package/components/_helpers/dialog__body-scroll-preventer.js +19 -11
- package/components/_helpers/icon__svg.js +25 -22
- package/components/_helpers/input.js +177 -146
- package/components/_helpers/query-assist__suggestions.js +90 -74
- package/components/_helpers/select__filter.js +69 -48
- package/components/_helpers/services-link.js +37 -29
- package/components/_helpers/sidebar.js +107 -99
- package/components/_helpers/tab-link.js +7 -7
- package/components/_helpers/theme.js +40 -31
- package/components/_helpers/title.js +72 -57
- package/components/alert/alert.js +202 -150
- package/components/alert/container.js +41 -32
- package/components/alert-service/alert-service.js +170 -105
- package/components/analytics/analytics.js +22 -12
- package/components/analytics/analytics__custom-plugin.js +75 -54
- package/components/auth/auth.js +36 -4
- package/components/auth/auth__core.js +1471 -746
- package/components/auth/background-flow.js +127 -87
- package/components/auth/down-notification.js +73 -30
- package/components/auth/iframe-flow.js +133 -75
- package/components/auth/request-builder.js +82 -46
- package/components/auth/response-parser.js +116 -86
- package/components/auth/storage.js +334 -171
- package/components/auth/token-validator.js +242 -137
- package/components/auth/window-flow.js +134 -92
- package/components/auth-dialog/auth-dialog.js +172 -114
- package/components/auth-dialog-service/auth-dialog-service.js +31 -8
- package/components/avatar/avatar-example-datauri.js +1 -23
- package/components/avatar/avatar.js +152 -119
- package/components/avatar/fallback-avatar.js +38 -22
- package/components/badge/badge.js +45 -35
- package/components/button/button.js +107 -86
- package/components/button-group/button-group.js +33 -19
- package/components/button-set/button-set.js +32 -20
- package/components/button-toolbar/button-toolbar.js +31 -19
- package/components/caret/caret.js +220 -186
- package/components/checkbox/checkbox.js +101 -76
- package/components/clipboard/clipboard-fallback.js +10 -10
- package/components/clipboard/clipboard.js +132 -35
- package/components/code/code.js +166 -92
- package/components/collapse/collapse-content.js +64 -42
- package/components/collapse/collapse-context.js +2 -2
- package/components/collapse/collapse-control.js +14 -12
- package/components/collapse/collapse.js +17 -11
- package/components/collapse/consts.js +4 -4
- package/components/collapse/utils.js +3 -1
- package/components/confirm/confirm.js +104 -66
- package/components/confirm-service/confirm-service.js +59 -37
- package/components/content-layout/content-layout.js +64 -43
- package/components/content-layout/sidebar.js +1 -0
- package/components/contenteditable/contenteditable.js +59 -50
- package/components/control-label/control-label.js +9 -9
- package/components/data-list/data-list.js +182 -129
- package/components/data-list/data-list.mock.js +6 -2
- package/components/data-list/item.js +170 -143
- package/components/data-list/selection.js +136 -76
- package/components/data-list/title.js +12 -1
- package/components/date-picker/consts.js +26 -19
- package/components/date-picker/date-input.js +144 -113
- package/components/date-picker/date-picker.js +282 -227
- package/components/date-picker/date-popup.js +395 -350
- package/components/date-picker/day.js +116 -87
- package/components/date-picker/month-names.js +66 -43
- package/components/date-picker/month-slider.js +76 -51
- package/components/date-picker/month.js +25 -16
- package/components/date-picker/months.js +50 -43
- package/components/date-picker/weekdays.js +22 -12
- package/components/date-picker/years.js +110 -83
- package/components/dialog/dialog.js +190 -142
- package/components/dialog/dialog__body-scroll-preventer.js +4 -0
- package/components/dropdown/anchor.js +9 -0
- package/components/dropdown/dropdown.js +213 -182
- package/components/dropdown-menu/dropdown-menu.js +97 -71
- package/components/editable-heading/editable-heading.js +127 -75
- package/components/error-bubble/error-bubble.js +60 -31
- package/components/error-message/error-message.js +59 -39
- package/components/footer/footer.js +30 -27
- package/components/global/compose.js +10 -1
- package/components/global/composeRefs.js +12 -7
- package/components/global/controls-height.js +2 -2
- package/components/global/create-stateful-context.js +15 -15
- package/components/global/data-tests.js +14 -6
- package/components/global/dom.js +86 -47
- package/components/global/focus-sensor-hoc.js +132 -122
- package/components/global/fuzzy-highlight.js +36 -22
- package/components/global/get-event-key.js +8 -8
- package/components/global/get-uid.js +8 -4
- package/components/global/inject-styles.js +15 -10
- package/components/global/listeners.js +51 -27
- package/components/global/memoize.js +12 -6
- package/components/global/normalize-indent.js +50 -19
- package/components/global/promise-with-timeout.js +8 -6
- package/components/global/prop-types.js +5 -3
- package/components/global/react-dom-renderer.js +44 -28
- package/components/global/react-render-adapter.js +1 -1
- package/components/global/rerender-hoc.js +30 -12
- package/components/global/schedule-raf.js +6 -5
- package/components/global/sniffer.js +1 -1
- package/components/global/theme.js +22 -0
- package/components/global/trivial-template-tag.js +10 -3
- package/components/global/typescript-utils.js +6 -2
- package/components/global/url.js +26 -20
- package/components/global/use-event-callback.js +4 -6
- package/components/grid/col.js +52 -35
- package/components/grid/grid.js +31 -17
- package/components/grid/row.js +47 -35
- package/components/group/group.js +25 -17
- package/components/header/header.js +78 -33
- package/components/header/logo.js +36 -20
- package/components/header/profile.js +199 -166
- package/components/header/services-link.js +4 -0
- package/components/header/services.js +116 -73
- package/components/header/smart-profile.js +203 -111
- package/components/header/smart-services.js +113 -62
- package/components/header/tray-icon.js +37 -21
- package/components/header/tray.js +32 -21
- package/components/heading/heading.js +25 -24
- package/components/http/http.js +353 -203
- package/components/http/http.mock.js +101 -49
- package/components/hub-source/hub-source.js +190 -83
- package/components/hub-source/hub-source__user.js +44 -11
- package/components/hub-source/hub-source__users-groups.js +65 -37
- package/components/i18n/i18n-context.js +10 -7
- package/components/i18n/i18n.js +10 -7
- package/components/icon/icon.js +93 -76
- package/components/icon/icon__svg.js +8 -0
- package/components/icon/index.js +8 -0
- package/components/input/input.js +13 -0
- package/components/island/adaptive-island-hoc.js +43 -30
- package/components/island/content.js +132 -115
- package/components/island/header.js +70 -57
- package/components/island/island.js +40 -28
- package/components/island-legacy/content-legacy.js +25 -17
- package/components/island-legacy/header-legacy.js +27 -19
- package/components/island-legacy/island-legacy.js +25 -17
- package/components/link/clickableLink.js +59 -44
- package/components/link/link.js +68 -57
- package/components/list/consts.js +2 -2
- package/components/list/list.js +698 -611
- package/components/list/list__custom.js +62 -44
- package/components/list/list__hint.js +19 -10
- package/components/list/list__item.js +174 -133
- package/components/list/list__link.js +50 -37
- package/components/list/list__separator.js +24 -14
- package/components/list/list__title.js +32 -22
- package/components/list/list__users-groups-source.js +126 -54
- package/components/loader/loader.js +74 -43
- package/components/loader/loader__core.js +263 -198
- package/components/loader-inline/loader-inline.js +35 -23
- package/components/loader-screen/loader-screen.js +46 -25
- package/components/login-dialog/login-dialog.js +158 -111
- package/components/login-dialog/service.js +34 -8
- package/components/markdown/markdown.js +23 -15
- package/components/message/message.js +203 -161
- package/components/old-browsers-message/old-browsers-message.js +18 -11
- package/components/old-browsers-message/old-browsers-message__stop.js +7 -0
- package/components/old-browsers-message/white-list.js +16 -8
- package/components/pager/pager.js +271 -212
- package/components/panel/panel.js +25 -17
- package/components/permissions/permissions.js +172 -127
- package/components/permissions/permissions__cache.js +224 -194
- package/components/popup/popup.consts.js +1 -1
- package/components/popup/popup.js +343 -284
- package/components/popup/popup.target.js +8 -9
- package/components/popup/position.js +106 -96
- package/components/popup-menu/popup-menu.js +81 -44
- package/components/progress-bar/progress-bar.js +104 -87
- package/components/query-assist/query-assist.js +916 -838
- package/components/query-assist/query-assist__suggestions.js +30 -1
- package/components/radio/radio.js +34 -19
- package/components/radio/radio__item.js +69 -52
- package/components/select/select.js +957 -852
- package/components/select/select__filter.js +30 -0
- package/components/select/select__popup.js +487 -373
- package/components/shortcuts/core.js +217 -166
- package/components/shortcuts/shortcut-title.js +11 -6
- package/components/shortcuts/shortcuts-hoc.js +45 -19
- package/components/shortcuts/shortcuts.js +75 -50
- package/components/slider/slider.js +122 -99
- package/components/slider/slider.utils.js +24 -14
- package/components/storage/storage.js +33 -4
- package/components/storage/storage__fallback.js +224 -149
- package/components/storage/storage__local.js +153 -90
- package/components/tab-trap/tab-trap.js +153 -122
- package/components/table/cell.js +26 -14
- package/components/table/disable-hover-hoc.js +51 -33
- package/components/table/header-cell.js +89 -64
- package/components/table/header.js +132 -104
- package/components/table/multitable.js +125 -107
- package/components/table/row-with-focus-sensor.js +69 -25
- package/components/table/row.js +216 -175
- package/components/table/selection-adapter.js +3 -1
- package/components/table/selection-shortcuts-hoc.js +181 -180
- package/components/table/selection.js +226 -156
- package/components/table/smart-table.js +88 -50
- package/components/table/table.js +358 -289
- package/components/tabs/collapsible-more.js +79 -46
- package/components/tabs/collapsible-tab.js +38 -31
- package/components/tabs/collapsible-tabs.js +153 -88
- package/components/tabs/custom-item.js +2 -4
- package/components/tabs/dumb-tabs.js +117 -74
- package/components/tabs/smart-tabs.js +69 -29
- package/components/tabs/tab-link.js +5 -1
- package/components/tabs/tab.js +31 -19
- package/components/tabs/tabs.js +31 -0
- package/components/tag/tag.js +173 -133
- package/components/tags-input/tags-input.js +427 -329
- package/components/tags-list/tags-list.js +78 -57
- package/components/text/text.js +39 -28
- package/components/toggle/toggle.js +70 -56
- package/components/tooltip/tooltip.js +190 -146
- package/components/user-agreement/service.js +371 -228
- package/components/user-agreement/toolbox.eula.js +1 -160
- package/components/user-agreement/user-agreement.js +120 -85
- package/components/user-card/card.js +29 -0
- package/components/user-card/smart-user-card-tooltip.js +111 -51
- package/components/user-card/tooltip.js +84 -47
- package/components/user-card/user-card.js +29 -0
- package/package.json +1 -1
@@ -1,4 +1,7 @@
|
|
1
|
-
import { _ as _extends } from '../_helpers/_rollupPluginBabelHelpers.js';
|
1
|
+
import { _ as _defineProperty, a as _inherits, b as _createClass, d as _objectSpread2, c as _objectWithoutProperties, e as _extends, f as _classCallCheck, g as _callSuper } from '../_helpers/_rollupPluginBabelHelpers.js';
|
2
|
+
import 'core-js/modules/es.array.map.js';
|
3
|
+
import 'core-js/modules/es.array.reduce.js';
|
4
|
+
import 'core-js/modules/es.object.to-string.js';
|
2
5
|
import React, { Component } from 'react';
|
3
6
|
import PropTypes from 'prop-types';
|
4
7
|
import { isAfter } from 'date-fns/isAfter';
|
@@ -13,8 +16,17 @@ import Years from './years.js';
|
|
13
16
|
import Weekdays from './weekdays.js';
|
14
17
|
import { dateType, parseTime } from './consts.js';
|
15
18
|
import { m as modules_0c7b7d96 } from '../_helpers/date-picker.js';
|
19
|
+
import 'core-js/modules/es.array.iterator.js';
|
20
|
+
import 'core-js/modules/es.map.js';
|
21
|
+
import 'core-js/modules/es.weak-map.js';
|
22
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
23
|
+
import 'core-js/modules/es.array.concat.js';
|
24
|
+
import 'core-js/modules/es.array.filter.js';
|
25
|
+
import 'core-js/modules/es.regexp.exec.js';
|
26
|
+
import 'core-js/modules/es.string.replace.js';
|
16
27
|
import 'classnames';
|
17
28
|
import '../_helpers/input.js';
|
29
|
+
import 'core-js/modules/es.object.values.js';
|
18
30
|
import '@jetbrains/icons/close-12px';
|
19
31
|
import '../global/prop-types.js';
|
20
32
|
import '../button/button.js';
|
@@ -23,13 +35,17 @@ import '../icon/icon.js';
|
|
23
35
|
import 'util-deprecate';
|
24
36
|
import '../icon/icon__constants.js';
|
25
37
|
import '../_helpers/icon__svg.js';
|
38
|
+
import 'core-js/modules/es.string.starts-with.js';
|
26
39
|
import '../link/clickableLink.js';
|
27
40
|
import '../global/controls-height.js';
|
28
41
|
import '../_helpers/button__classes.js';
|
29
42
|
import '../global/get-uid.js';
|
43
|
+
import 'core-js/modules/es.regexp.to-string.js';
|
30
44
|
import '../i18n/i18n-context.js';
|
31
45
|
import '../i18n/i18n.js';
|
46
|
+
import 'core-js/modules/es.set.js';
|
32
47
|
import '../global/composeRefs.js';
|
48
|
+
import 'core-js/modules/web.dom-collections.for-each.js';
|
33
49
|
import '../control-label/control-label.js';
|
34
50
|
import 'date-fns/addMonths';
|
35
51
|
import 'date-fns/getDay';
|
@@ -45,8 +61,12 @@ import 'date-fns/addDays';
|
|
45
61
|
import 'date-fns/format';
|
46
62
|
import 'date-fns/setDay';
|
47
63
|
import './day.js';
|
64
|
+
import 'core-js/modules/es.array.includes.js';
|
65
|
+
import 'core-js/modules/es.string.includes.js';
|
48
66
|
import 'date-fns/getDate';
|
49
67
|
import 'date-fns/isToday';
|
68
|
+
import 'core-js/modules/es.array.index-of.js';
|
69
|
+
import 'core-js/modules/es.array.slice.js';
|
50
70
|
import 'date-fns/add';
|
51
71
|
import './month-names.js';
|
52
72
|
import 'date-fns/isThisMonth';
|
@@ -60,384 +80,409 @@ import 'date-fns/isSameYear';
|
|
60
80
|
import 'date-fns/isThisYear';
|
61
81
|
import 'date-fns/setYear';
|
62
82
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
83
|
+
var _excluded = ["from", "to", "date", "time"];
|
84
|
+
var scrollExpDelay = 10;
|
85
|
+
var DatePopup = /*#__PURE__*/function (_Component) {
|
86
|
+
function DatePopup(props) {
|
87
|
+
var _this;
|
88
|
+
_classCallCheck(this, DatePopup);
|
89
|
+
_this = _callSuper(this, DatePopup, [props]);
|
90
|
+
_defineProperty(_this, "_scrollDate", void 0);
|
91
|
+
_defineProperty(_this, "_scrollTS", void 0);
|
92
|
+
_defineProperty(_this, "isInTimeMode", function () {
|
93
|
+
return !_this.props.range && _this.props.withTime || false;
|
94
|
+
});
|
95
|
+
_defineProperty(_this, "componentRef", /*#__PURE__*/React.createRef());
|
96
|
+
_defineProperty(_this, "handleWheel", function (e) {
|
97
|
+
if (e.cancelable) {
|
98
|
+
e.preventDefault();
|
99
|
+
}
|
100
|
+
});
|
101
|
+
_defineProperty(_this, "isValidDate", function (parsedText) {
|
102
|
+
var minDate = _this.parse(_this.props.minDate, 'date');
|
103
|
+
var maxDate = _this.parse(_this.props.maxDate, 'date');
|
104
|
+
if (parsedText) {
|
105
|
+
return !(minDate && isBefore(parsedText, minDate) || maxDate && isAfter(parsedText, maxDate));
|
106
|
+
}
|
107
|
+
return false;
|
108
|
+
});
|
109
|
+
_defineProperty(_this, "scheduleScroll", function () {
|
110
|
+
var current = _this.state.scrollDate && _this.parse(_this.state.scrollDate, 'date') || _this.parse(_this.props[_this.state.active], 'date') || new Date();
|
111
|
+
var goal = _this._scrollDate;
|
112
|
+
if (!current || !goal || DatePopup.sameDay(goal, current)) {
|
113
|
+
_this._scrollDate = null;
|
114
|
+
_this._scrollTS = null;
|
115
|
+
return;
|
116
|
+
}
|
117
|
+
if (_this._scrollTS) {
|
118
|
+
var diff = goal - Number(current);
|
119
|
+
var dt = Date.now() - _this._scrollTS;
|
120
|
+
var next = goal - diff * Math.pow(Math.E, -dt / scrollExpDelay);
|
121
|
+
_this.setState({
|
122
|
+
scrollDate: next
|
123
|
+
});
|
124
|
+
}
|
125
|
+
_this._scrollTS = Date.now();
|
126
|
+
window.requestAnimationFrame(_this.scheduleScroll);
|
127
|
+
});
|
128
|
+
_defineProperty(_this, "scrollTo", function (scrollDate) {
|
129
|
+
_this._scrollDate = scrollDate;
|
130
|
+
if (!_this._scrollTS) {
|
131
|
+
_this.scheduleScroll();
|
132
|
+
}
|
133
|
+
});
|
134
|
+
_defineProperty(_this, "hoverHandler", function (hoverDate) {
|
135
|
+
return _this.setState({
|
136
|
+
hoverDate
|
137
|
+
});
|
138
|
+
});
|
139
|
+
_defineProperty(_this, "handleActivate", memoize(function (name) {
|
140
|
+
return function () {
|
141
|
+
return _this.setState({
|
142
|
+
active: name
|
143
|
+
});
|
144
|
+
};
|
145
|
+
}));
|
146
|
+
_defineProperty(_this, "handleInput", function (text, name) {
|
147
|
+
if (name !== 'time') {
|
148
|
+
var parsed = _this.parse(text, name);
|
149
|
+
if (_this.isValidDate(parsed)) {
|
150
|
+
_this.scrollTo(Number(parsed));
|
151
|
+
}
|
152
|
+
}
|
153
|
+
_this.setState({
|
154
|
+
text,
|
155
|
+
hoverDate: null
|
156
|
+
});
|
157
|
+
});
|
158
|
+
_defineProperty(_this, "handleConfirm", memoize(function (name) {
|
159
|
+
return function () {
|
160
|
+
return _this.confirm(name);
|
161
|
+
};
|
162
|
+
}));
|
163
|
+
_defineProperty(_this, "selectHandler", function (date) {
|
164
|
+
if (_this.isInTimeMode()) {
|
165
|
+
_this.setState({
|
166
|
+
active: 'time'
|
167
|
+
}, function () {
|
168
|
+
return _this.select({
|
169
|
+
date
|
170
|
+
});
|
171
|
+
});
|
172
|
+
} else {
|
173
|
+
_this.select({
|
174
|
+
[_this.state.active]: date
|
175
|
+
});
|
176
|
+
}
|
177
|
+
});
|
178
|
+
_defineProperty(_this, "handleScroll", function (scrollDate) {
|
179
|
+
return _this.setState({
|
180
|
+
scrollDate
|
181
|
+
});
|
182
|
+
});
|
183
|
+
_defineProperty(_this, "onClear", function (e) {
|
184
|
+
var _this$props$onClear, _this$props, _this$componentRef$cu;
|
185
|
+
var changes;
|
186
|
+
if (_this.props.range) {
|
187
|
+
changes = {
|
188
|
+
from: null,
|
189
|
+
to: null
|
190
|
+
};
|
191
|
+
} else {
|
192
|
+
changes = {
|
193
|
+
date: null
|
194
|
+
};
|
195
|
+
}
|
196
|
+
_this.select(changes);
|
197
|
+
(_this$props$onClear = (_this$props = _this.props).onClear) === null || _this$props$onClear === void 0 || _this$props$onClear.call(_this$props, e);
|
198
|
+
(_this$componentRef$cu = _this.componentRef.current) === null || _this$componentRef$cu === void 0 || (_this$componentRef$cu = _this$componentRef$cu.querySelector('input')) === null || _this$componentRef$cu === void 0 || _this$componentRef$cu.focus();
|
199
|
+
});
|
200
|
+
var defaultState = {
|
98
201
|
text: null,
|
99
202
|
hoverDate: null,
|
100
203
|
scrollDate: null
|
101
204
|
};
|
102
|
-
|
103
|
-
|
104
|
-
withTime
|
105
|
-
} = props;
|
205
|
+
var range = props.range,
|
206
|
+
withTime = props.withTime;
|
106
207
|
if (!range) {
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
...defaultState,
|
208
|
+
var parsedDate = _this.parse(props.date, 'date');
|
209
|
+
var active = withTime && parsedDate && !props.time ? 'time' : 'date';
|
210
|
+
_this.state = _objectSpread2(_objectSpread2({}, defaultState), {}, {
|
111
211
|
active
|
112
|
-
};
|
212
|
+
});
|
113
213
|
} else if (props.from && !props.to) {
|
114
|
-
|
115
|
-
...defaultState,
|
214
|
+
_this.state = _objectSpread2(_objectSpread2({}, defaultState), {}, {
|
116
215
|
active: 'to'
|
117
|
-
};
|
216
|
+
});
|
118
217
|
} else {
|
119
|
-
|
120
|
-
...defaultState,
|
218
|
+
_this.state = _objectSpread2(_objectSpread2({}, defaultState), {}, {
|
121
219
|
active: 'from'
|
122
|
-
};
|
123
|
-
}
|
124
|
-
}
|
125
|
-
componentDidMount() {
|
126
|
-
if (this.componentRef.current) {
|
127
|
-
this.componentRef.current.addEventListener('wheel', this.handleWheel);
|
220
|
+
});
|
128
221
|
}
|
222
|
+
return _this;
|
129
223
|
}
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
224
|
+
_inherits(DatePopup, _Component);
|
225
|
+
return _createClass(DatePopup, [{
|
226
|
+
key: "componentDidMount",
|
227
|
+
value: function componentDidMount() {
|
228
|
+
if (this.componentRef.current) {
|
229
|
+
this.componentRef.current.addEventListener('wheel', this.handleWheel);
|
134
230
|
}
|
135
|
-
this.setState({
|
136
|
-
text: null
|
137
|
-
});
|
138
231
|
}
|
139
|
-
}
|
140
|
-
|
141
|
-
|
142
|
-
this.
|
232
|
+
}, {
|
233
|
+
key: "componentDidUpdate",
|
234
|
+
value: function componentDidUpdate(prevProps, prevState) {
|
235
|
+
if (this.state.active !== prevState.active) {
|
236
|
+
if (this.state.text && prevState.active) {
|
237
|
+
this.confirm(prevState.active);
|
238
|
+
}
|
239
|
+
this.setState({
|
240
|
+
text: null
|
241
|
+
});
|
242
|
+
}
|
143
243
|
}
|
144
|
-
}
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
if (e.cancelable) {
|
151
|
-
e.preventDefault();
|
244
|
+
}, {
|
245
|
+
key: "componentWillUnmount",
|
246
|
+
value: function componentWillUnmount() {
|
247
|
+
if (this.componentRef.current) {
|
248
|
+
this.componentRef.current.removeEventListener('wheel', this.handleWheel);
|
249
|
+
}
|
152
250
|
}
|
153
|
-
}
|
154
|
-
|
155
|
-
|
156
|
-
|
251
|
+
}, {
|
252
|
+
key: "parse",
|
253
|
+
value: function parse(text, type) {
|
254
|
+
if (type === 'time') {
|
255
|
+
return parseTime(String(text));
|
256
|
+
}
|
257
|
+
return this.props.parseDateInput(text);
|
157
258
|
}
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
this.props.onChange(adjustedDate);
|
177
|
-
this.props.onComplete();
|
178
|
-
} else if (!range && withTime) {
|
179
|
-
const date = this.parse(this.props.date, 'date');
|
180
|
-
const time = this.parse(this.props.time, 'time');
|
181
|
-
const changeToSubmit = {
|
182
|
-
date: changes.date || date,
|
183
|
-
time: changes.time || time
|
184
|
-
};
|
185
|
-
this.setState({
|
186
|
-
active: changes.date ? 'time' : 'date',
|
187
|
-
text: null,
|
188
|
-
scrollDate: null
|
189
|
-
});
|
190
|
-
this.props.onChange(changeToSubmit);
|
191
|
-
if (!changes.date && prevActive === 'time' && changeToSubmit.date && changeToSubmit.time) {
|
259
|
+
}, {
|
260
|
+
key: "select",
|
261
|
+
value: function select(changes) {
|
262
|
+
var _this$props2 = this.props,
|
263
|
+
range = _this$props2.range,
|
264
|
+
withTime = _this$props2.withTime;
|
265
|
+
var prevActive = this.state.active;
|
266
|
+
if (!range && !withTime) {
|
267
|
+
this.setState({
|
268
|
+
text: null,
|
269
|
+
scrollDate: null
|
270
|
+
});
|
271
|
+
var adjustedDate = changes.date && set(new Date(), {
|
272
|
+
year: changes.date.getFullYear(),
|
273
|
+
month: changes.date.getMonth(),
|
274
|
+
date: changes.date.getDate()
|
275
|
+
});
|
276
|
+
this.props.onChange(adjustedDate);
|
192
277
|
this.props.onComplete();
|
193
|
-
}
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
278
|
+
} else if (!range && withTime) {
|
279
|
+
var date = this.parse(this.props.date, 'date');
|
280
|
+
var time = this.parse(this.props.time, 'time');
|
281
|
+
var changeToSubmit = {
|
282
|
+
date: changes.date || date,
|
283
|
+
time: changes.time || time
|
284
|
+
};
|
285
|
+
this.setState({
|
286
|
+
active: changes.date ? 'time' : 'date',
|
287
|
+
text: null,
|
288
|
+
scrollDate: null
|
289
|
+
});
|
290
|
+
this.props.onChange(changeToSubmit);
|
291
|
+
if (!changes.date && prevActive === 'time' && changeToSubmit.date && changeToSubmit.time) {
|
292
|
+
this.props.onComplete();
|
293
|
+
}
|
294
|
+
} else {
|
295
|
+
var _this$props$changes = _objectSpread2(_objectSpread2({}, this.props), changes),
|
296
|
+
from = _this$props$changes.from,
|
297
|
+
to = _this$props$changes.to;
|
298
|
+
from = this.parse(from, 'from');
|
299
|
+
to = this.parse(to, 'to');
|
300
|
+
// proceed to setting the end by default
|
301
|
+
var active = 'to';
|
302
|
+
var complete = false;
|
303
|
+
// end is before beginning
|
304
|
+
if (from && to && isAfter(startOfDay(from), startOfDay(to))) {
|
305
|
+
// ignore the old end when beginning is changed
|
306
|
+
if (changes.from) {
|
307
|
+
to = null;
|
308
|
+
// treat range as reverse when end is changed
|
309
|
+
} else if (changes.to) {
|
310
|
+
to = from;
|
311
|
+
from = changes.to;
|
312
|
+
}
|
213
313
|
} else if (changes.to) {
|
214
|
-
|
215
|
-
|
314
|
+
active = 'from';
|
315
|
+
complete = !!from;
|
316
|
+
}
|
317
|
+
this.setState({
|
318
|
+
active,
|
319
|
+
hoverDate: null,
|
320
|
+
text: null
|
321
|
+
});
|
322
|
+
this.props.onChange({
|
323
|
+
from,
|
324
|
+
to
|
325
|
+
});
|
326
|
+
if (complete) {
|
327
|
+
this.props.onComplete();
|
216
328
|
}
|
217
|
-
} else if (changes.to) {
|
218
|
-
active = 'from';
|
219
|
-
complete = !!from;
|
220
|
-
}
|
221
|
-
this.setState({
|
222
|
-
active,
|
223
|
-
hoverDate: null,
|
224
|
-
text: null
|
225
|
-
});
|
226
|
-
this.props.onChange({
|
227
|
-
from,
|
228
|
-
to
|
229
|
-
});
|
230
|
-
if (complete) {
|
231
|
-
this.props.onComplete();
|
232
|
-
}
|
233
|
-
}
|
234
|
-
}
|
235
|
-
confirm(name) {
|
236
|
-
const text = this.state.text;
|
237
|
-
let result;
|
238
|
-
if (name === 'time') {
|
239
|
-
result = this.parse(text, name);
|
240
|
-
const time = this.parse('time' in this.props ? this.props.time : '', 'time');
|
241
|
-
const emptyCase = this.state.active === 'time' ? '00:00' : null;
|
242
|
-
result = result || time || emptyCase;
|
243
|
-
} else {
|
244
|
-
result = this.parse(text, name);
|
245
|
-
if (!this.isValidDate(result)) {
|
246
|
-
result = this.parse(name in this.props ? this.props[name] : '', name);
|
247
329
|
}
|
248
330
|
}
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
if (!current || !goal || DatePopup.sameDay(goal, current)) {
|
265
|
-
this._scrollDate = null;
|
266
|
-
this._scrollTS = null;
|
267
|
-
return;
|
268
|
-
}
|
269
|
-
if (this._scrollTS) {
|
270
|
-
const diff = goal - Number(current);
|
271
|
-
const dt = Date.now() - this._scrollTS;
|
272
|
-
const next = goal - diff * Math.E ** (-dt / scrollExpDelay);
|
273
|
-
this.setState({
|
274
|
-
scrollDate: next
|
275
|
-
});
|
276
|
-
}
|
277
|
-
this._scrollTS = Date.now();
|
278
|
-
window.requestAnimationFrame(this.scheduleScroll);
|
279
|
-
};
|
280
|
-
scrollTo = scrollDate => {
|
281
|
-
this._scrollDate = scrollDate;
|
282
|
-
if (!this._scrollTS) {
|
283
|
-
this.scheduleScroll();
|
284
|
-
}
|
285
|
-
};
|
286
|
-
hoverHandler = hoverDate => this.setState({
|
287
|
-
hoverDate
|
288
|
-
});
|
289
|
-
handleActivate = memoize(name => () => this.setState({
|
290
|
-
active: name
|
291
|
-
}));
|
292
|
-
handleInput = (text, name) => {
|
293
|
-
if (name !== 'time') {
|
294
|
-
const parsed = this.parse(text, name);
|
295
|
-
if (this.isValidDate(parsed)) {
|
296
|
-
this.scrollTo(Number(parsed));
|
331
|
+
}, {
|
332
|
+
key: "confirm",
|
333
|
+
value: function confirm(name) {
|
334
|
+
var text = this.state.text;
|
335
|
+
var result;
|
336
|
+
if (name === 'time') {
|
337
|
+
result = this.parse(text, name);
|
338
|
+
var time = this.parse('time' in this.props ? this.props.time : '', 'time');
|
339
|
+
var emptyCase = this.state.active === 'time' ? '00:00' : null;
|
340
|
+
result = result || time || emptyCase;
|
341
|
+
} else {
|
342
|
+
result = this.parse(text, name);
|
343
|
+
if (!this.isValidDate(result)) {
|
344
|
+
result = this.parse(name in this.props ? this.props[name] : '', name);
|
345
|
+
}
|
297
346
|
}
|
298
|
-
}
|
299
|
-
this.setState({
|
300
|
-
text,
|
301
|
-
hoverDate: null
|
302
|
-
});
|
303
|
-
};
|
304
|
-
handleConfirm = memoize(name => () => this.confirm(name));
|
305
|
-
selectHandler = date => {
|
306
|
-
if (this.isInTimeMode()) {
|
307
|
-
this.setState({
|
308
|
-
active: 'time'
|
309
|
-
}, () => this.select({
|
310
|
-
date
|
311
|
-
}));
|
312
|
-
} else {
|
313
347
|
this.select({
|
314
|
-
[
|
348
|
+
[name]: result
|
315
349
|
});
|
316
350
|
}
|
317
|
-
}
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
} = this.props;
|
350
|
-
const parsedDate = this.parse(this.props.date, 'date');
|
351
|
-
const parsedTo = this.parse(this.props.to, 'to');
|
352
|
-
const names = range ? ['from', 'to'] : ['date'];
|
353
|
-
const dates = names.reduce((obj, key) => {
|
354
|
-
const value = this.props[key];
|
355
|
-
return {
|
356
|
-
...obj,
|
357
|
-
[key]: this.parse(value, key)
|
358
|
-
};
|
359
|
-
}, {});
|
360
|
-
const activeDate = this.state.active !== 'time' ? this.state.hoverDate || (this.state.text != null ? this.parse(this.state.text, 'date') : null) : this.state.hoverDate || null;
|
361
|
-
const currentRange = range && dates.from && dates.to && [dates.from, dates.to] || null;
|
362
|
-
let activeRange = null;
|
363
|
-
if (range && activeDate) {
|
364
|
-
switch (this.state.active) {
|
365
|
-
case 'from':
|
366
|
-
if (dates.to && isAfter(startOfDay(activeDate), startOfDay(dates.to))) {
|
367
|
-
activeRange = [activeDate, dates.to];
|
368
|
-
}
|
369
|
-
break;
|
370
|
-
case 'to':
|
371
|
-
if (!dates.from) {
|
351
|
+
}, {
|
352
|
+
key: "render",
|
353
|
+
value: function render() {
|
354
|
+
var _this2 = this;
|
355
|
+
var _this$props3 = this.props,
|
356
|
+
range = _this$props3.range,
|
357
|
+
withTime = _this$props3.withTime,
|
358
|
+
locale = _this$props3.locale;
|
359
|
+
var _this$props4 = this.props;
|
360
|
+
_this$props4.from;
|
361
|
+
_this$props4.to;
|
362
|
+
_this$props4.date;
|
363
|
+
var time = _this$props4.time,
|
364
|
+
restProps = _objectWithoutProperties(_this$props4, _excluded);
|
365
|
+
var parsedDate = this.parse(this.props.date, 'date');
|
366
|
+
var parsedTo = this.parse(this.props.to, 'to');
|
367
|
+
var names = range ? ['from', 'to'] : ['date'];
|
368
|
+
var dates = names.reduce(function (obj, key) {
|
369
|
+
var value = _this2.props[key];
|
370
|
+
return _objectSpread2(_objectSpread2({}, obj), {}, {
|
371
|
+
[key]: _this2.parse(value, key)
|
372
|
+
});
|
373
|
+
}, {});
|
374
|
+
var activeDate = this.state.active !== 'time' ? this.state.hoverDate || (this.state.text != null ? this.parse(this.state.text, 'date') : null) : this.state.hoverDate || null;
|
375
|
+
var currentRange = range && dates.from && dates.to && [dates.from, dates.to] || null;
|
376
|
+
var activeRange = null;
|
377
|
+
if (range && activeDate) {
|
378
|
+
switch (this.state.active) {
|
379
|
+
case 'from':
|
380
|
+
if (dates.to && isAfter(startOfDay(activeDate), startOfDay(dates.to))) {
|
381
|
+
activeRange = [activeDate, dates.to];
|
382
|
+
}
|
372
383
|
break;
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
...restProps,
|
385
|
-
...dates,
|
386
|
-
scrollDate,
|
387
|
-
activeDate,
|
388
|
-
currentRange,
|
389
|
-
activeRange,
|
390
|
-
onScroll: this.handleScroll,
|
391
|
-
onScrollChange: this.scrollTo
|
392
|
-
};
|
393
|
-
const clearable = Boolean(this.props.onClear);
|
394
|
-
return /*#__PURE__*/React.createElement("div", {
|
395
|
-
className: modules_0c7b7d96.datePopup,
|
396
|
-
"data-test": "ring-date-popup",
|
397
|
-
ref: this.componentRef
|
398
|
-
}, /*#__PURE__*/React.createElement("div", {
|
399
|
-
className: modules_0c7b7d96.filterWrapper
|
400
|
-
}, names.map(name => {
|
401
|
-
let onClear;
|
402
|
-
if (clearable && name !== 'from' && !this.isInTimeMode()) {
|
403
|
-
onClear = this.onClear.bind(this);
|
384
|
+
case 'to':
|
385
|
+
if (!dates.from) {
|
386
|
+
break;
|
387
|
+
}
|
388
|
+
if (isBefore(startOfDay(activeDate), startOfDay(dates.from))) {
|
389
|
+
activeRange = [activeDate, dates.from];
|
390
|
+
} else {
|
391
|
+
activeRange = [dates.from, activeDate];
|
392
|
+
}
|
393
|
+
break;
|
394
|
+
}
|
404
395
|
}
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
396
|
+
var scrollDate = withTime && !range ? this.state.scrollDate || dates.date || new Date() : this.state.scrollDate || dates[this.state.active] || new Date();
|
397
|
+
var calendarProps = _objectSpread2(_objectSpread2(_objectSpread2({}, restProps), dates), {}, {
|
398
|
+
scrollDate,
|
399
|
+
activeDate,
|
400
|
+
currentRange,
|
401
|
+
activeRange,
|
402
|
+
onScroll: this.handleScroll,
|
403
|
+
onScrollChange: this.scrollTo
|
404
|
+
});
|
405
|
+
var clearable = Boolean(this.props.onClear);
|
406
|
+
return /*#__PURE__*/React.createElement("div", {
|
407
|
+
className: modules_0c7b7d96.datePopup,
|
408
|
+
"data-test": "ring-date-popup",
|
409
|
+
ref: this.componentRef
|
410
|
+
}, /*#__PURE__*/React.createElement("div", {
|
411
|
+
className: modules_0c7b7d96.filterWrapper
|
412
|
+
}, names.map(function (name) {
|
413
|
+
var onClear;
|
414
|
+
if (clearable && name !== 'from' && !_this2.isInTimeMode()) {
|
415
|
+
onClear = _this2.onClear.bind(_this2);
|
416
|
+
}
|
417
|
+
return /*#__PURE__*/React.createElement(DateInput, _extends({}, _this2.props, _this2.state, {
|
418
|
+
divider: name === 'from' && (dates[name] != null || parsedTo != null),
|
419
|
+
name: name,
|
420
|
+
key: name,
|
421
|
+
date: dates[name],
|
422
|
+
active: _this2.state.active === name,
|
423
|
+
onActivate: _this2.handleActivate(name),
|
424
|
+
onInput: _this2.handleInput,
|
425
|
+
onConfirm: _this2.handleConfirm(name),
|
426
|
+
onClear: onClear,
|
427
|
+
locale: locale
|
428
|
+
}));
|
429
|
+
}), this.isInTimeMode() ? /*#__PURE__*/React.createElement(DateInput, _extends({}, this.props, {
|
430
|
+
text: this.state.text,
|
431
|
+
divider: !!parsedDate,
|
432
|
+
hoverDate: null,
|
433
|
+
name: 'time',
|
434
|
+
key: 'time',
|
435
|
+
date: null,
|
436
|
+
time: time,
|
437
|
+
active: this.state.active === 'time',
|
438
|
+
onActivate: this.handleActivate('time'),
|
412
439
|
onInput: this.handleInput,
|
413
|
-
onConfirm: this.handleConfirm(
|
414
|
-
onClear: onClear,
|
440
|
+
onConfirm: this.handleConfirm('time'),
|
441
|
+
onClear: clearable && this.onClear || undefined,
|
415
442
|
locale: locale
|
416
|
-
}))
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
}
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
443
|
+
})) : ''), /*#__PURE__*/React.createElement(Weekdays, {
|
444
|
+
locale: locale
|
445
|
+
}), /*#__PURE__*/React.createElement("div", {
|
446
|
+
className: modules_0c7b7d96.calendar
|
447
|
+
}, /*#__PURE__*/React.createElement(Months, _extends({}, calendarProps, {
|
448
|
+
onHover: this.hoverHandler,
|
449
|
+
onSelect: this.selectHandler,
|
450
|
+
locale: locale
|
451
|
+
})), /*#__PURE__*/React.createElement(Years, calendarProps)), this.props.renderAfterCalendar && this.props.renderAfterCalendar(this.state));
|
452
|
+
}
|
453
|
+
}], [{
|
454
|
+
key: "sameDay",
|
455
|
+
value: function sameDay(next, prev) {
|
456
|
+
if (next && prev) {
|
457
|
+
return isSameDay(next, prev);
|
458
|
+
}
|
459
|
+
return next === prev;
|
460
|
+
}
|
461
|
+
}]);
|
462
|
+
}(Component);
|
463
|
+
_defineProperty(DatePopup, "propTypes", {
|
464
|
+
className: PropTypes.string,
|
465
|
+
date: dateType,
|
466
|
+
range: PropTypes.bool,
|
467
|
+
withTime: PropTypes.bool,
|
468
|
+
time: PropTypes.string,
|
469
|
+
from: dateType,
|
470
|
+
to: dateType,
|
471
|
+
renderAfterCalendar: PropTypes.func,
|
472
|
+
displayFormat: PropTypes.func,
|
473
|
+
parseDateInput: PropTypes.func,
|
474
|
+
onChange: PropTypes.func,
|
475
|
+
onComplete: PropTypes.func,
|
476
|
+
onClear: PropTypes.func,
|
477
|
+
minDate: dateType,
|
478
|
+
maxDate: dateType,
|
479
|
+
fromPlaceholder: PropTypes.string,
|
480
|
+
toPlaceholder: PropTypes.string,
|
481
|
+
timePlaceholder: PropTypes.string,
|
482
|
+
locale: PropTypes.object
|
483
|
+
});
|
484
|
+
_defineProperty(DatePopup, "defaultProps", {
|
485
|
+
onChange() {}
|
486
|
+
});
|
442
487
|
|
443
488
|
export { DatePopup as default };
|