@jetbrains/ring-ui-built 6.0.31 → 6.0.32
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/_rollupPluginBabelHelpers.js +1 -567
- package/components/_helpers/anchor.js +7 -6
- package/components/_helpers/button__classes.js +16 -14
- package/components/_helpers/caption.js +14 -20
- package/components/_helpers/card.js +95 -105
- package/components/_helpers/dialog__body-scroll-preventer.js +11 -19
- package/components/_helpers/icon__svg.js +22 -25
- package/components/_helpers/input.js +146 -177
- package/components/_helpers/query-assist__suggestions.js +74 -90
- package/components/_helpers/select__filter.js +48 -69
- package/components/_helpers/services-link.js +29 -37
- package/components/_helpers/sidebar.js +99 -107
- package/components/_helpers/tab-link.js +7 -7
- package/components/_helpers/theme.js +31 -40
- package/components/_helpers/title.js +57 -72
- package/components/alert/alert.js +150 -202
- package/components/alert/container.js +32 -41
- package/components/alert-service/alert-service.js +105 -170
- package/components/analytics/analytics.js +12 -22
- package/components/analytics/analytics__custom-plugin.js +54 -75
- package/components/auth/auth.js +4 -36
- package/components/auth/auth__core.js +746 -1471
- package/components/auth/background-flow.js +87 -127
- package/components/auth/down-notification.js +30 -73
- package/components/auth/iframe-flow.js +75 -133
- package/components/auth/request-builder.js +46 -82
- package/components/auth/response-parser.js +86 -116
- package/components/auth/storage.js +171 -334
- package/components/auth/token-validator.js +137 -242
- package/components/auth/window-flow.js +92 -134
- package/components/auth-dialog/auth-dialog.js +114 -172
- package/components/auth-dialog-service/auth-dialog-service.js +8 -31
- package/components/avatar/avatar-example-datauri.js +23 -1
- package/components/avatar/avatar.js +119 -152
- package/components/avatar/fallback-avatar.js +22 -38
- package/components/badge/badge.js +35 -45
- package/components/button/button.js +86 -107
- package/components/button-group/button-group.js +19 -33
- package/components/button-set/button-set.js +20 -32
- package/components/button-toolbar/button-toolbar.js +19 -31
- package/components/caret/caret.js +186 -220
- package/components/checkbox/checkbox.js +76 -101
- package/components/clipboard/clipboard-fallback.js +10 -10
- package/components/clipboard/clipboard.js +35 -132
- package/components/code/code.js +92 -166
- package/components/collapse/collapse-content.js +42 -64
- package/components/collapse/collapse-context.js +2 -2
- package/components/collapse/collapse-control.js +12 -14
- package/components/collapse/collapse.js +11 -17
- package/components/collapse/consts.js +4 -4
- package/components/collapse/utils.js +1 -3
- package/components/confirm/confirm.js +66 -104
- package/components/confirm-service/confirm-service.js +37 -59
- package/components/content-layout/content-layout.js +43 -64
- package/components/content-layout/sidebar.js +0 -1
- package/components/contenteditable/contenteditable.js +50 -59
- package/components/control-label/control-label.js +9 -9
- package/components/data-list/data-list.js +129 -182
- package/components/data-list/data-list.mock.js +2 -6
- package/components/data-list/item.js +143 -170
- package/components/data-list/selection.js +76 -136
- package/components/data-list/title.js +1 -12
- package/components/date-picker/consts.js +19 -26
- package/components/date-picker/date-input.js +113 -144
- package/components/date-picker/date-picker.js +227 -282
- package/components/date-picker/date-popup.js +350 -395
- package/components/date-picker/day.js +87 -116
- package/components/date-picker/month-names.js +43 -66
- package/components/date-picker/month-slider.js +51 -76
- package/components/date-picker/month.js +16 -25
- package/components/date-picker/months.js +43 -50
- package/components/date-picker/weekdays.js +12 -22
- package/components/date-picker/years.js +83 -110
- package/components/dialog/dialog.js +142 -190
- package/components/dialog/dialog__body-scroll-preventer.js +0 -4
- package/components/dropdown/anchor.js +0 -9
- package/components/dropdown/dropdown.js +182 -213
- package/components/dropdown-menu/dropdown-menu.js +71 -97
- package/components/editable-heading/editable-heading.js +75 -127
- package/components/error-bubble/error-bubble.js +31 -60
- package/components/error-message/error-message.js +39 -59
- package/components/footer/footer.js +27 -30
- package/components/global/compose.js +1 -10
- package/components/global/composeRefs.js +7 -12
- package/components/global/controls-height.js +2 -2
- package/components/global/create-stateful-context.js +15 -15
- package/components/global/data-tests.js +6 -14
- package/components/global/dom.js +47 -86
- package/components/global/focus-sensor-hoc.js +122 -132
- package/components/global/fuzzy-highlight.js +22 -36
- package/components/global/get-event-key.js +8 -8
- package/components/global/get-uid.js +4 -8
- package/components/global/inject-styles.js +10 -15
- package/components/global/listeners.js +27 -51
- package/components/global/memoize.js +6 -12
- package/components/global/normalize-indent.js +19 -50
- package/components/global/promise-with-timeout.js +6 -8
- package/components/global/prop-types.js +3 -5
- package/components/global/react-dom-renderer.js +28 -44
- package/components/global/react-render-adapter.js +1 -1
- package/components/global/rerender-hoc.js +12 -30
- package/components/global/schedule-raf.js +5 -6
- package/components/global/sniffer.js +1 -1
- package/components/global/theme.js +0 -22
- package/components/global/trivial-template-tag.js +3 -10
- package/components/global/typescript-utils.js +2 -6
- package/components/global/url.js +20 -26
- package/components/global/use-event-callback.js +6 -4
- package/components/grid/col.js +35 -52
- package/components/grid/grid.js +17 -31
- package/components/grid/row.js +35 -47
- package/components/group/group.js +17 -25
- package/components/header/header.js +33 -78
- package/components/header/logo.js +20 -36
- package/components/header/profile.js +166 -199
- package/components/header/services-link.js +0 -4
- package/components/header/services.js +73 -116
- package/components/header/smart-profile.js +111 -203
- package/components/header/smart-services.js +62 -113
- package/components/header/tray-icon.js +21 -37
- package/components/header/tray.js +21 -32
- package/components/heading/heading.js +24 -25
- package/components/http/http.d.ts +1 -3
- package/components/http/http.js +203 -353
- package/components/http/http.mock.js +49 -101
- package/components/hub-source/hub-source.js +83 -190
- package/components/hub-source/hub-source__user.js +11 -44
- package/components/hub-source/hub-source__users-groups.js +37 -65
- package/components/i18n/i18n-context.js +7 -10
- package/components/i18n/i18n.js +7 -10
- package/components/icon/icon.js +76 -93
- package/components/icon/icon__svg.js +0 -8
- package/components/icon/index.js +0 -8
- package/components/input/input.js +0 -13
- package/components/island/adaptive-island-hoc.js +30 -43
- package/components/island/content.js +115 -132
- package/components/island/header.js +57 -70
- package/components/island/island.js +28 -40
- package/components/island-legacy/content-legacy.js +17 -25
- package/components/island-legacy/header-legacy.js +19 -27
- package/components/island-legacy/island-legacy.js +17 -25
- package/components/link/clickableLink.js +44 -59
- package/components/link/link.js +57 -68
- package/components/list/consts.js +2 -2
- package/components/list/list.js +611 -698
- package/components/list/list__custom.js +44 -62
- package/components/list/list__hint.js +10 -19
- package/components/list/list__item.js +133 -174
- package/components/list/list__link.js +37 -50
- package/components/list/list__separator.js +14 -24
- package/components/list/list__title.js +22 -32
- package/components/list/list__users-groups-source.js +54 -126
- package/components/loader/loader.js +43 -74
- package/components/loader/loader__core.js +198 -263
- package/components/loader-inline/loader-inline.js +23 -35
- package/components/loader-screen/loader-screen.js +25 -46
- package/components/login-dialog/login-dialog.js +111 -158
- package/components/login-dialog/service.js +8 -34
- package/components/markdown/markdown.js +15 -23
- package/components/message/message.js +161 -203
- package/components/old-browsers-message/old-browsers-message.js +11 -18
- package/components/old-browsers-message/old-browsers-message__stop.js +0 -7
- package/components/old-browsers-message/white-list.js +8 -16
- package/components/pager/pager.js +212 -271
- package/components/panel/panel.js +17 -25
- package/components/permissions/permissions.js +127 -172
- package/components/permissions/permissions__cache.js +194 -224
- package/components/popup/popup.consts.js +1 -1
- package/components/popup/popup.js +284 -343
- package/components/popup/popup.target.js +9 -8
- package/components/popup/position.js +96 -106
- package/components/popup-menu/popup-menu.js +44 -80
- package/components/progress-bar/progress-bar.js +87 -104
- package/components/query-assist/query-assist.js +838 -916
- package/components/query-assist/query-assist__suggestions.js +1 -30
- package/components/radio/radio.js +19 -34
- package/components/radio/radio__item.js +52 -69
- package/components/select/select.js +852 -957
- package/components/select/select__filter.js +0 -30
- package/components/select/select__popup.js +373 -487
- package/components/shortcuts/core.js +166 -217
- package/components/shortcuts/shortcut-title.js +6 -11
- package/components/shortcuts/shortcuts-hoc.js +19 -45
- package/components/shortcuts/shortcuts.js +50 -75
- package/components/slider/slider.js +99 -122
- package/components/slider/slider.utils.js +14 -24
- package/components/storage/storage.js +4 -33
- package/components/storage/storage__fallback.js +149 -224
- package/components/storage/storage__local.js +90 -153
- package/components/tab-trap/tab-trap.js +122 -153
- package/components/table/cell.js +14 -26
- package/components/table/disable-hover-hoc.js +33 -51
- package/components/table/header-cell.js +64 -89
- package/components/table/header.js +104 -132
- package/components/table/multitable.js +107 -125
- package/components/table/row-with-focus-sensor.js +25 -69
- package/components/table/row.js +175 -216
- package/components/table/selection-adapter.js +1 -3
- package/components/table/selection-shortcuts-hoc.js +180 -181
- package/components/table/selection.js +156 -226
- package/components/table/smart-table.js +50 -88
- package/components/table/table.js +289 -358
- package/components/tabs/collapsible-more.js +46 -79
- package/components/tabs/collapsible-tab.js +31 -38
- package/components/tabs/collapsible-tabs.js +88 -153
- package/components/tabs/custom-item.js +4 -2
- package/components/tabs/dumb-tabs.js +74 -117
- package/components/tabs/smart-tabs.js +29 -69
- package/components/tabs/tab-link.js +1 -5
- package/components/tabs/tab.js +19 -31
- package/components/tabs/tabs.js +0 -31
- package/components/tag/tag.js +133 -173
- package/components/tags-input/tags-input.js +329 -427
- package/components/tags-list/tags-list.js +57 -78
- package/components/text/text.js +28 -39
- package/components/toggle/toggle.js +56 -70
- package/components/tooltip/tooltip.js +146 -190
- package/components/user-agreement/service.js +228 -371
- package/components/user-agreement/toolbox.eula.js +160 -1
- package/components/user-agreement/user-agreement.js +85 -120
- package/components/user-card/card.js +0 -29
- package/components/user-card/smart-user-card-tooltip.js +51 -111
- package/components/user-card/tooltip.js +47 -84
- package/components/user-card/user-card.js +0 -29
- package/package.json +1 -1
@@ -1,10 +1,3 @@
|
|
1
|
-
import { _ as _defineProperty, a as _inherits, b as _createClass, f as _classCallCheck, g as _callSuper } from '../_helpers/_rollupPluginBabelHelpers.js';
|
2
|
-
import 'core-js/modules/es.array.concat.js';
|
3
|
-
import 'core-js/modules/es.array.filter.js';
|
4
|
-
import 'core-js/modules/es.array.index-of.js';
|
5
|
-
import 'core-js/modules/es.array.reduce.js';
|
6
|
-
import 'core-js/modules/es.array.slice.js';
|
7
|
-
import 'core-js/modules/es.object.to-string.js';
|
8
1
|
import React, { PureComponent } from 'react';
|
9
2
|
import classNames from 'classnames';
|
10
3
|
import searchIcon from '@jetbrains/icons/search';
|
@@ -30,34 +23,14 @@ import { refObject } from '../global/prop-types.js';
|
|
30
23
|
import composeRefs from '../global/composeRefs.js';
|
31
24
|
import { DEFAULT_DIRECTIONS } from '../popup/popup.consts.js';
|
32
25
|
import { S as SelectFilter, m as modules_b607bec2 } from '../_helpers/select__filter.js';
|
26
|
+
import '../_helpers/_rollupPluginBabelHelpers.js';
|
33
27
|
import 'util-deprecate';
|
34
28
|
import '../icon/icon__constants.js';
|
35
29
|
import '../_helpers/icon__svg.js';
|
36
|
-
import 'core-js/modules/es.regexp.exec.js';
|
37
|
-
import 'core-js/modules/es.string.replace.js';
|
38
|
-
import 'core-js/modules/es.string.starts-with.js';
|
39
|
-
import 'core-js/modules/es.array.iterator.js';
|
40
|
-
import 'core-js/modules/es.map.js';
|
41
|
-
import 'core-js/modules/es.weak-map.js';
|
42
|
-
import 'core-js/modules/web.dom-collections.iterator.js';
|
43
|
-
import 'core-js/modules/es.object.entries.js';
|
44
|
-
import 'core-js/modules/es.regexp.to-string.js';
|
45
|
-
import 'core-js/modules/web.dom-collections.for-each.js';
|
46
30
|
import 'react-dom';
|
47
31
|
import '../global/schedule-raf.js';
|
48
32
|
import '../global/data-tests.js';
|
49
33
|
import '../tab-trap/tab-trap.js';
|
50
|
-
import 'core-js/modules/es.array.includes.js';
|
51
|
-
import 'core-js/modules/es.array.map.js';
|
52
|
-
import 'core-js/modules/es.array.sort.js';
|
53
|
-
import 'core-js/modules/es.string.includes.js';
|
54
|
-
import 'core-js/modules/es.object.assign.js';
|
55
|
-
import 'core-js/modules/es.set.js';
|
56
|
-
import 'core-js/modules/es.string.split.js';
|
57
|
-
import 'core-js/modules/es.symbol.js';
|
58
|
-
import 'core-js/modules/es.symbol.description.js';
|
59
|
-
import 'core-js/modules/es.array.find.js';
|
60
|
-
import 'core-js/modules/es.array.find-index.js';
|
61
34
|
import 'react-virtualized/dist/es/List';
|
62
35
|
import 'react-virtualized/dist/es/AutoSizer';
|
63
36
|
import 'react-virtualized/dist/es/WindowScroller';
|
@@ -71,9 +44,7 @@ import '../_helpers/list.js';
|
|
71
44
|
import '../list/list__item.js';
|
72
45
|
import '../avatar/avatar.js';
|
73
46
|
import '../global/url.js';
|
74
|
-
import 'core-js/modules/es.string.match.js';
|
75
47
|
import '../avatar/fallback-avatar.js';
|
76
|
-
import 'core-js/modules/es.array.from.js';
|
77
48
|
import '../checkbox/checkbox.js';
|
78
49
|
import '@jetbrains/icons/checkmark-12px';
|
79
50
|
import '@jetbrains/icons/remove-12px';
|
@@ -84,7 +55,6 @@ import '../list/list__separator.js';
|
|
84
55
|
import '../list/list__hint.js';
|
85
56
|
import '../list/consts.js';
|
86
57
|
import '../shortcuts/core.js';
|
87
|
-
import 'core-js/modules/es.array.splice.js';
|
88
58
|
import 'combokeys';
|
89
59
|
import '../global/sniffer.js';
|
90
60
|
import 'sniffr';
|
@@ -93,491 +63,407 @@ import '@jetbrains/icons/close-12px';
|
|
93
63
|
import '@jetbrains/icons/chevron-10px';
|
94
64
|
import '../_helpers/button__classes.js';
|
95
65
|
import '../_helpers/input.js';
|
96
|
-
import 'core-js/modules/es.object.values.js';
|
97
66
|
import '../i18n/i18n-context.js';
|
98
67
|
import '../i18n/i18n.js';
|
99
68
|
import '../control-label/control-label.js';
|
100
69
|
|
101
|
-
|
102
|
-
|
70
|
+
const FILTER_HEIGHT = 35;
|
71
|
+
const TOOLBAR_HEIGHT = 49;
|
103
72
|
function noop() {}
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
_defineProperty(_this, "popup", void 0);
|
142
|
-
_defineProperty(_this, "onListSelect", function (selected, event, opts) {
|
143
|
-
var getSelectItemEvent = function getSelectItemEvent() {
|
144
|
-
var customEvent = document.createEvent('Event');
|
145
|
-
customEvent.initEvent('select', true, false);
|
146
|
-
if (event && 'persist' in event) {
|
147
|
-
event.persist();
|
148
|
-
}
|
149
|
-
customEvent.originalEvent = event;
|
150
|
-
return customEvent;
|
151
|
-
};
|
152
|
-
_this.props.onSelect(selected, getSelectItemEvent(), opts);
|
153
|
-
});
|
154
|
-
_defineProperty(_this, "tabPress", function (event) {
|
155
|
-
_this.props.onCloseAttempt(event, true);
|
156
|
-
});
|
157
|
-
_defineProperty(_this, "onClickHandler", function () {
|
158
|
-
var _this$filter;
|
159
|
-
return (_this$filter = _this.filter) === null || _this$filter === void 0 ? void 0 : _this$filter.focus();
|
160
|
-
});
|
161
|
-
_defineProperty(_this, "handleRemoveTag", memoize(function (tag) {
|
162
|
-
return function (event) {
|
163
|
-
return _this.removeTag(tag, event);
|
164
|
-
};
|
165
|
-
}));
|
166
|
-
_defineProperty(_this, "handleTagClick", memoize(function (tag) {
|
167
|
-
return function () {
|
168
|
-
if (Array.isArray(_this.props.selected)) {
|
169
|
-
_this.setState({
|
170
|
-
tagsActiveIndex: _this.props.selected.indexOf(tag)
|
171
|
-
});
|
172
|
-
}
|
173
|
-
};
|
174
|
-
}));
|
175
|
-
_defineProperty(_this, "handleListResize", function () {
|
176
|
-
_this.forceUpdate();
|
177
|
-
});
|
178
|
-
_defineProperty(_this, "handleSelectAll", function () {
|
179
|
-
if (Array.isArray(_this.props.selected)) {
|
180
|
-
_this.props.onSelectAll(_this.props.data.filter(function (item) {
|
181
|
-
return !item.disabled;
|
182
|
-
}).length !== _this.props.selected.length);
|
183
|
-
}
|
184
|
-
});
|
185
|
-
_defineProperty(_this, "getSelectAll", function () {
|
186
|
-
var _multiple$renderSelec;
|
187
|
-
var multiple = _this.props.multiple;
|
188
|
-
var activeFilters = _this.props.data.filter(function (item) {
|
189
|
-
return !item.disabled;
|
190
|
-
});
|
191
|
-
return Array.isArray(_this.props.selected) && /*#__PURE__*/React.createElement("div", {
|
192
|
-
className: modules_b607bec2.selectAll
|
193
|
-
}, activeFilters.length === 0 ? /*#__PURE__*/React.createElement("span", null) : /*#__PURE__*/React.createElement(Button, {
|
194
|
-
text: true,
|
195
|
-
inline: true,
|
196
|
-
onClick: _this.handleSelectAll
|
197
|
-
}, activeFilters.length !== _this.props.selected.length ? multiple.selectAllLabel || 'Select all' : multiple.deselectAllLabel || 'Deselect all'), ((_multiple$renderSelec = multiple.renderSelectedItemsDescription) === null || _multiple$renderSelec === void 0 ? void 0 : _multiple$renderSelec.call(multiple, _this.props.selected, activeFilters.length)) || /*#__PURE__*/React.createElement(Text, {
|
198
|
-
info: true
|
199
|
-
}, "".concat(_this.props.selected.length, " selected")));
|
200
|
-
});
|
201
|
-
// Cache the value because this method is called
|
202
|
-
// inside `render` function which can be called N times
|
203
|
-
// and should be fast as possible.
|
204
|
-
// Cache invalidates each time hidden or userDefinedMaxHeight changes
|
205
|
-
_defineProperty(_this, "_adjustListMaxHeight", memoizeOne(function (hidden, userDefinedMaxHeight, ringPopupTarget) {
|
206
|
-
if (hidden) {
|
207
|
-
return userDefinedMaxHeight;
|
208
|
-
}
|
209
|
-
// Calculate list's maximum height that can't
|
210
|
-
// get beyond the screen
|
211
|
-
// @see RG-1838, JT-48358
|
212
|
-
var minMaxHeight = 100;
|
213
|
-
var directions = _this.props.directions || DEFAULT_DIRECTIONS;
|
214
|
-
// Note:
|
215
|
-
// Create a method which'll be called only when the popup opens and before
|
216
|
-
// render the list would be a better way
|
217
|
-
var anchorNode = _this.props.anchorElement;
|
218
|
-
var containerNode = getPopupContainer(ringPopupTarget) || document.documentElement;
|
219
|
-
return anchorNode != null ? Math.min(directions.reduce(function (maxHeight, direction) {
|
220
|
-
var _maxHeightForDirectio;
|
221
|
-
return Math.max(maxHeight, (_maxHeightForDirectio = maxHeightForDirection(direction, anchorNode, getStyles(containerNode).position !== 'static' ? containerNode : null)) !== null && _maxHeightForDirectio !== void 0 ? _maxHeightForDirectio : 0);
|
222
|
-
}, minMaxHeight), userDefinedMaxHeight) : userDefinedMaxHeight;
|
223
|
-
}));
|
224
|
-
_defineProperty(_this, "popupRef", function (el) {
|
225
|
-
_this.popup = el;
|
226
|
-
});
|
227
|
-
_defineProperty(_this, "list", void 0);
|
228
|
-
_defineProperty(_this, "listRef", function (el) {
|
229
|
-
_this.list = el;
|
230
|
-
});
|
231
|
-
_defineProperty(_this, "filterRef", function (el) {
|
232
|
-
_this.filter = el;
|
233
|
-
_this.caret = el && new Caret(el);
|
234
|
-
});
|
235
|
-
_defineProperty(_this, "shortcutsScope", getUID('select-popup-'));
|
236
|
-
_defineProperty(_this, "shortcutsMap", {
|
237
|
-
tab: _this.tabPress
|
238
|
-
});
|
239
|
-
_defineProperty(_this, "popupFilterShortcutsMap", {
|
240
|
-
up: function up(event) {
|
241
|
-
return _this.list && _this.list.upHandler(event);
|
242
|
-
},
|
243
|
-
down: function down(event) {
|
244
|
-
return _this.list && _this.list.downHandler(event);
|
245
|
-
},
|
246
|
-
home: function home(event) {
|
247
|
-
return _this.list && _this.list.homeHandler(event);
|
248
|
-
},
|
249
|
-
end: function end(event) {
|
250
|
-
return _this.list && _this.list.endHandler(event);
|
251
|
-
},
|
252
|
-
enter: function enter(event) {
|
253
|
-
return _this.list ? _this.list.enterHandler(event) : _this.props.onEmptyPopupEnter(event);
|
254
|
-
},
|
255
|
-
esc: function esc(event) {
|
256
|
-
return _this.props.onCloseAttempt(event, true);
|
257
|
-
},
|
258
|
-
tab: function tab(event) {
|
259
|
-
return _this.tabPress(event);
|
260
|
-
},
|
261
|
-
backspace: function backspace(event) {
|
262
|
-
return _this.handleBackspace(event);
|
263
|
-
},
|
264
|
-
del: function del() {
|
265
|
-
return _this.removeSelectedTag();
|
266
|
-
},
|
267
|
-
left: function left(event) {
|
268
|
-
return _this.handleNavigation(event, true);
|
269
|
-
},
|
270
|
-
right: function right(event) {
|
271
|
-
return _this.handleNavigation(event);
|
272
|
-
}
|
273
|
-
});
|
274
|
-
return _this;
|
73
|
+
const FilterWithShortcuts = shortcutsHOC(SelectFilter);
|
74
|
+
class SelectPopup extends PureComponent {
|
75
|
+
static defaultProps = {
|
76
|
+
data: [],
|
77
|
+
activeIndex: null,
|
78
|
+
toolbar: null,
|
79
|
+
topbar: null,
|
80
|
+
filter: false,
|
81
|
+
filterIcon: null,
|
82
|
+
filterRef: noop,
|
83
|
+
multiple: false,
|
84
|
+
message: null,
|
85
|
+
anchorElement: null,
|
86
|
+
maxHeight: 600,
|
87
|
+
minWidth: 240,
|
88
|
+
loading: false,
|
89
|
+
onSelect: noop,
|
90
|
+
onCloseAttempt: noop,
|
91
|
+
onOutsideClick: noop,
|
92
|
+
onFilter: noop,
|
93
|
+
onClear: noop,
|
94
|
+
onLoadMore: noop,
|
95
|
+
selected: [],
|
96
|
+
tags: null,
|
97
|
+
ringPopupTarget: null,
|
98
|
+
onSelectAll: noop,
|
99
|
+
onEmptyPopupEnter: noop
|
100
|
+
};
|
101
|
+
state = {
|
102
|
+
popupFilterShortcutsOptions: {
|
103
|
+
modal: true,
|
104
|
+
disabled: true
|
105
|
+
},
|
106
|
+
tagsActiveIndex: null
|
107
|
+
};
|
108
|
+
componentDidMount() {
|
109
|
+
window.document.addEventListener('mouseup', this.mouseUpHandler);
|
275
110
|
}
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
111
|
+
componentWillUnmount() {
|
112
|
+
window.document.removeEventListener('mouseup', this.mouseUpHandler);
|
113
|
+
}
|
114
|
+
isClickingPopup = false; // This flag is set to true while an item in the popup is being clicked
|
115
|
+
filter;
|
116
|
+
focusFilter() {
|
117
|
+
setTimeout(() => this.filter?.focus());
|
118
|
+
}
|
119
|
+
isEventTargetFilter(event) {
|
120
|
+
return event.target instanceof Element && event.target.matches('input,textarea');
|
121
|
+
}
|
122
|
+
caret;
|
123
|
+
handleNavigation(event, navigateLeft) {
|
124
|
+
if (this.isEventTargetFilter(event) && this.caret != null && Number(this.caret.getPosition()) > 0 || !Array.isArray(this.props.selected)) {
|
125
|
+
return;
|
281
126
|
}
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
127
|
+
let newIndex = null;
|
128
|
+
if (navigateLeft) {
|
129
|
+
newIndex = this.state.tagsActiveIndex === null ? this.props.selected.length - 1 : this.state.tagsActiveIndex - 1;
|
130
|
+
} else if (this.state.tagsActiveIndex !== null) {
|
131
|
+
newIndex = this.state.tagsActiveIndex + 1;
|
286
132
|
}
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
var _this2 = this;
|
291
|
-
setTimeout(function () {
|
292
|
-
var _this2$filter;
|
293
|
-
return (_this2$filter = _this2.filter) === null || _this2$filter === void 0 ? void 0 : _this2$filter.focus();
|
294
|
-
});
|
133
|
+
if (newIndex !== null && (newIndex >= this.props.selected.length || newIndex < 0)) {
|
134
|
+
newIndex = null;
|
135
|
+
this.focusFilter();
|
295
136
|
}
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
137
|
+
this.setState({
|
138
|
+
tagsActiveIndex: newIndex
|
139
|
+
});
|
140
|
+
}
|
141
|
+
removeTag(tag, event) {
|
142
|
+
if (!Array.isArray(this.props.selected)) {
|
143
|
+
return;
|
300
144
|
}
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
}
|
307
|
-
var newIndex = null;
|
308
|
-
if (navigateLeft) {
|
309
|
-
newIndex = this.state.tagsActiveIndex === null ? this.props.selected.length - 1 : this.state.tagsActiveIndex - 1;
|
310
|
-
} else if (this.state.tagsActiveIndex !== null) {
|
311
|
-
newIndex = this.state.tagsActiveIndex + 1;
|
312
|
-
}
|
313
|
-
if (newIndex !== null && (newIndex >= this.props.selected.length || newIndex < 0)) {
|
314
|
-
newIndex = null;
|
315
|
-
this.focusFilter();
|
316
|
-
}
|
145
|
+
const _tag = tag || this.props.selected.slice(0)[this.props.selected.length - 1];
|
146
|
+
if (_tag) {
|
147
|
+
this.onListSelect(_tag, event, {
|
148
|
+
tryKeepOpen: true
|
149
|
+
});
|
317
150
|
this.setState({
|
318
|
-
tagsActiveIndex:
|
151
|
+
tagsActiveIndex: null
|
319
152
|
});
|
153
|
+
this.focusFilter();
|
320
154
|
}
|
321
|
-
}
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
}
|
327
|
-
var _tag = tag || this.props.selected.slice(0)[this.props.selected.length - 1];
|
328
|
-
if (_tag) {
|
329
|
-
this.onListSelect(_tag, event, {
|
330
|
-
tryKeepOpen: true
|
331
|
-
});
|
332
|
-
this.setState({
|
333
|
-
tagsActiveIndex: null
|
334
|
-
});
|
335
|
-
this.focusFilter();
|
336
|
-
}
|
155
|
+
}
|
156
|
+
removeSelectedTag() {
|
157
|
+
if (Array.isArray(this.props.selected) && this.state.tagsActiveIndex != null) {
|
158
|
+
this.removeTag(this.props.selected[this.state.tagsActiveIndex]);
|
159
|
+
return false;
|
337
160
|
}
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
this.removeTag(this.props.selected[this.state.tagsActiveIndex]);
|
343
|
-
return false;
|
344
|
-
}
|
161
|
+
return true;
|
162
|
+
}
|
163
|
+
handleBackspace(event) {
|
164
|
+
if (!this.props.tags) {
|
345
165
|
return true;
|
346
166
|
}
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
167
|
+
if (!this.isEventTargetFilter(event)) {
|
168
|
+
this.removeSelectedTag();
|
169
|
+
return false;
|
170
|
+
}
|
171
|
+
if ((event.target instanceof HTMLInputElement || event.target instanceof HTMLTextAreaElement) && !event.target.value) {
|
172
|
+
this.removeTag();
|
173
|
+
return false;
|
174
|
+
}
|
175
|
+
return true;
|
176
|
+
}
|
177
|
+
onFilterFocus = () => {
|
178
|
+
this._togglePopupFilterShortcuts(false);
|
179
|
+
this.setState({
|
180
|
+
tagsActiveIndex: null
|
181
|
+
});
|
182
|
+
};
|
183
|
+
popupFilterOnBlur = () => {
|
184
|
+
if (this.state.tagsActiveIndex === null) {
|
185
|
+
this._togglePopupFilterShortcuts(true);
|
186
|
+
}
|
187
|
+
};
|
188
|
+
_togglePopupFilterShortcuts(shortcutsDisabled) {
|
189
|
+
this.setState({
|
190
|
+
popupFilterShortcutsOptions: {
|
191
|
+
modal: true,
|
192
|
+
disabled: shortcutsDisabled
|
356
193
|
}
|
357
|
-
|
358
|
-
|
359
|
-
|
194
|
+
});
|
195
|
+
}
|
196
|
+
mouseDownHandler = () => {
|
197
|
+
this.isClickingPopup = true;
|
198
|
+
};
|
199
|
+
mouseUpHandler = () => {
|
200
|
+
this.isClickingPopup = false;
|
201
|
+
};
|
202
|
+
popup;
|
203
|
+
isVisible() {
|
204
|
+
return this.popup && this.popup.isVisible();
|
205
|
+
}
|
206
|
+
onListSelect = (selected, event, opts) => {
|
207
|
+
const getSelectItemEvent = () => {
|
208
|
+
const customEvent = document.createEvent('Event');
|
209
|
+
customEvent.initEvent('select', true, false);
|
210
|
+
if (event && 'persist' in event) {
|
211
|
+
event.persist();
|
360
212
|
}
|
361
|
-
|
213
|
+
customEvent.originalEvent = event;
|
214
|
+
return customEvent;
|
215
|
+
};
|
216
|
+
this.props.onSelect(selected, getSelectItemEvent(), opts);
|
217
|
+
};
|
218
|
+
tabPress = event => {
|
219
|
+
this.props.onCloseAttempt(event, true);
|
220
|
+
};
|
221
|
+
onClickHandler = () => this.filter?.focus();
|
222
|
+
getFilter() {
|
223
|
+
if (this.props.filter || this.props.tags) {
|
224
|
+
var _this$props$filterIco;
|
225
|
+
return /*#__PURE__*/React.createElement("div", {
|
226
|
+
className: modules_b607bec2.filterWrapper,
|
227
|
+
"data-test": "ring-select-popup-filter"
|
228
|
+
}, !this.props.tags && /*#__PURE__*/React.createElement(Icon, {
|
229
|
+
glyph: (_this$props$filterIco = this.props.filterIcon) !== null && _this$props$filterIco !== void 0 ? _this$props$filterIco : searchIcon,
|
230
|
+
className: modules_b607bec2.filterIcon,
|
231
|
+
"data-test-custom": "ring-select-popup-filter-icon"
|
232
|
+
}), /*#__PURE__*/React.createElement(FilterWithShortcuts, {
|
233
|
+
rgShortcutsOptions: this.state.popupFilterShortcutsOptions,
|
234
|
+
rgShortcutsMap: this.popupFilterShortcutsMap,
|
235
|
+
value: this.props.filterValue,
|
236
|
+
inputRef: composeRefs(this.filterRef, this.props.filterRef),
|
237
|
+
onBlur: this.popupFilterOnBlur,
|
238
|
+
onFocus: this.onFilterFocus,
|
239
|
+
className: "ring-js-shortcuts",
|
240
|
+
inputClassName: classNames({
|
241
|
+
[modules_b607bec2.filterWithTagsInput]: this.props.tags
|
242
|
+
}),
|
243
|
+
placeholder: typeof this.props.filter === 'object' ? this.props.filter.placeholder : undefined,
|
244
|
+
height: this.props.tags ? ControlsHeight.S : ControlsHeight.L,
|
245
|
+
onChange: this.props.onFilter,
|
246
|
+
onClick: this.onClickHandler,
|
247
|
+
onClear: this.props.tags ? undefined : this.props.onClear,
|
248
|
+
"data-test-custom": "ring-select-popup-filter-input",
|
249
|
+
listId: this.props.listId,
|
250
|
+
enableShortcuts: Object.keys(this.popupFilterShortcutsMap)
|
251
|
+
}));
|
362
252
|
}
|
363
|
-
|
364
|
-
|
365
|
-
|
253
|
+
return null;
|
254
|
+
}
|
255
|
+
handleRemoveTag = memoize(tag => event => this.removeTag(tag, event));
|
256
|
+
handleTagClick = memoize(tag => () => {
|
257
|
+
if (Array.isArray(this.props.selected)) {
|
366
258
|
this.setState({
|
367
|
-
|
368
|
-
modal: true,
|
369
|
-
disabled: shortcutsDisabled
|
370
|
-
}
|
259
|
+
tagsActiveIndex: this.props.selected.indexOf(tag)
|
371
260
|
});
|
372
261
|
}
|
373
|
-
}
|
374
|
-
|
375
|
-
|
376
|
-
return
|
262
|
+
});
|
263
|
+
getCustomTag(tags) {
|
264
|
+
if (tags !== null && typeof tags !== 'boolean') {
|
265
|
+
return tags.customTagComponent;
|
377
266
|
}
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
inputClassName: classNames({
|
399
|
-
[modules_b607bec2.filterWithTagsInput]: this.props.tags
|
400
|
-
}),
|
401
|
-
placeholder: typeof this.props.filter === 'object' ? this.props.filter.placeholder : undefined,
|
402
|
-
height: this.props.tags ? ControlsHeight.S : ControlsHeight.L,
|
403
|
-
onChange: this.props.onFilter,
|
404
|
-
onClick: this.onClickHandler,
|
405
|
-
onClear: this.props.tags ? undefined : this.props.onClear,
|
406
|
-
"data-test-custom": "ring-select-popup-filter-input",
|
407
|
-
listId: this.props.listId,
|
408
|
-
enableShortcuts: Object.keys(this.popupFilterShortcutsMap)
|
409
|
-
}));
|
410
|
-
}
|
411
|
-
return null;
|
267
|
+
return undefined;
|
268
|
+
}
|
269
|
+
getTags() {
|
270
|
+
return Array.isArray(this.props.selected) && /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(TagsList, {
|
271
|
+
tags: this.props.selected,
|
272
|
+
activeIndex: this.state.tagsActiveIndex,
|
273
|
+
handleRemove: this.handleRemoveTag,
|
274
|
+
handleClick: this.handleTagClick,
|
275
|
+
disabled: this.props.disabled,
|
276
|
+
customTagComponent: this.getCustomTag(this.props.tags)
|
277
|
+
}));
|
278
|
+
}
|
279
|
+
getFilterWithTags() {
|
280
|
+
if (this.props.tags) {
|
281
|
+
const classes = classNames([modules_b607bec2.filterWithTags, {
|
282
|
+
[modules_b607bec2.filterWithTagsFocused]: !this.state.popupFilterShortcutsOptions.disabled
|
283
|
+
}]);
|
284
|
+
return /*#__PURE__*/React.createElement("div", {
|
285
|
+
className: classes
|
286
|
+
}, this.getTags(), this.getFilter());
|
412
287
|
}
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
288
|
+
return this.getFilter();
|
289
|
+
}
|
290
|
+
getBottomLine() {
|
291
|
+
const {
|
292
|
+
loading,
|
293
|
+
message,
|
294
|
+
data
|
295
|
+
} = this.props;
|
296
|
+
const hasMoreThanOneItem = data.length > 1;
|
297
|
+
return (loading || message) && /*#__PURE__*/React.createElement("div", {
|
298
|
+
className: classNames(modules_b607bec2.bottomLine, {
|
299
|
+
[modules_b607bec2.bottomLineOverItem]: hasMoreThanOneItem
|
300
|
+
})
|
301
|
+
}, loading && /*#__PURE__*/React.createElement(LoaderInline, null), message && /*#__PURE__*/React.createElement("div", {
|
302
|
+
className: modules_b607bec2.message
|
303
|
+
}, message));
|
304
|
+
}
|
305
|
+
handleListResize = () => {
|
306
|
+
this.forceUpdate();
|
307
|
+
};
|
308
|
+
getList(ringPopupTarget) {
|
309
|
+
if (this.props.data.length) {
|
310
|
+
let {
|
311
|
+
maxHeight
|
312
|
+
} = this.props;
|
313
|
+
if (this.props.anchorElement) {
|
314
|
+
maxHeight = this._adjustListMaxHeight(this.props.hidden, maxHeight, ringPopupTarget);
|
418
315
|
}
|
419
|
-
|
420
|
-
|
421
|
-
}, {
|
422
|
-
key: "getTags",
|
423
|
-
value: function getTags() {
|
424
|
-
return Array.isArray(this.props.selected) && /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(TagsList, {
|
425
|
-
tags: this.props.selected,
|
426
|
-
activeIndex: this.state.tagsActiveIndex,
|
427
|
-
handleRemove: this.handleRemoveTag,
|
428
|
-
handleClick: this.handleTagClick,
|
429
|
-
disabled: this.props.disabled,
|
430
|
-
customTagComponent: this.getCustomTag(this.props.tags)
|
431
|
-
}));
|
432
|
-
}
|
433
|
-
}, {
|
434
|
-
key: "getFilterWithTags",
|
435
|
-
value: function getFilterWithTags() {
|
436
|
-
if (this.props.tags) {
|
437
|
-
var classes = classNames([modules_b607bec2.filterWithTags, {
|
438
|
-
[modules_b607bec2.filterWithTagsFocused]: !this.state.popupFilterShortcutsOptions.disabled
|
439
|
-
}]);
|
440
|
-
return /*#__PURE__*/React.createElement("div", {
|
441
|
-
className: classes
|
442
|
-
}, this.getTags(), this.getFilter());
|
316
|
+
if (this.props.filter) {
|
317
|
+
maxHeight -= FILTER_HEIGHT;
|
443
318
|
}
|
444
|
-
|
445
|
-
|
446
|
-
}, {
|
447
|
-
key: "getBottomLine",
|
448
|
-
value: function getBottomLine() {
|
449
|
-
var _this$props = this.props,
|
450
|
-
loading = _this$props.loading,
|
451
|
-
message = _this$props.message,
|
452
|
-
data = _this$props.data;
|
453
|
-
var hasMoreThanOneItem = data.length > 1;
|
454
|
-
return (loading || message) && /*#__PURE__*/React.createElement("div", {
|
455
|
-
className: classNames(modules_b607bec2.bottomLine, {
|
456
|
-
[modules_b607bec2.bottomLineOverItem]: hasMoreThanOneItem
|
457
|
-
})
|
458
|
-
}, loading && /*#__PURE__*/React.createElement(LoaderInline, null), message && /*#__PURE__*/React.createElement("div", {
|
459
|
-
className: modules_b607bec2.message
|
460
|
-
}, message));
|
461
|
-
}
|
462
|
-
}, {
|
463
|
-
key: "getList",
|
464
|
-
value: function getList(ringPopupTarget) {
|
465
|
-
if (this.props.data.length) {
|
466
|
-
var maxHeight = this.props.maxHeight;
|
467
|
-
if (this.props.anchorElement) {
|
468
|
-
maxHeight = this._adjustListMaxHeight(this.props.hidden, maxHeight, ringPopupTarget);
|
469
|
-
}
|
470
|
-
if (this.props.filter) {
|
471
|
-
maxHeight -= FILTER_HEIGHT;
|
472
|
-
}
|
473
|
-
if (this.props.toolbar) {
|
474
|
-
maxHeight -= TOOLBAR_HEIGHT;
|
475
|
-
}
|
476
|
-
return /*#__PURE__*/React.createElement(List, {
|
477
|
-
id: this.props.listId,
|
478
|
-
maxHeight: maxHeight,
|
479
|
-
data: this.props.data,
|
480
|
-
activeIndex: this.props.activeIndex,
|
481
|
-
ref: this.listRef,
|
482
|
-
restoreActiveIndex: true,
|
483
|
-
activateFirstItem: true,
|
484
|
-
onSelect: this.onListSelect,
|
485
|
-
onResize: this.handleListResize,
|
486
|
-
onScrollToBottom: this.props.onLoadMore,
|
487
|
-
hidden: this.props.hidden,
|
488
|
-
shortcuts: !this.props.hidden,
|
489
|
-
disableMoveOverflow: this.props.disableMoveOverflow,
|
490
|
-
disableMoveDownOverflow: this.props.loading,
|
491
|
-
disableScrollToActive: this.props.disableScrollToActive,
|
492
|
-
compact: this.props.compact,
|
493
|
-
preventListOverscroll: this.props.preventListOverscroll,
|
494
|
-
renderOptimization: this.props.renderOptimization
|
495
|
-
});
|
319
|
+
if (this.props.toolbar) {
|
320
|
+
maxHeight -= TOOLBAR_HEIGHT;
|
496
321
|
}
|
497
|
-
return
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
hidden
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
left = _this$props2.left,
|
517
|
-
style = _this$props2.style,
|
518
|
-
dir = _this$props2.dir,
|
519
|
-
filter = _this$props2.filter;
|
520
|
-
var classes = classNames(modules_b607bec2.popup, className);
|
521
|
-
return /*#__PURE__*/React.createElement(PopupTargetContext.Consumer, null, function (ringPopupTarget) {
|
522
|
-
var filterWithTags = _this3.getFilterWithTags();
|
523
|
-
var selectAll = multiple && typeof multiple === 'object' && !multiple.limit && multiple.selectAll && _this3.getSelectAll();
|
524
|
-
var list = _this3.getList(_this3.props.ringPopupTarget || ringPopupTarget);
|
525
|
-
var bottomLine = _this3.getBottomLine();
|
526
|
-
var hasContent = filterWithTags || selectAll || list || bottomLine || toolbar || topbar;
|
527
|
-
return /*#__PURE__*/React.createElement(Popup, {
|
528
|
-
trapFocus: false,
|
529
|
-
ref: _this3.popupRef,
|
530
|
-
hidden: hidden || !hasContent,
|
531
|
-
attached: isInputMode,
|
532
|
-
className: classes,
|
533
|
-
dontCloseOnAnchorClick: true,
|
534
|
-
anchorElement: anchorElement,
|
535
|
-
minWidth: minWidth,
|
536
|
-
onCloseAttempt: onCloseAttempt,
|
537
|
-
onOutsideClick: onOutsideClick,
|
538
|
-
directions: directions,
|
539
|
-
top: top,
|
540
|
-
left: left,
|
541
|
-
onMouseDown: _this3.mouseDownHandler,
|
542
|
-
target: _this3.props.ringPopupTarget,
|
543
|
-
autoCorrectTopOverflow: false,
|
544
|
-
style: style
|
545
|
-
}, /*#__PURE__*/React.createElement("div", {
|
546
|
-
dir: dir
|
547
|
-
}, !hidden && filter && /*#__PURE__*/React.createElement(Shortcuts, {
|
548
|
-
map: _this3.shortcutsMap,
|
549
|
-
scope: _this3.shortcutsScope
|
550
|
-
}), topbar, hidden ? /*#__PURE__*/React.createElement("div", null) : filterWithTags, selectAll, list, bottomLine, toolbar));
|
322
|
+
return /*#__PURE__*/React.createElement(List, {
|
323
|
+
id: this.props.listId,
|
324
|
+
maxHeight: maxHeight,
|
325
|
+
data: this.props.data,
|
326
|
+
activeIndex: this.props.activeIndex,
|
327
|
+
ref: this.listRef,
|
328
|
+
restoreActiveIndex: true,
|
329
|
+
activateFirstItem: true,
|
330
|
+
onSelect: this.onListSelect,
|
331
|
+
onResize: this.handleListResize,
|
332
|
+
onScrollToBottom: this.props.onLoadMore,
|
333
|
+
hidden: this.props.hidden,
|
334
|
+
shortcuts: !this.props.hidden,
|
335
|
+
disableMoveOverflow: this.props.disableMoveOverflow,
|
336
|
+
disableMoveDownOverflow: this.props.loading,
|
337
|
+
disableScrollToActive: this.props.disableScrollToActive,
|
338
|
+
compact: this.props.compact,
|
339
|
+
preventListOverscroll: this.props.preventListOverscroll,
|
340
|
+
renderOptimization: this.props.renderOptimization
|
551
341
|
});
|
552
342
|
}
|
553
|
-
|
554
|
-
}
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
ringPopupTarget
|
578
|
-
|
579
|
-
|
580
|
-
}
|
343
|
+
return null;
|
344
|
+
}
|
345
|
+
handleSelectAll = () => {
|
346
|
+
if (Array.isArray(this.props.selected)) {
|
347
|
+
this.props.onSelectAll(this.props.data.filter(item => !item.disabled).length !== this.props.selected.length);
|
348
|
+
}
|
349
|
+
};
|
350
|
+
getSelectAll = () => {
|
351
|
+
const multiple = this.props.multiple;
|
352
|
+
const activeFilters = this.props.data.filter(item => !item.disabled);
|
353
|
+
return Array.isArray(this.props.selected) && /*#__PURE__*/React.createElement("div", {
|
354
|
+
className: modules_b607bec2.selectAll
|
355
|
+
}, activeFilters.length === 0 ? /*#__PURE__*/React.createElement("span", null) : /*#__PURE__*/React.createElement(Button, {
|
356
|
+
text: true,
|
357
|
+
inline: true,
|
358
|
+
onClick: this.handleSelectAll
|
359
|
+
}, activeFilters.length !== this.props.selected.length ? multiple.selectAllLabel || 'Select all' : multiple.deselectAllLabel || 'Deselect all'), multiple.renderSelectedItemsDescription?.(this.props.selected, activeFilters.length) || /*#__PURE__*/React.createElement(Text, {
|
360
|
+
info: true
|
361
|
+
}, `${this.props.selected.length} selected`));
|
362
|
+
};
|
363
|
+
// Cache the value because this method is called
|
364
|
+
// inside `render` function which can be called N times
|
365
|
+
// and should be fast as possible.
|
366
|
+
// Cache invalidates each time hidden or userDefinedMaxHeight changes
|
367
|
+
_adjustListMaxHeight = memoizeOne((hidden, userDefinedMaxHeight, ringPopupTarget) => {
|
368
|
+
if (hidden) {
|
369
|
+
return userDefinedMaxHeight;
|
370
|
+
}
|
371
|
+
// Calculate list's maximum height that can't
|
372
|
+
// get beyond the screen
|
373
|
+
// @see RG-1838, JT-48358
|
374
|
+
const minMaxHeight = 100;
|
375
|
+
const directions = this.props.directions || DEFAULT_DIRECTIONS;
|
376
|
+
// Note:
|
377
|
+
// Create a method which'll be called only when the popup opens and before
|
378
|
+
// render the list would be a better way
|
379
|
+
const anchorNode = this.props.anchorElement;
|
380
|
+
const containerNode = getPopupContainer(ringPopupTarget) || document.documentElement;
|
381
|
+
return anchorNode != null ? Math.min(directions.reduce((maxHeight, direction) => {
|
382
|
+
var _maxHeightForDirectio;
|
383
|
+
return Math.max(maxHeight, (_maxHeightForDirectio = maxHeightForDirection(direction, anchorNode, getStyles(containerNode).position !== 'static' ? containerNode : null)) !== null && _maxHeightForDirectio !== void 0 ? _maxHeightForDirectio : 0);
|
384
|
+
}, minMaxHeight), userDefinedMaxHeight) : userDefinedMaxHeight;
|
385
|
+
});
|
386
|
+
popupRef = el => {
|
387
|
+
this.popup = el;
|
388
|
+
};
|
389
|
+
list;
|
390
|
+
listRef = el => {
|
391
|
+
this.list = el;
|
392
|
+
};
|
393
|
+
filterRef = el => {
|
394
|
+
this.filter = el;
|
395
|
+
this.caret = el && new Caret(el);
|
396
|
+
};
|
397
|
+
shortcutsScope = getUID('select-popup-');
|
398
|
+
shortcutsMap = {
|
399
|
+
tab: this.tabPress
|
400
|
+
};
|
401
|
+
popupFilterShortcutsMap = {
|
402
|
+
up: event => this.list && this.list.upHandler(event),
|
403
|
+
down: event => this.list && this.list.downHandler(event),
|
404
|
+
home: event => this.list && this.list.homeHandler(event),
|
405
|
+
end: event => this.list && this.list.endHandler(event),
|
406
|
+
enter: event => this.list ? this.list.enterHandler(event) : this.props.onEmptyPopupEnter(event),
|
407
|
+
esc: event => this.props.onCloseAttempt(event, true),
|
408
|
+
tab: event => this.tabPress(event),
|
409
|
+
backspace: event => this.handleBackspace(event),
|
410
|
+
del: () => this.removeSelectedTag(),
|
411
|
+
left: event => this.handleNavigation(event, true),
|
412
|
+
right: event => this.handleNavigation(event)
|
413
|
+
};
|
414
|
+
render() {
|
415
|
+
const {
|
416
|
+
toolbar,
|
417
|
+
topbar,
|
418
|
+
className,
|
419
|
+
multiple,
|
420
|
+
hidden,
|
421
|
+
isInputMode,
|
422
|
+
anchorElement,
|
423
|
+
minWidth,
|
424
|
+
onCloseAttempt,
|
425
|
+
onOutsideClick,
|
426
|
+
directions,
|
427
|
+
top,
|
428
|
+
left,
|
429
|
+
style,
|
430
|
+
dir,
|
431
|
+
filter
|
432
|
+
} = this.props;
|
433
|
+
const classes = classNames(modules_b607bec2.popup, className);
|
434
|
+
return /*#__PURE__*/React.createElement(PopupTargetContext.Consumer, null, ringPopupTarget => {
|
435
|
+
const filterWithTags = this.getFilterWithTags();
|
436
|
+
const selectAll = multiple && typeof multiple === 'object' && !multiple.limit && multiple.selectAll && this.getSelectAll();
|
437
|
+
const list = this.getList(this.props.ringPopupTarget || ringPopupTarget);
|
438
|
+
const bottomLine = this.getBottomLine();
|
439
|
+
const hasContent = filterWithTags || selectAll || list || bottomLine || toolbar || topbar;
|
440
|
+
return /*#__PURE__*/React.createElement(Popup, {
|
441
|
+
trapFocus: false,
|
442
|
+
ref: this.popupRef,
|
443
|
+
hidden: hidden || !hasContent,
|
444
|
+
attached: isInputMode,
|
445
|
+
className: classes,
|
446
|
+
dontCloseOnAnchorClick: true,
|
447
|
+
anchorElement: anchorElement,
|
448
|
+
minWidth: minWidth,
|
449
|
+
onCloseAttempt: onCloseAttempt,
|
450
|
+
onOutsideClick: onOutsideClick,
|
451
|
+
directions: directions,
|
452
|
+
top: top,
|
453
|
+
left: left,
|
454
|
+
onMouseDown: this.mouseDownHandler,
|
455
|
+
target: this.props.ringPopupTarget,
|
456
|
+
autoCorrectTopOverflow: false,
|
457
|
+
style: style
|
458
|
+
}, /*#__PURE__*/React.createElement("div", {
|
459
|
+
dir: dir
|
460
|
+
}, !hidden && filter && /*#__PURE__*/React.createElement(Shortcuts, {
|
461
|
+
map: this.shortcutsMap,
|
462
|
+
scope: this.shortcutsScope
|
463
|
+
}), topbar, hidden ? /*#__PURE__*/React.createElement("div", null) : filterWithTags, selectAll, list, bottomLine, toolbar));
|
464
|
+
});
|
465
|
+
}
|
466
|
+
}
|
581
467
|
SelectPopup.propTypes = {
|
582
468
|
activeIndex: PropTypes.number,
|
583
469
|
anchorElement: PropTypes.instanceOf(HTMLElement),
|