@jetbrains/ring-ui-built 6.0.32 → 6.0.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (226) hide show
  1. package/components/_helpers/_rollupPluginBabelHelpers.js +567 -1
  2. package/components/_helpers/anchor.js +6 -7
  3. package/components/_helpers/button__classes.js +14 -16
  4. package/components/_helpers/caption.js +20 -14
  5. package/components/_helpers/card.js +105 -95
  6. package/components/_helpers/dialog__body-scroll-preventer.js +19 -11
  7. package/components/_helpers/icon__svg.js +25 -22
  8. package/components/_helpers/input.js +176 -146
  9. package/components/_helpers/query-assist__suggestions.js +90 -74
  10. package/components/_helpers/select__filter.js +69 -48
  11. package/components/_helpers/services-link.js +37 -29
  12. package/components/_helpers/sidebar.js +107 -99
  13. package/components/_helpers/tab-link.js +7 -7
  14. package/components/_helpers/theme.js +40 -31
  15. package/components/_helpers/title.js +72 -57
  16. package/components/alert/alert.js +202 -150
  17. package/components/alert/container.js +41 -32
  18. package/components/alert-service/alert-service.js +170 -105
  19. package/components/analytics/analytics.js +22 -12
  20. package/components/analytics/analytics__custom-plugin.js +75 -54
  21. package/components/auth/auth.js +36 -4
  22. package/components/auth/auth__core.js +1471 -746
  23. package/components/auth/background-flow.js +127 -87
  24. package/components/auth/down-notification.js +73 -30
  25. package/components/auth/iframe-flow.js +133 -75
  26. package/components/auth/request-builder.js +82 -46
  27. package/components/auth/response-parser.js +116 -86
  28. package/components/auth/storage.js +334 -171
  29. package/components/auth/token-validator.js +242 -137
  30. package/components/auth/window-flow.js +134 -92
  31. package/components/auth-dialog/auth-dialog.js +172 -114
  32. package/components/auth-dialog-service/auth-dialog-service.js +31 -8
  33. package/components/avatar/avatar-example-datauri.js +1 -23
  34. package/components/avatar/avatar.js +152 -119
  35. package/components/avatar/fallback-avatar.js +38 -22
  36. package/components/badge/badge.js +45 -35
  37. package/components/button/button.js +107 -86
  38. package/components/button-group/button-group.js +33 -19
  39. package/components/button-set/button-set.js +32 -20
  40. package/components/button-toolbar/button-toolbar.js +31 -19
  41. package/components/caret/caret.js +220 -186
  42. package/components/checkbox/checkbox.js +101 -76
  43. package/components/clipboard/clipboard-fallback.js +10 -10
  44. package/components/clipboard/clipboard.js +132 -35
  45. package/components/code/code.js +166 -92
  46. package/components/collapse/collapse-content.js +64 -42
  47. package/components/collapse/collapse-context.js +2 -2
  48. package/components/collapse/collapse-control.js +14 -12
  49. package/components/collapse/collapse.js +17 -11
  50. package/components/collapse/consts.js +4 -4
  51. package/components/collapse/utils.js +3 -1
  52. package/components/confirm/confirm.js +104 -66
  53. package/components/confirm-service/confirm-service.js +59 -37
  54. package/components/content-layout/content-layout.js +64 -43
  55. package/components/content-layout/sidebar.js +1 -0
  56. package/components/contenteditable/contenteditable.js +59 -50
  57. package/components/control-label/control-label.js +9 -9
  58. package/components/data-list/data-list.js +182 -129
  59. package/components/data-list/data-list.mock.js +6 -2
  60. package/components/data-list/item.js +170 -143
  61. package/components/data-list/selection.js +136 -76
  62. package/components/data-list/title.js +12 -1
  63. package/components/date-picker/consts.js +26 -19
  64. package/components/date-picker/date-input.js +144 -113
  65. package/components/date-picker/date-picker.js +282 -227
  66. package/components/date-picker/date-popup.js +395 -350
  67. package/components/date-picker/day.js +116 -87
  68. package/components/date-picker/month-names.js +66 -43
  69. package/components/date-picker/month-slider.js +76 -51
  70. package/components/date-picker/month.js +25 -16
  71. package/components/date-picker/months.js +50 -43
  72. package/components/date-picker/weekdays.js +22 -12
  73. package/components/date-picker/years.js +110 -83
  74. package/components/dialog/dialog.js +190 -142
  75. package/components/dialog/dialog__body-scroll-preventer.js +4 -0
  76. package/components/dropdown/anchor.js +9 -0
  77. package/components/dropdown/dropdown.js +213 -182
  78. package/components/dropdown-menu/dropdown-menu.js +97 -71
  79. package/components/editable-heading/editable-heading.js +127 -75
  80. package/components/error-bubble/error-bubble.js +60 -31
  81. package/components/error-message/error-message.js +59 -39
  82. package/components/footer/footer.js +30 -27
  83. package/components/global/compose.js +10 -1
  84. package/components/global/composeRefs.js +12 -7
  85. package/components/global/controls-height.js +2 -2
  86. package/components/global/create-stateful-context.js +15 -15
  87. package/components/global/data-tests.js +14 -6
  88. package/components/global/dom.js +86 -47
  89. package/components/global/focus-sensor-hoc.js +132 -122
  90. package/components/global/fuzzy-highlight.js +36 -22
  91. package/components/global/get-event-key.js +8 -8
  92. package/components/global/get-uid.js +8 -4
  93. package/components/global/inject-styles.js +15 -10
  94. package/components/global/listeners.js +51 -27
  95. package/components/global/memoize.js +12 -6
  96. package/components/global/normalize-indent.js +50 -19
  97. package/components/global/promise-with-timeout.js +8 -6
  98. package/components/global/prop-types.js +5 -3
  99. package/components/global/react-dom-renderer.js +44 -28
  100. package/components/global/react-render-adapter.js +1 -1
  101. package/components/global/rerender-hoc.js +30 -12
  102. package/components/global/schedule-raf.js +6 -5
  103. package/components/global/sniffer.js +1 -1
  104. package/components/global/theme.js +22 -0
  105. package/components/global/trivial-template-tag.js +10 -3
  106. package/components/global/typescript-utils.js +6 -2
  107. package/components/global/url.js +26 -20
  108. package/components/global/use-event-callback.js +4 -6
  109. package/components/grid/col.js +52 -35
  110. package/components/grid/grid.js +31 -17
  111. package/components/grid/row.js +47 -35
  112. package/components/group/group.js +25 -17
  113. package/components/header/header.js +78 -33
  114. package/components/header/logo.js +36 -20
  115. package/components/header/profile.js +199 -166
  116. package/components/header/services-link.js +4 -0
  117. package/components/header/services.js +116 -73
  118. package/components/header/smart-profile.js +203 -111
  119. package/components/header/smart-services.js +113 -62
  120. package/components/header/tray-icon.js +37 -21
  121. package/components/header/tray.js +32 -21
  122. package/components/heading/heading.js +25 -24
  123. package/components/http/http.d.ts +1 -2
  124. package/components/http/http.js +345 -203
  125. package/components/http/http.mock.d.ts +1 -5
  126. package/components/http/http.mock.js +101 -49
  127. package/components/hub-source/hub-source.js +190 -83
  128. package/components/hub-source/hub-source__user.js +44 -11
  129. package/components/hub-source/hub-source__users-groups.js +65 -37
  130. package/components/i18n/i18n-context.js +10 -7
  131. package/components/i18n/i18n.js +10 -7
  132. package/components/icon/icon.js +93 -76
  133. package/components/icon/icon__svg.js +8 -0
  134. package/components/icon/index.js +8 -0
  135. package/components/input/input.js +13 -0
  136. package/components/island/adaptive-island-hoc.js +43 -30
  137. package/components/island/content.js +132 -115
  138. package/components/island/header.js +70 -57
  139. package/components/island/island.js +40 -28
  140. package/components/island-legacy/content-legacy.js +25 -17
  141. package/components/island-legacy/header-legacy.js +27 -19
  142. package/components/island-legacy/island-legacy.js +25 -17
  143. package/components/link/clickableLink.js +59 -44
  144. package/components/link/link.js +68 -57
  145. package/components/list/consts.js +2 -2
  146. package/components/list/list.js +698 -611
  147. package/components/list/list__custom.js +62 -44
  148. package/components/list/list__hint.js +19 -10
  149. package/components/list/list__item.js +174 -133
  150. package/components/list/list__link.js +50 -37
  151. package/components/list/list__separator.js +24 -14
  152. package/components/list/list__title.js +32 -22
  153. package/components/list/list__users-groups-source.js +126 -54
  154. package/components/loader/loader.js +74 -43
  155. package/components/loader/loader__core.js +263 -198
  156. package/components/loader-inline/loader-inline.js +35 -23
  157. package/components/loader-screen/loader-screen.js +46 -25
  158. package/components/login-dialog/login-dialog.js +158 -111
  159. package/components/login-dialog/service.js +34 -8
  160. package/components/markdown/markdown.js +23 -15
  161. package/components/message/message.js +203 -161
  162. package/components/old-browsers-message/old-browsers-message.js +18 -11
  163. package/components/old-browsers-message/old-browsers-message__stop.js +7 -0
  164. package/components/old-browsers-message/white-list.js +17 -9
  165. package/components/pager/pager.js +271 -212
  166. package/components/panel/panel.js +25 -17
  167. package/components/permissions/permissions.js +172 -127
  168. package/components/permissions/permissions__cache.js +224 -194
  169. package/components/popup/popup.consts.js +1 -1
  170. package/components/popup/popup.js +343 -284
  171. package/components/popup/popup.target.js +8 -9
  172. package/components/popup/position.js +106 -96
  173. package/components/popup-menu/popup-menu.js +81 -44
  174. package/components/progress-bar/progress-bar.js +104 -87
  175. package/components/query-assist/query-assist.js +916 -838
  176. package/components/query-assist/query-assist__suggestions.js +30 -1
  177. package/components/radio/radio.js +34 -19
  178. package/components/radio/radio__item.js +69 -52
  179. package/components/select/select.js +957 -852
  180. package/components/select/select__filter.js +30 -0
  181. package/components/select/select__popup.js +487 -373
  182. package/components/shortcuts/core.js +217 -166
  183. package/components/shortcuts/shortcut-title.js +11 -6
  184. package/components/shortcuts/shortcuts-hoc.js +45 -19
  185. package/components/shortcuts/shortcuts.js +75 -50
  186. package/components/slider/slider.js +122 -99
  187. package/components/slider/slider.utils.js +24 -14
  188. package/components/storage/storage.js +33 -4
  189. package/components/storage/storage__fallback.js +224 -149
  190. package/components/storage/storage__local.js +153 -90
  191. package/components/tab-trap/tab-trap.js +153 -122
  192. package/components/table/cell.js +26 -14
  193. package/components/table/disable-hover-hoc.js +51 -33
  194. package/components/table/header-cell.js +89 -64
  195. package/components/table/header.js +132 -104
  196. package/components/table/multitable.js +125 -107
  197. package/components/table/row-with-focus-sensor.js +69 -25
  198. package/components/table/row.js +216 -175
  199. package/components/table/selection-adapter.js +3 -1
  200. package/components/table/selection-shortcuts-hoc.js +181 -180
  201. package/components/table/selection.js +226 -156
  202. package/components/table/smart-table.js +88 -50
  203. package/components/table/table.js +358 -289
  204. package/components/tabs/collapsible-more.js +79 -46
  205. package/components/tabs/collapsible-tab.js +38 -31
  206. package/components/tabs/collapsible-tabs.js +153 -88
  207. package/components/tabs/custom-item.js +2 -4
  208. package/components/tabs/dumb-tabs.js +117 -74
  209. package/components/tabs/smart-tabs.js +69 -29
  210. package/components/tabs/tab-link.js +5 -1
  211. package/components/tabs/tab.js +31 -19
  212. package/components/tabs/tabs.js +31 -0
  213. package/components/tag/tag.js +173 -133
  214. package/components/tags-input/tags-input.js +427 -329
  215. package/components/tags-list/tags-list.js +78 -57
  216. package/components/text/text.js +39 -28
  217. package/components/toggle/toggle.js +70 -56
  218. package/components/tooltip/tooltip.js +190 -146
  219. package/components/user-agreement/service.js +371 -228
  220. package/components/user-agreement/toolbox.eula.js +1 -160
  221. package/components/user-agreement/user-agreement.js +120 -85
  222. package/components/user-card/card.js +29 -0
  223. package/components/user-card/smart-user-card-tooltip.js +111 -51
  224. package/components/user-card/tooltip.js +84 -47
  225. package/components/user-card/user-card.js +29 -0
  226. package/package.json +1 -2
