@jetbrains/ring-ui-built 6.0.32 → 6.0.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (224) 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 +177 -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.js +353 -203
  124. package/components/http/http.mock.js +101 -49
  125. package/components/hub-source/hub-source.js +190 -83
  126. package/components/hub-source/hub-source__user.js +44 -11
  127. package/components/hub-source/hub-source__users-groups.js +65 -37
  128. package/components/i18n/i18n-context.js +10 -7
  129. package/components/i18n/i18n.js +10 -7
  130. package/components/icon/icon.js +93 -76
  131. package/components/icon/icon__svg.js +8 -0
  132. package/components/icon/index.js +8 -0
  133. package/components/input/input.js +13 -0
  134. package/components/island/adaptive-island-hoc.js +43 -30
  135. package/components/island/content.js +132 -115
  136. package/components/island/header.js +70 -57
  137. package/components/island/island.js +40 -28
  138. package/components/island-legacy/content-legacy.js +25 -17
  139. package/components/island-legacy/header-legacy.js +27 -19
  140. package/components/island-legacy/island-legacy.js +25 -17
  141. package/components/link/clickableLink.js +59 -44
  142. package/components/link/link.js +68 -57
  143. package/components/list/consts.js +2 -2
  144. package/components/list/list.js +698 -611
  145. package/components/list/list__custom.js +62 -44
  146. package/components/list/list__hint.js +19 -10
  147. package/components/list/list__item.js +174 -133
  148. package/components/list/list__link.js +50 -37
  149. package/components/list/list__separator.js +24 -14
  150. package/components/list/list__title.js +32 -22
  151. package/components/list/list__users-groups-source.js +126 -54
  152. package/components/loader/loader.js +74 -43
  153. package/components/loader/loader__core.js +263 -198
  154. package/components/loader-inline/loader-inline.js +35 -23
  155. package/components/loader-screen/loader-screen.js +46 -25
  156. package/components/login-dialog/login-dialog.js +158 -111
  157. package/components/login-dialog/service.js +34 -8
  158. package/components/markdown/markdown.js +23 -15
  159. package/components/message/message.js +203 -161
  160. package/components/old-browsers-message/old-browsers-message.js +18 -11
  161. package/components/old-browsers-message/old-browsers-message__stop.js +7 -0
  162. package/components/old-browsers-message/white-list.js +16 -8
  163. package/components/pager/pager.js +271 -212
  164. package/components/panel/panel.js +25 -17
  165. package/components/permissions/permissions.js +172 -127
  166. package/components/permissions/permissions__cache.js +224 -194
  167. package/components/popup/popup.consts.js +1 -1
  168. package/components/popup/popup.js +343 -284
  169. package/components/popup/popup.target.js +8 -9
  170. package/components/popup/position.js +106 -96
  171. package/components/popup-menu/popup-menu.js +81 -44
  172. package/components/progress-bar/progress-bar.js +104 -87
  173. package/components/query-assist/query-assist.js +916 -838
  174. package/components/query-assist/query-assist__suggestions.js +30 -1
  175. package/components/radio/radio.js +34 -19
  176. package/components/radio/radio__item.js +69 -52
  177. package/components/select/select.js +957 -852
  178. package/components/select/select__filter.js +30 -0
  179. package/components/select/select__popup.js +487 -373
  180. package/components/shortcuts/core.js +217 -166
  181. package/components/shortcuts/shortcut-title.js +11 -6
  182. package/components/shortcuts/shortcuts-hoc.js +45 -19
  183. package/components/shortcuts/shortcuts.js +75 -50
  184. package/components/slider/slider.js +122 -99
  185. package/components/slider/slider.utils.js +24 -14
  186. package/components/storage/storage.js +33 -4
  187. package/components/storage/storage__fallback.js +224 -149
  188. package/components/storage/storage__local.js +153 -90
  189. package/components/tab-trap/tab-trap.js +153 -122
  190. package/components/table/cell.js +26 -14
  191. package/components/table/disable-hover-hoc.js +51 -33
  192. package/components/table/header-cell.js +89 -64
  193. package/components/table/header.js +132 -104
  194. package/components/table/multitable.js +125 -107
  195. package/components/table/row-with-focus-sensor.js +69 -25
  196. package/components/table/row.js +216 -175
  197. package/components/table/selection-adapter.js +3 -1
  198. package/components/table/selection-shortcuts-hoc.js +181 -180
  199. package/components/table/selection.js +226 -156
  200. package/components/table/smart-table.js +88 -50
  201. package/components/table/table.js +358 -289
  202. package/components/tabs/collapsible-more.js +79 -46
  203. package/components/tabs/collapsible-tab.js +38 -31
  204. package/components/tabs/collapsible-tabs.js +153 -88
  205. package/components/tabs/custom-item.js +2 -4
  206. package/components/tabs/dumb-tabs.js +117 -74
  207. package/components/tabs/smart-tabs.js +69 -29
  208. package/components/tabs/tab-link.js +5 -1
  209. package/components/tabs/tab.js +31 -19
  210. package/components/tabs/tabs.js +31 -0
  211. package/components/tag/tag.js +173 -133
  212. package/components/tags-input/tags-input.js +427 -329
  213. package/components/tags-list/tags-list.js +78 -57
  214. package/components/text/text.js +39 -28
  215. package/components/toggle/toggle.js +70 -56
  216. package/components/tooltip/tooltip.js +190 -146
  217. package/components/user-agreement/service.js +371 -228
  218. package/components/user-agreement/toolbox.eula.js +1 -160
  219. package/components/user-agreement/user-agreement.js +120 -85
  220. package/components/user-card/card.js +29 -0
  221. package/components/user-card/smart-user-card-tooltip.js +111 -51
  222. package/components/user-card/tooltip.js +84 -47
  223. package/components/user-card/user-card.js +29 -0
  224. package/package.json +1 -1
