@jetbrains/ring-ui 4.1.0-beta.3 → 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/alert.test.js +21 -48
- package/components/alert/container.css +1 -1
- package/components/alert/container.test.js +3 -13
- 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 +3 -3
- package/components/analytics/analytics__ga-plugin.js +2 -2
- package/components/auth/auth.test.js +14 -7
- package/components/auth/auth__core.js +64 -33
- package/components/auth-dialog/auth-dialog.css +2 -3
- package/components/auth-dialog/auth-dialog.js +4 -1
- package/components/auth-dialog/auth-dialog.test.js +3 -19
- package/components/avatar/avatar.css +4 -1
- package/components/avatar/avatar.examples.js +3 -2
- package/components/avatar/avatar.js +34 -6
- package/components/avatar/avatar.test.js +20 -17
- 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/badge/badge.test.js +13 -20
- package/components/button/button.css +2 -2
- package/components/button/button.js +4 -1
- package/components/button/button.test.js +32 -33
- 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 +2 -5
- 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 +10 -5
- package/components/dialog/dialog.test.js +1 -1
- package/components/dialog/dialog__body-scroll-preventer.js +51 -31
- package/components/dialog-ng/dialog-ng.js +10 -10
- package/components/dialog-ng/{dialog-ng.html → dialog-ng__template.js} +2 -2
- package/components/dropdown/dropdown.examples.js +36 -1
- package/components/dropdown/dropdown.test.js +2 -2
- 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/input/input-legacy.css +7 -7
- package/components/island/header.js +2 -2
- package/components/island/island.css +8 -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 -7
- package/components/pager/pager.js +5 -3
- package/components/permissions/permissions.js +1 -1
- package/components/popup/popup.js +1 -1
- package/components/popup/popup.test.js +15 -13
- 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 -4
- 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/select/select__popup.js +1 -0
- 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/header.js +9 -1
- 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 +5 -9
- package/components/tabs/tab-link.js +4 -2
- package/components/tabs/tabs.css +32 -5
- 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 -5
- package/components/user-agreement/user-agreement.examples.js +7 -6
- package/components/user-agreement/user-agreement.js +11 -3
- package/package.json +85 -83
- 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 -123
- package/dist/_helpers/background-flow.js +0 -232
- package/dist/_helpers/badge.js +0 -3
- package/dist/_helpers/button.js +0 -145
- package/dist/_helpers/clickableLink.js +0 -65
- package/dist/_helpers/data-tests.js +0 -15
- package/dist/_helpers/disable-hover-hoc.js +0 -407
- package/dist/_helpers/dom.js +0 -101
- package/dist/_helpers/get-uid.js +0 -15
- package/dist/_helpers/linear-function.js +0 -17
- package/dist/_helpers/list.js +0 -1327
- package/dist/_helpers/logo.js +0 -36
- package/dist/_helpers/memoize.js +0 -17
- package/dist/_helpers/popup.js +0 -691
- package/dist/_helpers/popup.target.js +0 -27
- package/dist/_helpers/rerender-hoc.js +0 -49
- package/dist/_helpers/schedule-raf.js +0 -31
- package/dist/_helpers/sniffer.js +0 -6
- package/dist/_helpers/theme.js +0 -40
- package/dist/_helpers/url.js +0 -125
- package/dist/alert-service.js +0 -149
- package/dist/alert.js +0 -284
- package/dist/analytics.js +0 -116
- package/dist/auth-dialog-service.js +0 -56
- package/dist/auth-dialog.js +0 -122
- package/dist/auth.js +0 -1744
- package/dist/avatar.js +0 -152
- package/dist/badge.js +0 -52
- package/dist/button-group.js +0 -48
- package/dist/button-set.js +0 -27
- package/dist/button-toolbar.js +0 -30
- package/dist/button.js +0 -12
- package/dist/caret.js +0 -262
- package/dist/checkbox.js +0 -108
- package/dist/confirm-service.js +0 -102
- package/dist/confirm.js +0 -113
- package/dist/content-layout.js +0 -184
- package/dist/contenteditable.js +0 -81
- package/dist/data-list.js +0 -466
- package/dist/date-picker.js +0 -1398
- package/dist/dialog.js +0 -223
- package/dist/dropdown.js +0 -250
- package/dist/error-bubble.js +0 -56
- package/dist/error-message.js +0 -53
- package/dist/footer.js +0 -124
- package/dist/grid.js +0 -148
- package/dist/group.js +0 -34
- package/dist/header.js +0 -658
- package/dist/heading.js +0 -76
- package/dist/http.js +0 -207
- package/dist/hub-source.js +0 -130
- package/dist/icon.js +0 -211
- package/dist/input.js +0 -228
- package/dist/island.js +0 -314
- package/dist/link.js +0 -117
- package/dist/list.js +0 -29
- package/dist/loader-inline.js +0 -165
- package/dist/loader-screen.js +0 -45
- package/dist/loader.js +0 -338
- package/dist/login-dialog.js +0 -173
- package/dist/logo.js +0 -8
- package/dist/message.js +0 -226
- package/dist/old-browsers-message.js +0 -129
- package/dist/pager.js +0 -325
- package/dist/panel.js +0 -34
- package/dist/permissions.js +0 -466
- package/dist/popup-menu.js +0 -93
- package/dist/popup.js +0 -16
- package/dist/progress-bar.js +0 -111
- package/dist/proxy-attrs.js +0 -19
- package/dist/query-assist.js +0 -1081
- package/dist/radio.js +0 -112
- package/dist/select.js +0 -1920
- package/dist/selection.js +0 -213
- package/dist/shortcuts.js +0 -307
- package/dist/storage.js +0 -373
- package/dist/style.css +0 -1
- package/dist/tab-trap.js +0 -174
- package/dist/table.js +0 -903
- package/dist/tabs.js +0 -721
- package/dist/tag.js +0 -187
- package/dist/tags-input.js +0 -440
- package/dist/tags-list.js +0 -91
- package/dist/text.js +0 -38
- package/dist/toggle.js +0 -80
- package/dist/tooltip.js +0 -202
- package/dist/user-card.js +0 -218
package/dist/select.js
DELETED
|
@@ -1,1920 +0,0 @@
|
|
|
1
|
-
import { b as _defineProperty, _ as _objectWithoutProperties, a as _extends, c as _objectSpread2, d as _toPropertyKey } from './_helpers/_rollupPluginBabelHelpers.js';
|
|
2
|
-
import React, { Component, PureComponent, Fragment } from 'react';
|
|
3
|
-
import classNames from 'classnames';
|
|
4
|
-
import PropTypes from 'prop-types';
|
|
5
|
-
import chevronDown from '@jetbrains/icons/chevron-10px';
|
|
6
|
-
import closeIcon from '@jetbrains/icons/close';
|
|
7
|
-
import deepEqual from 'deep-equal';
|
|
8
|
-
import { Anchor } from './dropdown.js';
|
|
9
|
-
import Avatar, { Size } from './avatar.js';
|
|
10
|
-
import { a as DEFAULT_DIRECTIONS, g as getPopupContainer, m as maxHeightForDirection, P as Popup } from './_helpers/popup.js';
|
|
11
|
-
import { A as ActiveItemContext, L as List, g as getEventKey } from './_helpers/list.js';
|
|
12
|
-
import Input, { Size as Size$1 } from './input.js';
|
|
13
|
-
import Shortcuts from './shortcuts.js';
|
|
14
|
-
import { B as Button, m as modules_e81895c9 } from './_helpers/button.js';
|
|
15
|
-
import { j as joinDataTestAttributes } from './_helpers/data-tests.js';
|
|
16
|
-
import { g as getUID } from './_helpers/get-uid.js';
|
|
17
|
-
import { r as rerenderHOC } from './_helpers/rerender-hoc.js';
|
|
18
|
-
import { a as ThemeContext, T as Theme } from './_helpers/theme.js';
|
|
19
|
-
import { m as memoize } from './_helpers/memoize.js';
|
|
20
|
-
import searchIcon from '@jetbrains/icons/search';
|
|
21
|
-
import memoizeOne from 'memoize-one';
|
|
22
|
-
import Icon from './icon.js';
|
|
23
|
-
import { a as PopupTargetContext } from './_helpers/popup.target.js';
|
|
24
|
-
import LoaderInline from './loader-inline.js';
|
|
25
|
-
import { f as getStyles } from './_helpers/dom.js';
|
|
26
|
-
import TagsList from './tags-list.js';
|
|
27
|
-
import Caret from './caret.js';
|
|
28
|
-
import Text from './text.js';
|
|
29
|
-
import { s as sniffr } from './_helpers/sniffer.js';
|
|
30
|
-
import 'util-deprecate';
|
|
31
|
-
import 'focus-visible';
|
|
32
|
-
import './_helpers/clickableLink.js';
|
|
33
|
-
import './_helpers/url.js';
|
|
34
|
-
import 'react-dom';
|
|
35
|
-
import './_helpers/schedule-raf.js';
|
|
36
|
-
import './tab-trap.js';
|
|
37
|
-
import 'react-virtualized/dist/es/List';
|
|
38
|
-
import 'react-virtualized/dist/es/AutoSizer';
|
|
39
|
-
import 'react-virtualized/dist/es/WindowScroller';
|
|
40
|
-
import 'react-virtualized/dist/es/CellMeasurer';
|
|
41
|
-
import './link.js';
|
|
42
|
-
import './checkbox.js';
|
|
43
|
-
import '@jetbrains/icons/checkmark';
|
|
44
|
-
import '@jetbrains/icons/remove-10px';
|
|
45
|
-
import 'combokeys';
|
|
46
|
-
import 'sniffr';
|
|
47
|
-
import 'conic-gradient';
|
|
48
|
-
import './tag.js';
|
|
49
|
-
|
|
50
|
-
/** https://github.com/bevacqua/fuzzysearch + highlighting with Markdown */
|
|
51
|
-
const marker = '**';
|
|
52
|
-
function fuzzyHighlight(needle, haystack, caseSensitive = false) {
|
|
53
|
-
const ndl = caseSensitive ? needle : needle.toLowerCase();
|
|
54
|
-
const hstck = caseSensitive ? haystack : haystack.toLowerCase();
|
|
55
|
-
|
|
56
|
-
const result = (matched, highlight = haystack) => ({
|
|
57
|
-
matched,
|
|
58
|
-
highlight
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
const hlen = hstck.length;
|
|
62
|
-
const nlen = ndl.length;
|
|
63
|
-
|
|
64
|
-
if (nlen > hlen) {
|
|
65
|
-
return result(false);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
if (nlen === hlen) {
|
|
69
|
-
const matched = ndl === hstck;
|
|
70
|
-
return result(matched, matched ? `${marker}${haystack}${marker}` : haystack);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
let highlight = '';
|
|
74
|
-
let on = false;
|
|
75
|
-
let j = 0;
|
|
76
|
-
/* eslint-disable no-labels */
|
|
77
|
-
|
|
78
|
-
outer: for (let i = 0; i < nlen; i++) {
|
|
79
|
-
const nch = ndl[i];
|
|
80
|
-
|
|
81
|
-
while (j < hlen) {
|
|
82
|
-
const hch = hstck[j];
|
|
83
|
-
const match = hch === nch; // Don't turn highlight on for space characters
|
|
84
|
-
|
|
85
|
-
const nextOn = match && /\S/.test(hch);
|
|
86
|
-
|
|
87
|
-
if (nextOn !== on) {
|
|
88
|
-
highlight += marker;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
highlight += haystack[j++];
|
|
92
|
-
on = nextOn;
|
|
93
|
-
|
|
94
|
-
if (match) {
|
|
95
|
-
continue outer;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
return result(false);
|
|
100
|
-
}
|
|
101
|
-
/* eslint-enable */
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
if (on) {
|
|
105
|
-
highlight += marker;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
highlight += haystack.slice(j);
|
|
109
|
-
return result(true, highlight);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
function shortcutsHOC(ComposedComponent) {
|
|
113
|
-
var _class, _temp;
|
|
114
|
-
|
|
115
|
-
return _temp = _class = class WithShortcuts extends React.Component {
|
|
116
|
-
constructor(...args) {
|
|
117
|
-
super(...args);
|
|
118
|
-
|
|
119
|
-
_defineProperty(this, "_shortcutsScopeUid", getUID('rg-shortcuts-'));
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
render() {
|
|
123
|
-
const _this$props = this.props,
|
|
124
|
-
{
|
|
125
|
-
rgShortcutsOptions,
|
|
126
|
-
rgShortcutsMap
|
|
127
|
-
} = _this$props,
|
|
128
|
-
props = _objectWithoutProperties(_this$props, ["rgShortcutsOptions", "rgShortcutsMap"]);
|
|
129
|
-
|
|
130
|
-
return /*#__PURE__*/React.createElement(Shortcuts, {
|
|
131
|
-
scope: this._shortcutsScopeUid,
|
|
132
|
-
map: rgShortcutsMap,
|
|
133
|
-
options: rgShortcutsOptions,
|
|
134
|
-
disabled: rgShortcutsOptions.disabled
|
|
135
|
-
}, /*#__PURE__*/React.createElement(ComposedComponent, props));
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
}, _defineProperty(_class, "propTypes", {
|
|
139
|
-
rgShortcutsOptions: PropTypes.object,
|
|
140
|
-
rgShortcutsMap: PropTypes.object
|
|
141
|
-
}), _temp;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
var modules_b607bec2 = {"unit":"8px","filterWithTags":"selectPopup_filterWithTags__7e997a1d","filterWrapper":"selectPopup_filterWrapper__7e997a1d","filterWithTagsFocused":"selectPopup_filterWithTagsFocused__7e997a1d","filter":"selectPopup_filter__7e997a1d","filterIcon":"selectPopup_filterIcon__7e997a1d","bottomLine":"selectPopup_bottomLine__7e997a1d","message":"selectPopup_message__7e997a1d","selectAll":"selectPopup_selectAll__7e997a1d"};
|
|
145
|
-
|
|
146
|
-
function noop$2() {}
|
|
147
|
-
|
|
148
|
-
class SelectFilter extends Component {
|
|
149
|
-
constructor(...args) {
|
|
150
|
-
super(...args);
|
|
151
|
-
|
|
152
|
-
_defineProperty(this, "inputRef", el => {
|
|
153
|
-
this.input = el;
|
|
154
|
-
this.props.inputRef(el);
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
componentWillUnmount() {
|
|
159
|
-
this.blur();
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
focus() {
|
|
163
|
-
const {
|
|
164
|
-
input
|
|
165
|
-
} = this;
|
|
166
|
-
|
|
167
|
-
if (input && input !== document.activeElement) {
|
|
168
|
-
sniffr.browser.name === 'firefox' ? input.select() : input.focus();
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
blur() {
|
|
173
|
-
if (this.input && this.input === document.activeElement) {
|
|
174
|
-
this.input.blur();
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
render() {
|
|
179
|
-
const _this$props = this.props,
|
|
180
|
-
{
|
|
181
|
-
className,
|
|
182
|
-
listId
|
|
183
|
-
} = _this$props,
|
|
184
|
-
restProps = _objectWithoutProperties(_this$props, ["className", "listId"]);
|
|
185
|
-
|
|
186
|
-
const classes = classNames(modules_b607bec2.filter, className);
|
|
187
|
-
return /*#__PURE__*/React.createElement(ActiveItemContext.ValueContext.Consumer, null, activeItemId => /*#__PURE__*/React.createElement(Input, _extends({}, restProps, {
|
|
188
|
-
"aria-owns": listId,
|
|
189
|
-
"aria-activedescendant": activeItemId,
|
|
190
|
-
autoComplete: "off",
|
|
191
|
-
autoFocus: true,
|
|
192
|
-
borderless: true,
|
|
193
|
-
inputRef: this.inputRef,
|
|
194
|
-
className: classes
|
|
195
|
-
})));
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
_defineProperty(SelectFilter, "propTypes", {
|
|
201
|
-
placeholder: PropTypes.string,
|
|
202
|
-
className: PropTypes.string,
|
|
203
|
-
inputRef: PropTypes.func,
|
|
204
|
-
listId: PropTypes.string,
|
|
205
|
-
activeItemId: PropTypes.string
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
_defineProperty(SelectFilter, "defaultProps", {
|
|
209
|
-
placeholder: 'Filter items',
|
|
210
|
-
inputRef: noop$2
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
const INPUT_MARGIN_COMPENSATION = -14;
|
|
214
|
-
const FILTER_HEIGHT = 35;
|
|
215
|
-
const TOOLBAR_HEIGHT = 49;
|
|
216
|
-
|
|
217
|
-
function noop$1() {}
|
|
218
|
-
|
|
219
|
-
const FilterWithShortcuts = shortcutsHOC(SelectFilter);
|
|
220
|
-
class SelectPopup extends PureComponent {
|
|
221
|
-
constructor(...args) {
|
|
222
|
-
super(...args);
|
|
223
|
-
|
|
224
|
-
_defineProperty(this, "state", {
|
|
225
|
-
popupFilterShortcutsOptions: {
|
|
226
|
-
modal: true,
|
|
227
|
-
disabled: true
|
|
228
|
-
},
|
|
229
|
-
tagsActiveIndex: null
|
|
230
|
-
});
|
|
231
|
-
|
|
232
|
-
_defineProperty(this, "isClickingPopup", false);
|
|
233
|
-
|
|
234
|
-
_defineProperty(this, "onFilterFocus", () => {
|
|
235
|
-
this._togglePopupFilterShortcuts(false);
|
|
236
|
-
|
|
237
|
-
this.setState({
|
|
238
|
-
tagsActiveIndex: null
|
|
239
|
-
});
|
|
240
|
-
});
|
|
241
|
-
|
|
242
|
-
_defineProperty(this, "popupFilterOnBlur", () => {
|
|
243
|
-
if (this.state.tagsActiveIndex === null) {
|
|
244
|
-
this._togglePopupFilterShortcuts(true);
|
|
245
|
-
}
|
|
246
|
-
});
|
|
247
|
-
|
|
248
|
-
_defineProperty(this, "mouseDownHandler", () => {
|
|
249
|
-
this.isClickingPopup = true;
|
|
250
|
-
});
|
|
251
|
-
|
|
252
|
-
_defineProperty(this, "mouseUpHandler", () => {
|
|
253
|
-
this.isClickingPopup = false;
|
|
254
|
-
});
|
|
255
|
-
|
|
256
|
-
_defineProperty(this, "onListSelect", (selected, event, opts) => {
|
|
257
|
-
const getSelectItemEvent = () => {
|
|
258
|
-
let customEvent;
|
|
259
|
-
|
|
260
|
-
if (document.createEvent) {
|
|
261
|
-
customEvent = document.createEvent('Event');
|
|
262
|
-
customEvent.initEvent('select', true, false);
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
if (event && event.persist) {
|
|
266
|
-
event.persist();
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
customEvent.originalEvent = event;
|
|
270
|
-
return customEvent;
|
|
271
|
-
};
|
|
272
|
-
|
|
273
|
-
this.props.onSelect(selected, getSelectItemEvent(), opts);
|
|
274
|
-
});
|
|
275
|
-
|
|
276
|
-
_defineProperty(this, "tabPress", event => {
|
|
277
|
-
this.props.onCloseAttempt(event, true);
|
|
278
|
-
});
|
|
279
|
-
|
|
280
|
-
_defineProperty(this, "onClickHandler", () => this.filter.focus());
|
|
281
|
-
|
|
282
|
-
_defineProperty(this, "handleRemoveTag", memoize(tag => event => this.removeTag(tag, event)));
|
|
283
|
-
|
|
284
|
-
_defineProperty(this, "handleTagClick", memoize(tag => () => {
|
|
285
|
-
this.setState({
|
|
286
|
-
tagsActiveIndex: this.props.selected.indexOf(tag)
|
|
287
|
-
});
|
|
288
|
-
}));
|
|
289
|
-
|
|
290
|
-
_defineProperty(this, "handleListResize", () => {
|
|
291
|
-
this.forceUpdate();
|
|
292
|
-
});
|
|
293
|
-
|
|
294
|
-
_defineProperty(this, "handleSelectAll", () => this.props.onSelectAll(this.props.data.filter(item => !item.disabled).length !== this.props.selected.length));
|
|
295
|
-
|
|
296
|
-
_defineProperty(this, "getSelectAll", () => {
|
|
297
|
-
const activeFilters = this.props.data.filter(item => !item.disabled);
|
|
298
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
299
|
-
className: modules_b607bec2.selectAll
|
|
300
|
-
}, activeFilters.length === 0 ? /*#__PURE__*/React.createElement("span", null) : /*#__PURE__*/React.createElement(Button, {
|
|
301
|
-
text: true,
|
|
302
|
-
inline: true,
|
|
303
|
-
onClick: this.handleSelectAll
|
|
304
|
-
}, activeFilters.length !== this.props.selected.length ? 'Select all' : 'Deselect all'), /*#__PURE__*/React.createElement(Text, {
|
|
305
|
-
info: true
|
|
306
|
-
}, `${this.props.selected.length} selected`));
|
|
307
|
-
});
|
|
308
|
-
|
|
309
|
-
_defineProperty(this, "_adjustListMaxHeight", memoizeOne((hidden, userDefinedMaxHeight, ringPopupTarget) => {
|
|
310
|
-
if (hidden) {
|
|
311
|
-
return userDefinedMaxHeight;
|
|
312
|
-
} // Calculate list's maximum height that can't
|
|
313
|
-
// get beyond the screen
|
|
314
|
-
// @see RG-1838, JT-48358
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
const minMaxHeight = 100;
|
|
318
|
-
const directions = this.props.directions || DEFAULT_DIRECTIONS; // Note:
|
|
319
|
-
// Create a method which'll be called only when the popup opens and before
|
|
320
|
-
// render the list would be a better way
|
|
321
|
-
|
|
322
|
-
const anchorNode = this.props.anchorElement;
|
|
323
|
-
const containerNode = getPopupContainer(ringPopupTarget) || document.documentElement;
|
|
324
|
-
return Math.min(directions.reduce((maxHeight, direction) => Math.max(maxHeight, maxHeightForDirection(direction, anchorNode, getStyles(containerNode).position !== 'static' ? containerNode : null)), minMaxHeight), userDefinedMaxHeight);
|
|
325
|
-
}));
|
|
326
|
-
|
|
327
|
-
_defineProperty(this, "popupRef", el => {
|
|
328
|
-
this.popup = el;
|
|
329
|
-
});
|
|
330
|
-
|
|
331
|
-
_defineProperty(this, "listRef", el => {
|
|
332
|
-
this.list = el;
|
|
333
|
-
});
|
|
334
|
-
|
|
335
|
-
_defineProperty(this, "filterRef", el => {
|
|
336
|
-
this.filter = el;
|
|
337
|
-
this.caret = new Caret(this.filter);
|
|
338
|
-
});
|
|
339
|
-
|
|
340
|
-
_defineProperty(this, "shortcutsScope", getUID('select-popup-'));
|
|
341
|
-
|
|
342
|
-
_defineProperty(this, "shortcutsMap", {
|
|
343
|
-
tab: this.tabPress
|
|
344
|
-
});
|
|
345
|
-
|
|
346
|
-
_defineProperty(this, "popupFilterShortcuts", {
|
|
347
|
-
map: {
|
|
348
|
-
up: event => this.list && this.list.upHandler(event),
|
|
349
|
-
down: event => this.list && this.list.downHandler(event),
|
|
350
|
-
home: event => this.list && this.list.homeHandler(event),
|
|
351
|
-
end: event => this.list && this.list.endHandler(event),
|
|
352
|
-
enter: event => this.list ? this.list.enterHandler(event) : this.props.onEmptyPopupEnter(event),
|
|
353
|
-
esc: event => this.props.onCloseAttempt(event, true),
|
|
354
|
-
tab: event => this.tabPress(event),
|
|
355
|
-
backspace: event => this.handleBackspace(event),
|
|
356
|
-
del: () => this.removeSelectedTag(),
|
|
357
|
-
left: () => this.handleNavigation(true),
|
|
358
|
-
right: () => this.handleNavigation()
|
|
359
|
-
}
|
|
360
|
-
});
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
componentDidMount() {
|
|
364
|
-
window.document.addEventListener('mouseup', this.mouseUpHandler);
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
componentWillUnmount() {
|
|
368
|
-
window.document.removeEventListener('mouseup', this.mouseUpHandler);
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
// This flag is set to true while an item in the popup is being clicked
|
|
372
|
-
focusFilter() {
|
|
373
|
-
setTimeout(() => this.filter.focus());
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
isEventTargetFilter(event) {
|
|
377
|
-
return event.target && event.target.matches('input,textarea');
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
handleNavigation(navigateLeft) {
|
|
381
|
-
if (this.isEventTargetFilter(event) && this.caret.getPosition() > 0) {
|
|
382
|
-
return;
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
let newIndex = null;
|
|
386
|
-
|
|
387
|
-
if (navigateLeft) {
|
|
388
|
-
newIndex = this.state.tagsActiveIndex === null ? this.props.selected.length - 1 : this.state.tagsActiveIndex - 1;
|
|
389
|
-
} else if (this.state.tagsActiveIndex !== null) {
|
|
390
|
-
newIndex = this.state.tagsActiveIndex + 1;
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
if (newIndex !== null && (newIndex >= this.props.selected.length || newIndex < 0)) {
|
|
394
|
-
newIndex = null;
|
|
395
|
-
this.focusFilter();
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
this.setState({
|
|
399
|
-
tagsActiveIndex: newIndex
|
|
400
|
-
});
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
removeTag(tag, event) {
|
|
404
|
-
const _tag = tag || this.props.selected.slice(0)[this.props.selected.length - 1];
|
|
405
|
-
|
|
406
|
-
if (_tag) {
|
|
407
|
-
this.onListSelect(_tag, event, {
|
|
408
|
-
tryKeepOpen: true
|
|
409
|
-
});
|
|
410
|
-
this.setState({
|
|
411
|
-
tagsActiveIndex: null
|
|
412
|
-
});
|
|
413
|
-
this.focusFilter();
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
removeSelectedTag() {
|
|
418
|
-
if (this.state.tagsActiveIndex != null) {
|
|
419
|
-
this.removeTag(this.props.selected[this.state.tagsActiveIndex]);
|
|
420
|
-
return false;
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
return true;
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
handleBackspace(event) {
|
|
427
|
-
if (!this.props.tags) {
|
|
428
|
-
return true;
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
if (!this.isEventTargetFilter(event)) {
|
|
432
|
-
this.removeSelectedTag();
|
|
433
|
-
return false;
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
if (!event.target.value) {
|
|
437
|
-
this.removeTag();
|
|
438
|
-
return false;
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
return true;
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
_togglePopupFilterShortcuts(shortcutsDisabled) {
|
|
445
|
-
this.setState({
|
|
446
|
-
popupFilterShortcutsOptions: {
|
|
447
|
-
modal: true,
|
|
448
|
-
disabled: shortcutsDisabled
|
|
449
|
-
}
|
|
450
|
-
});
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
isVisible() {
|
|
454
|
-
return this.popup && this.popup.isVisible();
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
getFilter() {
|
|
458
|
-
if (this.props.filter || this.props.tags) {
|
|
459
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
460
|
-
className: modules_b607bec2.filterWrapper,
|
|
461
|
-
"data-test": "ring-select-popup-filter"
|
|
462
|
-
}, /*#__PURE__*/React.createElement(Icon, {
|
|
463
|
-
glyph: searchIcon,
|
|
464
|
-
className: modules_b607bec2.filterIcon,
|
|
465
|
-
"data-test-custom": "ring-select-popup-filter-icon"
|
|
466
|
-
}), /*#__PURE__*/React.createElement(FilterWithShortcuts, {
|
|
467
|
-
rgShortcutsOptions: this.state.popupFilterShortcutsOptions,
|
|
468
|
-
rgShortcutsMap: this.popupFilterShortcuts.map,
|
|
469
|
-
value: this.props.filterValue,
|
|
470
|
-
inputRef: this.filterRef,
|
|
471
|
-
onBlur: this.popupFilterOnBlur,
|
|
472
|
-
onFocus: this.onFilterFocus,
|
|
473
|
-
className: "ring-js-shortcuts",
|
|
474
|
-
placeholder: this.props.filter.placeholder,
|
|
475
|
-
onChange: this.props.onFilter,
|
|
476
|
-
onClick: this.onClickHandler,
|
|
477
|
-
onClear: this.props.onClear,
|
|
478
|
-
"data-test-custom": "ring-select-popup-filter-input",
|
|
479
|
-
listId: this.props.listId
|
|
480
|
-
}));
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
return null;
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
getTags() {
|
|
487
|
-
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(TagsList, {
|
|
488
|
-
tags: this.props.selected,
|
|
489
|
-
activeIndex: this.state.tagsActiveIndex,
|
|
490
|
-
handleRemove: this.handleRemoveTag,
|
|
491
|
-
handleClick: this.handleTagClick,
|
|
492
|
-
disabled: this.props.disabled
|
|
493
|
-
}));
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
getFilterWithTags() {
|
|
497
|
-
if (this.props.tags) {
|
|
498
|
-
const classes = classNames([modules_b607bec2.filterWithTags, {
|
|
499
|
-
[modules_b607bec2.filterWithTagsFocused]: !this.state.popupFilterShortcutsOptions.disabled
|
|
500
|
-
}]);
|
|
501
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
502
|
-
className: classes
|
|
503
|
-
}, this.getTags(), this.getFilter());
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
return this.getFilter();
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
getBottomLine() {
|
|
510
|
-
const {
|
|
511
|
-
loading,
|
|
512
|
-
message
|
|
513
|
-
} = this.props;
|
|
514
|
-
return (loading || message) && /*#__PURE__*/React.createElement("div", {
|
|
515
|
-
className: modules_b607bec2.bottomLine
|
|
516
|
-
}, loading && /*#__PURE__*/React.createElement(LoaderInline, null), message && /*#__PURE__*/React.createElement("div", {
|
|
517
|
-
className: modules_b607bec2.message
|
|
518
|
-
}, message));
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
getList(ringPopupTarget) {
|
|
522
|
-
if (this.props.data.length) {
|
|
523
|
-
let {
|
|
524
|
-
maxHeight
|
|
525
|
-
} = this.props;
|
|
526
|
-
|
|
527
|
-
if (this.props.anchorElement) {
|
|
528
|
-
maxHeight = this._adjustListMaxHeight(this.props.hidden, maxHeight, ringPopupTarget);
|
|
529
|
-
}
|
|
530
|
-
|
|
531
|
-
if (this.props.filter) {
|
|
532
|
-
maxHeight -= FILTER_HEIGHT;
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
if (this.props.toolbar) {
|
|
536
|
-
maxHeight -= TOOLBAR_HEIGHT;
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
return /*#__PURE__*/React.createElement(List, {
|
|
540
|
-
id: this.props.listId,
|
|
541
|
-
maxHeight: maxHeight,
|
|
542
|
-
data: this.props.data,
|
|
543
|
-
activeIndex: this.props.activeIndex,
|
|
544
|
-
ref: this.listRef,
|
|
545
|
-
restoreActiveIndex: true,
|
|
546
|
-
activateFirstItem: true,
|
|
547
|
-
onSelect: this.onListSelect,
|
|
548
|
-
onResize: this.handleListResize,
|
|
549
|
-
onScrollToBottom: this.props.onLoadMore,
|
|
550
|
-
hidden: this.props.hidden,
|
|
551
|
-
shortcuts: !this.props.hidden,
|
|
552
|
-
disableMoveOverflow: this.props.disableMoveOverflow,
|
|
553
|
-
disableMoveDownOverflow: this.props.loading,
|
|
554
|
-
disableScrollToActive: this.props.disableScrollToActive,
|
|
555
|
-
compact: this.props.compact,
|
|
556
|
-
renderOptimization: this.props.renderOptimization
|
|
557
|
-
});
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
return null;
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
render() {
|
|
564
|
-
const {
|
|
565
|
-
toolbar,
|
|
566
|
-
className,
|
|
567
|
-
multiple,
|
|
568
|
-
hidden,
|
|
569
|
-
isInputMode,
|
|
570
|
-
anchorElement,
|
|
571
|
-
minWidth,
|
|
572
|
-
onCloseAttempt,
|
|
573
|
-
directions,
|
|
574
|
-
top,
|
|
575
|
-
left,
|
|
576
|
-
style,
|
|
577
|
-
dir,
|
|
578
|
-
filter
|
|
579
|
-
} = this.props;
|
|
580
|
-
const classes = classNames(modules_b607bec2.popup, className);
|
|
581
|
-
return /*#__PURE__*/React.createElement(PopupTargetContext.Consumer, null, ringPopupTarget => {
|
|
582
|
-
const filterWithTags = this.getFilterWithTags();
|
|
583
|
-
const selectAll = multiple && !multiple.limit && multiple.selectAll && this.getSelectAll();
|
|
584
|
-
const list = this.getList(this.props.ringPopupTarget || ringPopupTarget);
|
|
585
|
-
const bottomLine = this.getBottomLine();
|
|
586
|
-
const hasContent = filterWithTags || selectAll || list || bottomLine || toolbar;
|
|
587
|
-
return /*#__PURE__*/React.createElement(Popup, {
|
|
588
|
-
trapFocus: false,
|
|
589
|
-
ref: this.popupRef,
|
|
590
|
-
hidden: hidden || !hasContent,
|
|
591
|
-
attached: isInputMode,
|
|
592
|
-
className: classes,
|
|
593
|
-
dontCloseOnAnchorClick: true,
|
|
594
|
-
anchorElement: anchorElement,
|
|
595
|
-
minWidth: minWidth,
|
|
596
|
-
onCloseAttempt: onCloseAttempt,
|
|
597
|
-
directions: directions,
|
|
598
|
-
top: top || (isInputMode ? INPUT_MARGIN_COMPENSATION : null),
|
|
599
|
-
left: left,
|
|
600
|
-
onMouseDown: this.mouseDownHandler,
|
|
601
|
-
target: this.props.ringPopupTarget,
|
|
602
|
-
autoCorrectTopOverflow: false,
|
|
603
|
-
style: style
|
|
604
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
605
|
-
dir: dir
|
|
606
|
-
}, !hidden && filter && /*#__PURE__*/React.createElement(Shortcuts, {
|
|
607
|
-
map: this.shortcutsMap,
|
|
608
|
-
scope: this.shortcutsScope
|
|
609
|
-
}), hidden ? /*#__PURE__*/React.createElement("div", null) : filterWithTags, selectAll, list, bottomLine, toolbar));
|
|
610
|
-
});
|
|
611
|
-
}
|
|
612
|
-
|
|
613
|
-
}
|
|
614
|
-
|
|
615
|
-
_defineProperty(SelectPopup, "propTypes", {
|
|
616
|
-
activeIndex: PropTypes.number,
|
|
617
|
-
anchorElement: PropTypes.instanceOf(HTMLElement),
|
|
618
|
-
className: PropTypes.string,
|
|
619
|
-
compact: PropTypes.bool,
|
|
620
|
-
data: PropTypes.array,
|
|
621
|
-
dir: PropTypes.oneOf(['ltr', 'rtl']),
|
|
622
|
-
directions: PropTypes.array,
|
|
623
|
-
disabled: PropTypes.bool,
|
|
624
|
-
disableMoveOverflow: PropTypes.bool,
|
|
625
|
-
disableScrollToActive: PropTypes.bool,
|
|
626
|
-
filter: PropTypes.oneOfType([PropTypes.bool, PropTypes.shape({
|
|
627
|
-
value: PropTypes.string,
|
|
628
|
-
placeholder: PropTypes.string
|
|
629
|
-
})]),
|
|
630
|
-
filterValue: PropTypes.string,
|
|
631
|
-
hidden: PropTypes.bool,
|
|
632
|
-
isInputMode: PropTypes.bool,
|
|
633
|
-
listId: PropTypes.string,
|
|
634
|
-
maxHeight: PropTypes.number,
|
|
635
|
-
message: PropTypes.string,
|
|
636
|
-
minWidth: PropTypes.number,
|
|
637
|
-
multiple: PropTypes.oneOfType([PropTypes.bool, PropTypes.shape({
|
|
638
|
-
label: PropTypes.string,
|
|
639
|
-
limit: PropTypes.number,
|
|
640
|
-
selectAll: PropTypes.bool
|
|
641
|
-
})]),
|
|
642
|
-
left: PropTypes.bool,
|
|
643
|
-
loading: PropTypes.bool,
|
|
644
|
-
onClear: PropTypes.func,
|
|
645
|
-
onCloseAttempt: PropTypes.func,
|
|
646
|
-
onEmptyPopupEnter: PropTypes.func,
|
|
647
|
-
onFilter: PropTypes.func,
|
|
648
|
-
onLoadMore: PropTypes.func,
|
|
649
|
-
onSelect: PropTypes.func,
|
|
650
|
-
onSelectAll: PropTypes.func,
|
|
651
|
-
renderOptimization: PropTypes.bool,
|
|
652
|
-
ringPopupTarget: PropTypes.string,
|
|
653
|
-
selected: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
|
|
654
|
-
style: PropTypes.object,
|
|
655
|
-
tags: PropTypes.object,
|
|
656
|
-
toolbar: PropTypes.node,
|
|
657
|
-
top: PropTypes.number
|
|
658
|
-
});
|
|
659
|
-
|
|
660
|
-
_defineProperty(SelectPopup, "defaultProps", {
|
|
661
|
-
data: [],
|
|
662
|
-
activeIndex: null,
|
|
663
|
-
toolbar: null,
|
|
664
|
-
filter: false,
|
|
665
|
-
multiple: false,
|
|
666
|
-
message: null,
|
|
667
|
-
anchorElement: null,
|
|
668
|
-
maxHeight: 600,
|
|
669
|
-
minWidth: 240,
|
|
670
|
-
loading: false,
|
|
671
|
-
onSelect: noop$1,
|
|
672
|
-
onCloseAttempt: noop$1,
|
|
673
|
-
onFilter: noop$1,
|
|
674
|
-
onClear: noop$1,
|
|
675
|
-
onLoadMore: noop$1,
|
|
676
|
-
selected: [],
|
|
677
|
-
tags: null,
|
|
678
|
-
ringPopupTarget: null,
|
|
679
|
-
onSelectAll: noop$1,
|
|
680
|
-
onEmptyPopupEnter: noop$1
|
|
681
|
-
});
|
|
682
|
-
|
|
683
|
-
var modules_9d0de074 = {"unit":"8px","resetButton":"global_resetButton__0f8f4370","select":"select_select__695ec655","value":"select_value__695ec655 global_ellipsis__0f8f4370 global_font__0f8f4370","icons":"select_icons__695ec655","toolbar":"select_toolbar__695ec655","button":"select_button__695ec655","buttonSpaced":"select_buttonSpaced__695ec655","inputMode":"select_inputMode__695ec655","buttonMode":"select_buttonMode__695ec655","selectedIcon":"select_selectedIcon__695ec655 global_resetButton__0f8f4370","clearIcon":"select_clearIcon__695ec655","sizeS":"select_sizeS__695ec655","sizeM":"select_sizeM__695ec655","sizeL":"select_sizeL__695ec655","sizeFULL":"select_sizeFULL__695ec655","sizeAUTO":"select_sizeAUTO__695ec655","materialMode":"select_materialMode__695ec655","open":"select_open__695ec655","buttonValue":"select_buttonValue__695ec655 global_ellipsis__0f8f4370","buttonValueOpen":"select_buttonValueOpen__695ec655","label":"select_label__695ec655","disabled":"select_disabled__695ec655","selectedLabel":"select_selectedLabel__695ec655","avatar":"select_avatar__695ec655","popup":"select_popup__695ec655","chevron":"select_chevron__695ec655","chevronIcon":"select_chevronIcon__695ec655"};
|
|
684
|
-
|
|
685
|
-
/**
|
|
686
|
-
* @name Select
|
|
687
|
-
*/
|
|
688
|
-
|
|
689
|
-
function noop() {}
|
|
690
|
-
/**
|
|
691
|
-
* @enum {number}
|
|
692
|
-
*/
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
const Type = {
|
|
696
|
-
BUTTON: 'BUTTON',
|
|
697
|
-
INPUT: 'INPUT',
|
|
698
|
-
CUSTOM: 'CUSTOM',
|
|
699
|
-
INLINE: 'INLINE',
|
|
700
|
-
MATERIAL: 'MATERIAL',
|
|
701
|
-
INPUT_WITHOUT_CONTROLS: 'INPUT_WITHOUT_CONTROLS'
|
|
702
|
-
};
|
|
703
|
-
const ICON_WIDTH = 20;
|
|
704
|
-
const getStyle = memoize(iconsLength => ({
|
|
705
|
-
paddingRight: iconsLength * ICON_WIDTH
|
|
706
|
-
}));
|
|
707
|
-
|
|
708
|
-
const isInputMode = type => type === Type.INPUT || type === Type.INPUT_WITHOUT_CONTROLS;
|
|
709
|
-
|
|
710
|
-
function getLowerCaseLabel(item) {
|
|
711
|
-
if (List.isItemType(List.ListProps.Type.SEPARATOR, item) || List.isItemType(List.ListProps.Type.HINT, item) || item.label == null) {
|
|
712
|
-
return null;
|
|
713
|
-
}
|
|
714
|
-
|
|
715
|
-
return item.label.toLowerCase();
|
|
716
|
-
}
|
|
717
|
-
|
|
718
|
-
function doesLabelMatch(itemToCheck, fn) {
|
|
719
|
-
const lowerCaseLabel = getLowerCaseLabel(itemToCheck);
|
|
720
|
-
|
|
721
|
-
if (lowerCaseLabel == null) {
|
|
722
|
-
return true;
|
|
723
|
-
}
|
|
724
|
-
|
|
725
|
-
return fn(lowerCaseLabel);
|
|
726
|
-
}
|
|
727
|
-
|
|
728
|
-
function getFilterFn(filter) {
|
|
729
|
-
if (filter.fn) {
|
|
730
|
-
return filter.fn;
|
|
731
|
-
}
|
|
732
|
-
|
|
733
|
-
if (filter.fuzzy) {
|
|
734
|
-
return (itemToCheck, checkString) => doesLabelMatch(itemToCheck, lowerCaseLabel => fuzzyHighlight(checkString, lowerCaseLabel).matched);
|
|
735
|
-
}
|
|
736
|
-
|
|
737
|
-
return (itemToCheck, checkString) => doesLabelMatch(itemToCheck, lowerCaseLabel => lowerCaseLabel.indexOf(checkString) >= 0);
|
|
738
|
-
}
|
|
739
|
-
|
|
740
|
-
const buildMultipleMap = selected => selected.reduce((acc, item) => {
|
|
741
|
-
acc[item.key] = true;
|
|
742
|
-
return acc;
|
|
743
|
-
}, {});
|
|
744
|
-
|
|
745
|
-
function getListItems(props, state, rawFilterString, data = props.data) {
|
|
746
|
-
let filterString = rawFilterString.trim();
|
|
747
|
-
|
|
748
|
-
if (isInputMode(props.type) && state.selected && filterString === state.selected.label) {
|
|
749
|
-
filterString = ''; // ignore multiple if it is exactly the selected item
|
|
750
|
-
}
|
|
751
|
-
|
|
752
|
-
const lowerCaseString = filterString.toLowerCase();
|
|
753
|
-
const filteredData = [];
|
|
754
|
-
let exactMatch = false;
|
|
755
|
-
const check = getFilterFn(props.filter);
|
|
756
|
-
|
|
757
|
-
for (let i = 0; i < data.length; i++) {
|
|
758
|
-
const item = _objectSpread2({}, data[i]);
|
|
759
|
-
|
|
760
|
-
if (check(item, lowerCaseString, data)) {
|
|
761
|
-
exactMatch = item.label === filterString;
|
|
762
|
-
|
|
763
|
-
if (props.multiple && !props.multiple.removeSelectedItems) {
|
|
764
|
-
item.checkbox = !!state.multipleMap[item.key];
|
|
765
|
-
}
|
|
766
|
-
|
|
767
|
-
if (props.multiple && props.multiple.limit) {
|
|
768
|
-
item.disabled = props.multiple.limit === state.selected.length && !state.selected.find(selectedItem => selectedItem.key === item.key);
|
|
769
|
-
} // Ignore item if it's multiple and is already selected
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
if (!(props.multiple && props.multiple.removeSelectedItems && state.multipleMap[item.key])) {
|
|
773
|
-
filteredData.push(item);
|
|
774
|
-
}
|
|
775
|
-
}
|
|
776
|
-
}
|
|
777
|
-
|
|
778
|
-
let addButton = null;
|
|
779
|
-
const {
|
|
780
|
-
add
|
|
781
|
-
} = props;
|
|
782
|
-
|
|
783
|
-
if (add && filterString && !exactMatch || add && add.alwaysVisible) {
|
|
784
|
-
if (!(add.regexp && !add.regexp.test(filterString)) && !(add.minlength && filterString.length < +add.minlength) || add.alwaysVisible) {
|
|
785
|
-
let label;
|
|
786
|
-
|
|
787
|
-
if (add.label) {
|
|
788
|
-
label = typeof add.label === 'function' ? add.label(filterString) : add.label;
|
|
789
|
-
} else {
|
|
790
|
-
label = filterString;
|
|
791
|
-
}
|
|
792
|
-
|
|
793
|
-
addButton = {
|
|
794
|
-
prefix: add.prefix,
|
|
795
|
-
label,
|
|
796
|
-
delayed: add.hasOwnProperty('delayed') ? add.delayed : true
|
|
797
|
-
};
|
|
798
|
-
}
|
|
799
|
-
}
|
|
800
|
-
|
|
801
|
-
return {
|
|
802
|
-
filteredData,
|
|
803
|
-
addButton
|
|
804
|
-
};
|
|
805
|
-
}
|
|
806
|
-
|
|
807
|
-
function getSelectedIndex(selected, data, multiple) {
|
|
808
|
-
const firstSelected = multiple ? selected[0] : selected;
|
|
809
|
-
|
|
810
|
-
if (firstSelected == null) {
|
|
811
|
-
return null;
|
|
812
|
-
}
|
|
813
|
-
|
|
814
|
-
for (let i = 0; i < data.length; i++) {
|
|
815
|
-
const item = data[i];
|
|
816
|
-
|
|
817
|
-
if (item.key === undefined) {
|
|
818
|
-
continue;
|
|
819
|
-
}
|
|
820
|
-
|
|
821
|
-
if (item.key === firstSelected.key) {
|
|
822
|
-
return i;
|
|
823
|
-
}
|
|
824
|
-
}
|
|
825
|
-
|
|
826
|
-
return null;
|
|
827
|
-
}
|
|
828
|
-
|
|
829
|
-
const getItemLabel = ({
|
|
830
|
-
selectedLabel,
|
|
831
|
-
label
|
|
832
|
-
}) => selectedLabel != null ? selectedLabel : label;
|
|
833
|
-
|
|
834
|
-
const getValueForFilter = (selected, type, filterValue) => selected && isInputMode(type) ? getItemLabel(selected) : filterValue;
|
|
835
|
-
|
|
836
|
-
function isSameSelected(prevSelected, selected) {
|
|
837
|
-
if (!prevSelected || !selected || prevSelected.length !== selected.length) {
|
|
838
|
-
return false;
|
|
839
|
-
}
|
|
840
|
-
|
|
841
|
-
const keysMap = selected.reduce((result, item) => {
|
|
842
|
-
result[item.key] = true;
|
|
843
|
-
return result;
|
|
844
|
-
}, {});
|
|
845
|
-
return prevSelected.every(it => keysMap[it.key]);
|
|
846
|
-
}
|
|
847
|
-
/**
|
|
848
|
-
* @name Select
|
|
849
|
-
* @constructor
|
|
850
|
-
* @extends {Component}
|
|
851
|
-
*/
|
|
852
|
-
|
|
853
|
-
/**
|
|
854
|
-
* Displays a select.
|
|
855
|
-
*/
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
class Select extends Component {
|
|
859
|
-
constructor(...args) {
|
|
860
|
-
super(...args);
|
|
861
|
-
|
|
862
|
-
_defineProperty(this, "state", {
|
|
863
|
-
data: [],
|
|
864
|
-
shownData: [],
|
|
865
|
-
selected: this.props.multiple ? [] : null,
|
|
866
|
-
selectedIndex: null,
|
|
867
|
-
filterValue: this.props.filter && this.props.filter.value || '',
|
|
868
|
-
shortcutsEnabled: false,
|
|
869
|
-
popupShortcuts: false,
|
|
870
|
-
showPopup: false,
|
|
871
|
-
prevData: this.props.data,
|
|
872
|
-
prevSelected: null,
|
|
873
|
-
prevMultiple: this.props.multiple,
|
|
874
|
-
multipleMap: {},
|
|
875
|
-
addButton: null
|
|
876
|
-
});
|
|
877
|
-
|
|
878
|
-
_defineProperty(this, "id", getUID('select-'));
|
|
879
|
-
|
|
880
|
-
_defineProperty(this, "shortcutsScope", this.id);
|
|
881
|
-
|
|
882
|
-
_defineProperty(this, "listId", `${this.id}:list`);
|
|
883
|
-
|
|
884
|
-
_defineProperty(this, "_focusHandler", () => {
|
|
885
|
-
this.props.onFocus();
|
|
886
|
-
this.setState({
|
|
887
|
-
shortcutsEnabled: true,
|
|
888
|
-
focused: true
|
|
889
|
-
});
|
|
890
|
-
});
|
|
891
|
-
|
|
892
|
-
_defineProperty(this, "_blurHandler", () => {
|
|
893
|
-
this.props.onBlur();
|
|
894
|
-
|
|
895
|
-
if (this._popup && this._popup.isVisible() && !this._popup.isClickingPopup) {
|
|
896
|
-
window.setTimeout(() => {
|
|
897
|
-
this.setState({
|
|
898
|
-
showPopup: false
|
|
899
|
-
});
|
|
900
|
-
});
|
|
901
|
-
}
|
|
902
|
-
|
|
903
|
-
if (!this._popup.isClickingPopup) {
|
|
904
|
-
this.setState({
|
|
905
|
-
shortcutsEnabled: false,
|
|
906
|
-
focused: false
|
|
907
|
-
});
|
|
908
|
-
}
|
|
909
|
-
});
|
|
910
|
-
|
|
911
|
-
_defineProperty(this, "nodeRef", el => {
|
|
912
|
-
this.node = el;
|
|
913
|
-
});
|
|
914
|
-
|
|
915
|
-
_defineProperty(this, "_popup", null);
|
|
916
|
-
|
|
917
|
-
_defineProperty(this, "onEmptyPopupEnter", () => {
|
|
918
|
-
if (this.state.addButton) {
|
|
919
|
-
this.addHandler();
|
|
920
|
-
}
|
|
921
|
-
});
|
|
922
|
-
|
|
923
|
-
_defineProperty(this, "_onEnter", () => {
|
|
924
|
-
if (this.state.addButton && this.state.shownData.length === 0) {
|
|
925
|
-
this.addHandler();
|
|
926
|
-
}
|
|
927
|
-
|
|
928
|
-
this.props.onDone();
|
|
929
|
-
|
|
930
|
-
if (!this._popup.isVisible() && this.props.allowAny) {
|
|
931
|
-
return true;
|
|
932
|
-
}
|
|
933
|
-
|
|
934
|
-
return undefined;
|
|
935
|
-
});
|
|
936
|
-
|
|
937
|
-
_defineProperty(this, "_onEsc", event => {
|
|
938
|
-
if (!this._popup.isVisible()) {
|
|
939
|
-
return true;
|
|
940
|
-
} else if (this.props.multiple || !this.props.getInitial) {
|
|
941
|
-
return false;
|
|
942
|
-
}
|
|
943
|
-
|
|
944
|
-
const selected = {
|
|
945
|
-
key: Math.random(),
|
|
946
|
-
label: this.props.getInitial()
|
|
947
|
-
};
|
|
948
|
-
this.setState({
|
|
949
|
-
selected,
|
|
950
|
-
filterValue: this.getValueForFilter(selected)
|
|
951
|
-
}, () => {
|
|
952
|
-
this.props.onChange(selected, event);
|
|
953
|
-
this.props.onReset();
|
|
954
|
-
});
|
|
955
|
-
return undefined;
|
|
956
|
-
});
|
|
957
|
-
|
|
958
|
-
_defineProperty(this, "_inputShortcutHandler", () => {
|
|
959
|
-
if (this.state.focused && this._popup && !this._popup.isVisible()) {
|
|
960
|
-
this._clickHandler();
|
|
961
|
-
}
|
|
962
|
-
});
|
|
963
|
-
|
|
964
|
-
_defineProperty(this, "popupRef", el => {
|
|
965
|
-
this._popup = el;
|
|
966
|
-
});
|
|
967
|
-
|
|
968
|
-
_defineProperty(this, "addHandler", () => {
|
|
969
|
-
const value = this.filterValue();
|
|
970
|
-
|
|
971
|
-
this._hidePopup();
|
|
972
|
-
|
|
973
|
-
this.props.onAdd(value);
|
|
974
|
-
});
|
|
975
|
-
|
|
976
|
-
_defineProperty(this, "getLowerCaseLabel", getLowerCaseLabel);
|
|
977
|
-
|
|
978
|
-
_defineProperty(this, "doesLabelMatch", doesLabelMatch);
|
|
979
|
-
|
|
980
|
-
_defineProperty(this, "_clickHandler", () => {
|
|
981
|
-
if (!this.props.disabled) {
|
|
982
|
-
if (this.state.showPopup) {
|
|
983
|
-
this._hidePopup();
|
|
984
|
-
} else {
|
|
985
|
-
this.props.onBeforeOpen();
|
|
986
|
-
|
|
987
|
-
this._showPopup();
|
|
988
|
-
}
|
|
989
|
-
}
|
|
990
|
-
});
|
|
991
|
-
|
|
992
|
-
_defineProperty(this, "_selectButtonKeyboardHack", event => {
|
|
993
|
-
const key = getEventKey(event);
|
|
994
|
-
|
|
995
|
-
if (key === 'Enter' || key === ' ') {
|
|
996
|
-
this._clickHandler();
|
|
997
|
-
}
|
|
998
|
-
});
|
|
999
|
-
|
|
1000
|
-
_defineProperty(this, "_filterChangeHandler", e => {
|
|
1001
|
-
this._setFilter(e.target.value, e);
|
|
1002
|
-
});
|
|
1003
|
-
|
|
1004
|
-
_defineProperty(this, "_setFilter", (value, event = {}) => {
|
|
1005
|
-
if (this.isInputMode() && !this.state.focused) {
|
|
1006
|
-
return;
|
|
1007
|
-
}
|
|
1008
|
-
|
|
1009
|
-
if (value === this.state.filterValue) {
|
|
1010
|
-
return;
|
|
1011
|
-
}
|
|
1012
|
-
|
|
1013
|
-
const filterValue = value.replace(/^\s+/g, '');
|
|
1014
|
-
this.props.onFilter(filterValue);
|
|
1015
|
-
|
|
1016
|
-
if (this.props.allowAny) {
|
|
1017
|
-
const fakeSelected = {
|
|
1018
|
-
key: Math.random(),
|
|
1019
|
-
label: filterValue
|
|
1020
|
-
};
|
|
1021
|
-
this.setState({
|
|
1022
|
-
selected: filterValue === '' ? null : fakeSelected,
|
|
1023
|
-
selectedIndex: null
|
|
1024
|
-
}, () => {
|
|
1025
|
-
this.props.onSelect(fakeSelected, event);
|
|
1026
|
-
this.props.onChange(fakeSelected, event);
|
|
1027
|
-
});
|
|
1028
|
-
}
|
|
1029
|
-
|
|
1030
|
-
!this._popup.isVisible() && this.props.onBeforeOpen();
|
|
1031
|
-
this.setState({
|
|
1032
|
-
filterValue
|
|
1033
|
-
}, () => {
|
|
1034
|
-
this._showPopup();
|
|
1035
|
-
});
|
|
1036
|
-
});
|
|
1037
|
-
|
|
1038
|
-
_defineProperty(this, "_redrawPopup", () => {
|
|
1039
|
-
if (this.props.multiple) {
|
|
1040
|
-
setTimeout(() => {
|
|
1041
|
-
//setTimeout solves events order and bubbling issue
|
|
1042
|
-
this.isInputMode() && this.clearFilter();
|
|
1043
|
-
|
|
1044
|
-
this._showPopup();
|
|
1045
|
-
}, 0);
|
|
1046
|
-
}
|
|
1047
|
-
});
|
|
1048
|
-
|
|
1049
|
-
_defineProperty(this, "_listSelectHandler", (selected, event, opts = {}) => {
|
|
1050
|
-
const isItem = List.isItemType.bind(null, List.ListProps.Type.ITEM);
|
|
1051
|
-
const isCustomItem = List.isItemType.bind(null, List.ListProps.Type.CUSTOM);
|
|
1052
|
-
const isSelectItemEvent = event && (event.type === 'select' || event.type === 'keydown');
|
|
1053
|
-
|
|
1054
|
-
if (isSelectItemEvent) {
|
|
1055
|
-
event.preventDefault();
|
|
1056
|
-
}
|
|
1057
|
-
|
|
1058
|
-
if (!isItem(selected) && !isCustomItem(selected) || selected.disabled || selected.isResetItem) {
|
|
1059
|
-
return;
|
|
1060
|
-
}
|
|
1061
|
-
|
|
1062
|
-
if (!this.props.multiple) {
|
|
1063
|
-
this._hidePopup(isSelectItemEvent);
|
|
1064
|
-
|
|
1065
|
-
this.setState({
|
|
1066
|
-
selected,
|
|
1067
|
-
selectedIndex: this._getSelectedIndex(selected, this.props.data)
|
|
1068
|
-
}, () => {
|
|
1069
|
-
const newFilterValue = this.isInputMode() && !this.props.hideSelected ? getItemLabel(selected) : '';
|
|
1070
|
-
this.filterValue(newFilterValue);
|
|
1071
|
-
this.props.onFilter(newFilterValue);
|
|
1072
|
-
this.props.onSelect(selected, event);
|
|
1073
|
-
this.props.onChange(selected, event);
|
|
1074
|
-
});
|
|
1075
|
-
} else {
|
|
1076
|
-
const {
|
|
1077
|
-
tryKeepOpen
|
|
1078
|
-
} = opts;
|
|
1079
|
-
|
|
1080
|
-
if (!tryKeepOpen) {
|
|
1081
|
-
this._hidePopup(isSelectItemEvent);
|
|
1082
|
-
}
|
|
1083
|
-
|
|
1084
|
-
if (selected.key == null) {
|
|
1085
|
-
throw new Error('Multiple selection requires each item to have the "key" property');
|
|
1086
|
-
}
|
|
1087
|
-
|
|
1088
|
-
this.setState(prevState => {
|
|
1089
|
-
const currentSelection = prevState.selected;
|
|
1090
|
-
let nextSelection;
|
|
1091
|
-
|
|
1092
|
-
if (!prevState.multipleMap[selected.key]) {
|
|
1093
|
-
nextSelection = currentSelection.concat(selected);
|
|
1094
|
-
this.props.onSelect && this.props.onSelect(selected, event);
|
|
1095
|
-
} else {
|
|
1096
|
-
nextSelection = currentSelection.filter(item => item.key !== selected.key);
|
|
1097
|
-
this.props.onDeselect && this.props.onDeselect(selected);
|
|
1098
|
-
}
|
|
1099
|
-
|
|
1100
|
-
this.props.onChange(nextSelection, event);
|
|
1101
|
-
const nextState = {
|
|
1102
|
-
selected: nextSelection,
|
|
1103
|
-
selectedIndex: this._getSelectedIndex(selected, this.props.data)
|
|
1104
|
-
};
|
|
1105
|
-
|
|
1106
|
-
if (this.props.multiple.limit && nextSelection.length === this.props.multiple.limit) {
|
|
1107
|
-
nextState.shownData = prevState.shownData.map(item => nextSelection.find(selectedItem => selectedItem.key === item.key) ? item : _objectSpread2(_objectSpread2({}, item), {}, {
|
|
1108
|
-
disabled: true
|
|
1109
|
-
}));
|
|
1110
|
-
}
|
|
1111
|
-
|
|
1112
|
-
if (!prevState.multipleMap[selected.key]) {
|
|
1113
|
-
nextState.multipleMap = _objectSpread2(_objectSpread2({}, prevState.multipleMap), {}, {
|
|
1114
|
-
[selected.key]: true
|
|
1115
|
-
});
|
|
1116
|
-
} else {
|
|
1117
|
-
const _prevState$multipleMa = prevState.multipleMap,
|
|
1118
|
-
_selected$key = selected.key,
|
|
1119
|
-
restMultipleMap = _objectWithoutProperties(_prevState$multipleMa, [_selected$key].map(_toPropertyKey));
|
|
1120
|
-
|
|
1121
|
-
nextState.multipleMap = restMultipleMap;
|
|
1122
|
-
}
|
|
1123
|
-
|
|
1124
|
-
return nextState;
|
|
1125
|
-
}, () => {
|
|
1126
|
-
if (tryKeepOpen) {
|
|
1127
|
-
this._redrawPopup();
|
|
1128
|
-
}
|
|
1129
|
-
});
|
|
1130
|
-
}
|
|
1131
|
-
});
|
|
1132
|
-
|
|
1133
|
-
_defineProperty(this, "_listSelectAllHandler", (isSelectAll = true) => {
|
|
1134
|
-
const isItem = List.isItemType.bind(null, List.ListProps.Type.ITEM);
|
|
1135
|
-
const isCustomItem = List.isItemType.bind(null, List.ListProps.Type.CUSTOM);
|
|
1136
|
-
this.setState(prevState => {
|
|
1137
|
-
const currentSelection = prevState.selected;
|
|
1138
|
-
let nextSelection;
|
|
1139
|
-
|
|
1140
|
-
if (isSelectAll) {
|
|
1141
|
-
nextSelection = this.props.data.filter(item => (isItem(item) || isCustomItem(item)) && !item.disabled);
|
|
1142
|
-
nextSelection.filter(item => !this.props.selected.find(selectedItem => item.key === selectedItem.key)).forEach(item => {
|
|
1143
|
-
this.props.onSelect && this.props.onSelect(item);
|
|
1144
|
-
});
|
|
1145
|
-
} else {
|
|
1146
|
-
nextSelection = [];
|
|
1147
|
-
currentSelection.forEach(item => {
|
|
1148
|
-
this.props.onDeselect && this.props.onDeselect(item);
|
|
1149
|
-
});
|
|
1150
|
-
}
|
|
1151
|
-
|
|
1152
|
-
this.props.onChange(nextSelection, event);
|
|
1153
|
-
return {
|
|
1154
|
-
filterValue: '',
|
|
1155
|
-
selected: nextSelection,
|
|
1156
|
-
selectedIndex: isSelectAll ? this._getSelectedIndex(nextSelection, this.props.data) : null,
|
|
1157
|
-
shownData: prevState.shownData.map(item => _objectSpread2(_objectSpread2({}, item), {}, {
|
|
1158
|
-
checkbox: isSelectAll
|
|
1159
|
-
})),
|
|
1160
|
-
multipleMap: isSelectAll ? buildMultipleMap(this.props.data.filter(item => !item.disabled)) : {}
|
|
1161
|
-
};
|
|
1162
|
-
}, this._redrawPopup);
|
|
1163
|
-
});
|
|
1164
|
-
|
|
1165
|
-
_defineProperty(this, "_onCloseAttempt", (event, isEsc) => {
|
|
1166
|
-
if (this.isInputMode()) {
|
|
1167
|
-
if (!this.props.allowAny) {
|
|
1168
|
-
if (this.props.hideSelected || !this.state.selected || this.props.multiple) {
|
|
1169
|
-
this.clearFilter();
|
|
1170
|
-
} else if (this.state.selected) {
|
|
1171
|
-
this.filterValue(getItemLabel(this.state.selected));
|
|
1172
|
-
}
|
|
1173
|
-
}
|
|
1174
|
-
}
|
|
1175
|
-
|
|
1176
|
-
const isTagRemoved = this.props.tags && event && event.target && event.target.matches('[data-test="ring-tag-remove"]');
|
|
1177
|
-
|
|
1178
|
-
if (!isTagRemoved) {
|
|
1179
|
-
this._hidePopup(isEsc);
|
|
1180
|
-
}
|
|
1181
|
-
});
|
|
1182
|
-
|
|
1183
|
-
_defineProperty(this, "clearFilter", e => {
|
|
1184
|
-
this._setFilter('', e);
|
|
1185
|
-
});
|
|
1186
|
-
|
|
1187
|
-
_defineProperty(this, "clear", event => {
|
|
1188
|
-
if (event) {
|
|
1189
|
-
event.stopPropagation();
|
|
1190
|
-
}
|
|
1191
|
-
|
|
1192
|
-
const empty = Select._getEmptyValue(this.props.multiple);
|
|
1193
|
-
|
|
1194
|
-
this.setState({
|
|
1195
|
-
selected: empty,
|
|
1196
|
-
selectedIndex: null,
|
|
1197
|
-
filterValue: ''
|
|
1198
|
-
}, () => {
|
|
1199
|
-
if (this.props.onChange) {
|
|
1200
|
-
this.props.onChange(empty, event);
|
|
1201
|
-
}
|
|
1202
|
-
});
|
|
1203
|
-
return false;
|
|
1204
|
-
});
|
|
1205
|
-
|
|
1206
|
-
_defineProperty(this, "popupRef", el => {
|
|
1207
|
-
this._popup = el;
|
|
1208
|
-
});
|
|
1209
|
-
|
|
1210
|
-
_defineProperty(this, "buttonRef", el => {
|
|
1211
|
-
this.button = el;
|
|
1212
|
-
});
|
|
1213
|
-
|
|
1214
|
-
_defineProperty(this, "filterRef", el => {
|
|
1215
|
-
this.filter = el;
|
|
1216
|
-
});
|
|
1217
|
-
}
|
|
1218
|
-
|
|
1219
|
-
static _getEmptyValue(multiple) {
|
|
1220
|
-
return multiple ? [] : null;
|
|
1221
|
-
}
|
|
1222
|
-
|
|
1223
|
-
static getDerivedStateFromProps(nextProps, prevState) {
|
|
1224
|
-
const {
|
|
1225
|
-
multiple,
|
|
1226
|
-
data,
|
|
1227
|
-
type
|
|
1228
|
-
} = nextProps;
|
|
1229
|
-
const {
|
|
1230
|
-
prevSelected,
|
|
1231
|
-
prevData,
|
|
1232
|
-
prevMultiple,
|
|
1233
|
-
filterValue
|
|
1234
|
-
} = prevState;
|
|
1235
|
-
const nextState = {
|
|
1236
|
-
prevData: data,
|
|
1237
|
-
prevSelected: nextProps.selected,
|
|
1238
|
-
prevMultiple: multiple
|
|
1239
|
-
};
|
|
1240
|
-
|
|
1241
|
-
if ('data' in nextProps && data !== prevData) {
|
|
1242
|
-
const {
|
|
1243
|
-
filteredData,
|
|
1244
|
-
addButton
|
|
1245
|
-
} = getListItems(nextProps, prevState, filterValue, data);
|
|
1246
|
-
Object.assign(nextState, {
|
|
1247
|
-
shownData: filteredData,
|
|
1248
|
-
addButton
|
|
1249
|
-
});
|
|
1250
|
-
|
|
1251
|
-
if (prevState.selected) {
|
|
1252
|
-
Object.assign(nextState, {
|
|
1253
|
-
selectedIndex: getSelectedIndex(prevState.selected, data, multiple),
|
|
1254
|
-
prevFilterValue: getValueForFilter(prevState.selected, type, filterValue)
|
|
1255
|
-
});
|
|
1256
|
-
}
|
|
1257
|
-
}
|
|
1258
|
-
|
|
1259
|
-
if ('selected' in nextProps && nextProps.selected !== prevSelected) {
|
|
1260
|
-
const selected = nextProps.selected || Select._getEmptyValue(multiple);
|
|
1261
|
-
|
|
1262
|
-
const selectedIndex = getSelectedIndex(selected, data || prevData, multiple);
|
|
1263
|
-
Object.assign(nextState, {
|
|
1264
|
-
selected,
|
|
1265
|
-
prevFilterValue: getValueForFilter(selected, type, filterValue)
|
|
1266
|
-
});
|
|
1267
|
-
|
|
1268
|
-
if (!multiple || !isSameSelected(prevSelected, selected)) {
|
|
1269
|
-
Object.assign(nextState, {
|
|
1270
|
-
selectedIndex
|
|
1271
|
-
});
|
|
1272
|
-
}
|
|
1273
|
-
}
|
|
1274
|
-
|
|
1275
|
-
if (prevMultiple !== multiple && !deepEqual(prevMultiple, multiple)) {
|
|
1276
|
-
nextState.selected = Select._getEmptyValue(multiple);
|
|
1277
|
-
}
|
|
1278
|
-
|
|
1279
|
-
const {
|
|
1280
|
-
selected
|
|
1281
|
-
} = _objectSpread2(_objectSpread2({}, prevState), nextState);
|
|
1282
|
-
|
|
1283
|
-
if (selected && multiple) {
|
|
1284
|
-
nextState.multipleMap = buildMultipleMap(selected);
|
|
1285
|
-
const {
|
|
1286
|
-
filteredData,
|
|
1287
|
-
addButton
|
|
1288
|
-
} = getListItems(nextProps, nextState, filterValue, data);
|
|
1289
|
-
Object.assign(nextState, {
|
|
1290
|
-
shownData: filteredData,
|
|
1291
|
-
addButton
|
|
1292
|
-
});
|
|
1293
|
-
}
|
|
1294
|
-
|
|
1295
|
-
return nextState;
|
|
1296
|
-
}
|
|
1297
|
-
|
|
1298
|
-
componentDidUpdate(prevProps, prevState) {
|
|
1299
|
-
const {
|
|
1300
|
-
showPopup,
|
|
1301
|
-
selected
|
|
1302
|
-
} = this.state;
|
|
1303
|
-
const {
|
|
1304
|
-
onClose,
|
|
1305
|
-
onOpen,
|
|
1306
|
-
onChange,
|
|
1307
|
-
multiple
|
|
1308
|
-
} = this.props;
|
|
1309
|
-
|
|
1310
|
-
if (prevState.showPopup && !showPopup) {
|
|
1311
|
-
onClose(selected);
|
|
1312
|
-
} else if (!prevState.showPopup && showPopup) {
|
|
1313
|
-
onOpen();
|
|
1314
|
-
}
|
|
1315
|
-
|
|
1316
|
-
if (multiple !== prevProps.multiple && !deepEqual(multiple, prevProps.multiple)) {
|
|
1317
|
-
onChange(selected);
|
|
1318
|
-
}
|
|
1319
|
-
}
|
|
1320
|
-
|
|
1321
|
-
getValueForFilter(selected) {
|
|
1322
|
-
return getValueForFilter(selected, this.props.type, this.state.filterValue);
|
|
1323
|
-
}
|
|
1324
|
-
|
|
1325
|
-
_getSelectedIndex(selected, data) {
|
|
1326
|
-
return getSelectedIndex(selected, data, this.props.multiple);
|
|
1327
|
-
}
|
|
1328
|
-
|
|
1329
|
-
_getResetOption() {
|
|
1330
|
-
const isOptionsSelected = this.state.selected && this.state.selected.length;
|
|
1331
|
-
const hasTagsResetProp = this.props.tags && this.props.tags.reset;
|
|
1332
|
-
|
|
1333
|
-
if (!isOptionsSelected || !hasTagsResetProp) {
|
|
1334
|
-
return null;
|
|
1335
|
-
}
|
|
1336
|
-
|
|
1337
|
-
const {
|
|
1338
|
-
reset
|
|
1339
|
-
} = this.props.tags;
|
|
1340
|
-
|
|
1341
|
-
const resetHandler = (item, event) => {
|
|
1342
|
-
this.clear(event);
|
|
1343
|
-
this.clearFilter();
|
|
1344
|
-
this.props.onFilter('');
|
|
1345
|
-
this.setState(prevState => ({
|
|
1346
|
-
shownData: prevState.shownData.slice(reset.separator ? 2 : 1),
|
|
1347
|
-
multipleMap: {}
|
|
1348
|
-
}));
|
|
1349
|
-
|
|
1350
|
-
this._redrawPopup();
|
|
1351
|
-
};
|
|
1352
|
-
|
|
1353
|
-
return {
|
|
1354
|
-
isResetItem: true,
|
|
1355
|
-
separator: reset.separator,
|
|
1356
|
-
key: reset.label,
|
|
1357
|
-
rgItemType: List.ListProps.Type.CUSTOM,
|
|
1358
|
-
template: /*#__PURE__*/React.createElement(Button, {
|
|
1359
|
-
text: true,
|
|
1360
|
-
className: modules_9d0de074.button,
|
|
1361
|
-
"data-test": "ring-select-reset-tags-button"
|
|
1362
|
-
}, reset.label),
|
|
1363
|
-
glyph: reset.glyph,
|
|
1364
|
-
onClick: resetHandler
|
|
1365
|
-
};
|
|
1366
|
-
}
|
|
1367
|
-
|
|
1368
|
-
_prependResetOption(shownData) {
|
|
1369
|
-
const resetOption = this._getResetOption();
|
|
1370
|
-
|
|
1371
|
-
const margin = {
|
|
1372
|
-
rgItemType: List.ListProps.Type.MARGIN
|
|
1373
|
-
};
|
|
1374
|
-
|
|
1375
|
-
if (resetOption) {
|
|
1376
|
-
const resetItems = [margin, resetOption, margin];
|
|
1377
|
-
|
|
1378
|
-
if (resetOption.separator) {
|
|
1379
|
-
resetItems.push({
|
|
1380
|
-
rgItemType: List.ListProps.Type.SEPARATOR
|
|
1381
|
-
});
|
|
1382
|
-
}
|
|
1383
|
-
|
|
1384
|
-
return resetItems.concat(shownData);
|
|
1385
|
-
}
|
|
1386
|
-
|
|
1387
|
-
return shownData;
|
|
1388
|
-
}
|
|
1389
|
-
|
|
1390
|
-
_renderPopup() {
|
|
1391
|
-
const anchorElement = this.props.targetElement || this.node;
|
|
1392
|
-
const {
|
|
1393
|
-
showPopup,
|
|
1394
|
-
shownData
|
|
1395
|
-
} = this.state;
|
|
1396
|
-
|
|
1397
|
-
const _shownData = this._prependResetOption(shownData);
|
|
1398
|
-
|
|
1399
|
-
let message = null;
|
|
1400
|
-
|
|
1401
|
-
if (this.props.loading) {
|
|
1402
|
-
message = this.props.loadingMessage;
|
|
1403
|
-
} else if (!shownData.length) {
|
|
1404
|
-
message = this.props.notFoundMessage;
|
|
1405
|
-
}
|
|
1406
|
-
|
|
1407
|
-
return /*#__PURE__*/React.createElement(SelectPopup, {
|
|
1408
|
-
data: _shownData,
|
|
1409
|
-
message: message,
|
|
1410
|
-
toolbar: showPopup && this.getToolbar(),
|
|
1411
|
-
loading: this.props.loading,
|
|
1412
|
-
activeIndex: this.state.selectedIndex,
|
|
1413
|
-
hidden: !showPopup,
|
|
1414
|
-
ref: this.popupRef,
|
|
1415
|
-
maxHeight: this.props.maxHeight,
|
|
1416
|
-
minWidth: this.props.minWidth,
|
|
1417
|
-
directions: this.props.directions,
|
|
1418
|
-
className: this.props.popupClassName,
|
|
1419
|
-
style: this.props.popupStyle,
|
|
1420
|
-
top: this.props.top,
|
|
1421
|
-
left: this.props.left,
|
|
1422
|
-
filter: this.isInputMode() ? false : this.props.filter // disable popup filter in INPUT mode
|
|
1423
|
-
,
|
|
1424
|
-
multiple: this.props.multiple,
|
|
1425
|
-
filterValue: this.state.filterValue,
|
|
1426
|
-
anchorElement: anchorElement,
|
|
1427
|
-
onCloseAttempt: this._onCloseAttempt,
|
|
1428
|
-
onSelect: this._listSelectHandler,
|
|
1429
|
-
onSelectAll: this._listSelectAllHandler,
|
|
1430
|
-
onFilter: this._filterChangeHandler,
|
|
1431
|
-
onClear: this.clearFilter,
|
|
1432
|
-
onLoadMore: this.props.onLoadMore,
|
|
1433
|
-
isInputMode: this.isInputMode(),
|
|
1434
|
-
selected: this.state.selected,
|
|
1435
|
-
tags: this.props.tags,
|
|
1436
|
-
compact: this.props.compact,
|
|
1437
|
-
renderOptimization: this.props.renderOptimization,
|
|
1438
|
-
ringPopupTarget: this.props.ringPopupTarget,
|
|
1439
|
-
disableMoveOverflow: this.props.disableMoveOverflow,
|
|
1440
|
-
disableScrollToActive: this.props.disableScrollToActive,
|
|
1441
|
-
dir: this.props.dir,
|
|
1442
|
-
onEmptyPopupEnter: this.onEmptyPopupEnter,
|
|
1443
|
-
listId: this.listId
|
|
1444
|
-
});
|
|
1445
|
-
}
|
|
1446
|
-
|
|
1447
|
-
_showPopup() {
|
|
1448
|
-
if (!this.node) {
|
|
1449
|
-
return;
|
|
1450
|
-
}
|
|
1451
|
-
|
|
1452
|
-
const shownData = this.getListItems(this.filterValue());
|
|
1453
|
-
this.setState({
|
|
1454
|
-
showPopup: !!shownData.length || !this.props.allowAny,
|
|
1455
|
-
shownData
|
|
1456
|
-
});
|
|
1457
|
-
}
|
|
1458
|
-
|
|
1459
|
-
_hidePopup(tryFocusAnchor) {
|
|
1460
|
-
if (this.node && this.state.showPopup) {
|
|
1461
|
-
this.setState({
|
|
1462
|
-
showPopup: false,
|
|
1463
|
-
filterValue: ''
|
|
1464
|
-
});
|
|
1465
|
-
|
|
1466
|
-
if (tryFocusAnchor) {
|
|
1467
|
-
const restoreFocusNode = this.props.targetElement || this.node.querySelector('[data-test~=ring-select__focus]');
|
|
1468
|
-
|
|
1469
|
-
if (restoreFocusNode) {
|
|
1470
|
-
restoreFocusNode.focus();
|
|
1471
|
-
}
|
|
1472
|
-
}
|
|
1473
|
-
}
|
|
1474
|
-
}
|
|
1475
|
-
|
|
1476
|
-
getToolbar() {
|
|
1477
|
-
const {
|
|
1478
|
-
hint
|
|
1479
|
-
} = this.props;
|
|
1480
|
-
const {
|
|
1481
|
-
prefix,
|
|
1482
|
-
label,
|
|
1483
|
-
delayed
|
|
1484
|
-
} = this.state.addButton || {};
|
|
1485
|
-
const isToolbarHasElements = this.state.addButton || hint;
|
|
1486
|
-
|
|
1487
|
-
if (!isToolbarHasElements) {
|
|
1488
|
-
return null;
|
|
1489
|
-
}
|
|
1490
|
-
|
|
1491
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
1492
|
-
className: classNames({
|
|
1493
|
-
[modules_9d0de074.toolbar]: !!this.state.addButton
|
|
1494
|
-
}),
|
|
1495
|
-
"data-test": "ring-select-toolbar"
|
|
1496
|
-
}, this.state.addButton && /*#__PURE__*/React.createElement(Button, {
|
|
1497
|
-
text: true,
|
|
1498
|
-
delayed: delayed,
|
|
1499
|
-
className: classNames(modules_9d0de074.button, modules_9d0de074.buttonSpaced),
|
|
1500
|
-
onClick: this.addHandler,
|
|
1501
|
-
"data-test": "ring-select-toolbar-button"
|
|
1502
|
-
}, prefix ? `${prefix} ${label}` : label), hint && /*#__PURE__*/React.createElement(List.ListHint, {
|
|
1503
|
-
label: hint,
|
|
1504
|
-
"data-test": "ring-select-toolbar-hint"
|
|
1505
|
-
}));
|
|
1506
|
-
}
|
|
1507
|
-
|
|
1508
|
-
getFilterFn() {
|
|
1509
|
-
return getFilterFn(this.props.filter);
|
|
1510
|
-
}
|
|
1511
|
-
|
|
1512
|
-
getListItems(rawFilterString, data) {
|
|
1513
|
-
const {
|
|
1514
|
-
filteredData,
|
|
1515
|
-
addButton
|
|
1516
|
-
} = getListItems(this.props, this.state, rawFilterString, data);
|
|
1517
|
-
this.setState({
|
|
1518
|
-
addButton
|
|
1519
|
-
});
|
|
1520
|
-
return filteredData;
|
|
1521
|
-
}
|
|
1522
|
-
|
|
1523
|
-
filterValue(setValue) {
|
|
1524
|
-
if (typeof setValue === 'string' || typeof setValue === 'number') {
|
|
1525
|
-
this.setState({
|
|
1526
|
-
filterValue: setValue
|
|
1527
|
-
});
|
|
1528
|
-
} else {
|
|
1529
|
-
return this.state.filterValue;
|
|
1530
|
-
}
|
|
1531
|
-
|
|
1532
|
-
return undefined;
|
|
1533
|
-
}
|
|
1534
|
-
|
|
1535
|
-
isInputMode() {
|
|
1536
|
-
return isInputMode(this.props.type);
|
|
1537
|
-
}
|
|
1538
|
-
|
|
1539
|
-
_rebuildMultipleMap(selected, multiple) {
|
|
1540
|
-
if (selected && multiple) {
|
|
1541
|
-
this.setState({
|
|
1542
|
-
multipleMap: buildMultipleMap(selected)
|
|
1543
|
-
});
|
|
1544
|
-
}
|
|
1545
|
-
}
|
|
1546
|
-
|
|
1547
|
-
_selectionIsEmpty() {
|
|
1548
|
-
return this.props.multiple && !this.state.selected.length || !this.state.selected;
|
|
1549
|
-
}
|
|
1550
|
-
|
|
1551
|
-
_getLabel() {
|
|
1552
|
-
return this.props.label || this.props.selectedLabel || 'Select an option';
|
|
1553
|
-
}
|
|
1554
|
-
|
|
1555
|
-
_getSelectedString() {
|
|
1556
|
-
if (this.props.multiple) {
|
|
1557
|
-
const labels = [];
|
|
1558
|
-
|
|
1559
|
-
for (let i = 0; i < this.state.selected.length; i++) {
|
|
1560
|
-
labels.push(getItemLabel(this.state.selected[i]));
|
|
1561
|
-
}
|
|
1562
|
-
|
|
1563
|
-
return labels.filter(Boolean).join(', ');
|
|
1564
|
-
} else {
|
|
1565
|
-
return getItemLabel(this.state.selected);
|
|
1566
|
-
}
|
|
1567
|
-
}
|
|
1568
|
-
|
|
1569
|
-
_getIcons() {
|
|
1570
|
-
const {
|
|
1571
|
-
selected
|
|
1572
|
-
} = this.state;
|
|
1573
|
-
const {
|
|
1574
|
-
disabled,
|
|
1575
|
-
clear,
|
|
1576
|
-
hideArrow
|
|
1577
|
-
} = this.props;
|
|
1578
|
-
const icons = [];
|
|
1579
|
-
|
|
1580
|
-
if (selected !== null && selected !== void 0 && selected.icon) {
|
|
1581
|
-
icons.push( /*#__PURE__*/React.createElement("button", {
|
|
1582
|
-
title: "Toggle options popup",
|
|
1583
|
-
type: "button",
|
|
1584
|
-
className: modules_9d0de074.selectedIcon,
|
|
1585
|
-
key: "selected",
|
|
1586
|
-
onClick: this._clickHandler,
|
|
1587
|
-
style: {
|
|
1588
|
-
backgroundImage: `url(${selected.icon})`
|
|
1589
|
-
}
|
|
1590
|
-
}));
|
|
1591
|
-
}
|
|
1592
|
-
|
|
1593
|
-
if (clear && !disabled && !this._selectionIsEmpty()) {
|
|
1594
|
-
icons.push( /*#__PURE__*/React.createElement(Button, {
|
|
1595
|
-
title: "Clear selection",
|
|
1596
|
-
"data-test": "ring-clear-select",
|
|
1597
|
-
className: modules_9d0de074.clearIcon,
|
|
1598
|
-
key: "close",
|
|
1599
|
-
onClick: this.clear,
|
|
1600
|
-
icon: closeIcon
|
|
1601
|
-
}));
|
|
1602
|
-
}
|
|
1603
|
-
|
|
1604
|
-
if (!hideArrow) {
|
|
1605
|
-
icons.push( /*#__PURE__*/React.createElement(Button, {
|
|
1606
|
-
title: "Toggle options popup",
|
|
1607
|
-
className: modules_9d0de074.chevron,
|
|
1608
|
-
iconClassName: modules_9d0de074.chevronIcon,
|
|
1609
|
-
icon: chevronDown,
|
|
1610
|
-
key: "hide",
|
|
1611
|
-
onClick: this._clickHandler
|
|
1612
|
-
}));
|
|
1613
|
-
}
|
|
1614
|
-
|
|
1615
|
-
return icons;
|
|
1616
|
-
}
|
|
1617
|
-
|
|
1618
|
-
_getAvatar() {
|
|
1619
|
-
return this.state.selected && this.state.selected.avatar && /*#__PURE__*/React.createElement(Avatar, {
|
|
1620
|
-
className: modules_9d0de074.avatar,
|
|
1621
|
-
url: this.state.selected.avatar,
|
|
1622
|
-
size: Size.Size20
|
|
1623
|
-
});
|
|
1624
|
-
}
|
|
1625
|
-
|
|
1626
|
-
getShortcutsMap() {
|
|
1627
|
-
return {
|
|
1628
|
-
enter: this._onEnter,
|
|
1629
|
-
esc: this._onEsc,
|
|
1630
|
-
up: this._inputShortcutHandler,
|
|
1631
|
-
down: this._inputShortcutHandler,
|
|
1632
|
-
right: noop,
|
|
1633
|
-
left: noop,
|
|
1634
|
-
'shift+up': noop,
|
|
1635
|
-
'shift+down': noop,
|
|
1636
|
-
space: noop
|
|
1637
|
-
};
|
|
1638
|
-
}
|
|
1639
|
-
|
|
1640
|
-
renderSelect(activeItemId) {
|
|
1641
|
-
var _this$_popup, _this$_popup$list;
|
|
1642
|
-
|
|
1643
|
-
const dataTest = this.props['data-test'];
|
|
1644
|
-
const {
|
|
1645
|
-
shortcutsEnabled
|
|
1646
|
-
} = this.state;
|
|
1647
|
-
const classes = classNames(modules_9d0de074.select, 'ring-js-shortcuts', this.props.className, {
|
|
1648
|
-
[modules_9d0de074[`size${this.props.size}`]]: this.props.type !== Type.INLINE,
|
|
1649
|
-
[modules_9d0de074.disabled]: this.props.disabled
|
|
1650
|
-
});
|
|
1651
|
-
|
|
1652
|
-
const icons = this._getIcons();
|
|
1653
|
-
|
|
1654
|
-
const style = getStyle(icons.length);
|
|
1655
|
-
const iconsNode = /*#__PURE__*/React.createElement("span", {
|
|
1656
|
-
className: modules_9d0de074.icons
|
|
1657
|
-
}, icons);
|
|
1658
|
-
const ariaProps = this.state.showPopup ? {
|
|
1659
|
-
'aria-owns': this.listId,
|
|
1660
|
-
'aria-activedescendant': activeItemId
|
|
1661
|
-
} : {};
|
|
1662
|
-
|
|
1663
|
-
switch (this.props.type) {
|
|
1664
|
-
case Type.INPUT_WITHOUT_CONTROLS:
|
|
1665
|
-
case Type.INPUT:
|
|
1666
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
1667
|
-
ref: this.nodeRef,
|
|
1668
|
-
className: classNames(classes, modules_9d0de074.inputMode),
|
|
1669
|
-
"data-test": joinDataTestAttributes('ring-select', dataTest)
|
|
1670
|
-
}, shortcutsEnabled && /*#__PURE__*/React.createElement(Shortcuts, {
|
|
1671
|
-
map: this.getShortcutsMap(),
|
|
1672
|
-
scope: this.shortcutsScope
|
|
1673
|
-
}), /*#__PURE__*/React.createElement(Input, _extends({}, ariaProps, {
|
|
1674
|
-
autoComplete: "off",
|
|
1675
|
-
id: this.props.id,
|
|
1676
|
-
onClick: this._clickHandler,
|
|
1677
|
-
inputRef: this.filterRef,
|
|
1678
|
-
disabled: this.props.disabled,
|
|
1679
|
-
value: this.state.filterValue,
|
|
1680
|
-
borderless: this.props.type === Type.INPUT_WITHOUT_CONTROLS,
|
|
1681
|
-
style: style,
|
|
1682
|
-
size: Size$1.FULL,
|
|
1683
|
-
onChange: this._filterChangeHandler,
|
|
1684
|
-
onFocus: this._focusHandler,
|
|
1685
|
-
onBlur: this._blurHandler,
|
|
1686
|
-
label: this.props.type === Type.INPUT ? this._getLabel() : null,
|
|
1687
|
-
placeholder: this.props.inputPlaceholder,
|
|
1688
|
-
onKeyDown: this.props.onKeyDown,
|
|
1689
|
-
"data-test": "ring-select__focus",
|
|
1690
|
-
enableShortcuts: shortcutsEnabled ? Object.keys(_objectSpread2(_objectSpread2({}, this.getShortcutsMap()), (_this$_popup = this._popup) === null || _this$_popup === void 0 ? void 0 : (_this$_popup$list = _this$_popup.list) === null || _this$_popup$list === void 0 ? void 0 : _this$_popup$list.shortcutsMap)) : undefined
|
|
1691
|
-
})), this.props.type === Type.INPUT && iconsNode, this._renderPopup());
|
|
1692
|
-
|
|
1693
|
-
case Type.BUTTON:
|
|
1694
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
1695
|
-
ref: this.nodeRef,
|
|
1696
|
-
className: classNames(classes, modules_9d0de074.buttonMode),
|
|
1697
|
-
"data-test": joinDataTestAttributes('ring-select', dataTest)
|
|
1698
|
-
}, shortcutsEnabled && /*#__PURE__*/React.createElement(Shortcuts, {
|
|
1699
|
-
map: this.getShortcutsMap(),
|
|
1700
|
-
scope: this.shortcutsScope
|
|
1701
|
-
}), /*#__PURE__*/React.createElement(ThemeContext.Consumer, null, contextTheme => /*#__PURE__*/React.createElement("div", _extends({}, ariaProps, {
|
|
1702
|
-
id: this.props.id,
|
|
1703
|
-
onClick: this._clickHandler,
|
|
1704
|
-
onKeyPress: this._selectButtonKeyboardHack,
|
|
1705
|
-
className: classNames(modules_e81895c9.button, modules_e81895c9[this.props.theme || contextTheme || Theme.LIGHT], modules_9d0de074.buttonValue, {
|
|
1706
|
-
[modules_9d0de074.buttonValueOpen]: this.state.showPopup
|
|
1707
|
-
}),
|
|
1708
|
-
role: "button",
|
|
1709
|
-
tabIndex: 0,
|
|
1710
|
-
disabled: this.props.disabled,
|
|
1711
|
-
style: style,
|
|
1712
|
-
"data-test": "ring-select__button ring-select__focus"
|
|
1713
|
-
}), this._getAvatar(), this._selectionIsEmpty() ? this._getLabel() : this._getSelectedString(), iconsNode)), this._renderPopup());
|
|
1714
|
-
|
|
1715
|
-
case Type.MATERIAL:
|
|
1716
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
1717
|
-
ref: this.nodeRef,
|
|
1718
|
-
className: classNames(classes, modules_9d0de074.materialMode),
|
|
1719
|
-
"data-test": joinDataTestAttributes('ring-select', dataTest)
|
|
1720
|
-
}, shortcutsEnabled && /*#__PURE__*/React.createElement(Shortcuts, {
|
|
1721
|
-
map: this.getShortcutsMap(),
|
|
1722
|
-
scope: this.shortcutsScope
|
|
1723
|
-
}), !this._selectionIsEmpty() && this.props.selectedLabel && /*#__PURE__*/React.createElement("span", {
|
|
1724
|
-
className: modules_9d0de074.selectedLabel
|
|
1725
|
-
}, this.props.selectedLabel), /*#__PURE__*/React.createElement("button", _extends({}, ariaProps, {
|
|
1726
|
-
id: this.props.id,
|
|
1727
|
-
onClick: this._clickHandler,
|
|
1728
|
-
type: "button",
|
|
1729
|
-
disabled: this.props.disabled,
|
|
1730
|
-
className: classNames(modules_9d0de074.value, {
|
|
1731
|
-
[modules_9d0de074.open]: this.state.showPopup,
|
|
1732
|
-
[modules_9d0de074.label]: this._selectionIsEmpty()
|
|
1733
|
-
}),
|
|
1734
|
-
"aria-label": this._getLabel(),
|
|
1735
|
-
style: style,
|
|
1736
|
-
"data-test": "ring-select__focus",
|
|
1737
|
-
ref: this.buttonRef
|
|
1738
|
-
}), this._getAvatar(), this._selectionIsEmpty() ? this._getLabel() : this._getSelectedString()), iconsNode, this._renderPopup());
|
|
1739
|
-
|
|
1740
|
-
case Type.INLINE:
|
|
1741
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
1742
|
-
className: classes,
|
|
1743
|
-
ref: this.nodeRef,
|
|
1744
|
-
"data-test": joinDataTestAttributes('ring-select', dataTest)
|
|
1745
|
-
}, shortcutsEnabled && /*#__PURE__*/React.createElement(Shortcuts, {
|
|
1746
|
-
map: this.getShortcutsMap(),
|
|
1747
|
-
scope: this.shortcutsScope
|
|
1748
|
-
}), /*#__PURE__*/React.createElement(Anchor, _extends({}, ariaProps, {
|
|
1749
|
-
id: this.props.id,
|
|
1750
|
-
onClick: this._clickHandler,
|
|
1751
|
-
"data-test": "ring-select__focus",
|
|
1752
|
-
disabled: this.props.disabled,
|
|
1753
|
-
active: this.state.showPopup
|
|
1754
|
-
}), this._selectionIsEmpty() ? this._getLabel() : this._getSelectedString()), this._renderPopup());
|
|
1755
|
-
|
|
1756
|
-
default:
|
|
1757
|
-
if (this.props.customAnchor) {
|
|
1758
|
-
return /*#__PURE__*/React.createElement(Fragment, null, shortcutsEnabled && /*#__PURE__*/React.createElement(Shortcuts, {
|
|
1759
|
-
map: this.getShortcutsMap(),
|
|
1760
|
-
scope: this.shortcutsScope
|
|
1761
|
-
}), this.props.customAnchor({
|
|
1762
|
-
wrapperProps: {
|
|
1763
|
-
ref: this.nodeRef,
|
|
1764
|
-
'data-test': joinDataTestAttributes('ring-select', dataTest)
|
|
1765
|
-
},
|
|
1766
|
-
buttonProps: _objectSpread2(_objectSpread2({}, ariaProps), {}, {
|
|
1767
|
-
id: this.props.id,
|
|
1768
|
-
onClick: this._clickHandler,
|
|
1769
|
-
disabled: this.props.disabled,
|
|
1770
|
-
children: this._selectionIsEmpty() ? this._getLabel() : this._getSelectedString(),
|
|
1771
|
-
'data-test': 'ring-select_focus'
|
|
1772
|
-
}),
|
|
1773
|
-
popup: this._renderPopup()
|
|
1774
|
-
}));
|
|
1775
|
-
}
|
|
1776
|
-
|
|
1777
|
-
return /*#__PURE__*/React.createElement("span", {
|
|
1778
|
-
id: this.props.id,
|
|
1779
|
-
ref: this.nodeRef,
|
|
1780
|
-
"data-test": "ring-select"
|
|
1781
|
-
}, this._renderPopup());
|
|
1782
|
-
}
|
|
1783
|
-
}
|
|
1784
|
-
|
|
1785
|
-
render() {
|
|
1786
|
-
return /*#__PURE__*/React.createElement(ActiveItemContext.Provider, null, /*#__PURE__*/React.createElement(ActiveItemContext.ValueContext.Consumer, null, activeItemId => this.renderSelect(activeItemId)));
|
|
1787
|
-
}
|
|
1788
|
-
|
|
1789
|
-
}
|
|
1790
|
-
|
|
1791
|
-
_defineProperty(Select, "propTypes", {
|
|
1792
|
-
className: PropTypes.string,
|
|
1793
|
-
id: PropTypes.string,
|
|
1794
|
-
multiple: PropTypes.oneOfType([PropTypes.bool, PropTypes.object]),
|
|
1795
|
-
allowAny: PropTypes.bool,
|
|
1796
|
-
filter: PropTypes.oneOfType([PropTypes.bool, PropTypes.object]),
|
|
1797
|
-
getInitial: PropTypes.func,
|
|
1798
|
-
onClose: PropTypes.func,
|
|
1799
|
-
onOpen: PropTypes.func,
|
|
1800
|
-
onDone: PropTypes.func,
|
|
1801
|
-
onFilter: PropTypes.func,
|
|
1802
|
-
onChange: PropTypes.func,
|
|
1803
|
-
onReset: PropTypes.func,
|
|
1804
|
-
onLoadMore: PropTypes.func,
|
|
1805
|
-
onAdd: PropTypes.func,
|
|
1806
|
-
onBeforeOpen: PropTypes.func,
|
|
1807
|
-
onSelect: PropTypes.func,
|
|
1808
|
-
onDeselect: PropTypes.func,
|
|
1809
|
-
onFocus: PropTypes.func,
|
|
1810
|
-
onBlur: PropTypes.func,
|
|
1811
|
-
onKeyDown: PropTypes.func,
|
|
1812
|
-
selected: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
|
|
1813
|
-
data: PropTypes.array,
|
|
1814
|
-
tags: PropTypes.object,
|
|
1815
|
-
targetElement: PropTypes.object,
|
|
1816
|
-
loading: PropTypes.bool,
|
|
1817
|
-
loadingMessage: PropTypes.string,
|
|
1818
|
-
notFoundMessage: PropTypes.string,
|
|
1819
|
-
maxHeight: PropTypes.number,
|
|
1820
|
-
minWidth: PropTypes.number,
|
|
1821
|
-
directions: PropTypes.array,
|
|
1822
|
-
popupClassName: PropTypes.string,
|
|
1823
|
-
popupStyle: PropTypes.object,
|
|
1824
|
-
top: PropTypes.number,
|
|
1825
|
-
left: PropTypes.number,
|
|
1826
|
-
renderOptimization: PropTypes.bool,
|
|
1827
|
-
ringPopupTarget: PropTypes.string,
|
|
1828
|
-
hint: List.ListHint.propTypes.label,
|
|
1829
|
-
add: PropTypes.object,
|
|
1830
|
-
type: PropTypes.oneOf(Object.values(Type)),
|
|
1831
|
-
disabled: PropTypes.bool,
|
|
1832
|
-
hideSelected: PropTypes.bool,
|
|
1833
|
-
label: PropTypes.string,
|
|
1834
|
-
selectedLabel: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.node), PropTypes.node]),
|
|
1835
|
-
inputPlaceholder: PropTypes.string,
|
|
1836
|
-
clear: PropTypes.bool,
|
|
1837
|
-
hideArrow: PropTypes.bool,
|
|
1838
|
-
compact: PropTypes.bool,
|
|
1839
|
-
size: PropTypes.oneOf(Object.values(Size$1)),
|
|
1840
|
-
theme: PropTypes.string,
|
|
1841
|
-
customAnchor: PropTypes.func,
|
|
1842
|
-
disableMoveOverflow: PropTypes.bool,
|
|
1843
|
-
disableScrollToActive: PropTypes.bool,
|
|
1844
|
-
dir: PropTypes.oneOf(['ltr', 'rtl']),
|
|
1845
|
-
'data-test': PropTypes.string
|
|
1846
|
-
});
|
|
1847
|
-
|
|
1848
|
-
_defineProperty(Select, "defaultProps", {
|
|
1849
|
-
data: [],
|
|
1850
|
-
filter: false,
|
|
1851
|
-
// enable filter (not in INPUT modes)
|
|
1852
|
-
multiple: false,
|
|
1853
|
-
// multiple can be an object - see demo for more information
|
|
1854
|
-
clear: false,
|
|
1855
|
-
// enable clear button that clears the "selected" state
|
|
1856
|
-
loading: false,
|
|
1857
|
-
// show a loading indicator while data is loading
|
|
1858
|
-
disabled: false,
|
|
1859
|
-
// disable select
|
|
1860
|
-
loadingMessage: 'Loading...',
|
|
1861
|
-
notFoundMessage: 'No options found',
|
|
1862
|
-
type: Type.MATERIAL,
|
|
1863
|
-
size: Size$1.M,
|
|
1864
|
-
targetElement: null,
|
|
1865
|
-
// element to bind the popup to (select BUTTON or INPUT by default)
|
|
1866
|
-
hideSelected: false,
|
|
1867
|
-
// INPUT mode: clears the input after an option is selected (useful when the selection is displayed in some custom way elsewhere)
|
|
1868
|
-
allowAny: false,
|
|
1869
|
-
// INPUT mode: allows any value to be entered, hides the dropdown icon
|
|
1870
|
-
hideArrow: false,
|
|
1871
|
-
// hide dropdown arrow icon
|
|
1872
|
-
maxHeight: 600,
|
|
1873
|
-
// height of the options list, including the filter and the 'Add' button
|
|
1874
|
-
directions: [Popup.PopupProps.Directions.BOTTOM_RIGHT, Popup.PopupProps.Directions.BOTTOM_LEFT, Popup.PopupProps.Directions.TOP_LEFT, Popup.PopupProps.Directions.TOP_RIGHT],
|
|
1875
|
-
selected: null,
|
|
1876
|
-
// current selection (item / array of items)
|
|
1877
|
-
label: '',
|
|
1878
|
-
// BUTTON or INPUT label (nothing selected)
|
|
1879
|
-
selectedLabel: '',
|
|
1880
|
-
// BUTTON or INPUT label (something selected)
|
|
1881
|
-
inputPlaceholder: '',
|
|
1882
|
-
// Placeholder for input modes
|
|
1883
|
-
hint: null,
|
|
1884
|
-
// hint text to display under the list
|
|
1885
|
-
shortcutsEnabled: false,
|
|
1886
|
-
onBeforeOpen: noop,
|
|
1887
|
-
onLoadMore: noop,
|
|
1888
|
-
onOpen: noop,
|
|
1889
|
-
onClose: noop,
|
|
1890
|
-
onFilter: noop,
|
|
1891
|
-
// search string as first argument
|
|
1892
|
-
onFocus: noop,
|
|
1893
|
-
onBlur: noop,
|
|
1894
|
-
onKeyDown: noop,
|
|
1895
|
-
onSelect: noop,
|
|
1896
|
-
// single + multi
|
|
1897
|
-
onDeselect: noop,
|
|
1898
|
-
// multi
|
|
1899
|
-
onChange: noop,
|
|
1900
|
-
// multi
|
|
1901
|
-
onAdd: noop,
|
|
1902
|
-
// search string as first argument
|
|
1903
|
-
onDone: noop,
|
|
1904
|
-
onReset: noop,
|
|
1905
|
-
tags: null,
|
|
1906
|
-
onRemoveTag: noop,
|
|
1907
|
-
ringPopupTarget: null,
|
|
1908
|
-
dir: 'ltr'
|
|
1909
|
-
});
|
|
1910
|
-
|
|
1911
|
-
_defineProperty(Select, "Type", Type);
|
|
1912
|
-
|
|
1913
|
-
_defineProperty(Select, "Size", Size$1);
|
|
1914
|
-
|
|
1915
|
-
_defineProperty(Select, "Theme", Theme);
|
|
1916
|
-
|
|
1917
|
-
const RerenderableSelect = rerenderHOC(Select);
|
|
1918
|
-
|
|
1919
|
-
export default Select;
|
|
1920
|
-
export { RerenderableSelect };
|