@jetbrains/ring-ui-built 7.0.65 → 7.0.70
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/_helpers/anchor.js +12 -17
- package/components/_helpers/avatar-info.js +4 -5
- package/components/_helpers/button.classes.js +20 -21
- package/components/_helpers/caption.js +3 -3
- package/components/_helpers/card.js +26 -32
- package/components/_helpers/dialog-body-scroll-preventer.js +1 -2
- package/components/_helpers/icon-svg.js +9 -12
- package/components/_helpers/input.js +78 -86
- package/components/_helpers/loader-core.js +260 -0
- package/components/_helpers/query-assist-suggestions.js +0 -1
- package/components/_helpers/select-filter.js +19 -26
- package/components/_helpers/services-link.js +9 -12
- package/components/_helpers/sidebar.js +36 -44
- package/components/_helpers/tab-link.js +9 -11
- package/components/_helpers/theme.js +20 -24
- package/components/_helpers/title.js +12 -17
- package/components/alert/alert.js +41 -49
- package/components/alert/container.js +9 -12
- package/components/alert-service/alert-service.js +23 -32
- package/components/analytics/analytics-custom-plugin.js +12 -17
- package/components/analytics/analytics.js +1 -3
- package/components/auth/auth-core.js +128 -170
- package/components/auth/auth.js +3 -10
- package/components/auth/background-flow.js +5 -8
- package/components/auth/down-notification.js +9 -17
- package/components/auth/iframe-flow.js +13 -19
- package/components/auth/request-builder.js +4 -9
- package/components/auth/response-parser.js +9 -12
- package/components/auth/storage.js +12 -18
- package/components/auth/token-validator.js +19 -30
- package/components/auth/window-flow.js +22 -27
- package/components/auth-dialog/auth-dialog.js +40 -48
- package/components/auth-dialog-service/auth-dialog-service.js +10 -13
- package/components/avatar/avatar.figma.js +6 -6
- package/components/avatar/avatar.js +58 -59
- package/components/avatar/fallback-avatar.js +8 -11
- package/components/avatar-stack/avatar-stack.figma.js +10 -11
- package/components/avatar-stack/avatar-stack.js +25 -31
- package/components/banner/banner.js +0 -6
- package/components/breadcrumbs/breadcrumbs.figma.js +8 -6
- package/components/breadcrumbs/breadcrumbs.js +4 -5
- package/components/button/button.figma.js +15 -10
- package/components/button/button.js +59 -64
- package/components/button-group/button-group.js +11 -15
- package/components/button-group/caption.js +0 -1
- package/components/button-set/button-set.js +9 -12
- package/components/button-toolbar/button-toolbar.js +8 -11
- package/components/caret/caret.js +20 -28
- package/components/checkbox/checkbox-group.figma.js +8 -10
- package/components/checkbox/checkbox.figma.js +5 -5
- package/components/checkbox/checkbox.js +27 -35
- package/components/clipboard/clipboard-fallback.js +3 -3
- package/components/clipboard/clipboard.js +3 -16
- package/components/code/code.js +8 -14
- package/components/collapse/collapse-content.js +10 -15
- package/components/collapse/collapse-control.js +5 -7
- package/components/collapse/collapse.js +9 -11
- package/components/collapse/utils.js +1 -1
- package/components/confirm/confirm.js +17 -26
- package/components/confirm-service/confirm-service.js +30 -31
- package/components/content-layout/content-layout.js +21 -28
- package/components/content-layout/sidebar.js +0 -2
- package/components/contenteditable/contenteditable.js +23 -28
- package/components/control-help/control-help.js +8 -10
- package/components/control-label/control-label.js +12 -17
- package/components/data-list/data-list.js +57 -65
- package/components/data-list/data-list.mock.js +0 -4
- package/components/data-list/item.js +65 -72
- package/components/data-list/selection.js +11 -19
- package/components/data-list/title.js +0 -4
- package/components/date-picker/consts.js +3 -4
- package/components/date-picker/date-input.js +25 -33
- package/components/date-picker/date-picker.js +179 -193
- package/components/date-picker/date-popup.js +135 -127
- package/components/date-picker/day.d.ts +1 -1
- package/components/date-picker/day.js +24 -30
- package/components/date-picker/month-names.js +7 -12
- package/components/date-picker/month-slider.js +16 -22
- package/components/date-picker/month.js +3 -5
- package/components/date-picker/months.js +6 -6
- package/components/date-picker/weekdays.js +0 -1
- package/components/date-picker/years.js +20 -26
- package/components/dialog/dialog-body-scroll-preventer.js +0 -1
- package/components/dialog/dialog.js +73 -83
- package/components/dropdown/anchor.js +0 -4
- package/components/dropdown/dropdown.js +98 -114
- package/components/dropdown-menu/dropdown-menu.js +80 -79
- package/components/editable-heading/editable-heading.js +48 -54
- package/components/error-bubble/error-bubble.figma.js +4 -4
- package/components/error-bubble/error-bubble.js +9 -13
- package/components/error-message/error-message.js +1 -6
- package/components/footer/footer.js +11 -15
- package/components/global/compose-refs.js +1 -4
- package/components/global/compose.js +1 -4
- package/components/global/configuration.js +3 -3
- package/components/global/controls-height.js +0 -1
- package/components/global/create-stateful-context.js +10 -14
- package/components/global/data-tests.js +2 -10
- package/components/global/dom.js +6 -19
- package/components/global/focus-sensor-hoc.js +74 -87
- package/components/global/fuzzy-highlight.js +3 -8
- package/components/global/get-uid.js +1 -1
- package/components/global/inject-styles.js +5 -6
- package/components/global/listeners.js +2 -11
- package/components/global/memoize.js +0 -2
- package/components/global/normalize-indent.js +2 -6
- package/components/global/promise-with-timeout.js +4 -5
- package/components/global/react-dom-renderer.js +4 -9
- package/components/global/rerender-hoc.js +8 -11
- package/components/global/schedule-raf.js +1 -2
- package/components/global/theme.js +0 -5
- package/components/global/trivial-template-tag.js +1 -6
- package/components/global/url.js +2 -6
- package/components/global/use-event-callback.js +2 -3
- package/components/grid/col.js +7 -18
- package/components/grid/grid.js +9 -14
- package/components/grid/row.js +7 -11
- package/components/group/group.js +9 -12
- package/components/header/header-icon.js +8 -13
- package/components/header/header.js +16 -27
- package/components/header/links.js +7 -10
- package/components/header/logo.js +12 -16
- package/components/header/profile.js +73 -83
- package/components/header/services-link.js +0 -2
- package/components/header/services.js +32 -43
- package/components/header/smart-profile.js +44 -59
- package/components/header/smart-services.js +33 -45
- package/components/header/tray.js +8 -10
- package/components/heading/heading.js +27 -27
- package/components/http/http.js +120 -125
- package/components/http/http.mock.js +6 -10
- package/components/hub-source/hub-source-user.js +6 -13
- package/components/hub-source/hub-source-users-groups.js +8 -12
- package/components/hub-source/hub-source.js +8 -10
- package/components/i18n/i18n-context.js +4 -7
- package/components/i18n/i18n.js +5 -5
- package/components/icon/icon-svg.js +0 -4
- package/components/icon/icon.js +28 -32
- package/components/icon/index.js +0 -4
- package/components/input/input.figma.js +8 -8
- package/components/input/input.js +0 -4
- package/components/island/adaptive-island-hoc.js +19 -23
- package/components/island/content.js +70 -75
- package/components/island/header.js +21 -21
- package/components/island/island.js +11 -14
- package/components/link/clickable-link.js +30 -37
- package/components/link/link.js +27 -29
- package/components/list/list-custom.js +6 -11
- package/components/list/list-item.js +49 -56
- package/components/list/list-separator.js +0 -1
- package/components/list/list-title.js +0 -1
- package/components/list/list-users-groups-source.js +14 -22
- package/components/list/list.classes.js +8 -9
- package/components/list/list.js +387 -404
- package/components/loader/loader-core.js +2 -265
- package/components/loader/loader.d.ts +8 -0
- package/components/loader/loader.js +43 -29
- package/components/loader-inline/loader-inline.js +9 -12
- package/components/loader-screen/loader-screen.js +10 -14
- package/components/login-dialog/login-dialog.js +46 -54
- package/components/login-dialog/service.js +13 -15
- package/components/message/message.js +65 -79
- package/components/old-browsers-message/old-browsers-message-stop.js +0 -3
- package/components/old-browsers-message/old-browsers-message.js +1 -4
- package/components/old-browsers-message/white-list.js +5 -7
- package/components/pager/pager.js +73 -88
- package/components/panel/panel.js +9 -12
- package/components/permissions/permissions-cache.js +6 -8
- package/components/permissions/permissions.js +19 -21
- package/components/popup/popup.js +136 -145
- package/components/popup/popup.target.js +8 -10
- package/components/popup/position-css.js +19 -27
- package/components/popup/position.js +22 -28
- package/components/popup-menu/popup-menu.js +27 -37
- package/components/progress-bar/progress-bar.js +26 -32
- package/components/query-assist/query-assist-suggestions.js +0 -6
- package/components/query-assist/query-assist.js +432 -468
- package/components/radio/radio-item.js +30 -40
- package/components/radio/radio.js +6 -10
- package/components/scrollable-section/scrollable-section.js +7 -10
- package/components/select/select-filter.js +0 -6
- package/components/select/select-popup.js +155 -174
- package/components/select/select.js +464 -479
- package/components/shortcuts/core.js +40 -45
- package/components/shortcuts/shortcut-title.js +0 -1
- package/components/shortcuts/shortcuts-hoc.js +9 -15
- package/components/shortcuts/shortcuts.js +3 -5
- package/components/slider/slider.js +53 -66
- package/components/slider/slider.utils.js +1 -4
- package/components/storage/storage-local.js +2 -8
- package/components/storage/storage.js +0 -5
- package/components/style.css +1 -1
- package/components/tab-trap/tab-trap.js +21 -30
- package/components/table/cell.js +3 -4
- package/components/table/disable-hover-hoc.js +24 -28
- package/components/table/header-cell.js +30 -38
- package/components/table/header.js +20 -28
- package/components/table/multitable.js +81 -101
- package/components/table/row-with-focus-sensor.js +17 -28
- package/components/table/row.js +89 -99
- package/components/table/selection-adapter.js +0 -2
- package/components/table/selection-shortcuts-hoc.js +159 -161
- package/components/table/selection.js +23 -31
- package/components/table/simple-table.js +16 -22
- package/components/table/smart-table.js +19 -26
- package/components/table/table.js +137 -146
- package/components/tabs/collapsible-more.js +34 -47
- package/components/tabs/collapsible-tab.js +28 -33
- package/components/tabs/collapsible-tabs.js +18 -26
- package/components/tabs/custom-item.js +3 -6
- package/components/tabs/dumb-tabs.js +48 -64
- package/components/tabs/smart-tabs.js +14 -23
- package/components/tabs/tab-link.js +0 -2
- package/components/tabs/tab.js +0 -1
- package/components/tabs/tabs.js +0 -7
- package/components/tag/tag.js +30 -35
- package/components/tags-input/tags-input.js +192 -218
- package/components/tags-list/tags-list.js +26 -31
- package/components/text/text.js +16 -19
- package/components/toggle/toggle.js +19 -23
- package/components/tooltip/tooltip.js +110 -121
- package/components/upload/upload.js +19 -28
- package/components/user-agreement/service.js +247 -252
- package/components/user-agreement/toolbox.eula.js +160 -1
- package/components/user-agreement/user-agreement.js +23 -32
- package/components/user-card/card.js +0 -5
- package/components/user-card/smart-user-card-tooltip.js +41 -50
- package/components/user-card/tooltip.js +32 -38
- package/components/user-card/user-card.js +0 -5
- package/package.json +9 -3
- package/components/_helpers/_rollupPluginBabelHelpers.js +0 -72
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { _ as _defineProperty, a as _objectWithoutProperties, b as _objectSpread2 } from '../_helpers/_rollupPluginBabelHelpers.js';
|
|
2
|
-
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
3
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
4
2
|
import { PureComponent } from 'react';
|
|
5
3
|
import classNames from 'classnames';
|
|
@@ -23,8 +21,6 @@ import { I18nContext } from '../i18n/i18n-context.js';
|
|
|
23
21
|
import DatePopup from './date-popup.js';
|
|
24
22
|
import { s as styles } from '../_helpers/date-picker.js';
|
|
25
23
|
import formats from './formats.js';
|
|
26
|
-
import 'core-js/modules/es.regexp.exec.js';
|
|
27
|
-
import 'core-js/modules/es.string.replace.js';
|
|
28
24
|
import 'react-dom';
|
|
29
25
|
import '../global/get-uid.js';
|
|
30
26
|
import '../global/schedule-raf.js';
|
|
@@ -38,7 +34,6 @@ import '../global/data-tests.js';
|
|
|
38
34
|
import '../tab-trap/tab-trap.js';
|
|
39
35
|
import '../global/configuration.js';
|
|
40
36
|
import '../popup/position.js';
|
|
41
|
-
import 'core-js/modules/es.array.sort.js';
|
|
42
37
|
import '../popup/popup.consts.js';
|
|
43
38
|
import '../popup/popup.target.js';
|
|
44
39
|
import '../popup/position-css.js';
|
|
@@ -92,143 +87,182 @@ import 'date-fns/isThisYear';
|
|
|
92
87
|
import 'date-fns/setYear';
|
|
93
88
|
import './weekdays.js';
|
|
94
89
|
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}, datePopupProps), {}, {
|
|
117
|
-
onComplete: onComplete
|
|
118
|
-
}))
|
|
119
|
-
}));
|
|
120
|
-
};
|
|
90
|
+
const PopupComponent = ({
|
|
91
|
+
hidden = false,
|
|
92
|
+
className,
|
|
93
|
+
popupRef,
|
|
94
|
+
onClear,
|
|
95
|
+
datePopupProps,
|
|
96
|
+
onComplete,
|
|
97
|
+
...restProps
|
|
98
|
+
}) => jsx(Popup, {
|
|
99
|
+
hidden: hidden,
|
|
100
|
+
className: className,
|
|
101
|
+
ref: popupRef,
|
|
102
|
+
directions: [Popup.PopupProps.Directions.BOTTOM_RIGHT, Popup.PopupProps.Directions.BOTTOM_LEFT, Popup.PopupProps.Directions.TOP_LEFT, Popup.PopupProps.Directions.TOP_RIGHT],
|
|
103
|
+
...restProps,
|
|
104
|
+
trapFocus: true,
|
|
105
|
+
children: jsx(DatePopup, {
|
|
106
|
+
onClear: onClear,
|
|
107
|
+
...datePopupProps,
|
|
108
|
+
onComplete: onComplete
|
|
109
|
+
})
|
|
110
|
+
});
|
|
121
111
|
/**
|
|
122
112
|
* @name Date Picker
|
|
123
113
|
*/
|
|
124
114
|
class DatePicker extends PureComponent {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
var
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
if (
|
|
160
|
-
return
|
|
161
|
-
}
|
|
162
|
-
if (typeof date === 'number') {
|
|
163
|
-
return new Date(date);
|
|
164
|
-
}
|
|
165
|
-
return parseDateInput(date);
|
|
166
|
-
}));
|
|
167
|
-
// eslint-disable-next-line complexity
|
|
168
|
-
_defineProperty(this, "getAnchorText", () => {
|
|
169
|
-
var _ref4;
|
|
170
|
-
const {
|
|
171
|
-
range,
|
|
172
|
-
datePlaceholder,
|
|
173
|
-
dateTimePlaceholder,
|
|
174
|
-
rangePlaceholder,
|
|
175
|
-
withTime,
|
|
176
|
-
displayFormat,
|
|
177
|
-
displayMonthFormat,
|
|
178
|
-
displayDayFormat,
|
|
179
|
-
translations,
|
|
180
|
-
locale
|
|
181
|
-
} = this.props;
|
|
182
|
-
const {
|
|
183
|
-
translate
|
|
184
|
-
} = this.context;
|
|
185
|
-
const date = this.parse(this.props.date);
|
|
186
|
-
const from = this.parse(this.props.from);
|
|
187
|
-
const to = this.parse(this.props.to);
|
|
188
|
-
const time = this.formatTime();
|
|
189
|
-
if (!range && !withTime) {
|
|
190
|
-
var _ref2;
|
|
191
|
-
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');
|
|
192
|
-
}
|
|
193
|
-
if (!range && withTime) {
|
|
194
|
-
if (!date && !time) {
|
|
195
|
-
var _ref3;
|
|
196
|
-
return (_ref3 = dateTimePlaceholder !== null && dateTimePlaceholder !== void 0 ? dateTimePlaceholder : translations === null || translations === void 0 ? void 0 : translations.setDateTime) !== null && _ref3 !== void 0 ? _ref3 : translate('setDateTime');
|
|
197
|
-
}
|
|
198
|
-
return "".concat(date && displayFormat(date, locale) || '—', ", ").concat(time || '—');
|
|
115
|
+
static defaultProps = {
|
|
116
|
+
className: '',
|
|
117
|
+
date: null,
|
|
118
|
+
withTime: false,
|
|
119
|
+
range: false,
|
|
120
|
+
from: null,
|
|
121
|
+
to: null,
|
|
122
|
+
clear: false,
|
|
123
|
+
inline: false,
|
|
124
|
+
size: Size.M,
|
|
125
|
+
displayFormat: (date, locale) => date ? format(date, 'd MMM yyyy', {
|
|
126
|
+
locale
|
|
127
|
+
}) : '',
|
|
128
|
+
displayMonthFormat: (date, locale) => date ? format(date, 'd MMM', {
|
|
129
|
+
locale
|
|
130
|
+
}) : '',
|
|
131
|
+
displayDayFormat: (date, locale) => date ? format(date, 'd', {
|
|
132
|
+
locale
|
|
133
|
+
}) : '',
|
|
134
|
+
displayTimeFormat: (date, locale) => date ? format(date, 'HH:mm', {
|
|
135
|
+
locale
|
|
136
|
+
}) : '',
|
|
137
|
+
minDate: null,
|
|
138
|
+
maxDate: null,
|
|
139
|
+
onChange() {},
|
|
140
|
+
applyTimeInput(date, timeString) {
|
|
141
|
+
var _timeString$split$map;
|
|
142
|
+
const [hours, minutes] = (_timeString$split$map = timeString?.split(':').map(Number)) !== null && _timeString$split$map !== void 0 ? _timeString$split$map : [];
|
|
143
|
+
return minutes !== null && minutes !== undefined ? set(date, {
|
|
144
|
+
hours,
|
|
145
|
+
minutes
|
|
146
|
+
}) : date;
|
|
147
|
+
},
|
|
148
|
+
parseDateInput(string) {
|
|
149
|
+
if (!string) {
|
|
150
|
+
return null;
|
|
199
151
|
}
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
return "".concat(displayMonthFormat(from, locale), " \u2014 ").concat(displayFormat(to, locale));
|
|
152
|
+
const today = new Date();
|
|
153
|
+
for (const format of formats) {
|
|
154
|
+
const date = parse(string, format, today);
|
|
155
|
+
if (isValid(date)) {
|
|
156
|
+
return date;
|
|
206
157
|
}
|
|
207
|
-
if (!isSameDay(from, to)) {
|
|
208
|
-
return "".concat(displayDayFormat(from, locale), " \u2014 ").concat(displayFormat(to, locale));
|
|
209
|
-
}
|
|
210
|
-
return "".concat(displayFormat(to, locale));
|
|
211
|
-
}
|
|
212
|
-
if (from) {
|
|
213
|
-
return "".concat(displayFormat(from, locale), " \u2014");
|
|
214
158
|
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
static contextType = I18nContext;
|
|
163
|
+
handleChange = change => {
|
|
164
|
+
const {
|
|
165
|
+
onChange,
|
|
166
|
+
withTime,
|
|
167
|
+
applyTimeInput
|
|
168
|
+
} = this.props;
|
|
169
|
+
const adjustedChange = withTime && !(change instanceof Date) && change?.date ? applyTimeInput(change.date, change.time) : change;
|
|
170
|
+
onChange(adjustedChange);
|
|
171
|
+
};
|
|
172
|
+
clear = () => {
|
|
173
|
+
let change = null;
|
|
174
|
+
if (this.props.range) {
|
|
175
|
+
change = {
|
|
176
|
+
from: null,
|
|
177
|
+
to: null
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
this.handleChange(change);
|
|
181
|
+
};
|
|
182
|
+
popup;
|
|
183
|
+
popupRef = el => {
|
|
184
|
+
this.popup = el;
|
|
185
|
+
};
|
|
186
|
+
closePopup = () => {
|
|
187
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
188
|
+
this.popup?._onCloseAttempt();
|
|
189
|
+
};
|
|
190
|
+
parse = memoize(date => {
|
|
191
|
+
const {
|
|
192
|
+
parseDateInput
|
|
193
|
+
} = this.props;
|
|
194
|
+
if (date instanceof Date) {
|
|
195
|
+
return date;
|
|
196
|
+
}
|
|
197
|
+
if (typeof date === 'number') {
|
|
198
|
+
return new Date(date);
|
|
199
|
+
}
|
|
200
|
+
return parseDateInput(date);
|
|
201
|
+
});
|
|
221
202
|
formatTime() {
|
|
222
203
|
const {
|
|
223
204
|
displayTimeFormat,
|
|
224
205
|
locale
|
|
225
206
|
} = this.props;
|
|
226
207
|
const date = this.parse(this.props.date);
|
|
227
|
-
if (date
|
|
208
|
+
if (date) {
|
|
228
209
|
return displayTimeFormat(date, locale);
|
|
229
210
|
}
|
|
230
211
|
return null;
|
|
231
212
|
}
|
|
213
|
+
// eslint-disable-next-line complexity
|
|
214
|
+
getAnchorText = () => {
|
|
215
|
+
var _ref3;
|
|
216
|
+
const {
|
|
217
|
+
range,
|
|
218
|
+
datePlaceholder,
|
|
219
|
+
dateTimePlaceholder,
|
|
220
|
+
rangePlaceholder,
|
|
221
|
+
withTime,
|
|
222
|
+
displayFormat,
|
|
223
|
+
displayMonthFormat,
|
|
224
|
+
displayDayFormat,
|
|
225
|
+
translations,
|
|
226
|
+
locale
|
|
227
|
+
} = this.props;
|
|
228
|
+
const {
|
|
229
|
+
translate
|
|
230
|
+
} = this.context;
|
|
231
|
+
const date = this.parse(this.props.date);
|
|
232
|
+
const from = this.parse(this.props.from);
|
|
233
|
+
const to = this.parse(this.props.to);
|
|
234
|
+
const time = this.formatTime();
|
|
235
|
+
if (!range && !withTime) {
|
|
236
|
+
var _ref;
|
|
237
|
+
return date ? displayFormat(date, locale) : (_ref = datePlaceholder !== null && datePlaceholder !== void 0 ? datePlaceholder : translations?.setDate) !== null && _ref !== void 0 ? _ref : translate('setDate');
|
|
238
|
+
}
|
|
239
|
+
if (!range && withTime) {
|
|
240
|
+
if (!date && !time) {
|
|
241
|
+
var _ref2;
|
|
242
|
+
return (_ref2 = dateTimePlaceholder !== null && dateTimePlaceholder !== void 0 ? dateTimePlaceholder : translations?.setDateTime) !== null && _ref2 !== void 0 ? _ref2 : translate('setDateTime');
|
|
243
|
+
}
|
|
244
|
+
return `${date && displayFormat(date, locale) || '—'}, ${time || '—'}`;
|
|
245
|
+
}
|
|
246
|
+
if (from && to) {
|
|
247
|
+
if (!isSameYear(from, to)) {
|
|
248
|
+
return `${displayFormat(from, locale)} — ${displayFormat(to, locale)}`;
|
|
249
|
+
}
|
|
250
|
+
if (!isSameMonth(from, to)) {
|
|
251
|
+
return `${displayMonthFormat(from, locale)} — ${displayFormat(to, locale)}`;
|
|
252
|
+
}
|
|
253
|
+
if (!isSameDay(from, to)) {
|
|
254
|
+
return `${displayDayFormat(from, locale)} — ${displayFormat(to, locale)}`;
|
|
255
|
+
}
|
|
256
|
+
return `${displayFormat(to, locale)}`;
|
|
257
|
+
}
|
|
258
|
+
if (from) {
|
|
259
|
+
return `${displayFormat(from, locale)} —`;
|
|
260
|
+
}
|
|
261
|
+
if (to) {
|
|
262
|
+
return `— ${displayFormat(to, locale)}`;
|
|
263
|
+
}
|
|
264
|
+
return (_ref3 = rangePlaceholder !== null && rangePlaceholder !== void 0 ? rangePlaceholder : translations?.setPeriod) !== null && _ref3 !== void 0 ? _ref3 : translate('setPeriod');
|
|
265
|
+
};
|
|
232
266
|
render() {
|
|
233
267
|
var _this$props$disabled, _this$props$disabled2;
|
|
234
268
|
const anchorContent = jsxs("div", {
|
|
@@ -241,20 +275,19 @@ class DatePicker extends PureComponent {
|
|
|
241
275
|
className: styles.chevronDownIcon
|
|
242
276
|
})]
|
|
243
277
|
});
|
|
244
|
-
const
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
const classes = classNames(styles.datePicker, className, styles["size".concat(this.props.size)], {
|
|
278
|
+
const {
|
|
279
|
+
className,
|
|
280
|
+
popupClassName,
|
|
281
|
+
clear,
|
|
282
|
+
inline,
|
|
283
|
+
dropdownProps,
|
|
284
|
+
translations,
|
|
285
|
+
...datePopupProps
|
|
286
|
+
} = this.props;
|
|
287
|
+
const classes = classNames(styles.datePicker, className, styles[`size${this.props.size}`], {
|
|
255
288
|
[styles.inline]: inline
|
|
256
289
|
});
|
|
257
|
-
return jsx(Dropdown,
|
|
290
|
+
return jsx(Dropdown, {
|
|
258
291
|
className: classes,
|
|
259
292
|
disabled: this.props.disabled,
|
|
260
293
|
"data-test": 'ring-date-picker',
|
|
@@ -264,77 +297,30 @@ class DatePicker extends PureComponent {
|
|
|
264
297
|
disabled: (_this$props$disabled = this.props.disabled) !== null && _this$props$disabled !== void 0 ? _this$props$disabled : false,
|
|
265
298
|
pseudo: true,
|
|
266
299
|
children: this.getAnchorText()
|
|
267
|
-
}) : jsx(Button,
|
|
300
|
+
}) : jsx(Button, {
|
|
268
301
|
"data-test-ring-dropdown-anchor": true,
|
|
269
302
|
className: styles.anchor,
|
|
270
303
|
inline: false,
|
|
271
|
-
disabled: (_this$props$disabled2 = this.props.disabled) !== null && _this$props$disabled2 !== void 0 ? _this$props$disabled2 : false
|
|
272
|
-
|
|
304
|
+
disabled: (_this$props$disabled2 = this.props.disabled) !== null && _this$props$disabled2 !== void 0 ? _this$props$disabled2 : false,
|
|
305
|
+
...this.props.buttonAttributes,
|
|
273
306
|
children: anchorContent
|
|
274
|
-
})
|
|
275
|
-
|
|
307
|
+
}),
|
|
308
|
+
...dropdownProps,
|
|
276
309
|
children: jsx(PopupComponent, {
|
|
277
310
|
className: popupClassName,
|
|
278
311
|
popupRef: this.popupRef,
|
|
279
312
|
onClear: clear ? this.clear : null,
|
|
280
|
-
datePopupProps:
|
|
313
|
+
datePopupProps: {
|
|
314
|
+
...datePopupProps,
|
|
281
315
|
translations,
|
|
282
316
|
onChange: this.handleChange,
|
|
283
317
|
parseDateInput: this.parse,
|
|
284
318
|
time: this.formatTime()
|
|
285
|
-
}
|
|
319
|
+
},
|
|
286
320
|
onComplete: this.closePopup
|
|
287
321
|
})
|
|
288
|
-
})
|
|
322
|
+
});
|
|
289
323
|
}
|
|
290
324
|
}
|
|
291
|
-
_defineProperty(DatePicker, "defaultProps", {
|
|
292
|
-
className: '',
|
|
293
|
-
date: null,
|
|
294
|
-
withTime: false,
|
|
295
|
-
range: false,
|
|
296
|
-
from: null,
|
|
297
|
-
to: null,
|
|
298
|
-
clear: false,
|
|
299
|
-
inline: false,
|
|
300
|
-
size: Size.M,
|
|
301
|
-
displayFormat: (date, locale) => date ? format(date, 'd MMM yyyy', {
|
|
302
|
-
locale
|
|
303
|
-
}) : '',
|
|
304
|
-
displayMonthFormat: (date, locale) => date ? format(date, 'd MMM', {
|
|
305
|
-
locale
|
|
306
|
-
}) : '',
|
|
307
|
-
displayDayFormat: (date, locale) => date ? format(date, 'd', {
|
|
308
|
-
locale
|
|
309
|
-
}) : '',
|
|
310
|
-
displayTimeFormat: (date, locale) => date ? format(date, 'HH:mm', {
|
|
311
|
-
locale
|
|
312
|
-
}) : '',
|
|
313
|
-
minDate: null,
|
|
314
|
-
maxDate: null,
|
|
315
|
-
onChange() {},
|
|
316
|
-
applyTimeInput(date, timeString) {
|
|
317
|
-
var _timeString$split$map;
|
|
318
|
-
const [hours, minutes] = (_timeString$split$map = timeString === null || timeString === void 0 ? void 0 : timeString.split(':').map(Number)) !== null && _timeString$split$map !== void 0 ? _timeString$split$map : [];
|
|
319
|
-
return minutes !== null && minutes !== undefined ? set(date, {
|
|
320
|
-
hours,
|
|
321
|
-
minutes
|
|
322
|
-
}) : date;
|
|
323
|
-
},
|
|
324
|
-
parseDateInput(string) {
|
|
325
|
-
if (!string) {
|
|
326
|
-
return null;
|
|
327
|
-
}
|
|
328
|
-
const today = new Date();
|
|
329
|
-
for (const format of formats) {
|
|
330
|
-
const date = parse(string, format, today);
|
|
331
|
-
if (isValid(date)) {
|
|
332
|
-
return date;
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
return null;
|
|
336
|
-
}
|
|
337
|
-
});
|
|
338
|
-
_defineProperty(DatePicker, "contextType", I18nContext);
|
|
339
325
|
|
|
340
326
|
export { DatePicker as default };
|