@@ -1,4 +1,7 @@
1
- import { _ as _extends } from '../_helpers/_rollupPluginBabelHelpers.js';
1
+ import { _ as _defineProperty, j as _slicedToArray, l as _createForOfIteratorHelper, a as _inherits, b as _createClass, c as _objectWithoutProperties, e as _extends, d as _objectSpread2, f as _classCallCheck, g as _callSuper } from '../_helpers/_rollupPluginBabelHelpers.js';
2
+ import 'core-js/modules/es.array.concat.js';
3
+ import 'core-js/modules/es.array.map.js';
4
+ import 'core-js/modules/es.object.values.js';
2
5
  import React, { PureComponent } from 'react';
3
6
  import PropTypes from 'prop-types';
4
7
  import classNames from 'classnames';
@@ -23,18 +26,40 @@ import DatePopup from './date-popup.js';
23
26
  import { dateType } from './consts.js';
24
27
  import { m as modules_0c7b7d96 } from '../_helpers/date-picker.js';
25
28
  import formats from './formats.js';
29
+ import 'core-js/modules/es.array.iterator.js';
30
+ import 'core-js/modules/es.map.js';
31
+ import 'core-js/modules/es.object.to-string.js';
32
+ import 'core-js/modules/es.weak-map.js';
33
+ import 'core-js/modules/web.dom-collections.iterator.js';
34
+ import 'core-js/modules/es.object.entries.js';
35
+ import 'core-js/modules/es.regexp.exec.js';
36
+ import 'core-js/modules/es.regexp.to-string.js';
37
+ import 'core-js/modules/es.string.replace.js';
38
+ import 'core-js/modules/web.dom-collections.for-each.js';
26
39
  import 'react-dom';
27
40
  import '../global/get-uid.js';
28
41
  import '../global/schedule-raf.js';
29
42
  import '../global/dom.js';
43
+ import 'core-js/modules/es.array.filter.js';
44
+ import 'core-js/modules/es.object.assign.js';
45
+ import 'core-js/modules/es.set.js';
46
+ import 'core-js/modules/es.string.split.js';
30
47
  import '../shortcuts/shortcuts.js';
