@jetbrains/ring-ui 5.0.127 → 5.0.129
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/alert/alert.js +2 -1
- package/components/alert/container.js +2 -1
- package/components/auth/auth__core.js +2 -1
- package/components/auth/request-builder.js +2 -1
- package/components/auth/response-parser.js +2 -1
- package/components/auth/token-validator.js +2 -1
- package/components/auth-dialog/auth-dialog.js +2 -1
- package/components/avatar/avatar.js +2 -1
- package/components/badge/badge.js +2 -1
- package/components/button/button.js +2 -1
- package/components/button-group/button-group.js +2 -1
- package/components/button-group/caption.js +2 -1
- package/components/button-set/button-set.js +2 -1
- package/components/button-toolbar/button-toolbar.js +2 -1
- package/components/caret/caret.js +2 -1
- package/components/checkbox/checkbox.js +2 -1
- package/components/code/code.js +2 -1
- package/components/confirm/confirm.js +2 -1
- package/components/content-layout/content-layout.js +2 -1
- package/components/content-layout/sidebar.js +2 -1
- package/components/data-list/data-list.js +2 -1
- package/components/data-list/item.js +2 -1
- package/components/date-picker/date-input.js +2 -1
- package/components/date-picker/date-picker.js +2 -1
- package/components/date-picker/date-popup.js +2 -1
- package/components/date-picker/day.js +2 -1
- package/components/date-picker/month-slider.js +2 -1
- package/components/date-picker/years.js +2 -1
- package/components/dialog/dialog.d.ts +4 -16
- package/components/dialog/dialog.js +6 -3
- package/components/dropdown/dropdown.js +2 -1
- package/components/error-bubble/error-bubble.js +2 -1
- package/components/error-message/error-message.js +2 -1
- package/components/footer/footer.js +1 -0
- package/components/global/react-dom-renderer.js +2 -1
- package/components/grid/col.js +2 -1
- package/components/grid/grid.js +2 -1
- package/components/grid/row.js +2 -1
- package/components/group/group.js +2 -1
- package/components/header/logo.js +2 -1
- package/components/header/profile.js +2 -1
- package/components/header/services-link.js +2 -1
- package/components/header/services.js +2 -1
- package/components/header/smart-profile.js +2 -1
- package/components/header/smart-services.js +2 -1
- package/components/header/tray-icon.js +2 -1
- package/components/header/tray.js +2 -1
- package/components/hub-source/hub-source.js +2 -1
- package/components/icon/icon.js +2 -1
- package/components/input/input.js +2 -1
- package/components/island/island.js +2 -1
- package/components/island-legacy/content-legacy.js +2 -1
- package/components/island-legacy/header-legacy.js +2 -1
- package/components/island-legacy/island-legacy.js +2 -1
- package/components/link/clickableLink.js +2 -1
- package/components/list/list.js +2 -1
- package/components/list/list__hint.js +2 -1
- package/components/list/list__users-groups-source.js +2 -1
- package/components/loader/loader.js +2 -1
- package/components/loader/loader__core.js +2 -1
- package/components/loader-screen/loader-screen.js +2 -1
- package/components/login-dialog/login-dialog.js +2 -1
- package/components/message/message.js +2 -1
- package/components/pager/pager.js +2 -1
- package/components/panel/panel.js +2 -1
- package/components/permissions/permissions.js +2 -1
- package/components/permissions/permissions__cache.js +2 -1
- package/components/popup/popup.js +2 -1
- package/components/popup-menu/popup-menu.js +2 -1
- package/components/progress-bar/progress-bar.js +2 -1
- package/components/query-assist/query-assist.js +4 -3
- package/components/radio/radio.js +2 -1
- package/components/radio/radio__item.js +2 -1
- package/components/select/select.js +2 -1
- package/components/select/select__filter.js +2 -1
- package/components/select/select__popup.js +4 -2
- package/components/shortcuts/shortcuts.js +2 -1
- package/components/storage/storage__fallback.js +2 -1
- package/components/tab-trap/tab-trap.js +2 -1
- package/components/table/cell.js +2 -1
- package/components/table/header-cell.js +2 -1
- package/components/table/header.js +2 -1
- package/components/table/multitable.js +2 -1
- package/components/table/row.d.ts +1 -0
- package/components/table/row.js +6 -4
- package/components/table/smart-table.d.ts +1 -0
- package/components/table/table.d.ts +2 -0
- package/components/table/table.js +8 -4
- package/components/tabs/smart-tabs.js +2 -1
- package/components/tabs/tab.js +2 -1
- package/components/tag/tag.js +2 -1
- package/components/tags-input/tags-input.d.ts +1 -1
- package/components/tags-input/tags-input.js +3 -2
- package/components/tags-list/tags-list.js +2 -1
- package/components/text/text.js +2 -1
- package/components/tooltip/tooltip.js +2 -1
- package/components/user-agreement/user-agreement.js +2 -1
- package/components/user-card/card.js +2 -1
- package/components/user-card/smart-user-card-tooltip.d.ts +1 -1
- package/components/user-card/smart-user-card-tooltip.js +2 -1
- package/components/user-card/tooltip.js +2 -1
- package/dist/_helpers/_rollupPluginBabelHelpers.js +1 -29
- package/dist/_helpers/anchor.js +1 -1
- package/dist/_helpers/card.js +44 -47
- package/dist/_helpers/footer.js +1 -0
- package/dist/_helpers/select__filter.js +10 -13
- package/dist/_helpers/services-link.js +10 -10
- package/dist/_helpers/sidebar.js +34 -37
- package/dist/_helpers/theme.js +1 -1
- package/dist/_helpers/title.js +12 -16
- package/dist/alert/alert.js +63 -66
- package/dist/alert/container.js +5 -5
- package/dist/alert-service/alert-service.js +5 -7
- package/dist/analytics/analytics.js +1 -2
- package/dist/analytics/analytics__custom-plugin.js +6 -8
- package/dist/auth/auth.js +1 -1
- package/dist/auth/auth__core.js +26 -26
- package/dist/auth/background-flow.js +4 -5
- package/dist/auth/iframe-flow.js +12 -12
- package/dist/auth/landing.js +1 -1
- package/dist/auth/request-builder.js +3 -5
- package/dist/auth/response-parser.js +5 -6
- package/dist/auth/storage.js +12 -12
- package/dist/auth/token-validator.js +13 -16
- package/dist/auth/window-flow.js +18 -19
- package/dist/auth-dialog/auth-dialog.js +54 -57
- package/dist/auth-dialog-service/auth-dialog-service.js +1 -1
- package/dist/auth-ng/auth-ng.js +1 -1
- package/dist/avatar/avatar.js +30 -33
- package/dist/avatar-ng/avatar-ng.js +1 -1
- package/dist/badge/badge.js +10 -10
- package/dist/badge-ng/badge-ng.js +1 -1
- package/dist/breadcrumb-ng/breadcrumb-ng.js +0 -1
- package/dist/button/button.js +24 -27
- package/dist/button-group/button-group.js +5 -5
- package/dist/button-group/caption.js +4 -4
- package/dist/button-ng/button-ng.js +68 -69
- package/dist/button-set/button-set.js +6 -6
- package/dist/button-toolbar/button-toolbar.js +6 -6
- package/dist/caret/caret.js +2 -4
- package/dist/checkbox/checkbox.js +27 -30
- package/dist/checkbox-ng/checkbox-ng.js +0 -1
- package/dist/code/code.js +17 -21
- package/dist/confirm/confirm.js +31 -34
- package/dist/confirm-ng/confirm-ng.js +1 -1
- package/dist/confirm-service/confirm-service.js +1 -1
- package/dist/content-layout/content-layout.js +17 -20
- package/dist/contenteditable/contenteditable.js +11 -11
- package/dist/data-list/data-list.js +49 -55
- package/dist/data-list/item.js +64 -67
- package/dist/data-list/selection.js +0 -1
- package/dist/data-list/title.js +1 -1
- package/dist/data-list-ng/data-list-ng.js +1 -1
- package/dist/date-picker/date-input.js +39 -42
- package/dist/date-picker/date-picker.js +162 -165
- package/dist/date-picker/date-popup.js +119 -119
- package/dist/date-picker/day.js +34 -38
- package/dist/date-picker/month-names.js +11 -14
- package/dist/date-picker/month-slider.js +24 -28
- package/dist/date-picker/month.js +1 -1
- package/dist/date-picker/months.js +1 -1
- package/dist/date-picker/years.js +9 -13
- package/dist/dialog/dialog.d.ts +4 -16
- package/dist/dialog/dialog.js +68 -65
- package/dist/dialog-ng/dialog-ng.js +21 -22
- package/dist/docked-panel-ng/docked-panel-ng.js +0 -1
- package/dist/dropdown/dropdown.js +101 -104
- package/dist/dropdown-menu/dropdown-menu.js +1 -1
- package/dist/editable-heading/editable-heading.js +1 -1
- package/dist/error-bubble/error-bubble.js +6 -6
- package/dist/error-message/error-message.js +10 -10
- package/dist/error-message-ng/error-message-ng.js +0 -1
- package/dist/footer-ng/footer-ng.js +19 -21
- package/dist/global/angular-component-factory.js +2 -3
- package/dist/global/dom.js +1 -5
- package/dist/global/focus-sensor-hoc.js +58 -61
- package/dist/global/listeners.js +1 -5
- package/dist/global/react-dom-renderer.js +8 -12
- package/dist/global/rerender-hoc.js +1 -5
- package/dist/global/ring-angular-component.js +1 -3
- package/dist/grid/col.js +13 -14
- package/dist/grid/grid.js +5 -5
- package/dist/grid/row.js +16 -17
- package/dist/group/group.js +5 -5
- package/dist/header/header.js +10 -10
- package/dist/header/logo.js +9 -9
- package/dist/header/profile.js +58 -58
- package/dist/header/services.js +19 -22
- package/dist/header/smart-profile.js +40 -43
- package/dist/header/smart-services.js +28 -31
- package/dist/header/tray-icon.js +6 -6
- package/dist/header/tray.js +5 -5
- package/dist/heading/heading.js +1 -1
- package/dist/heading-ng/heading-ng.js +1 -1
- package/dist/http/http.js +111 -107
- package/dist/http/http.mock.js +3 -4
- package/dist/hub-source/hub-source.js +7 -9
- package/dist/hub-source/hub-source__user.js +0 -1
- package/dist/hub-source/hub-source__users-groups.js +4 -5
- package/dist/icon/icon.js +18 -18
- package/dist/icon/icon__svg.js +1 -1
- package/dist/icon-ng/icon-ng.js +0 -1
- package/dist/input/input.js +35 -38
- package/dist/input-ng/input-ng.js +25 -26
- package/dist/island/adaptive-island-hoc.js +21 -25
- package/dist/island/content.js +62 -65
- package/dist/island/header.js +11 -11
- package/dist/island/island.js +8 -8
- package/dist/island-legacy/content-legacy.js +5 -5
- package/dist/island-legacy/header-legacy.js +5 -5
- package/dist/island-legacy/island-legacy.js +5 -5
- package/dist/link/clickableLink.js +27 -30
- package/dist/link/link.js +16 -16
- package/dist/list/list.js +389 -391
- package/dist/list/list__custom.js +6 -10
- package/dist/list/list__hint.js +3 -4
- package/dist/list/list__item.js +4 -7
- package/dist/list/list__link.js +1 -1
- package/dist/list/list__users-groups-source.js +3 -3
- package/dist/loader/loader.js +16 -19
- package/dist/loader/loader__core.js +62 -62
- package/dist/loader-inline/loader-inline.js +6 -6
- package/dist/loader-ng/loader-ng.js +3 -4
- package/dist/loader-screen/loader-screen.js +6 -6
- package/dist/loader-screen-ng/loader-screen-ng.js +0 -1
- package/dist/login-dialog/login-dialog.js +55 -58
- package/dist/login-dialog/service.js +1 -1
- package/dist/markdown/code.js +0 -1
- package/dist/markdown/markdown.js +1 -1
- package/dist/message/message.js +22 -25
- package/dist/old-browsers-message/white-list.js +2 -2
- package/dist/pager/pager.js +55 -58
- package/dist/pager-ng/pager-ng.js +1 -1
- package/dist/panel/panel.js +5 -5
- package/dist/panel-ng/panel-ng.js +0 -1
- package/dist/permissions/permissions.js +14 -16
- package/dist/permissions/permissions__cache.js +4 -6
- package/dist/permissions-ng/permissions-ng.js +1 -1
- package/dist/place-under-ng/place-under-ng.js +0 -1
- package/dist/popup/popup.js +118 -121
- package/dist/popup/popup.target.js +1 -1
- package/dist/popup/position.js +0 -1
- package/dist/popup-menu/popup-menu.js +19 -22
- package/dist/progress-bar/progress-bar.js +41 -44
- package/dist/progress-bar-ng/progress-bar-ng.js +1 -1
- package/dist/promised-click-ng/promised-click-ng.js +0 -1
- package/dist/query-assist/query-assist.js +507 -501
- package/dist/query-assist/query-assist__suggestions.js +1 -1
- package/dist/query-assist-ng/query-assist-ng.js +1 -1
- package/dist/radio/radio.js +10 -13
- package/dist/radio/radio__item.js +19 -22
- package/dist/select/select.js +350 -349
- package/dist/select/select__popup.js +148 -152
- package/dist/select-ng/select-ng.js +1 -1
- package/dist/select-ng/select-ng__lazy.js +4 -4
- package/dist/select-ng/select-ng__options.js +14 -15
- package/dist/shortcuts/core.js +35 -36
- package/dist/shortcuts/shortcuts-hoc.js +7 -11
- package/dist/shortcuts/shortcuts.js +10 -11
- package/dist/shortcuts-hint-ng/shortcuts-hint-ng.js +0 -1
- package/dist/shortcuts-ng/shortcuts-ng.js +0 -1
- package/dist/sidebar-ng/sidebar-ng.js +0 -1
- package/dist/storage/storage.js +1 -1
- package/dist/storage/storage__fallback.js +8 -10
- package/dist/storage/storage__local.js +2 -2
- package/dist/style.css +1 -1
- package/dist/tab-trap/tab-trap.js +84 -86
- package/dist/table/cell.js +6 -6
- package/dist/table/disable-hover-hoc.js +23 -25
- package/dist/table/header-cell.js +28 -31
- package/dist/table/header.js +58 -61
- package/dist/table/multitable.js +91 -95
- package/dist/table/row-with-focus-sensor.js +15 -18
- package/dist/table/row.d.ts +1 -0
- package/dist/table/row.js +54 -55
- package/dist/table/selection-shortcuts-hoc.js +145 -147
- package/dist/table/selection.js +7 -9
- package/dist/table/smart-table.d.ts +1 -0
- package/dist/table/smart-table.js +21 -24
- package/dist/table/table.d.ts +2 -0
- package/dist/table/table.js +107 -109
- package/dist/table-legacy-ng/table-legacy-ng.js +1 -1
- package/dist/table-legacy-ng/table-legacy-ng__pager.js +1 -1
- package/dist/table-legacy-ng/table-legacy-ng__selection.js +1 -3
- package/dist/table-legacy-ng/table-legacy-ng__toolbar.js +0 -1
- package/dist/table-ng/smart-table-ng.js +1 -1
- package/dist/table-ng/table-ng.js +1 -1
- package/dist/tabs/collapsible-more.js +1 -1
- package/dist/tabs/collapsible-tab.js +1 -1
- package/dist/tabs/dumb-tabs.js +46 -49
- package/dist/tabs/smart-tabs.js +10 -10
- package/dist/tabs/tab.js +7 -8
- package/dist/tag/tag.js +42 -45
- package/dist/tags-input/tags-input.d.ts +1 -1
- package/dist/tags-input/tags-input.js +214 -213
- package/dist/tags-input-ng/tags-input-ng.js +1 -1
- package/dist/tags-list/tags-list.js +20 -20
- package/dist/template-ng/template-ng.js +25 -26
- package/dist/text/text.js +6 -6
- package/dist/toggle/toggle.js +19 -19
- package/dist/toggle-ng/toggle-ng.js +1 -1
- package/dist/tooltip/tooltip.js +86 -89
- package/dist/tooltip-ng/tooltip-ng.js +1 -1
- package/dist/user-agreement/service.js +207 -205
- package/dist/user-agreement/user-agreement.js +39 -42
- package/dist/user-card/smart-user-card-tooltip.d.ts +1 -1
- package/dist/user-card/smart-user-card-tooltip.js +32 -35
- package/dist/user-card/tooltip.js +26 -26
- package/dist/user-card-ng/user-card-ng.js +1 -1
- package/package.json +17 -17
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as
|
|
1
|
+
import { _ as _extends } from '../_helpers/_rollupPluginBabelHelpers.js';
|
|
2
2
|
import React, { PureComponent } from 'react';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import classNames from 'classnames';
|
|
@@ -120,90 +120,127 @@ PopupComponent.propTypes = {
|
|
|
120
120
|
* @name Date Picker
|
|
121
121
|
*/
|
|
122
122
|
class DatePicker extends PureComponent {
|
|
123
|
-
|
|
124
|
-
|
|
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
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
123
|
+
static propTypes = {
|
|
124
|
+
className: PropTypes.string,
|
|
125
|
+
popupClassName: PropTypes.string,
|
|
126
|
+
date: dateType,
|
|
127
|
+
withTime: PropTypes.bool,
|
|
128
|
+
range: PropTypes.bool,
|
|
129
|
+
from: dateType,
|
|
130
|
+
to: dateType,
|
|
131
|
+
clear: PropTypes.bool,
|
|
132
|
+
inline: PropTypes.bool,
|
|
133
|
+
displayFormat: PropTypes.func,
|
|
134
|
+
displayMonthFormat: PropTypes.func,
|
|
135
|
+
displayDayFormat: PropTypes.func,
|
|
136
|
+
displayTimeFormat: PropTypes.func,
|
|
137
|
+
parseDateInput: PropTypes.func,
|
|
138
|
+
applyTimeInput: PropTypes.func,
|
|
139
|
+
datePlaceholder: PropTypes.string,
|
|
140
|
+
dateTimePlaceholder: PropTypes.string,
|
|
141
|
+
rangePlaceholder: PropTypes.string,
|
|
142
|
+
onChange: PropTypes.func,
|
|
143
|
+
dropdownProps: PropTypes.object,
|
|
144
|
+
disabled: PropTypes.bool,
|
|
145
|
+
minDate: dateType,
|
|
146
|
+
maxDate: dateType,
|
|
147
|
+
translations: PropTypes.object,
|
|
148
|
+
locale: PropTypes.object,
|
|
149
|
+
size: PropTypes.oneOf(Object.values(Size))
|
|
150
|
+
};
|
|
151
|
+
static defaultProps = {
|
|
152
|
+
className: '',
|
|
153
|
+
date: null,
|
|
154
|
+
withTime: false,
|
|
155
|
+
range: false,
|
|
156
|
+
from: null,
|
|
157
|
+
to: null,
|
|
158
|
+
clear: false,
|
|
159
|
+
inline: false,
|
|
160
|
+
size: Size.M,
|
|
161
|
+
displayFormat: (date, locale) => date ? format(date, 'd MMM yyyy', {
|
|
162
|
+
locale
|
|
163
|
+
}) : '',
|
|
164
|
+
displayMonthFormat: (date, locale) => date ? format(date, 'd MMM', {
|
|
165
|
+
locale
|
|
166
|
+
}) : '',
|
|
167
|
+
displayDayFormat: (date, locale) => date ? format(date, 'd', {
|
|
168
|
+
locale
|
|
169
|
+
}) : '',
|
|
170
|
+
displayTimeFormat: (date, locale) => date ? format(date, 'HH:mm', {
|
|
171
|
+
locale
|
|
172
|
+
}) : '',
|
|
173
|
+
datePlaceholder: 'Set a date',
|
|
174
|
+
dateTimePlaceholder: 'Set date and time',
|
|
175
|
+
rangePlaceholder: 'Set a period',
|
|
176
|
+
minDate: null,
|
|
177
|
+
maxDate: null,
|
|
178
|
+
onChange() {},
|
|
179
|
+
translations: {
|
|
180
|
+
setDate: 'Set a date',
|
|
181
|
+
setDateTime: 'Set date and time',
|
|
182
|
+
setPeriod: 'Set a period'
|
|
183
|
+
},
|
|
184
|
+
applyTimeInput(date, timeString) {
|
|
185
|
+
var _timeString$split$map;
|
|
186
|
+
const [hours, minutes] = (_timeString$split$map = timeString?.split(':').map(Number)) !== null && _timeString$split$map !== void 0 ? _timeString$split$map : [];
|
|
187
|
+
return minutes != null ? set(date, {
|
|
188
|
+
hours,
|
|
189
|
+
minutes
|
|
190
|
+
}) : date;
|
|
191
|
+
},
|
|
192
|
+
parseDateInput(string) {
|
|
193
|
+
if (!string) {
|
|
194
|
+
return null;
|
|
160
195
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
datePlaceholder,
|
|
167
|
-
dateTimePlaceholder,
|
|
168
|
-
rangePlaceholder,
|
|
169
|
-
withTime,
|
|
170
|
-
displayFormat,
|
|
171
|
-
displayMonthFormat,
|
|
172
|
-
displayDayFormat,
|
|
173
|
-
translations,
|
|
174
|
-
locale
|
|
175
|
-
} = this.props;
|
|
176
|
-
const date = this.parse(this.props.date);
|
|
177
|
-
const from = this.parse(this.props.from);
|
|
178
|
-
const to = this.parse(this.props.to);
|
|
179
|
-
const time = this.formatTime();
|
|
180
|
-
if (!range && !withTime) {
|
|
181
|
-
return date ? displayFormat(date, locale) : datePlaceholder !== null && datePlaceholder !== void 0 ? datePlaceholder : translations.setDate;
|
|
182
|
-
} else if (!range && withTime) {
|
|
183
|
-
if (!date && !time) {
|
|
184
|
-
return dateTimePlaceholder !== null && dateTimePlaceholder !== void 0 ? dateTimePlaceholder : translations.setDateTime;
|
|
185
|
-
} else {
|
|
186
|
-
return `${date && displayFormat(date, locale) || '—'}, ${time || '—'}`;
|
|
196
|
+
const today = new Date();
|
|
197
|
+
for (const format of formats) {
|
|
198
|
+
const date = parse(string, format, today);
|
|
199
|
+
if (isValid(date)) {
|
|
200
|
+
return date;
|
|
187
201
|
}
|
|
188
|
-
} else if (from && to) {
|
|
189
|
-
if (!isSameYear(from, to)) {
|
|
190
|
-
return `${displayFormat(from, locale)} — ${displayFormat(to, locale)}`;
|
|
191
|
-
} else if (!isSameMonth(from, to)) {
|
|
192
|
-
return `${displayMonthFormat(from, locale)} — ${displayFormat(to, locale)}`;
|
|
193
|
-
} else if (!isSameDay(from, to)) {
|
|
194
|
-
return `${displayDayFormat(from, locale)} — ${displayFormat(to, locale)}`;
|
|
195
|
-
} else {
|
|
196
|
-
return `${displayFormat(to, locale)}`;
|
|
197
|
-
}
|
|
198
|
-
} else if (from) {
|
|
199
|
-
return `${displayFormat(from, locale)} —`;
|
|
200
|
-
} else if (to) {
|
|
201
|
-
return `— ${displayFormat(to, locale)}`;
|
|
202
|
-
} else {
|
|
203
|
-
return rangePlaceholder !== null && rangePlaceholder !== void 0 ? rangePlaceholder : translations.setPeriod;
|
|
204
202
|
}
|
|
205
|
-
|
|
206
|
-
|
|
203
|
+
return null;
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
handleChange = change => {
|
|
207
|
+
const {
|
|
208
|
+
onChange,
|
|
209
|
+
withTime,
|
|
210
|
+
applyTimeInput
|
|
211
|
+
} = this.props;
|
|
212
|
+
const adjustedChange = withTime && !(change instanceof Date) && change?.date != null ? applyTimeInput(change.date, change.time) : change;
|
|
213
|
+
onChange(adjustedChange);
|
|
214
|
+
};
|
|
215
|
+
clear = () => {
|
|
216
|
+
let change = null;
|
|
217
|
+
if (this.props.range) {
|
|
218
|
+
change = {
|
|
219
|
+
from: null,
|
|
220
|
+
to: null
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
this.handleChange(change);
|
|
224
|
+
};
|
|
225
|
+
popup;
|
|
226
|
+
popupRef = el => {
|
|
227
|
+
this.popup = el;
|
|
228
|
+
};
|
|
229
|
+
closePopup = () => {
|
|
230
|
+
this.popup?._onCloseAttempt();
|
|
231
|
+
};
|
|
232
|
+
parse = memoize(date => {
|
|
233
|
+
const {
|
|
234
|
+
parseDateInput
|
|
235
|
+
} = this.props;
|
|
236
|
+
if (date instanceof Date) {
|
|
237
|
+
return date;
|
|
238
|
+
}
|
|
239
|
+
if (typeof date === 'number') {
|
|
240
|
+
return new Date(date);
|
|
241
|
+
}
|
|
242
|
+
return parseDateInput(date);
|
|
243
|
+
});
|
|
207
244
|
formatTime() {
|
|
208
245
|
const {
|
|
209
246
|
displayTimeFormat,
|
|
@@ -215,6 +252,49 @@ class DatePicker extends PureComponent {
|
|
|
215
252
|
}
|
|
216
253
|
return null;
|
|
217
254
|
}
|
|
255
|
+
getAnchorText = () => {
|
|
256
|
+
const {
|
|
257
|
+
range,
|
|
258
|
+
datePlaceholder,
|
|
259
|
+
dateTimePlaceholder,
|
|
260
|
+
rangePlaceholder,
|
|
261
|
+
withTime,
|
|
262
|
+
displayFormat,
|
|
263
|
+
displayMonthFormat,
|
|
264
|
+
displayDayFormat,
|
|
265
|
+
translations,
|
|
266
|
+
locale
|
|
267
|
+
} = this.props;
|
|
268
|
+
const date = this.parse(this.props.date);
|
|
269
|
+
const from = this.parse(this.props.from);
|
|
270
|
+
const to = this.parse(this.props.to);
|
|
271
|
+
const time = this.formatTime();
|
|
272
|
+
if (!range && !withTime) {
|
|
273
|
+
return date ? displayFormat(date, locale) : datePlaceholder !== null && datePlaceholder !== void 0 ? datePlaceholder : translations.setDate;
|
|
274
|
+
} else if (!range && withTime) {
|
|
275
|
+
if (!date && !time) {
|
|
276
|
+
return dateTimePlaceholder !== null && dateTimePlaceholder !== void 0 ? dateTimePlaceholder : translations.setDateTime;
|
|
277
|
+
} else {
|
|
278
|
+
return `${date && displayFormat(date, locale) || '—'}, ${time || '—'}`;
|
|
279
|
+
}
|
|
280
|
+
} else if (from && to) {
|
|
281
|
+
if (!isSameYear(from, to)) {
|
|
282
|
+
return `${displayFormat(from, locale)} — ${displayFormat(to, locale)}`;
|
|
283
|
+
} else if (!isSameMonth(from, to)) {
|
|
284
|
+
return `${displayMonthFormat(from, locale)} — ${displayFormat(to, locale)}`;
|
|
285
|
+
} else if (!isSameDay(from, to)) {
|
|
286
|
+
return `${displayDayFormat(from, locale)} — ${displayFormat(to, locale)}`;
|
|
287
|
+
} else {
|
|
288
|
+
return `${displayFormat(to, locale)}`;
|
|
289
|
+
}
|
|
290
|
+
} else if (from) {
|
|
291
|
+
return `${displayFormat(from, locale)} —`;
|
|
292
|
+
} else if (to) {
|
|
293
|
+
return `— ${displayFormat(to, locale)}`;
|
|
294
|
+
} else {
|
|
295
|
+
return rangePlaceholder !== null && rangePlaceholder !== void 0 ? rangePlaceholder : translations.setPeriod;
|
|
296
|
+
}
|
|
297
|
+
};
|
|
218
298
|
render() {
|
|
219
299
|
var _this$props$disabled, _this$props$disabled2;
|
|
220
300
|
const anchorContent = /*#__PURE__*/React.createElement("div", {
|
|
@@ -269,88 +349,5 @@ class DatePicker extends PureComponent {
|
|
|
269
349
|
}));
|
|
270
350
|
}
|
|
271
351
|
}
|
|
272
|
-
_defineProperty(DatePicker, "propTypes", {
|
|
273
|
-
className: PropTypes.string,
|
|
274
|
-
popupClassName: PropTypes.string,
|
|
275
|
-
date: dateType,
|
|
276
|
-
withTime: PropTypes.bool,
|
|
277
|
-
range: PropTypes.bool,
|
|
278
|
-
from: dateType,
|
|
279
|
-
to: dateType,
|
|
280
|
-
clear: PropTypes.bool,
|
|
281
|
-
inline: PropTypes.bool,
|
|
282
|
-
displayFormat: PropTypes.func,
|
|
283
|
-
displayMonthFormat: PropTypes.func,
|
|
284
|
-
displayDayFormat: PropTypes.func,
|
|
285
|
-
displayTimeFormat: PropTypes.func,
|
|
286
|
-
parseDateInput: PropTypes.func,
|
|
287
|
-
applyTimeInput: PropTypes.func,
|
|
288
|
-
datePlaceholder: PropTypes.string,
|
|
289
|
-
dateTimePlaceholder: PropTypes.string,
|
|
290
|
-
rangePlaceholder: PropTypes.string,
|
|
291
|
-
onChange: PropTypes.func,
|
|
292
|
-
dropdownProps: PropTypes.object,
|
|
293
|
-
disabled: PropTypes.bool,
|
|
294
|
-
minDate: dateType,
|
|
295
|
-
maxDate: dateType,
|
|
296
|
-
translations: PropTypes.object,
|
|
297
|
-
locale: PropTypes.object,
|
|
298
|
-
size: PropTypes.oneOf(Object.values(Size))
|
|
299
|
-
});
|
|
300
|
-
_defineProperty(DatePicker, "defaultProps", {
|
|
301
|
-
className: '',
|
|
302
|
-
date: null,
|
|
303
|
-
withTime: false,
|
|
304
|
-
range: false,
|
|
305
|
-
from: null,
|
|
306
|
-
to: null,
|
|
307
|
-
clear: false,
|
|
308
|
-
inline: false,
|
|
309
|
-
size: Size.M,
|
|
310
|
-
displayFormat: (date, locale) => date ? format(date, 'd MMM yyyy', {
|
|
311
|
-
locale
|
|
312
|
-
}) : '',
|
|
313
|
-
displayMonthFormat: (date, locale) => date ? format(date, 'd MMM', {
|
|
314
|
-
locale
|
|
315
|
-
}) : '',
|
|
316
|
-
displayDayFormat: (date, locale) => date ? format(date, 'd', {
|
|
317
|
-
locale
|
|
318
|
-
}) : '',
|
|
319
|
-
displayTimeFormat: (date, locale) => date ? format(date, 'HH:mm', {
|
|
320
|
-
locale
|
|
321
|
-
}) : '',
|
|
322
|
-
datePlaceholder: 'Set a date',
|
|
323
|
-
dateTimePlaceholder: 'Set date and time',
|
|
324
|
-
rangePlaceholder: 'Set a period',
|
|
325
|
-
minDate: null,
|
|
326
|
-
maxDate: null,
|
|
327
|
-
onChange() {},
|
|
328
|
-
translations: {
|
|
329
|
-
setDate: 'Set a date',
|
|
330
|
-
setDateTime: 'Set date and time',
|
|
331
|
-
setPeriod: 'Set a period'
|
|
332
|
-
},
|
|
333
|
-
applyTimeInput(date, timeString) {
|
|
334
|
-
var _timeString$split$map;
|
|
335
|
-
const [hours, minutes] = (_timeString$split$map = timeString?.split(':').map(Number)) !== null && _timeString$split$map !== void 0 ? _timeString$split$map : [];
|
|
336
|
-
return minutes != null ? set(date, {
|
|
337
|
-
hours,
|
|
338
|
-
minutes
|
|
339
|
-
}) : date;
|
|
340
|
-
},
|
|
341
|
-
parseDateInput(string) {
|
|
342
|
-
if (!string) {
|
|
343
|
-
return null;
|
|
344
|
-
}
|
|
345
|
-
const today = new Date();
|
|
346
|
-
for (const format of formats) {
|
|
347
|
-
const date = parse(string, format, today);
|
|
348
|
-
if (isValid(date)) {
|
|
349
|
-
return date;
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
return null;
|
|
353
|
-
}
|
|
354
|
-
});
|
|
355
352
|
|
|
356
353
|
export { DatePicker as default };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as
|
|
1
|
+
import { _ as _extends } from '../_helpers/_rollupPluginBabelHelpers.js';
|
|
2
2
|
import React, { Component } from 'react';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import isAfter from 'date-fns/isAfter';
|
|
@@ -68,101 +68,33 @@ class DatePopup extends Component {
|
|
|
68
68
|
}
|
|
69
69
|
return next === prev;
|
|
70
70
|
}
|
|
71
|
+
static propTypes = {
|
|
72
|
+
className: PropTypes.string,
|
|
73
|
+
date: dateType,
|
|
74
|
+
range: PropTypes.bool,
|
|
75
|
+
withTime: PropTypes.bool,
|
|
76
|
+
time: PropTypes.string,
|
|
77
|
+
from: dateType,
|
|
78
|
+
to: dateType,
|
|
79
|
+
renderAfterCalendar: PropTypes.func,
|
|
80
|
+
displayFormat: PropTypes.func,
|
|
81
|
+
parseDateInput: PropTypes.func,
|
|
82
|
+
onChange: PropTypes.func,
|
|
83
|
+
onComplete: PropTypes.func,
|
|
84
|
+
onClear: PropTypes.func,
|
|
85
|
+
minDate: dateType,
|
|
86
|
+
maxDate: dateType,
|
|
87
|
+
hidden: PropTypes.bool,
|
|
88
|
+
fromPlaceholder: PropTypes.string,
|
|
89
|
+
toPlaceholder: PropTypes.string,
|
|
90
|
+
timePlaceholder: PropTypes.string,
|
|
91
|
+
locale: PropTypes.object
|
|
92
|
+
};
|
|
93
|
+
static defaultProps = {
|
|
94
|
+
onChange() {}
|
|
95
|
+
};
|
|
71
96
|
constructor(props) {
|
|
72
97
|
super(props);
|
|
73
|
-
_defineProperty(this, "_scrollDate", void 0);
|
|
74
|
-
_defineProperty(this, "_scrollTS", void 0);
|
|
75
|
-
_defineProperty(this, "isInTimeMode", () => !this.props.range && this.props.withTime || false);
|
|
76
|
-
_defineProperty(this, "componentRef", /*#__PURE__*/React.createRef());
|
|
77
|
-
_defineProperty(this, "handleWheel", e => {
|
|
78
|
-
if (e.cancelable) {
|
|
79
|
-
e.preventDefault();
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
_defineProperty(this, "isValidDate", parsedText => {
|
|
83
|
-
const minDate = this.parse(this.props.minDate, 'date');
|
|
84
|
-
const maxDate = this.parse(this.props.maxDate, 'date');
|
|
85
|
-
if (parsedText) {
|
|
86
|
-
return !(minDate && isBefore(parsedText, minDate) || maxDate && isAfter(parsedText, maxDate));
|
|
87
|
-
}
|
|
88
|
-
return false;
|
|
89
|
-
});
|
|
90
|
-
_defineProperty(this, "scheduleScroll", () => {
|
|
91
|
-
const current = this.state.scrollDate && this.parse(this.state.scrollDate, 'date') || this.parse(this.props[this.state.active], 'date') || new Date();
|
|
92
|
-
const goal = this._scrollDate;
|
|
93
|
-
if (!current || !goal || DatePopup.sameDay(goal, current)) {
|
|
94
|
-
this._scrollDate = null;
|
|
95
|
-
this._scrollTS = null;
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
if (this._scrollTS) {
|
|
99
|
-
const diff = goal - Number(current);
|
|
100
|
-
const dt = Date.now() - this._scrollTS;
|
|
101
|
-
const next = goal - diff * Math.E ** (-dt / scrollExpDelay);
|
|
102
|
-
this.setState({
|
|
103
|
-
scrollDate: next
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
this._scrollTS = Date.now();
|
|
107
|
-
window.requestAnimationFrame(this.scheduleScroll);
|
|
108
|
-
});
|
|
109
|
-
_defineProperty(this, "scrollTo", scrollDate => {
|
|
110
|
-
this._scrollDate = scrollDate;
|
|
111
|
-
if (!this._scrollTS) {
|
|
112
|
-
this.scheduleScroll();
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
_defineProperty(this, "hoverHandler", hoverDate => this.setState({
|
|
116
|
-
hoverDate
|
|
117
|
-
}));
|
|
118
|
-
_defineProperty(this, "handleActivate", memoize(name => () => this.setState({
|
|
119
|
-
active: name
|
|
120
|
-
})));
|
|
121
|
-
_defineProperty(this, "handleInput", (text, name) => {
|
|
122
|
-
if (name !== 'time') {
|
|
123
|
-
const parsed = this.parse(text, name);
|
|
124
|
-
if (this.isValidDate(parsed)) {
|
|
125
|
-
this.scrollTo(Number(parsed));
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
this.setState({
|
|
129
|
-
text,
|
|
130
|
-
hoverDate: null
|
|
131
|
-
});
|
|
132
|
-
});
|
|
133
|
-
_defineProperty(this, "handleConfirm", memoize(name => () => this.confirm(name)));
|
|
134
|
-
_defineProperty(this, "selectHandler", date => {
|
|
135
|
-
if (this.isInTimeMode()) {
|
|
136
|
-
this.setState({
|
|
137
|
-
active: 'time'
|
|
138
|
-
}, () => this.select({
|
|
139
|
-
date
|
|
140
|
-
}));
|
|
141
|
-
} else {
|
|
142
|
-
this.select({
|
|
143
|
-
[this.state.active]: date
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
_defineProperty(this, "handleScroll", scrollDate => this.setState({
|
|
148
|
-
scrollDate
|
|
149
|
-
}));
|
|
150
|
-
_defineProperty(this, "onClear", e => {
|
|
151
|
-
let changes;
|
|
152
|
-
if (this.props.range) {
|
|
153
|
-
changes = {
|
|
154
|
-
from: null,
|
|
155
|
-
to: null
|
|
156
|
-
};
|
|
157
|
-
} else {
|
|
158
|
-
changes = {
|
|
159
|
-
date: null
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
this.select(changes);
|
|
163
|
-
this.props.onClear?.(e);
|
|
164
|
-
this.componentRef.current?.querySelector('input')?.focus();
|
|
165
|
-
});
|
|
166
98
|
const defaultState = {
|
|
167
99
|
text: null,
|
|
168
100
|
hoverDate: null,
|
|
@@ -213,6 +145,15 @@ class DatePopup extends Component {
|
|
|
213
145
|
this.componentRef.current.removeEventListener('wheel', this.handleWheel);
|
|
214
146
|
}
|
|
215
147
|
}
|
|
148
|
+
_scrollDate;
|
|
149
|
+
_scrollTS;
|
|
150
|
+
isInTimeMode = () => !this.props.range && this.props.withTime || false;
|
|
151
|
+
componentRef = /*#__PURE__*/React.createRef();
|
|
152
|
+
handleWheel = e => {
|
|
153
|
+
if (e.cancelable) {
|
|
154
|
+
e.preventDefault();
|
|
155
|
+
}
|
|
156
|
+
};
|
|
216
157
|
parse(text, type) {
|
|
217
158
|
if (type === 'time') {
|
|
218
159
|
return parseTime(String(text));
|
|
@@ -312,6 +253,90 @@ class DatePopup extends Component {
|
|
|
312
253
|
[name]: result
|
|
313
254
|
});
|
|
314
255
|
}
|
|
256
|
+
isValidDate = parsedText => {
|
|
257
|
+
const minDate = this.parse(this.props.minDate, 'date');
|
|
258
|
+
const maxDate = this.parse(this.props.maxDate, 'date');
|
|
259
|
+
if (parsedText) {
|
|
260
|
+
return !(minDate && isBefore(parsedText, minDate) || maxDate && isAfter(parsedText, maxDate));
|
|
261
|
+
}
|
|
262
|
+
return false;
|
|
263
|
+
};
|
|
264
|
+
scheduleScroll = () => {
|
|
265
|
+
const current = this.state.scrollDate && this.parse(this.state.scrollDate, 'date') || this.parse(this.props[this.state.active], 'date') || new Date();
|
|
266
|
+
const goal = this._scrollDate;
|
|
267
|
+
if (!current || !goal || DatePopup.sameDay(goal, current)) {
|
|
268
|
+
this._scrollDate = null;
|
|
269
|
+
this._scrollTS = null;
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
if (this._scrollTS) {
|
|
273
|
+
const diff = goal - Number(current);
|
|
274
|
+
const dt = Date.now() - this._scrollTS;
|
|
275
|
+
const next = goal - diff * Math.E ** (-dt / scrollExpDelay);
|
|
276
|
+
this.setState({
|
|
277
|
+
scrollDate: next
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
this._scrollTS = Date.now();
|
|
281
|
+
window.requestAnimationFrame(this.scheduleScroll);
|
|
282
|
+
};
|
|
283
|
+
scrollTo = scrollDate => {
|
|
284
|
+
this._scrollDate = scrollDate;
|
|
285
|
+
if (!this._scrollTS) {
|
|
286
|
+
this.scheduleScroll();
|
|
287
|
+
}
|
|
288
|
+
};
|
|
289
|
+
hoverHandler = hoverDate => this.setState({
|
|
290
|
+
hoverDate
|
|
291
|
+
});
|
|
292
|
+
handleActivate = memoize(name => () => this.setState({
|
|
293
|
+
active: name
|
|
294
|
+
}));
|
|
295
|
+
handleInput = (text, name) => {
|
|
296
|
+
if (name !== 'time') {
|
|
297
|
+
const parsed = this.parse(text, name);
|
|
298
|
+
if (this.isValidDate(parsed)) {
|
|
299
|
+
this.scrollTo(Number(parsed));
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
this.setState({
|
|
303
|
+
text,
|
|
304
|
+
hoverDate: null
|
|
305
|
+
});
|
|
306
|
+
};
|
|
307
|
+
handleConfirm = memoize(name => () => this.confirm(name));
|
|
308
|
+
selectHandler = date => {
|
|
309
|
+
if (this.isInTimeMode()) {
|
|
310
|
+
this.setState({
|
|
311
|
+
active: 'time'
|
|
312
|
+
}, () => this.select({
|
|
313
|
+
date
|
|
314
|
+
}));
|
|
315
|
+
} else {
|
|
316
|
+
this.select({
|
|
317
|
+
[this.state.active]: date
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
};
|
|
321
|
+
handleScroll = scrollDate => this.setState({
|
|
322
|
+
scrollDate
|
|
323
|
+
});
|
|
324
|
+
onClear = e => {
|
|
325
|
+
let changes;
|
|
326
|
+
if (this.props.range) {
|
|
327
|
+
changes = {
|
|
328
|
+
from: null,
|
|
329
|
+
to: null
|
|
330
|
+
};
|
|
331
|
+
} else {
|
|
332
|
+
changes = {
|
|
333
|
+
date: null
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
this.select(changes);
|
|
337
|
+
this.props.onClear?.(e);
|
|
338
|
+
this.componentRef.current?.querySelector('input')?.focus();
|
|
339
|
+
};
|
|
315
340
|
render() {
|
|
316
341
|
const {
|
|
317
342
|
range,
|
|
@@ -420,30 +445,5 @@ class DatePopup extends Component {
|
|
|
420
445
|
})), /*#__PURE__*/React.createElement(Years, calendarProps)), this.props.renderAfterCalendar && this.props.renderAfterCalendar(this.state));
|
|
421
446
|
}
|
|
422
447
|
}
|
|
423
|
-
_defineProperty(DatePopup, "propTypes", {
|
|
424
|
-
className: PropTypes.string,
|
|
425
|
-
date: dateType,
|
|
426
|
-
range: PropTypes.bool,
|
|
427
|
-
withTime: PropTypes.bool,
|
|
428
|
-
time: PropTypes.string,
|
|
429
|
-
from: dateType,
|
|
430
|
-
to: dateType,
|
|
431
|
-
renderAfterCalendar: PropTypes.func,
|
|
432
|
-
displayFormat: PropTypes.func,
|
|
433
|
-
parseDateInput: PropTypes.func,
|
|
434
|
-
onChange: PropTypes.func,
|
|
435
|
-
onComplete: PropTypes.func,
|
|
436
|
-
onClear: PropTypes.func,
|
|
437
|
-
minDate: dateType,
|
|
438
|
-
maxDate: dateType,
|
|
439
|
-
hidden: PropTypes.bool,
|
|
440
|
-
fromPlaceholder: PropTypes.string,
|
|
441
|
-
toPlaceholder: PropTypes.string,
|
|
442
|
-
timePlaceholder: PropTypes.string,
|
|
443
|
-
locale: PropTypes.object
|
|
444
|
-
});
|
|
445
|
-
_defineProperty(DatePopup, "defaultProps", {
|
|
446
|
-
onChange() {}
|
|
447
|
-
});
|
|
448
448
|
|
|
449
449
|
export { DatePopup as default };
|