@@ -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
- 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 = {
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
- const {
103
- range,
104
- withTime
105
- } = props;
205
+ var range = props.range,
206
+ withTime = props.withTime;
106
207
  if (!range) {
107
- const parsedDate = this.parse(props.date, 'date');
108
- const active = withTime && parsedDate && !props.time ? 'time' : 'date';
109
- this.state = {
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
- this.state = {
115
- ...defaultState,
214
+ _this.state = _objectSpread2(_objectSpread2({}, defaultState), {}, {
116
215
  active: 'to'
117
- };
216
+ });
118
217
  } else {
119
- this.state = {
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
- componentDidUpdate(prevProps, prevState) {
131
- if (this.state.active !== prevState.active) {
132
- if (this.state.text && prevState.active) {
133
- this.confirm(prevState.active);
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
- componentWillUnmount() {
141
- if (this.componentRef.current) {
142
- this.componentRef.current.removeEventListener('wheel', this.handleWheel);
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
- _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();
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
- parse(text, type) {
155
- if (type === 'time') {
156
- return parseTime(String(text));
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
- 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) {
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
- } 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
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
- to = from;
215
- from = changes.to;
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
- 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
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
- [this.state.active]: date
348
+ [name]: result
315
349
  });
316
350
  }
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) {
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
- if (isBefore(startOfDay(activeDate), startOfDay(dates.from))) {
375
- activeRange = [activeDate, dates.from];
376
- } else {
377
- activeRange = [dates.from, activeDate];
378
- }
379
- break;
380
- }
381
- }
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);
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
- 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),
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(name),
414
- onClear: onClear,
440
+ onConfirm: this.handleConfirm('time'),
441
+ onClear: clearable && this.onClear || undefined,
415
442
  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
- }
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 };