31
48
  import '../shortcuts/core.js';
49
+ import 'core-js/modules/es.array.find-index.js';
50
+ import 'core-js/modules/es.array.includes.js';
51
+ import 'core-js/modules/es.array.slice.js';
52
+ import 'core-js/modules/es.array.splice.js';
53
+ import 'core-js/modules/es.string.includes.js';
54
+ import 'core-js/modules/es.string.match.js';
32
55
  import 'combokeys';
33
56
  import '../global/sniffer.js';
34
57
  import 'sniffr';
35
58
  import '../global/data-tests.js';
59
+ import 'core-js/modules/es.array.reduce.js';
36
60
  import '../tab-trap/tab-trap.js';
37
61
  import '../popup/position.js';
62
+ import 'core-js/modules/es.array.sort.js';
38
63
  import '../popup/popup.consts.js';
39
64
  import '../popup/popup.target.js';
40
65
  import '../global/typescript-utils.js';
@@ -43,6 +68,7 @@ import '@jetbrains/icons/chevron-10px';
43
68
  import 'util-deprecate';
44
69
  import '../icon/icon__constants.js';
45
70
  import '../_helpers/icon__svg.js';
71
+ import 'core-js/modules/es.string.starts-with.js';
46
72
  import '../link/clickableLink.js';
47
73
  import '../global/controls-height.js';
48
74
  import '../_helpers/button__classes.js';
@@ -57,6 +83,7 @@ import 'date-fns/isBefore';
57
83
  import 'date-fns/startOfDay';
58
84
  import 'date-fns';
59
85
  import './date-input.js';
86
+ import 'core-js/modules/es.array.index-of.js';
60
87
  import 'date-fns/add';
61
88
  import './months.js';
62
89
  import 'date-fns/addMonths';
@@ -85,16 +112,17 @@ import 'date-fns/isThisYear';
85
112
  import 'date-fns/setYear';
86
113
  import './weekdays.js';
87
114
 
