@jetbrains/ring-ui 4.1.0-beta.9 → 4.1.1
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/CHANGELOG.md +13 -0
- package/README.md +17 -15
- package/babel.config.js +3 -2
- package/components/alert/alert.js +9 -3
- package/components/alert/container.css +1 -1
- package/components/alert-service/alert-service.examples.css +18 -0
- package/components/alert-service/alert-service.examples.js +21 -0
- package/components/alert-service/alert-service.js +10 -3
- package/components/analytics/analytics__fus-plugin.js +1 -1
- package/components/auth/auth.test.js +14 -7
- package/components/auth/auth__core.js +64 -33
- package/components/auth-dialog/auth-dialog.js +1 -0
- package/components/avatar/avatar.css +4 -1
- package/components/avatar/avatar.examples.js +3 -2
- package/components/avatar/avatar.js +31 -6
- package/components/avatar/fallback-avatar.js +136 -0
- package/components/avatar-editor-ng/avatar-editor-ng.css +2 -2
- package/components/avatar-editor-ng/avatar-editor-ng.js +2 -1
- package/components/avatar-editor-ng/{avatar-editor-ng.html → avatar-editor-ng__template.js} +2 -2
- package/components/button/button.css +2 -2
- package/components/button/button.js +4 -1
- package/components/button-group/button-group.js +1 -1
- package/components/button-group/caption.js +1 -1
- package/components/button-ng/button-ng.js +1 -1
- package/components/button-set-ng/button-set-ng.js +3 -1
- package/components/checkbox/checkbox.css +1 -1
- package/components/code/code.js +1 -1
- package/components/confirm/confirm.js +1 -0
- package/components/confirm-service/confirm-service.js +5 -5
- package/components/content-layout/content-layout.css +1 -1
- package/components/data-list/data-list.css +1 -1
- package/components/date-picker/date-input.js +5 -4
- package/components/date-picker/date-picker.css +34 -22
- package/components/date-picker/date-picker.js +16 -14
- package/components/date-picker/date-popup.js +22 -7
- package/components/date-picker/month-names.js +8 -5
- package/components/date-picker/month.js +6 -2
- package/components/date-picker/weekdays.js +10 -2
- package/components/dialog/dialog.examples.js +3 -1
- package/components/dialog/dialog.js +5 -2
- package/components/dialog/dialog.test.js +1 -1
- package/components/dialog/dialog__body-scroll-preventer.js +2 -2
- package/components/dialog-ng/dialog-ng.js +7 -8
- package/components/dialog-ng/{dialog-ng.html → dialog-ng__template.js} +2 -2
- package/components/dropdown/dropdown.examples.js +36 -1
- package/components/dropdown-menu/dropdown-menu.examples.js +47 -0
- package/components/dropdown-menu/dropdown-menu.js +117 -0
- package/components/dropdown-menu/dropdown-menu.test.js +76 -0
- package/components/error-bubble/error-bubble-legacy.css +1 -1
- package/components/error-bubble/error-bubble.css +1 -1
- package/components/error-bubble/error-bubble.examples.js +1 -1
- package/components/error-page/error-page.css +2 -2
- package/components/footer-ng/footer-ng.js +13 -3
- package/components/form/form.css +2 -2
- package/components/form-ng/form-ng.js +3 -1
- package/components/global/global.css +1 -1
- package/components/global/theme.js +1 -1
- package/components/global/variables.css +8 -1
- package/components/grid/grid.css +10 -9
- package/components/header/header.css +1 -1
- package/components/header/header.examples.js +7 -8
- package/components/header/profile.js +10 -11
- package/components/http/http.js +1 -1
- package/components/icon/icon.css +5 -4
- package/components/island/island.css +4 -3
- package/components/island-legacy/island-legacy.css +3 -1
- package/components/list/list.js +6 -1
- package/components/list/list__custom.js +9 -3
- package/components/list/list__item.js +8 -2
- package/components/list/list__link.js +2 -1
- package/components/loader-inline/loader-inline.css +1 -1
- package/components/loader-screen/loader-screen.css +1 -1
- package/components/message/message.css +1 -1
- package/components/message/message.examples.js +8 -5
- package/components/pager/pager.js +5 -3
- package/components/permissions/permissions.js +1 -1
- package/components/progress-bar/progress-bar.css +1 -1
- package/components/progress-bar/progress-bar.examples.js +3 -3
- package/components/progress-bar/progress-bar.js +5 -2
- package/components/progress-bar/progress-bar.test.js +12 -13
- package/components/progress-bar-ng/progress-bar-ng.examples.js +3 -3
- package/components/query-assist/query-assist.css +13 -3
- package/components/query-assist/query-assist.examples.js +3 -1
- package/components/query-assist/query-assist.js +56 -12
- package/components/query-assist/query-assist.test.js +37 -5
- package/components/save-field-ng/save-field-ng.css +0 -3
- package/components/save-field-ng/save-field-ng.js +3 -1
- package/components/save-field-ng/{save-field-ng.html → save-field-ng__template.js} +2 -2
- package/components/select/select.css +12 -7
- package/components/select/select.examples.js +13 -0
- package/components/select/select.js +30 -43
- package/components/select/select.test.js +4 -5
- package/components/shortcuts-hint-ng/shortcuts-hint-ng.css +1 -1
- package/components/shortcuts-hint-ng/shortcuts-hint-ng.js +1 -1
- package/components/shortcuts-hint-ng/{shortcuts-hint-ng.html → shortcuts-hint-ng__template.js} +2 -2
- package/components/sidebar/sidebar.css +1 -0
- package/components/sidebar-ng/sidebar-ng.js +6 -2
- package/components/sidebar-ng/{sidebar-ng__button.html → sidebar-ng__button-template.js} +2 -2
- package/components/sidebar-ng/{sidebar-ng.html → sidebar-ng__template.js} +2 -2
- package/components/table/row.js +2 -1
- package/components/table/table.css +2 -1
- package/components/table-legacy/table-legacy.css +2 -2
- package/components/table-legacy/table-legacy__toolbar.css +2 -2
- package/components/table-legacy-ng/table-legacy-ng.js +38 -5
- package/components/table-legacy-ng/table-legacy-ng__pager.js +7 -1
- package/components/tabs/collapsible-tab.js +2 -2
- package/components/tabs/collapsible-tabs.js +4 -8
- package/components/tabs/tab-link.js +4 -2
- package/components/tabs/tabs.css +27 -0
- package/components/tabs-ng/tabs-ng.js +4 -2
- package/components/tabs-ng/{tabs-ng.html → tabs-ng__template.js} +6 -2
- package/components/tag/tag.css +5 -2
- package/components/tag/tag.examples.js +3 -0
- package/components/tag/tag.js +19 -16
- package/components/tags-input/tag-input.examples.js +1 -1
- package/components/tags-input/tags-input.js +5 -2
- package/components/template-ng/template-ng.js +1 -1
- package/components/tooltip/tooltip.js +7 -2
- package/components/user-agreement/user-agreement.css +1 -1
- package/components/user-agreement/user-agreement.examples.js +7 -4
- package/components/user-agreement/user-agreement.js +1 -0
- package/package.json +75 -78
- package/webpack.config.js +14 -10
- package/components/button-set-ng/button-set-ng.html +0 -1
- package/components/footer-ng/footer-ng.html +0 -13
- package/components/form-ng/form-ng__error-bubble.html +0 -3
- package/components/table-legacy-ng/table-legacy-ng.html +0 -4
- package/components/table-legacy-ng/table-legacy-ng__column.html +0 -12
- package/components/table-legacy-ng/table-legacy-ng__header.html +0 -4
- package/components/table-legacy-ng/table-legacy-ng__pager.html +0 -7
- package/components/table-legacy-ng/table-legacy-ng__row.html +0 -12
- package/components/table-legacy-ng/table-legacy-ng__title.html +0 -9
- package/dist/_helpers/_rollupPluginBabelHelpers.js +0 -127
- package/dist/_helpers/anchor.js +0 -33
- package/dist/_helpers/badge.js +0 -3
- package/dist/_helpers/button__classes.js +0 -39
- package/dist/_helpers/caption.js +0 -25
- package/dist/_helpers/card.js +0 -77
- package/dist/_helpers/date-picker.js +0 -3
- package/dist/_helpers/dialog__body-scroll-preventer.js +0 -56
- package/dist/_helpers/grid.js +0 -3
- package/dist/_helpers/header.js +0 -3
- package/dist/_helpers/icon__svg.js +0 -83
- package/dist/_helpers/inject-styles.js +0 -22
- package/dist/_helpers/island.js +0 -3
- package/dist/_helpers/list.js +0 -3
- package/dist/_helpers/query-assist__suggestions.js +0 -95
- package/dist/_helpers/select__filter.js +0 -78
- package/dist/_helpers/services-link.js +0 -42
- package/dist/_helpers/sidebar.js +0 -127
- package/dist/_helpers/table.js +0 -3
- package/dist/_helpers/tabs.js +0 -3
- package/dist/_helpers/title.js +0 -99
- package/dist/alert/alert.js +0 -254
- package/dist/alert/container.js +0 -50
- package/dist/alert-service/alert-service.js +0 -159
- package/dist/analytics/analytics.js +0 -116
- package/dist/analytics/analytics__custom-plugin.js +0 -127
- package/dist/analytics/analytics__fus-plugin.js +0 -101
- package/dist/analytics/analytics__ga-plugin.js +0 -66
- package/dist/analytics/analytics__plugin-utils.js +0 -79
- package/dist/auth/auth.js +0 -90
- package/dist/auth/auth__core.js +0 -987
- package/dist/auth/background-flow.js +0 -123
- package/dist/auth/down-notification.js +0 -111
- package/dist/auth/iframe-flow.js +0 -147
- package/dist/auth/landing-entry.js +0 -5
- package/dist/auth/landing.js +0 -84
- package/dist/auth/request-builder.js +0 -75
- package/dist/auth/response-parser.js +0 -117
- package/dist/auth/storage.js +0 -279
- package/dist/auth/token-validator.js +0 -176
- package/dist/auth/window-flow.js +0 -133
- package/dist/auth-dialog/auth-dialog.js +0 -132
- package/dist/auth-dialog-service/auth-dialog-service.js +0 -67
- package/dist/avatar/avatar-example-datauri.js +0 -26
- package/dist/avatar/avatar.js +0 -155
- package/dist/badge/badge.js +0 -52
- package/dist/button/button.js +0 -117
- package/dist/button/button__classes.js +0 -5
- package/dist/button-group/button-group.js +0 -30
- package/dist/button-group/caption.js +0 -5
- package/dist/button-set/button-set.js +0 -27
- package/dist/button-toolbar/button-toolbar.js +0 -30
- package/dist/caret/caret.js +0 -264
- package/dist/checkbox/checkbox.js +0 -110
- package/dist/confirm/confirm.js +0 -122
- package/dist/confirm-service/confirm-service.js +0 -112
- package/dist/content-layout/content-layout.js +0 -67
- package/dist/content-layout/sidebar.js +0 -6
- package/dist/contenteditable/contenteditable.js +0 -81
- package/dist/data-list/data-list.js +0 -203
- package/dist/data-list/data-list.mock.js +0 -190
- package/dist/data-list/item.js +0 -225
- package/dist/data-list/selection.js +0 -101
- package/dist/data-list/title.js +0 -16
- package/dist/date-picker/consts.js +0 -70
- package/dist/date-picker/date-input.js +0 -169
- package/dist/date-picker/date-picker.js +0 -356
- package/dist/date-picker/date-popup.js +0 -459
- package/dist/date-picker/day.js +0 -119
- package/dist/date-picker/formats.js +0 -3
- package/dist/date-picker/month-names.js +0 -92
- package/dist/date-picker/month-slider.js +0 -83
- package/dist/date-picker/month.js +0 -48
- package/dist/date-picker/months.js +0 -121
- package/dist/date-picker/weekdays.js +0 -24
- package/dist/date-picker/years.js +0 -109
- package/dist/dialog/dialog.js +0 -197
- package/dist/dialog/dialog__body-scroll-preventer.js +0 -2
- package/dist/dropdown/anchor.js +0 -16
- package/dist/dropdown/dropdown.js +0 -236
- package/dist/error-bubble/error-bubble.js +0 -59
- package/dist/error-message/error-message.js +0 -55
- package/dist/footer/footer.js +0 -127
- package/dist/global/angular-component-factory.js +0 -83
- package/dist/global/compose.js +0 -9
- package/dist/global/composeRefs.js +0 -15
- package/dist/global/conic-gradient.js +0 -37
- package/dist/global/create-stateful-context.js +0 -54
- package/dist/global/data-tests.js +0 -22
- package/dist/global/dom.js +0 -124
- package/dist/global/focus-sensor-hoc.js +0 -147
- package/dist/global/fuzzy-highlight.js +0 -67
- package/dist/global/get-event-key.js +0 -111
- package/dist/global/get-uid.js +0 -15
- package/dist/global/inject-styles.js +0 -17
- package/dist/global/linear-function.js +0 -18
- package/dist/global/listeners.js +0 -42
- package/dist/global/memoize.js +0 -18
- package/dist/global/normalize-indent.js +0 -28
- package/dist/global/promise-with-timeout.js +0 -13
- package/dist/global/radial-gradient-mask.js +0 -49
- package/dist/global/react-dom-renderer.js +0 -45
- package/dist/global/rerender-hoc.js +0 -53
- package/dist/global/ring-angular-component.js +0 -24
- package/dist/global/schedule-raf.js +0 -31
- package/dist/global/sniffer.js +0 -6
- package/dist/global/supports-css.js +0 -20
- package/dist/global/theme.js +0 -56
- package/dist/global/trivial-template-tag.js +0 -15
- package/dist/global/url.js +0 -163
- package/dist/global/variables_dark.js +0 -57
- package/dist/grid/col.js +0 -62
- package/dist/grid/grid.js +0 -35
- package/dist/grid/row.js +0 -66
- package/dist/group/group.js +0 -34
- package/dist/header/header.js +0 -144
- package/dist/header/logo.js +0 -39
- package/dist/header/profile.js +0 -212
- package/dist/header/services-link.js +0 -10
- package/dist/header/services.js +0 -135
- package/dist/header/smart-profile.js +0 -227
- package/dist/header/smart-services.js +0 -159
- package/dist/header/tray-icon.js +0 -45
- package/dist/header/tray.js +0 -33
- package/dist/heading/heading.js +0 -76
- package/dist/http/http.js +0 -216
- package/dist/http/http.mock.js +0 -65
- package/dist/hub-source/hub-source.js +0 -130
- package/dist/hub-source/hub-source__user.js +0 -28
- package/dist/hub-source/hub-source__users-groups.js +0 -62
- package/dist/icon/icon.js +0 -105
- package/dist/icon/icon__constants.js +0 -33
- package/dist/icon/icon__svg.js +0 -6
- package/dist/icon/index.js +0 -9
- package/dist/input/input.js +0 -231
- package/dist/island/adaptive-island-hoc.js +0 -48
- package/dist/island/content.js +0 -158
- package/dist/island/header.js +0 -85
- package/dist/island/island.js +0 -53
- package/dist/island-legacy/content-legacy.js +0 -28
- package/dist/island-legacy/header-legacy.js +0 -30
- package/dist/island-legacy/island-legacy.js +0 -30
- package/dist/link/clickableLink.js +0 -65
- package/dist/link/link.js +0 -118
- package/dist/list/consts.js +0 -26
- package/dist/list/list.js +0 -800
- package/dist/list/list__custom.js +0 -82
- package/dist/list/list__hint.js +0 -26
- package/dist/list/list__item.js +0 -197
- package/dist/list/list__link.js +0 -65
- package/dist/list/list__separator.js +0 -30
- package/dist/list/list__title.js +0 -39
- package/dist/list/list__users-groups-source.js +0 -124
- package/dist/loader/loader.js +0 -72
- package/dist/loader/loader__core.js +0 -272
- package/dist/loader-inline/inject-styles.js +0 -11
- package/dist/loader-inline/loader-inline.js +0 -58
- package/dist/loader-screen/loader-screen.js +0 -46
- package/dist/login-dialog/login-dialog.js +0 -184
- package/dist/login-dialog/service.js +0 -67
- package/dist/message/message.js +0 -232
- package/dist/old-browsers-message/old-browsers-message.js +0 -101
- package/dist/old-browsers-message/old-browsers-message__stop.js +0 -5
- package/dist/old-browsers-message/white-list.js +0 -34
- package/dist/pager/pager.js +0 -352
- package/dist/panel/panel.js +0 -34
- package/dist/permissions/permissions.js +0 -200
- package/dist/permissions/permissions__cache.js +0 -272
- package/dist/popup/popup.consts.js +0 -41
- package/dist/popup/popup.js +0 -389
- package/dist/popup/popup.target.js +0 -27
- package/dist/popup/position.js +0 -280
- package/dist/popup-menu/popup-menu.js +0 -108
- package/dist/progress-bar/progress-bar.js +0 -111
- package/dist/proxy-attrs/proxy-attrs.js +0 -19
- package/dist/query-assist/query-assist.js +0 -1023
- package/dist/query-assist/query-assist__suggestions.js +0 -43
- package/dist/radio/radio.js +0 -39
- package/dist/radio/radio__item.js +0 -82
- package/dist/select/select.js +0 -1335
- package/dist/select/select__filter.js +0 -49
- package/dist/select/select__popup.js +0 -541
- package/dist/shortcuts/core.js +0 -245
- package/dist/shortcuts/shortcut-title.js +0 -51
- package/dist/shortcuts/shortcuts-hoc.js +0 -43
- package/dist/shortcuts/shortcuts.js +0 -72
- package/dist/storage/storage.js +0 -55
- package/dist/storage/storage__fallback.js +0 -214
- package/dist/storage/storage__local.js +0 -150
- package/dist/style.css +0 -1
- package/dist/tab-trap/tab-trap.js +0 -178
- package/dist/table/cell.js +0 -25
- package/dist/table/disable-hover-hoc.js +0 -53
- package/dist/table/header-cell.js +0 -91
- package/dist/table/header.js +0 -189
- package/dist/table/multitable.js +0 -140
- package/dist/table/row-with-focus-sensor.js +0 -79
- package/dist/table/row.js +0 -270
- package/dist/table/selection-adapter.js +0 -14
- package/dist/table/selection-shortcuts-hoc.js +0 -212
- package/dist/table/selection.js +0 -221
- package/dist/table/smart-table.js +0 -113
- package/dist/table/table.js +0 -405
- package/dist/tabs/collapsible-more.js +0 -193
- package/dist/tabs/collapsible-tab.js +0 -90
- package/dist/tabs/collapsible-tabs.js +0 -361
- package/dist/tabs/custom-item.js +0 -13
- package/dist/tabs/dumb-tabs.js +0 -159
- package/dist/tabs/smart-tabs.js +0 -102
- package/dist/tabs/tab-link.js +0 -35
- package/dist/tabs/tab.js +0 -32
- package/dist/tabs/tabs.js +0 -65
- package/dist/tag/tag.js +0 -190
- package/dist/tags-input/tags-input.js +0 -474
- package/dist/tags-list/tags-list.js +0 -94
- package/dist/text/text.js +0 -38
- package/dist/toggle/toggle.js +0 -80
- package/dist/tooltip/tooltip.js +0 -205
- package/dist/user-card/card.js +0 -14
- package/dist/user-card/smart-user-card-tooltip.js +0 -112
- package/dist/user-card/tooltip.js +0 -91
- package/dist/user-card/user-card.js +0 -46
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import Selection$1 from '../table/selection.js';
|
|
2
|
-
|
|
3
|
-
class Selection extends Selection$1 {
|
|
4
|
-
_buildData(data) {
|
|
5
|
-
return new Set(this._getDescendants(data));
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
_buildSelected(data, selected) {
|
|
9
|
-
const _selected = new Set(selected);
|
|
10
|
-
|
|
11
|
-
[...data].forEach(item => {
|
|
12
|
-
if (_selected.has(item)) {
|
|
13
|
-
this._selectDescendants(item, _selected);
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
return _selected;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
_getDescendants(items) {
|
|
20
|
-
let result = [];
|
|
21
|
-
items.forEach(item => {
|
|
22
|
-
result.push(item);
|
|
23
|
-
result = [...result, ...this._getDescendants(this._getChildren(item))];
|
|
24
|
-
});
|
|
25
|
-
return result;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
_getAncestors(item) {
|
|
29
|
-
let result = [];
|
|
30
|
-
const parent = [...this._data].find(it => this._getChildren(it).includes(item));
|
|
31
|
-
|
|
32
|
-
if (parent) {
|
|
33
|
-
result = [parent, ...this._getAncestors(parent)];
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return result;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
_selectDescendants(item, selected) {
|
|
40
|
-
this._getDescendants(this._getChildren(item)).forEach(it => selected.add(it));
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
_deselectDescendants(item, selected) {
|
|
44
|
-
this._getDescendants(this._getChildren(item)).forEach(it => selected.delete(it));
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
_selectAncestors(item, selected) {
|
|
48
|
-
this._getAncestors(item).forEach(ancestor => {
|
|
49
|
-
const groupIsSelected = this._getChildren(ancestor).filter(it => this._isItemSelectable(it)).every(it => selected.has(it));
|
|
50
|
-
|
|
51
|
-
if (groupIsSelected) {
|
|
52
|
-
selected.add(ancestor);
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
_deselectAncestors(item, selected) {
|
|
58
|
-
this._getAncestors(item).forEach(it => selected.delete(it));
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
select() {
|
|
62
|
-
let value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this._focused;
|
|
63
|
-
|
|
64
|
-
if (!value || !this._isItemSelectable(value)) {
|
|
65
|
-
return this;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const selected = new Set(this._selected);
|
|
69
|
-
selected.add(value);
|
|
70
|
-
|
|
71
|
-
this._selectDescendants(value, selected);
|
|
72
|
-
|
|
73
|
-
this._selectAncestors(value, selected);
|
|
74
|
-
|
|
75
|
-
return this.cloneWith({
|
|
76
|
-
selected
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
deselect() {
|
|
81
|
-
let value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this._focused;
|
|
82
|
-
|
|
83
|
-
if (!value || !this._isItemSelectable(value)) {
|
|
84
|
-
return this;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const selected = new Set(this._selected);
|
|
88
|
-
selected.delete(value);
|
|
89
|
-
|
|
90
|
-
this._deselectDescendants(value, selected);
|
|
91
|
-
|
|
92
|
-
this._deselectAncestors(value, selected);
|
|
93
|
-
|
|
94
|
-
return this.cloneWith({
|
|
95
|
-
selected
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
export default Selection;
|
package/dist/data-list/title.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import '../_helpers/_rollupPluginBabelHelpers.js';
|
|
2
|
-
import 'react';
|
|
3
|
-
import 'prop-types';
|
|
4
|
-
import 'classnames';
|
|
5
|
-
import '../global/focus-sensor-hoc.js';
|
|
6
|
-
import '../checkbox/checkbox.js';
|
|
7
|
-
import '../global/get-uid.js';
|
|
8
|
-
export { T as default } from '../_helpers/title.js';
|
|
9
|
-
import '../global/composeRefs.js';
|
|
10
|
-
import '@jetbrains/icons/checkmark';
|
|
11
|
-
import '@jetbrains/icons/remove-10px';
|
|
12
|
-
import '../icon/icon.js';
|
|
13
|
-
import 'util-deprecate';
|
|
14
|
-
import '../icon/icon__constants.js';
|
|
15
|
-
import '../_helpers/icon__svg.js';
|
|
16
|
-
import '../global/memoize.js';
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import PropTypes from 'prop-types';
|
|
2
|
-
import add from 'date-fns/add';
|
|
3
|
-
|
|
4
|
-
const unit = 8; // px;
|
|
5
|
-
|
|
6
|
-
const units = {
|
|
7
|
-
unit,
|
|
8
|
-
|
|
9
|
-
/* eslint-disable no-magic-numbers */
|
|
10
|
-
cellSize: unit * 3,
|
|
11
|
-
calHeight: unit * 36,
|
|
12
|
-
yearHeight: unit * 4
|
|
13
|
-
/* eslint-enable */
|
|
14
|
-
|
|
15
|
-
};
|
|
16
|
-
const YEAR = 12;
|
|
17
|
-
const WEEK = 7;
|
|
18
|
-
const weekdays = {
|
|
19
|
-
MO: 1,
|
|
20
|
-
TU: 2,
|
|
21
|
-
WE: 3,
|
|
22
|
-
TH: 4,
|
|
23
|
-
FR: 5,
|
|
24
|
-
SA: 6,
|
|
25
|
-
SU: 0
|
|
26
|
-
};
|
|
27
|
-
const MIDDLE_DAY = 15;
|
|
28
|
-
|
|
29
|
-
const durationToMillis = duration => +add(0, duration);
|
|
30
|
-
|
|
31
|
-
const yearDuration = durationToMillis({
|
|
32
|
-
years: 1
|
|
33
|
-
});
|
|
34
|
-
const yearScrollSpeed = yearDuration / (YEAR * units.cellSize);
|
|
35
|
-
const DOUBLE = 2;
|
|
36
|
-
const HALF = 0.5;
|
|
37
|
-
function linear(x0, y0, a) {
|
|
38
|
-
return {
|
|
39
|
-
y(x) {
|
|
40
|
-
return +y0 + (x - x0) * a;
|
|
41
|
-
},
|
|
42
|
-
|
|
43
|
-
x(y) {
|
|
44
|
-
return +x0 + (y - y0) / a;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
const deprecatedPropType = replacement => (props, propName) => {
|
|
50
|
-
if (propName in props) {
|
|
51
|
-
return new Error(`"${propName}" prop is deprecated and will be removed in 5.0. ${replacement} instead. See https://github.com/JetBrains/ring-ui/blob/master/CHANGELOG.md#310 for details`);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return undefined;
|
|
55
|
-
};
|
|
56
|
-
const dateType = PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.string, PropTypes.number]);
|
|
57
|
-
function parseTime(time) {
|
|
58
|
-
let result = null;
|
|
59
|
-
|
|
60
|
-
if (/^([01][0-9]|2[0-3]):[0-5][0-9]$/.test(time)) {
|
|
61
|
-
result = time;
|
|
62
|
-
} else if (/^([0-9]|2[0-3]):[0-5][0-9]$/.test(time)) {
|
|
63
|
-
result = `0${time}`;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return result;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export default units;
|
|
70
|
-
export { DOUBLE, HALF, MIDDLE_DAY, WEEK, YEAR, dateType, deprecatedPropType, linear, parseTime, weekdays, yearDuration, yearScrollSpeed };
|
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
import { _ as _defineProperty } from '../_helpers/_rollupPluginBabelHelpers.js';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import classNames from 'classnames';
|
|
4
|
-
import PropTypes from 'prop-types';
|
|
5
|
-
import Input from '../input/input.js';
|
|
6
|
-
import { dateType } from './consts.js';
|
|
7
|
-
import { m as modules_0c7b7d96 } from '../_helpers/date-picker.js';
|
|
8
|
-
import '@jetbrains/icons/close';
|
|
9
|
-
import '../global/theme.js';
|
|
10
|
-
import '../button/button.js';
|
|
11
|
-
import 'focus-visible';
|
|
12
|
-
import '@jetbrains/icons/chevron-10px';
|
|
13
|
-
import '../icon/icon.js';
|
|
14
|
-
import 'util-deprecate';
|
|
15
|
-
import '../icon/icon__constants.js';
|
|
16
|
-
import '../_helpers/icon__svg.js';
|
|
17
|
-
import '../global/memoize.js';
|
|
18
|
-
import '../link/clickableLink.js';
|
|
19
|
-
import '../_helpers/button__classes.js';
|
|
20
|
-
import '../global/get-uid.js';
|
|
21
|
-
import 'date-fns/add';
|
|
22
|
-
|
|
23
|
-
class DateInput extends React.PureComponent {
|
|
24
|
-
constructor() {
|
|
25
|
-
super(...arguments);
|
|
26
|
-
|
|
27
|
-
_defineProperty(this, "inputRef", el => {
|
|
28
|
-
this.input = el;
|
|
29
|
-
this.updateInput(this.props);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
_defineProperty(this, "handleChange", e => this.props.onInput(e.target.value, e.target.dataset.name));
|
|
33
|
-
|
|
34
|
-
_defineProperty(this, "handleKeyDown", e => e.key === 'Enter' && this.props.onConfirm());
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
componentDidUpdate(prevProps) {
|
|
38
|
-
const {
|
|
39
|
-
hidden,
|
|
40
|
-
text,
|
|
41
|
-
active
|
|
42
|
-
} = this.props;
|
|
43
|
-
|
|
44
|
-
if (!hidden && prevProps.hidden || text !== prevProps.text || active !== prevProps.active) {
|
|
45
|
-
this.updateInput({
|
|
46
|
-
text,
|
|
47
|
-
active
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
updateInput(_ref) {
|
|
53
|
-
let {
|
|
54
|
-
text,
|
|
55
|
-
active
|
|
56
|
-
} = _ref;
|
|
57
|
-
const el = this.input;
|
|
58
|
-
|
|
59
|
-
if (!el) {
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
if (active) {
|
|
64
|
-
el.focus();
|
|
65
|
-
|
|
66
|
-
if (!text) {
|
|
67
|
-
el.select();
|
|
68
|
-
}
|
|
69
|
-
} else {
|
|
70
|
-
el.blur();
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
render() {
|
|
75
|
-
const {
|
|
76
|
-
active,
|
|
77
|
-
divider,
|
|
78
|
-
text,
|
|
79
|
-
time,
|
|
80
|
-
name,
|
|
81
|
-
hoverDate,
|
|
82
|
-
date,
|
|
83
|
-
displayFormat,
|
|
84
|
-
translations,
|
|
85
|
-
onActivate,
|
|
86
|
-
onClear,
|
|
87
|
-
fromPlaceholder,
|
|
88
|
-
toPlaceholder,
|
|
89
|
-
timePlaceholder
|
|
90
|
-
} = this.props;
|
|
91
|
-
let displayText = '';
|
|
92
|
-
|
|
93
|
-
if (active && hoverDate) {
|
|
94
|
-
displayText = displayFormat(hoverDate);
|
|
95
|
-
} else if (active && text != null) {
|
|
96
|
-
displayText = text;
|
|
97
|
-
} else if (date) {
|
|
98
|
-
displayText = displayFormat(date);
|
|
99
|
-
} else if (name === 'time') {
|
|
100
|
-
displayText = time || '';
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
const placeholder = (() => {
|
|
104
|
-
switch (name) {
|
|
105
|
-
case 'from':
|
|
106
|
-
return fromPlaceholder || translations.addFirstDate;
|
|
107
|
-
|
|
108
|
-
case 'to':
|
|
109
|
-
return toPlaceholder || translations.addSecondDate;
|
|
110
|
-
|
|
111
|
-
case 'time':
|
|
112
|
-
return timePlaceholder || translations.addTime;
|
|
113
|
-
|
|
114
|
-
default:
|
|
115
|
-
return translations.selectName.replace('%name%', name);
|
|
116
|
-
}
|
|
117
|
-
})();
|
|
118
|
-
|
|
119
|
-
const classes = classNames(modules_0c7b7d96.filter, modules_0c7b7d96[`${name}Input`], divider && modules_0c7b7d96[`${name}InputWithDivider`], 'ring-js-shortcuts');
|
|
120
|
-
return /*#__PURE__*/React.createElement(Input, {
|
|
121
|
-
autoComplete: "off",
|
|
122
|
-
borderless: true,
|
|
123
|
-
"data-name": name,
|
|
124
|
-
inputRef: this.inputRef,
|
|
125
|
-
className: classes,
|
|
126
|
-
value: displayText,
|
|
127
|
-
onChange: this.handleChange,
|
|
128
|
-
onFocus: onActivate,
|
|
129
|
-
onKeyDown: this.handleKeyDown,
|
|
130
|
-
onClear: onClear,
|
|
131
|
-
placeholder: placeholder
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
_defineProperty(DateInput, "propTypes", {
|
|
138
|
-
active: PropTypes.bool,
|
|
139
|
-
divider: PropTypes.bool,
|
|
140
|
-
name: PropTypes.string,
|
|
141
|
-
text: PropTypes.string,
|
|
142
|
-
hoverDate: dateType,
|
|
143
|
-
date: dateType,
|
|
144
|
-
time: PropTypes.string,
|
|
145
|
-
displayFormat: PropTypes.func,
|
|
146
|
-
hidden: PropTypes.bool,
|
|
147
|
-
translations: PropTypes.object,
|
|
148
|
-
fromPlaceholder: PropTypes.string,
|
|
149
|
-
toPlaceholder: PropTypes.string,
|
|
150
|
-
timePlaceholder: PropTypes.string,
|
|
151
|
-
onInput: PropTypes.func,
|
|
152
|
-
onActivate: PropTypes.func,
|
|
153
|
-
onConfirm: PropTypes.func,
|
|
154
|
-
onClear: PropTypes.func
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
_defineProperty(DateInput, "defaultProps", {
|
|
158
|
-
fromPlaceholder: null,
|
|
159
|
-
toPlaceholder: null,
|
|
160
|
-
timePlaceholder: null,
|
|
161
|
-
translations: {
|
|
162
|
-
addFirstDate: 'Add first date',
|
|
163
|
-
addSecondDate: 'Add second date',
|
|
164
|
-
addTime: 'Add time',
|
|
165
|
-
selectName: 'Select %name%'
|
|
166
|
-
}
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
export default DateInput;
|
|
@@ -1,356 +0,0 @@
|
|
|
1
|
-
import { _ as _defineProperty, a as _objectWithoutProperties, b as _extends, c as _objectSpread2 } from '../_helpers/_rollupPluginBabelHelpers.js';
|
|
2
|
-
import React, { PureComponent } from 'react';
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
4
|
-
import classNames from 'classnames';
|
|
5
|
-
import format from 'date-fns/format';
|
|
6
|
-
import isSameDay from 'date-fns/isSameDay';
|
|
7
|
-
import isSameMonth from 'date-fns/isSameMonth';
|
|
8
|
-
import isSameYear from 'date-fns/isSameYear';
|
|
9
|
-
import isValid from 'date-fns/isValid';
|
|
10
|
-
import parse from 'date-fns/parse';
|
|
11
|
-
import set from 'date-fns/set';
|
|
12
|
-
import memoize from '../global/memoize.js';
|
|
13
|
-
import Popup from '../popup/popup.js';
|
|
14
|
-
import Dropdown from '../dropdown/dropdown.js';
|
|
15
|
-
import DatePopup from './date-popup.js';
|
|
16
|
-
import { dateType, deprecatedPropType } from './consts.js';
|
|
17
|
-
import { m as modules_0c7b7d96 } from '../_helpers/date-picker.js';
|
|
18
|
-
import formats from './formats.js';
|
|
19
|
-
import DateInput from './date-input.js';
|
|
20
|
-
import { A as Anchor } from '../_helpers/anchor.js';
|
|
21
|
-
import 'react-dom';
|
|
22
|
-
import '../global/get-uid.js';
|
|
23
|
-
import '../global/schedule-raf.js';
|
|
24
|
-
import '../global/dom.js';
|
|
25
|
-
import '../shortcuts/shortcuts.js';
|
|
26
|
-
import '../shortcuts/core.js';
|
|
27
|
-
import 'combokeys';
|
|
28
|
-
import '../global/sniffer.js';
|
|
29
|
-
import 'sniffr';
|
|
30
|
-
import '../global/data-tests.js';
|
|
31
|
-
import '../tab-trap/tab-trap.js';
|
|
32
|
-
import '../popup/position.js';
|
|
33
|
-
import '../popup/popup.consts.js';
|
|
34
|
-
import '../popup/popup.target.js';
|
|
35
|
-
import 'date-fns/isAfter';
|
|
36
|
-
import 'date-fns/isBefore';
|
|
37
|
-
import 'date-fns/startOfDay';
|
|
38
|
-
import '@jetbrains/icons/calendar';
|
|
39
|
-
import '../icon/icon.js';
|
|
40
|
-
import 'util-deprecate';
|
|
41
|
-
import '../icon/icon__constants.js';
|
|
42
|
-
import '../_helpers/icon__svg.js';
|
|
43
|
-
import './months.js';
|
|
44
|
-
import 'date-fns/addMonths';
|
|
45
|
-
import 'date-fns/getDay';
|
|
46
|
-
import 'date-fns/getDaysInMonth';
|
|
47
|
-
import 'date-fns/startOfHour';
|
|
48
|
-
import 'date-fns/startOfMonth';
|
|
49
|
-
import 'date-fns/subMonths';
|
|
50
|
-
import 'date-fns/endOfMonth';
|
|
51
|
-
import '../global/linear-function.js';
|
|
52
|
-
import './month.js';
|
|
53
|
-
import 'date-fns/addDays';
|
|
54
|
-
import 'date-fns/setDay';
|
|
55
|
-
import './day.js';
|
|
56
|
-
import 'date-fns/getDate';
|
|
57
|
-
import 'date-fns/isToday';
|
|
58
|
-
import './month-names.js';
|
|
59
|
-
import 'date-fns/isThisMonth';
|
|
60
|
-
import 'date-fns/startOfYear';
|
|
61
|
-
import './month-slider.js';
|
|
62
|
-
import 'date-fns/addYears';
|
|
63
|
-
import 'date-fns/subYears';
|
|
64
|
-
import './years.js';
|
|
65
|
-
import 'date-fns/getYear';
|
|
66
|
-
import 'date-fns/isThisYear';
|
|
67
|
-
import 'date-fns/setYear';
|
|
68
|
-
import './weekdays.js';
|
|
69
|
-
import 'date-fns/add';
|
|
70
|
-
import '../input/input.js';
|
|
71
|
-
import '@jetbrains/icons/close';
|
|
72
|
-
import '../global/theme.js';
|
|
73
|
-
import '../button/button.js';
|
|
74
|
-
import 'focus-visible';
|
|
75
|
-
import '@jetbrains/icons/chevron-10px';
|
|
76
|
-
import '../link/clickableLink.js';
|
|
77
|
-
import '../_helpers/button__classes.js';
|
|
78
|
-
|
|
79
|
-
const PopupComponent = _ref => {
|
|
80
|
-
let {
|
|
81
|
-
hidden,
|
|
82
|
-
className,
|
|
83
|
-
popupRef,
|
|
84
|
-
onClear,
|
|
85
|
-
datePopupProps,
|
|
86
|
-
onComplete
|
|
87
|
-
} = _ref,
|
|
88
|
-
restProps = _objectWithoutProperties(_ref, ["hidden", "className", "popupRef", "onClear", "datePopupProps", "onComplete"]);
|
|
89
|
-
|
|
90
|
-
return /*#__PURE__*/React.createElement(Popup, _extends({
|
|
91
|
-
hidden: hidden,
|
|
92
|
-
keepMounted: true,
|
|
93
|
-
className: className,
|
|
94
|
-
ref: popupRef,
|
|
95
|
-
directions: [Popup.PopupProps.Directions.BOTTOM_RIGHT, Popup.PopupProps.Directions.BOTTOM_LEFT, Popup.PopupProps.Directions.TOP_LEFT, Popup.PopupProps.Directions.TOP_RIGHT]
|
|
96
|
-
}, restProps), /*#__PURE__*/React.createElement(DatePopup, _extends({
|
|
97
|
-
onClear: onClear
|
|
98
|
-
}, datePopupProps, {
|
|
99
|
-
onComplete: onComplete,
|
|
100
|
-
hidden: hidden
|
|
101
|
-
})));
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
PopupComponent.propTypes = {
|
|
105
|
-
hidden: PropTypes.bool,
|
|
106
|
-
className: PropTypes.string,
|
|
107
|
-
popupRef: PropTypes.func,
|
|
108
|
-
onClear: PropTypes.func,
|
|
109
|
-
datePopupProps: PropTypes.shape(DatePopup.propTypes),
|
|
110
|
-
onComplete: PropTypes.func
|
|
111
|
-
};
|
|
112
|
-
/**
|
|
113
|
-
* @name Date Picker
|
|
114
|
-
*/
|
|
115
|
-
|
|
116
|
-
class DatePicker extends PureComponent {
|
|
117
|
-
constructor() {
|
|
118
|
-
super(...arguments);
|
|
119
|
-
|
|
120
|
-
_defineProperty(this, "handleChange", change => {
|
|
121
|
-
const {
|
|
122
|
-
onChange,
|
|
123
|
-
onDateChange,
|
|
124
|
-
withTime,
|
|
125
|
-
applyTimeInput
|
|
126
|
-
} = this.props;
|
|
127
|
-
const adjustedChange = withTime && change.date != null ? applyTimeInput(change.date, change.time) : change;
|
|
128
|
-
onChange(adjustedChange);
|
|
129
|
-
|
|
130
|
-
if (onDateChange != null) {
|
|
131
|
-
onDateChange(adjustedChange);
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
_defineProperty(this, "clear", () => {
|
|
136
|
-
let change = null;
|
|
137
|
-
|
|
138
|
-
if (this.props.range) {
|
|
139
|
-
change = {
|
|
140
|
-
from: null,
|
|
141
|
-
to: null
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
this.handleChange(change);
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
_defineProperty(this, "popupRef", el => {
|
|
149
|
-
this.popup = el;
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
_defineProperty(this, "closePopup", () => {
|
|
153
|
-
this.popup._onCloseAttempt();
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
_defineProperty(this, "parse", memoize(date => {
|
|
157
|
-
const {
|
|
158
|
-
parseDateInput
|
|
159
|
-
} = this.props;
|
|
160
|
-
|
|
161
|
-
if (date instanceof Date) {
|
|
162
|
-
return date;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
if (typeof date === 'number') {
|
|
166
|
-
return new Date(date);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
return parseDateInput(date);
|
|
170
|
-
}));
|
|
171
|
-
|
|
172
|
-
_defineProperty(this, "getAnchorText", () => {
|
|
173
|
-
const {
|
|
174
|
-
range,
|
|
175
|
-
datePlaceholder,
|
|
176
|
-
dateTimePlaceholder,
|
|
177
|
-
rangePlaceholder,
|
|
178
|
-
withTime,
|
|
179
|
-
displayFormat,
|
|
180
|
-
displayMonthFormat,
|
|
181
|
-
displayDayFormat,
|
|
182
|
-
translations
|
|
183
|
-
} = this.props;
|
|
184
|
-
const date = this.parse(this.props.date);
|
|
185
|
-
const from = this.parse(this.props.from);
|
|
186
|
-
const to = this.parse(this.props.to);
|
|
187
|
-
const time = this.formatTime();
|
|
188
|
-
let text;
|
|
189
|
-
|
|
190
|
-
if (!range && !withTime) {
|
|
191
|
-
text = date ? displayFormat(date) : datePlaceholder || translations.setDate;
|
|
192
|
-
} else if (!range && withTime) {
|
|
193
|
-
if (!date && !time) {
|
|
194
|
-
text = dateTimePlaceholder || translations.setDateTime;
|
|
195
|
-
} else {
|
|
196
|
-
text = `${date && displayFormat(date) || '—'}, ${time || '—'}`;
|
|
197
|
-
}
|
|
198
|
-
} else if (!from && !to) {
|
|
199
|
-
text = rangePlaceholder || translations.setPeriod;
|
|
200
|
-
} else if (!to) {
|
|
201
|
-
text = `${displayFormat(from)} —`;
|
|
202
|
-
} else if (!from) {
|
|
203
|
-
text = `— ${displayFormat(to)}`;
|
|
204
|
-
} else if (!isSameYear(from, to)) {
|
|
205
|
-
text = `${displayFormat(from)} — ${displayFormat(to)}`;
|
|
206
|
-
} else if (!isSameMonth(from, to)) {
|
|
207
|
-
text = `${displayMonthFormat(from)} — ${displayFormat(to)}`;
|
|
208
|
-
} else if (!isSameDay(from, to)) {
|
|
209
|
-
text = `${displayDayFormat(from)} — ${displayFormat(to)}`;
|
|
210
|
-
} else {
|
|
211
|
-
text = `${displayFormat(to)}`;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
return text;
|
|
215
|
-
});
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
formatTime() {
|
|
219
|
-
const {
|
|
220
|
-
displayTimeFormat
|
|
221
|
-
} = this.props;
|
|
222
|
-
const date = this.parse(this.props.date);
|
|
223
|
-
|
|
224
|
-
if (date != null) {
|
|
225
|
-
return displayTimeFormat(date);
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
return null;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
render() {
|
|
232
|
-
const text = this.getAnchorText();
|
|
233
|
-
|
|
234
|
-
if (this.props.disabled) {
|
|
235
|
-
return /*#__PURE__*/React.createElement(Anchor, {
|
|
236
|
-
disabled: true
|
|
237
|
-
}, text);
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
const _this$props = this.props,
|
|
241
|
-
{
|
|
242
|
-
className,
|
|
243
|
-
popupClassName,
|
|
244
|
-
clear,
|
|
245
|
-
dropdownProps,
|
|
246
|
-
translations
|
|
247
|
-
} = _this$props,
|
|
248
|
-
datePopupProps = _objectWithoutProperties(_this$props, ["className", "popupClassName", "clear", "dropdownProps", "translations"]);
|
|
249
|
-
|
|
250
|
-
const classes = classNames(modules_0c7b7d96.datePicker, className); // We want to provide translations further down to DateInput.
|
|
251
|
-
// Yet we should pass at least DateInput default translations not to have them empty.
|
|
252
|
-
|
|
253
|
-
datePopupProps.translations = Object.assign({}, DateInput.defaultProps.translations, translations);
|
|
254
|
-
return /*#__PURE__*/React.createElement(Dropdown, _extends({
|
|
255
|
-
className: classes,
|
|
256
|
-
anchor: text
|
|
257
|
-
}, dropdownProps), /*#__PURE__*/React.createElement(PopupComponent, {
|
|
258
|
-
className: popupClassName,
|
|
259
|
-
popupRef: this.popupRef,
|
|
260
|
-
onClear: clear ? this.clear : null,
|
|
261
|
-
datePopupProps: _objectSpread2(_objectSpread2({}, datePopupProps), {}, {
|
|
262
|
-
onChange: this.handleChange,
|
|
263
|
-
parseDateInput: this.parse,
|
|
264
|
-
time: this.formatTime()
|
|
265
|
-
}),
|
|
266
|
-
onComplete: this.closePopup
|
|
267
|
-
}));
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
}
|
|
271
|
-
|
|
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
|
-
displayFormat: PropTypes.func,
|
|
282
|
-
displayMonthFormat: PropTypes.func,
|
|
283
|
-
displayDayFormat: PropTypes.func,
|
|
284
|
-
displayTimeFormat: PropTypes.func,
|
|
285
|
-
parseDateInput: PropTypes.func,
|
|
286
|
-
applyTimeInput: PropTypes.func,
|
|
287
|
-
datePlaceholder: PropTypes.string,
|
|
288
|
-
dateTimePlaceholder: PropTypes.string,
|
|
289
|
-
rangePlaceholder: PropTypes.string,
|
|
290
|
-
onChange: PropTypes.func,
|
|
291
|
-
// TODO: Remove in 5.0
|
|
292
|
-
onDateChange: deprecatedPropType('Use "onChange"'),
|
|
293
|
-
dropdownProps: PropTypes.object,
|
|
294
|
-
disabled: PropTypes.bool,
|
|
295
|
-
minDate: dateType,
|
|
296
|
-
maxDate: dateType,
|
|
297
|
-
translations: PropTypes.object
|
|
298
|
-
});
|
|
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
|
-
displayFormat: date => date ? format(date, 'd MMM yyyy') : '',
|
|
309
|
-
displayMonthFormat: date => date ? format(date, 'd MMM') : '',
|
|
310
|
-
displayDayFormat: date => date ? format(date, 'd') : '',
|
|
311
|
-
displayTimeFormat: date => date ? format(date, 'HH:mm') : '',
|
|
312
|
-
datePlaceholder: 'Set a date',
|
|
313
|
-
dateTimePlaceholder: 'Set date and time',
|
|
314
|
-
rangePlaceholder: 'Set a period',
|
|
315
|
-
minDate: null,
|
|
316
|
-
maxDate: null,
|
|
317
|
-
|
|
318
|
-
onChange() {},
|
|
319
|
-
|
|
320
|
-
translations: {
|
|
321
|
-
setDate: 'Set a date',
|
|
322
|
-
setDateTime: 'Set date and time',
|
|
323
|
-
setPeriod: 'Set a period'
|
|
324
|
-
},
|
|
325
|
-
|
|
326
|
-
applyTimeInput(date, timeString) {
|
|
327
|
-
var _timeString$split;
|
|
328
|
-
|
|
329
|
-
const [hours, minutes] = (_timeString$split = timeString === null || timeString === void 0 ? void 0 : timeString.split(':')) !== null && _timeString$split !== void 0 ? _timeString$split : [];
|
|
330
|
-
return minutes != null ? set(date, {
|
|
331
|
-
hours,
|
|
332
|
-
minutes
|
|
333
|
-
}) : date;
|
|
334
|
-
},
|
|
335
|
-
|
|
336
|
-
parseDateInput(string) {
|
|
337
|
-
if (!string) {
|
|
338
|
-
return null;
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
const today = new Date();
|
|
342
|
-
|
|
343
|
-
for (const format of formats) {
|
|
344
|
-
const date = parse(string, format, today);
|
|
345
|
-
|
|
346
|
-
if (isValid(date)) {
|
|
347
|
-
return date;
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
return null;
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
});
|
|
355
|
-
|
|
356
|
-
export default DatePicker;
|