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