88
- const PopupComponent = _ref => {
89
- let {
90
- hidden = false,
91
- className,
92
- popupRef,
93
- onClear,
94
- datePopupProps,
95
- onComplete,
96
- ...restProps
97
- } = _ref;
115
+ var _excluded = ["hidden", "className", "popupRef", "onClear", "datePopupProps", "onComplete"],
116
+ _excluded2 = ["className", "popupClassName", "clear", "inline", "dropdownProps", "translations"];
117
+ var PopupComponent = function PopupComponent(_ref) {
118
+ var _ref$hidden = _ref.hidden,
119
+ hidden = _ref$hidden === void 0 ? false : _ref$hidden,
120
+ className = _ref.className,
121
+ popupRef = _ref.popupRef,
122
+ onClear = _ref.onClear,
123
+ datePopupProps = _ref.datePopupProps,
124
+ onComplete = _ref.onComplete,
125
+ restProps = _objectWithoutProperties(_ref, _excluded);
98
126
  return /*#__PURE__*/React.createElement(Popup, _extends({
99
127
  hidden: hidden,
100
128
  className: className,
@@ -117,232 +145,259 @@ PopupComponent.propTypes = {
117
145
  /**
118
146
  * @name Date Picker
119
147
  */
120
- class DatePicker extends PureComponent {
121
- static propTypes = {
122
- className: PropTypes.string,
123
- popupClassName: PropTypes.string,
124
- date: dateType,
125
- withTime: PropTypes.bool,
126
- range: PropTypes.bool,
127
- from: dateType,
128
- to: dateType,
129
- clear: PropTypes.bool,
130
- inline: PropTypes.bool,
131
- displayFormat: PropTypes.func,
132
- displayMonthFormat: PropTypes.func,
133
- displayDayFormat: PropTypes.func,
134
- displayTimeFormat: PropTypes.func,
135
- parseDateInput: PropTypes.func,
136
- applyTimeInput: PropTypes.func,
137
- datePlaceholder: PropTypes.string,
138
- dateTimePlaceholder: PropTypes.string,
139
- rangePlaceholder: PropTypes.string,
140
- onChange: PropTypes.func,
141
- dropdownProps: PropTypes.object,
142
- disabled: PropTypes.bool,
143
- minDate: dateType,
144
- maxDate: dateType,
145
- translations: PropTypes.object,
146
- locale: PropTypes.object,
147
- size: PropTypes.oneOf(Object.values(Size))
148
- };
149
- static defaultProps = {
150
- className: '',
151
- date: null,
152
- withTime: false,
153
- range: false,
154
- from: null,
155
- to: null,
156
- clear: false,
157
- inline: false,
158
- size: Size.M,
159
- displayFormat: (date, locale) => date ? format(date, 'd MMM yyyy', {
160
- locale
161
- }) : '',
162
- displayMonthFormat: (date, locale) => date ? format(date, 'd MMM', {
163
- locale
164
- }) : '',
165
- displayDayFormat: (date, locale) => date ? format(date, 'd', {
166
- locale
167
- }) : '',
168
- displayTimeFormat: (date, locale) => date ? format(date, 'HH:mm', {
169
- locale
170
- }) : '',
171
- minDate: null,
172
- maxDate: null,
173
- onChange() {},
174
- applyTimeInput(date, timeString) {
175
- var _timeString$split$map;
176
- const [hours, minutes] = (_timeString$split$map = timeString?.split(':').map(Number)) !== null && _timeString$split$map !== void 0 ? _timeString$split$map : [];
177
- return minutes != null ? set(date, {
178
- hours,
179
- minutes
180
- }) : date;
181
- },
182
- parseDateInput(string) {
183
- if (!string) {
184
- return null;
148
+ var DatePicker = /*#__PURE__*/function (_PureComponent) {
149
+ function DatePicker() {
150
+ var _this;
151
+ _classCallCheck(this, DatePicker);
152
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
153
+ args[_key] = arguments[_key];
154
+ }
155
+ _this = _callSuper(this, DatePicker, [].concat(args));
156
+ _defineProperty(_this, "handleChange", function (change) {
157
+ var _this$props = _this.props,
158
+ onChange = _this$props.onChange,
159
+ withTime = _this$props.withTime,
160
+ applyTimeInput = _this$props.applyTimeInput;
161
+ var adjustedChange = withTime && !(change instanceof Date) && (change === null || change === void 0 ? void 0 : change.date) != null ? applyTimeInput(change.date, change.time) : change;
162
+ onChange(adjustedChange);
163
+ });
164
+ _defineProperty(_this, "clear", function () {
165
+ var change = null;
166
+ if (_this.props.range) {
167
+ change = {
168
+ from: null,
169
+ to: null
170
+ };
185
171
  }
186
- const today = new Date();
187
- for (const format of formats) {
188
- const date = parse(string, format, today);
189
- if (isValid(date)) {
190
- return date;
172
+ _this.handleChange(change);
173
+ });
174
+ _defineProperty(_this, "popup", void 0);
175
+ _defineProperty(_this, "popupRef", function (el) {
176
+ _this.popup = el;
177
+ });
178
+ _defineProperty(_this, "closePopup", function () {
179
+ var _this$popup;
180
+ (_this$popup = _this.popup) === null || _this$popup === void 0 || _this$popup._onCloseAttempt();
181
+ });
182
+ _defineProperty(_this, "parse", memoize(function (date) {
183
+ var parseDateInput = _this.props.parseDateInput;
184
+ if (date instanceof Date) {
185
+ return date;
186
+ }
187
+ if (typeof date === 'number') {
188
+ return new Date(date);
189
+ }
190
+ return parseDateInput(date);
191
+ }));
192
+ _defineProperty(_this, "getAnchorText", function () {
193
+ var _this$props2 = _this.props,
194
+ range = _this$props2.range,
195
+ datePlaceholder = _this$props2.datePlaceholder,
196
+ dateTimePlaceholder = _this$props2.dateTimePlaceholder,
197
+ rangePlaceholder = _this$props2.rangePlaceholder,
198
+ withTime = _this$props2.withTime,
199
+ displayFormat = _this$props2.displayFormat,
200
+ displayMonthFormat = _this$props2.displayMonthFormat,
201
+ displayDayFormat = _this$props2.displayDayFormat,
202
+ translations = _this$props2.translations,
203
+ locale = _this$props2.locale;
204
+ var translate = _this.context.translate;
205
+ var date = _this.parse(_this.props.date);
206
+ var from = _this.parse(_this.props.from);
207
+ var to = _this.parse(_this.props.to);
208
+ var time = _this.formatTime();
209
+ if (!range && !withTime) {
210
+ var _ref2;
211
+ return date ? displayFormat(date, locale) : (_ref2 = datePlaceholder !== null && datePlaceholder !== void 0 ? datePlaceholder : translations === null || translations === void 0 ? void 0 : translations.setDate) !== null && _ref2 !== void 0 ? _ref2 : translate('setDate');
212
+ } else if (!range && withTime) {
213
+ if (!date && !time) {
214
+ var _ref3;
215
+ return (_ref3 = dateTimePlaceholder !== null && dateTimePlaceholder !== void 0 ? dateTimePlaceholder : translations === null || translations === void 0 ? void 0 : translations.setDateTime) !== null && _ref3 !== void 0 ? _ref3 : translate('setDateTime');
216
+ } else {
217
+ return "".concat(date && displayFormat(date, locale) || '—', ", ").concat(time || '—');
218
+ }
219
+ } else if (from && to) {
220
+ if (!isSameYear(from, to)) {
221
+ return "".concat(displayFormat(from, locale), " \u2014 ").concat(displayFormat(to, locale));
222
+ } else if (!isSameMonth(from, to)) {
223
+ return "".concat(displayMonthFormat(from, locale), " \u2014 ").concat(displayFormat(to, locale));
224
+ } else if (!isSameDay(from, to)) {
225
+ return "".concat(displayDayFormat(from, locale), " \u2014 ").concat(displayFormat(to, locale));
226
+ } else {
227
+ return "".concat(displayFormat(to, locale));
191
228
  }
229
+ } else if (from) {
230
+ return "".concat(displayFormat(from, locale), " \u2014");
231
+ } else if (to) {
232
+ return "\u2014 ".concat(displayFormat(to, locale));
233
+ } else {
234
+ var _ref4;
235
+ return (_ref4 = rangePlaceholder !== null && rangePlaceholder !== void 0 ? rangePlaceholder : translations === null || translations === void 0 ? void 0 : translations.setPeriod) !== null && _ref4 !== void 0 ? _ref4 : translate('setPeriod');
236
+ }
237
+ });
238
+ return _this;
239
+ }
240
+ _inherits(DatePicker, _PureComponent);
241
+ return _createClass(DatePicker, [{
242
+ key: "formatTime",
243
+ value: function formatTime() {
244
+ var _this$props3 = this.props,
245
+ displayTimeFormat = _this$props3.displayTimeFormat,
246
+ locale = _this$props3.locale;
247
+ var date = this.parse(this.props.date);
248
+ if (date != null) {
249
+ return displayTimeFormat(date, locale);
192
250
  }
193
251
  return null;
194
252
  }
195
- };
196
- static contextType = I18nContext;
197
- handleChange = change => {
198
- const {
199
- onChange,
200
- withTime,
201
- applyTimeInput
202
- } = this.props;
203
- const adjustedChange = withTime && !(change instanceof Date) && change?.date != null ? applyTimeInput(change.date, change.time) : change;
204
- onChange(adjustedChange);
205
- };
206
- clear = () => {
207
- let change = null;
208
- if (this.props.range) {
209
- change = {
210
- from: null,
211
- to: null
212
- };
213
- }
214
- this.handleChange(change);
215
- };
216
- popup;
217
- popupRef = el => {
218
- this.popup = el;
219
- };
220
- closePopup = () => {
221
- this.popup?._onCloseAttempt();
222
- };
223
- parse = memoize(date => {
224
- const {
225
- parseDateInput
226
- } = this.props;
227
- if (date instanceof Date) {
228
- return date;
253
+ }, {
254
+ key: "render",
255
+ value: function render() {
256
+ var _this$props$disabled, _this$props$disabled2;
257
+ var anchorContent = /*#__PURE__*/React.createElement("div", {
258
+ className: modules_0c7b7d96.anchorContent
259
+ }, /*#__PURE__*/React.createElement(Icon, {
260
+ glyph: calendarIcon,
261
+ className: modules_0c7b7d96.calendarIcon
262
+ }), this.getAnchorText(), /*#__PURE__*/React.createElement(Icon, {
263
+ glyph: chevronDownIcon,
264
+ className: modules_0c7b7d96.chevronDownIcon
265
+ }));
266
+ var _this$props4 = this.props,
267
+ className = _this$props4.className,
268
+ popupClassName = _this$props4.popupClassName,
269
+ clear = _this$props4.clear,
270
+ inline = _this$props4.inline,
271
+ dropdownProps = _this$props4.dropdownProps,
272
+ translations = _this$props4.translations,
273
+ datePopupProps = _objectWithoutProperties(_this$props4, _excluded2);
274
+ var classes = classNames(modules_0c7b7d96.datePicker, className, modules_0c7b7d96["size".concat(this.props.size)], {
275
+ [modules_0c7b7d96.inline]: inline
276
+ });
277
+ return /*#__PURE__*/React.createElement(Dropdown, _extends({
278
+ className: classes,
279
+ disabled: this.props.disabled,
280
+ anchor: inline ? /*#__PURE__*/React.createElement(Link, {
281
+ "data-test-ring-dropdown-anchor": true,
282
+ className: modules_0c7b7d96.anchor,
283
+ disabled: (_this$props$disabled = this.props.disabled) !== null && _this$props$disabled !== void 0 ? _this$props$disabled : false,
284
+ pseudo: true
285
+ }, this.getAnchorText()) : /*#__PURE__*/React.createElement(Button, {
286
+ "data-test-ring-dropdown-anchor": true,
287
+ className: modules_0c7b7d96.anchor,
288
+ text: false,
289
+ disabled: (_this$props$disabled2 = this.props.disabled) !== null && _this$props$disabled2 !== void 0 ? _this$props$disabled2 : false
290
+ }, anchorContent)
291
+ }, dropdownProps), /*#__PURE__*/React.createElement(PopupComponent, {
292
+ className: popupClassName,
293
+ popupRef: this.popupRef,
294
+ onClear: clear ? this.clear : null,
295
+ datePopupProps: _objectSpread2(_objectSpread2({}, datePopupProps), {}, {
296
+ translations,
297
+ onChange: this.handleChange,
298
+ parseDateInput: this.parse,
299
+ time: this.formatTime()
300
+ }),
301
+ onComplete: this.closePopup
302
+ }));
229
303
  }
230
- if (typeof date === 'number') {
231
- return new Date(date);
232
- }
233
- return parseDateInput(date);
234
- });
235
- formatTime() {
236
- const {
237
- displayTimeFormat,
304
+ }]);
305
+ }(PureComponent);
306
+ _defineProperty(DatePicker, "propTypes", {
307
+ className: PropTypes.string,
308
+ popupClassName: PropTypes.string,
309
+ date: dateType,
310
+ withTime: PropTypes.bool,
311
+ range: PropTypes.bool,
312
+ from: dateType,
313
+ to: dateType,
314
+ clear: PropTypes.bool,
315
+ inline: PropTypes.bool,
316
+ displayFormat: PropTypes.func,
317
+ displayMonthFormat: PropTypes.func,
318
+ displayDayFormat: PropTypes.func,
319
+ displayTimeFormat: PropTypes.func,
320
+ parseDateInput: PropTypes.func,
321
+ applyTimeInput: PropTypes.func,
322
+ datePlaceholder: PropTypes.string,
323
+ dateTimePlaceholder: PropTypes.string,
324
+ rangePlaceholder: PropTypes.string,
325
+ onChange: PropTypes.func,
326
+ dropdownProps: PropTypes.object,
327
+ disabled: PropTypes.bool,
328
+ minDate: dateType,
329
+ maxDate: dateType,
330
+ translations: PropTypes.object,
331
+ locale: PropTypes.object,
332
+ size: PropTypes.oneOf(Object.values(Size))
333
+ });
334
+ _defineProperty(DatePicker, "defaultProps", {
335
+ className: '',
336
+ date: null,
337
+ withTime: false,
338
+ range: false,
339
+ from: null,
340
+ to: null,
341
+ clear: false,
342
+ inline: false,
343
+ size: Size.M,
344
+ displayFormat: function displayFormat(date, locale) {
345
+ return date ? format(date, 'd MMM yyyy', {
238
346
  locale
239
- } = this.props;
240
- const date = this.parse(this.props.date);
241
- if (date != null) {
242
- return displayTimeFormat(date, locale);
243
- }
244
- return null;
245
- }
246
- getAnchorText = () => {
247
- const {
248
- range,
249
- datePlaceholder,
250
- dateTimePlaceholder,
251
- rangePlaceholder,
252
- withTime,
253
- displayFormat,
254
- displayMonthFormat,
255
- displayDayFormat,
256
- translations,
347
+ }) : '';
348
+ },
349
+ displayMonthFormat: function displayMonthFormat(date, locale) {
350
+ return date ? format(date, 'd MMM', {
257
351
  locale
258
- } = this.props;
259
- const {
260
- translate
261
- } = this.context;
262
- const date = this.parse(this.props.date);
263
- const from = this.parse(this.props.from);
264
- const to = this.parse(this.props.to);
265
- const time = this.formatTime();
266
- if (!range && !withTime) {
267
- var _ref2;
268
- return date ? displayFormat(date, locale) : (_ref2 = datePlaceholder !== null && datePlaceholder !== void 0 ? datePlaceholder : translations?.setDate) !== null && _ref2 !== void 0 ? _ref2 : translate('setDate');
269
- } else if (!range && withTime) {
270
- if (!date && !time) {
271
- var _ref3;
272
- return (_ref3 = dateTimePlaceholder !== null && dateTimePlaceholder !== void 0 ? dateTimePlaceholder : translations?.setDateTime) !== null && _ref3 !== void 0 ? _ref3 : translate('setDateTime');
273
- } else {
274
- return `${date && displayFormat(date, locale) || '—'}, ${time || '—'}`;
275
- }
276
- } else if (from && to) {
277
- if (!isSameYear(from, to)) {
278
- return `${displayFormat(from, locale)} — ${displayFormat(to, locale)}`;
279
- } else if (!isSameMonth(from, to)) {
280
- return `${displayMonthFormat(from, locale)} — ${displayFormat(to, locale)}`;
281
- } else if (!isSameDay(from, to)) {
282
- return `${displayDayFormat(from, locale)} ${displayFormat(to, locale)}`;
283
- } else {
284
- return `${displayFormat(to, locale)}`;
352
+ }) : '';
353
+ },
354
+ displayDayFormat: function displayDayFormat(date, locale) {
355
+ return date ? format(date, 'd', {
356
+ locale
357
+ }) : '';
358
+ },
359
+ displayTimeFormat: function displayTimeFormat(date, locale) {
360
+ return date ? format(date, 'HH:mm', {
361
+ locale
362
+ }) : '';
363
+ },
364
+ minDate: null,
365
+ maxDate: null,
366
+ onChange() {},
367
+ applyTimeInput(date, timeString) {
368
+ var _timeString$split$map;
369
+ var _ref5 = (_timeString$split$map = timeString === null || timeString === void 0 ? void 0 : timeString.split(':').map(Number)) !== null && _timeString$split$map !== void 0 ? _timeString$split$map : [],
370
+ _ref6 = _slicedToArray(_ref5, 2),
371
+ hours = _ref6[0],
372
+ minutes = _ref6[1];
373
+ return minutes != null ? set(date, {
374
+ hours,
375
+ minutes
376
+ }) : date;
377
+ },
378
+ parseDateInput(string) {
379
+ if (!string) {
380
+ return null;
381
+ }
382
+ var today = new Date();
383
+ var _iterator = _createForOfIteratorHelper(formats),
384
+ _step;
385
+ try {
386
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
387
+ var format = _step.value;
388
+ var date = parse(string, format, today);
389
+ if (isValid(date)) {
390
+ return date;
391
+ }
285
392
  }
286
- } else if (from) {
287
- return `${displayFormat(from, locale)} —`;
288
- } else if (to) {
289
- return `— ${displayFormat(to, locale)}`;
290
- } else {
291
- var _ref4;
292
- return (_ref4 = rangePlaceholder !== null && rangePlaceholder !== void 0 ? rangePlaceholder : translations?.setPeriod) !== null && _ref4 !== void 0 ? _ref4 : translate('setPeriod');
393
+ } catch (err) {
394
+ _iterator.e(err);
395
+ } finally {
396
+ _iterator.f();
293
397
  }
294
- };
295
- render() {
296
- var _this$props$disabled, _this$props$disabled2;
297
- const anchorContent = /*#__PURE__*/React.createElement("div", {
298
- className: modules_0c7b7d96.anchorContent
299
- }, /*#__PURE__*/React.createElement(Icon, {
300
- glyph: calendarIcon,
301
- className: modules_0c7b7d96.calendarIcon
302
- }), this.getAnchorText(), /*#__PURE__*/React.createElement(Icon, {
303
- glyph: chevronDownIcon,
304
- className: modules_0c7b7d96.chevronDownIcon
305
- }));
306
- const {
307
- className,
308
- popupClassName,
309
- clear,
310
- inline,
311
- dropdownProps,
312
- translations,
313
- ...datePopupProps
314
- } = this.props;
315
- const classes = classNames(modules_0c7b7d96.datePicker, className, modules_0c7b7d96[`size${this.props.size}`], {
316
- [modules_0c7b7d96.inline]: inline
317
- });
318
- return /*#__PURE__*/React.createElement(Dropdown, _extends({
319
- className: classes,
320
- disabled: this.props.disabled,
321
- anchor: inline ? /*#__PURE__*/React.createElement(Link, {
322
- "data-test-ring-dropdown-anchor": true,
323
- className: modules_0c7b7d96.anchor,
324
- disabled: (_this$props$disabled = this.props.disabled) !== null && _this$props$disabled !== void 0 ? _this$props$disabled : false,
325
- pseudo: true
326
- }, this.getAnchorText()) : /*#__PURE__*/React.createElement(Button, {
327
- "data-test-ring-dropdown-anchor": true,
328
- className: modules_0c7b7d96.anchor,
329
- text: false,
330
- disabled: (_this$props$disabled2 = this.props.disabled) !== null && _this$props$disabled2 !== void 0 ? _this$props$disabled2 : false
331
- }, anchorContent)
332
- }, dropdownProps), /*#__PURE__*/React.createElement(PopupComponent, {
333
- className: popupClassName,
334
- popupRef: this.popupRef,
335
- onClear: clear ? this.clear : null,
336
- datePopupProps: {
337
- ...datePopupProps,
338
- translations,
339
- onChange: this.handleChange,
340
- parseDateInput: this.parse,
341
- time: this.formatTime()
342
- },
343
- onComplete: this.closePopup
344
- }));
398
+ return null;
345
399
  }
346
- }
400
+ });
401
+ _defineProperty(DatePicker, "contextType", I18nContext);
347
402
 
348
403
  export { DatePicker as default };