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