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