@jetbrains/ring-ui-built 6.0.30 → 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 +7 -629
- 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/style.css +1 -1
- 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,15 +1,4 @@
|
|
1
|
-
import
|
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.iterator.js';
|
6
|
-
import 'core-js/modules/es.array.map.js';
|
7
|
-
import 'core-js/modules/es.map.js';
|
8
|
-
import 'core-js/modules/es.object.assign.js';
|
9
|
-
import 'core-js/modules/es.object.to-string.js';
|
10
|
-
import 'core-js/modules/es.promise.js';
|
11
|
-
import 'core-js/modules/web.dom-collections.iterator.js';
|
12
|
-
import React, { Component, PureComponent } from 'react';
|
1
|
+
import React, { PureComponent, Component } from 'react';
|
13
2
|
import PropTypes from 'prop-types';
|
14
3
|
import classNames from 'classnames';
|
15
4
|
import getEventKey from '../global/get-event-key.js';
|
@@ -22,20 +11,12 @@ import { S as Size, m as modules_88cfaf40 } from '../_helpers/input.js';
|
|
22
11
|
import { ControlsHeightContext } from '../global/controls-height.js';
|
23
12
|
import getUID from '../global/get-uid.js';
|
24
13
|
import { ControlLabel } from '../control-label/control-label.js';
|
25
|
-
import '
|
26
|
-
import 'core-js/modules/es.array.reduce.js';
|
27
|
-
import 'core-js/modules/es.array.slice.js';
|
28
|
-
import 'core-js/modules/es.object.values.js';
|
29
|
-
import 'core-js/modules/es.regexp.exec.js';
|
30
|
-
import 'core-js/modules/es.string.replace.js';
|
31
|
-
import 'core-js/modules/es.string.trim.js';
|
32
|
-
import 'core-js/modules/web.dom-collections.for-each.js';
|
14
|
+
import '../_helpers/_rollupPluginBabelHelpers.js';
|
33
15
|
import '@jetbrains/icons/chevron-down';
|
34
16
|
import '@jetbrains/icons/close-12px';
|
35
17
|
import 'deep-equal';
|
36
18
|
import '../dropdown/dropdown.js';
|
37
19
|
import '../global/data-tests.js';
|
38
|
-
import 'core-js/modules/es.object.entries.js';
|
39
20
|
import '../global/typescript-utils.js';
|
40
21
|
import '../_helpers/anchor.js';
|
41
22
|
import '@jetbrains/icons/chevron-10px';
|
@@ -43,40 +24,26 @@ import '../icon/icon.js';
|
|
43
24
|
import 'util-deprecate';
|
44
25
|
import '../icon/icon__constants.js';
|
45
26
|
import '../_helpers/icon__svg.js';
|
46
|
-
import 'core-js/modules/es.string.starts-with.js';
|
47
|
-
import 'core-js/modules/es.weak-map.js';
|
48
27
|
import '../button/button.js';
|
49
28
|
import '../link/clickableLink.js';
|
50
29
|
import '../_helpers/button__classes.js';
|
51
30
|
import '../avatar/avatar.js';
|
52
31
|
import '../global/url.js';
|
53
|
-
import 'core-js/modules/es.string.match.js';
|
54
32
|
import '../global/dom.js';
|
55
|
-
import 'core-js/modules/es.set.js';
|
56
|
-
import 'core-js/modules/es.string.split.js';
|
57
33
|
import '../avatar/fallback-avatar.js';
|
58
|
-
import 'core-js/modules/es.array.from.js';
|
59
|
-
import 'core-js/modules/es.regexp.to-string.js';
|
60
34
|
import '../popup/popup.js';
|
61
35
|
import 'react-dom';
|
62
36
|
import '../global/schedule-raf.js';
|
63
37
|
import '../shortcuts/shortcuts.js';
|
64
38
|
import '../shortcuts/core.js';
|
65
|
-
import 'core-js/modules/es.array.find-index.js';
|
66
|
-
import 'core-js/modules/es.array.includes.js';
|
67
|
-
import 'core-js/modules/es.array.splice.js';
|
68
|
-
import 'core-js/modules/es.string.includes.js';
|
69
39
|
import 'combokeys';
|
70
40
|
import '../global/sniffer.js';
|
71
41
|
import 'sniffr';
|
72
42
|
import '../tab-trap/tab-trap.js';
|
73
43
|
import '../popup/position.js';
|
74
|
-
import 'core-js/modules/es.array.sort.js';
|
75
44
|
import '../popup/popup.consts.js';
|
76
45
|
import '../popup/popup.target.js';
|
77
46
|
import '../list/list.js';
|
78
|
-
import 'core-js/modules/es.symbol.js';
|
79
|
-
import 'core-js/modules/es.symbol.description.js';
|
80
47
|
import 'react-virtualized/dist/es/List';
|
81
48
|
import 'react-virtualized/dist/es/AutoSizer';
|
82
49
|
import 'react-virtualized/dist/es/WindowScroller';
|
@@ -115,418 +82,353 @@ function noop() {}
|
|
115
82
|
/**
|
116
83
|
* @name Tags Input
|
117
84
|
*/
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
85
|
+
const POPUP_VERTICAL_SHIFT = 2;
|
86
|
+
class TagsInput extends PureComponent {
|
87
|
+
static propTypes = {
|
88
|
+
className: PropTypes.string,
|
89
|
+
tags: PropTypes.array,
|
90
|
+
/**
|
91
|
+
* Datasource should return array(or promise) of suggestions.
|
92
|
+
* Each suggestion should contain key and label fields.
|
93
|
+
* DataSource should handle caching and response racing (when later request
|
94
|
+
* responded earlier) by himself.
|
95
|
+
*/
|
96
|
+
dataSource: PropTypes.func,
|
97
|
+
onAddTag: PropTypes.func,
|
98
|
+
onRemoveTag: PropTypes.func,
|
99
|
+
customTagComponent: PropTypes.instanceOf(Component),
|
100
|
+
maxPopupHeight: PropTypes.number,
|
101
|
+
minPopupWidth: PropTypes.number,
|
102
|
+
placeholder: PropTypes.string,
|
103
|
+
canNotBeEmpty: PropTypes.bool,
|
104
|
+
disabled: PropTypes.bool,
|
105
|
+
autoOpen: PropTypes.bool,
|
106
|
+
renderOptimization: PropTypes.bool,
|
107
|
+
filter: PropTypes.oneOfType([PropTypes.bool, PropTypes.shape({
|
108
|
+
fn: PropTypes.func
|
109
|
+
})]),
|
110
|
+
size: PropTypes.string,
|
111
|
+
height: PropTypes.string,
|
112
|
+
label: PropTypes.node,
|
113
|
+
loadingMessage: PropTypes.string,
|
114
|
+
notFoundMessage: PropTypes.string,
|
115
|
+
hint: PropTypes.node,
|
116
|
+
allowAddNewTags: PropTypes.bool
|
117
|
+
};
|
118
|
+
static defaultProps = {
|
119
|
+
dataSource: noop,
|
120
|
+
onAddTag: noop,
|
121
|
+
onRemoveTag: noop,
|
122
|
+
customTagComponent: null,
|
123
|
+
maxPopupHeight: 500,
|
124
|
+
minPopupWidth: 360,
|
125
|
+
canNotBeEmpty: false,
|
126
|
+
disabled: false,
|
127
|
+
autoOpen: false,
|
128
|
+
renderOptimization: true,
|
129
|
+
allowAddNewTags: false,
|
130
|
+
filter: {
|
131
|
+
fn: () => true
|
132
|
+
},
|
133
|
+
placeholder: 'Select an option',
|
134
|
+
size: Size.M
|
135
|
+
};
|
136
|
+
constructor(props) {
|
137
|
+
super(props);
|
138
|
+
this.ngModelStateField = TagsInput.ngModelStateField;
|
139
|
+
}
|
140
|
+
state = {
|
141
|
+
tags: [],
|
142
|
+
prevTags: null,
|
143
|
+
suggestions: [],
|
144
|
+
loading: true,
|
145
|
+
focused: false,
|
146
|
+
query: '',
|
147
|
+
activeIndex: 0
|
148
|
+
};
|
149
|
+
static getDerivedStateFromProps(_ref, _ref2) {
|
150
|
+
let {
|
151
|
+
tags
|
152
|
+
} = _ref;
|
153
|
+
let {
|
154
|
+
prevTags
|
155
|
+
} = _ref2;
|
156
|
+
const nextState = {
|
157
|
+
prevTags: tags
|
158
|
+
};
|
159
|
+
if (tags != null && tags !== prevTags) {
|
160
|
+
Object.assign(nextState, {
|
161
|
+
tags,
|
162
|
+
activeIndex: tags.length
|
163
|
+
});
|
164
|
+
}
|
165
|
+
return nextState;
|
166
|
+
}
|
167
|
+
componentDidMount() {
|
168
|
+
if (this.props.autoOpen && !this.props.disabled) {
|
169
|
+
this.focusInput();
|
170
|
+
this.loadSuggestions();
|
171
|
+
this.select?._showPopup();
|
172
|
+
}
|
173
|
+
}
|
174
|
+
static ngModelStateField = 'tags';
|
175
|
+
ngModelStateField;
|
176
|
+
static contextType = ControlsHeightContext;
|
177
|
+
id = this.props.id || getUID('ring-tags-list-');
|
178
|
+
node;
|
179
|
+
nodeRef = node => {
|
180
|
+
this.node = node;
|
181
|
+
};
|
182
|
+
input;
|
183
|
+
caret;
|
184
|
+
getInputNode() {
|
185
|
+
if (!this.input) {
|
186
|
+
this.input = this.select?.filter;
|
187
|
+
if (this.input) {
|
188
|
+
this.caret = new Caret(this.input);
|
174
189
|
}
|
175
|
-
|
190
|
+
}
|
191
|
+
return this.input;
|
192
|
+
}
|
193
|
+
setActiveIndex(activeIndex) {
|
194
|
+
this.setState({
|
195
|
+
activeIndex
|
176
196
|
});
|
177
|
-
|
178
|
-
|
179
|
-
|
197
|
+
}
|
198
|
+
focusInput = () => {
|
199
|
+
this.getInputNode()?.focus();
|
200
|
+
};
|
201
|
+
focus = () => {
|
202
|
+
this.focusInput();
|
203
|
+
};
|
204
|
+
addTag = tag => {
|
205
|
+
if (tag == null) {
|
206
|
+
return;
|
207
|
+
}
|
208
|
+
const isUniqueTag = this.state.tags.filter(item => tag.key === item.key).length === 0;
|
209
|
+
this.select?.clear();
|
210
|
+
this.select?.filterValue('');
|
211
|
+
if (isUniqueTag) {
|
212
|
+
this.setState(prevState => ({
|
213
|
+
tags: prevState.tags.concat([tag])
|
180
214
|
}));
|
181
|
-
|
182
|
-
|
215
|
+
this.props.onAddTag({
|
216
|
+
tag
|
183
217
|
});
|
184
|
-
|
185
|
-
|
186
|
-
|
218
|
+
this.setActiveIndex();
|
219
|
+
}
|
220
|
+
};
|
221
|
+
onRemoveTag(tagToRemove) {
|
222
|
+
return Promise.resolve(this.props.onRemoveTag({
|
223
|
+
tag: tagToRemove
|
224
|
+
})).then(() => {
|
225
|
+
const tags = this.state.tags.filter(tag => tag !== tagToRemove);
|
226
|
+
if (this.node) {
|
227
|
+
this.setState({
|
228
|
+
tags
|
229
|
+
});
|
230
|
+
this.focusInput();
|
231
|
+
}
|
232
|
+
return tags;
|
233
|
+
}, this.focusInput);
|
234
|
+
}
|
235
|
+
clickHandler = event => {
|
236
|
+
if (event.target !== this.node && event.target.parentElement !== this.node) {
|
237
|
+
return;
|
238
|
+
}
|
239
|
+
this.select?._clickHandler();
|
240
|
+
};
|
241
|
+
filterExistingTags = suggestions => {
|
242
|
+
const tagsMap = new Map(this.state.tags.map(tag => [tag.key, tag]));
|
243
|
+
return suggestions.filter(suggestion => !tagsMap.has(suggestion.key));
|
244
|
+
};
|
245
|
+
loadSuggestions = (() => {
|
246
|
+
var _this = this;
|
247
|
+
return function () {
|
248
|
+
let query = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
187
249
|
return _this.setState({
|
188
250
|
loading: true,
|
189
251
|
query
|
190
|
-
},
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
}
|
203
|
-
_context.t0 = suggestionsResult;
|
204
|
-
_context.next = 9;
|
205
|
-
break;
|
206
|
-
case 6:
|
207
|
-
_context.next = 8;
|
208
|
-
return suggestionsResult;
|
209
|
-
case 8:
|
210
|
-
_context.t0 = _context.sent;
|
211
|
-
case 9:
|
212
|
-
allSuggestions = _context.t0;
|
213
|
-
suggestions = _this.filterExistingTags(allSuggestions);
|
214
|
-
if (_this.node && query === _this.state.query) {
|
215
|
-
_this.setState({
|
216
|
-
suggestions,
|
217
|
-
loading: false
|
218
|
-
});
|
219
|
-
}
|
220
|
-
_context.next = 17;
|
221
|
-
break;
|
222
|
-
case 14:
|
223
|
-
_context.prev = 14;
|
224
|
-
_context.t1 = _context["catch"](0);
|
225
|
-
_this.setState({
|
226
|
-
loading: false
|
227
|
-
});
|
228
|
-
case 17:
|
229
|
-
case "end":
|
230
|
-
return _context.stop();
|
231
|
-
}
|
232
|
-
}, _callee, null, [[0, 14]]);
|
233
|
-
})));
|
234
|
-
});
|
235
|
-
_defineProperty(_this, "_focusHandler", function () {
|
236
|
-
_this.setActiveIndex(null);
|
237
|
-
_this.setState({
|
238
|
-
focused: true
|
239
|
-
});
|
240
|
-
});
|
241
|
-
_defineProperty(_this, "_blurHandler", function () {
|
242
|
-
_this.setState({
|
243
|
-
focused: false
|
244
|
-
});
|
245
|
-
});
|
246
|
-
_defineProperty(_this, "selectTag", function (moveForward) {
|
247
|
-
var activeIndex = typeof _this.state.activeIndex === 'number' ? _this.state.activeIndex : _this.state.tags.length + 1;
|
248
|
-
var newActiveIndex = activeIndex + (moveForward ? 1 : -1);
|
249
|
-
if (newActiveIndex >= _this.state.tags.length) {
|
250
|
-
newActiveIndex = _this.state.tags.length - 1;
|
251
|
-
} else if (newActiveIndex < 0) {
|
252
|
-
newActiveIndex = 0;
|
253
|
-
}
|
254
|
-
if (_this.state.activeIndex !== newActiveIndex) {
|
255
|
-
_this.setActiveIndex(newActiveIndex);
|
256
|
-
}
|
257
|
-
});
|
258
|
-
_defineProperty(_this, "handleKeyDown", function (event) {
|
259
|
-
var _this$select4;
|
260
|
-
var key = getEventKey(event);
|
261
|
-
var isInputFocused = function isInputFocused() {
|
262
|
-
var _this$getInputNode$ta, _this$getInputNode2;
|
263
|
-
return event.target instanceof Element && event.target.matches((_this$getInputNode$ta = (_this$getInputNode2 = _this.getInputNode()) === null || _this$getInputNode2 === void 0 ? void 0 : _this$getInputNode2.tagName) !== null && _this$getInputNode$ta !== void 0 ? _this$getInputNode$ta : '');
|
264
|
-
};
|
265
|
-
if (key === ' ' && _this.props.allowAddNewTags) {
|
266
|
-
var _this$getInputNode3;
|
267
|
-
event.stopPropagation();
|
268
|
-
var value = (_this$getInputNode3 = _this.getInputNode()) === null || _this$getInputNode3 === void 0 ? void 0 : _this$getInputNode3.value;
|
269
|
-
if (value != null && value !== '') {
|
270
|
-
_this.handleTagCreation(value);
|
271
|
-
}
|
272
|
-
return true;
|
273
|
-
}
|
274
|
-
if ((_this$select4 = _this.select) !== null && _this$select4 !== void 0 && (_this$select4 = _this$select4._popup) !== null && _this$select4 !== void 0 && _this$select4.isVisible()) {
|
275
|
-
return true;
|
276
|
-
}
|
277
|
-
if (key === 'ArrowLeft') {
|
278
|
-
if (_this.getInputNode() && _this.caret != null && Number(_this.caret.getPosition()) > 0) {
|
279
|
-
return true;
|
280
|
-
}
|
281
|
-
_this.selectTag();
|
282
|
-
return false;
|
283
|
-
}
|
284
|
-
if (key === 'ArrowRight' && !isInputFocused()) {
|
285
|
-
if (_this.state.activeIndex === _this.state.tags.length - 1) {
|
286
|
-
if (!_this.props.disabled) {
|
287
|
-
var _this$getInputNode4;
|
288
|
-
(_this$getInputNode4 = _this.getInputNode()) === null || _this$getInputNode4 === void 0 || _this$getInputNode4.focus();
|
289
|
-
_this.setActiveIndex();
|
252
|
+
}, async () => {
|
253
|
+
try {
|
254
|
+
const suggestionsResult = _this.props.dataSource({
|
255
|
+
query
|
256
|
+
});
|
257
|
+
const allSuggestions = Array.isArray(suggestionsResult) ? suggestionsResult : await suggestionsResult;
|
258
|
+
const suggestions = _this.filterExistingTags(allSuggestions);
|
259
|
+
if (_this.node && query === _this.state.query) {
|
260
|
+
_this.setState({
|
261
|
+
suggestions,
|
262
|
+
loading: false
|
263
|
+
});
|
290
264
|
}
|
291
|
-
}
|
292
|
-
_this.
|
293
|
-
|
294
|
-
return false;
|
295
|
-
}
|
296
|
-
if (!_this.props.disabled) {
|
297
|
-
var _this$getInputNode5;
|
298
|
-
if (key === 'Backspace' && !((_this$getInputNode5 = _this.getInputNode()) !== null && _this$getInputNode5 !== void 0 && _this$getInputNode5.value)) {
|
299
|
-
var _this$select5;
|
300
|
-
event.preventDefault();
|
301
|
-
var tagsLength = _this.state.tags.length;
|
302
|
-
(_this$select5 = _this.select) === null || _this$select5 === void 0 || _this$select5._hidePopup(true); // otherwise confirmation may be overlapped by popup
|
303
|
-
_this.onRemoveTag(_this.state.tags[tagsLength - 1]);
|
304
|
-
return false;
|
305
|
-
}
|
306
|
-
if ((key === 'Delete' || key === 'Backspace') && _this.state.activeIndex != null && _this.state.tags[_this.state.activeIndex]) {
|
307
|
-
_this.onRemoveTag(_this.state.tags[_this.state.activeIndex]).then(function () {
|
308
|
-
return _this.selectTag(true);
|
265
|
+
} catch (e) {
|
266
|
+
_this.setState({
|
267
|
+
loading: false
|
309
268
|
});
|
310
|
-
return false;
|
311
269
|
}
|
312
|
-
}
|
313
|
-
return true;
|
314
|
-
});
|
315
|
-
_defineProperty(_this, "handleClick", memoize(function (tag) {
|
316
|
-
return function () {
|
317
|
-
_this.setActiveIndex(_this.state.tags.indexOf(tag));
|
318
|
-
};
|
319
|
-
}));
|
320
|
-
_defineProperty(_this, "handleRemove", memoize(function (tag) {
|
321
|
-
return function () {
|
322
|
-
return _this.onRemoveTag(tag);
|
323
|
-
};
|
324
|
-
}));
|
325
|
-
_defineProperty(_this, "handleTagCreation", function (label) {
|
326
|
-
_this.addTag({
|
327
|
-
key: label,
|
328
|
-
label
|
329
270
|
});
|
271
|
+
};
|
272
|
+
})();
|
273
|
+
_focusHandler = () => {
|
274
|
+
this.setActiveIndex(null);
|
275
|
+
this.setState({
|
276
|
+
focused: true
|
330
277
|
});
|
331
|
-
|
332
|
-
|
333
|
-
|
278
|
+
};
|
279
|
+
_blurHandler = () => {
|
280
|
+
this.setState({
|
281
|
+
focused: false
|
334
282
|
});
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
var _this$select6;
|
344
|
-
this.focusInput();
|
345
|
-
this.loadSuggestions();
|
346
|
-
(_this$select6 = this.select) === null || _this$select6 === void 0 || _this$select6._showPopup();
|
347
|
-
}
|
283
|
+
};
|
284
|
+
selectTag = moveForward => {
|
285
|
+
const activeIndex = typeof this.state.activeIndex === 'number' ? this.state.activeIndex : this.state.tags.length + 1;
|
286
|
+
let newActiveIndex = activeIndex + (moveForward ? 1 : -1);
|
287
|
+
if (newActiveIndex >= this.state.tags.length) {
|
288
|
+
newActiveIndex = this.state.tags.length - 1;
|
289
|
+
} else if (newActiveIndex < 0) {
|
290
|
+
newActiveIndex = 0;
|
348
291
|
}
|
349
|
-
|
350
|
-
|
351
|
-
value: function getInputNode() {
|
352
|
-
if (!this.input) {
|
353
|
-
var _this$select7;
|
354
|
-
this.input = (_this$select7 = this.select) === null || _this$select7 === void 0 ? void 0 : _this$select7.filter;
|
355
|
-
if (this.input) {
|
356
|
-
this.caret = new Caret(this.input);
|
357
|
-
}
|
358
|
-
}
|
359
|
-
return this.input;
|
292
|
+
if (this.state.activeIndex !== newActiveIndex) {
|
293
|
+
this.setActiveIndex(newActiveIndex);
|
360
294
|
}
|
361
|
-
}
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
295
|
+
};
|
296
|
+
handleKeyDown = event => {
|
297
|
+
const key = getEventKey(event);
|
298
|
+
const isInputFocused = () => {
|
299
|
+
var _this$getInputNode$ta;
|
300
|
+
return event.target instanceof Element && event.target.matches((_this$getInputNode$ta = this.getInputNode()?.tagName) !== null && _this$getInputNode$ta !== void 0 ? _this$getInputNode$ta : '');
|
301
|
+
};
|
302
|
+
if (key === ' ' && this.props.allowAddNewTags) {
|
303
|
+
event.stopPropagation();
|
304
|
+
const value = this.getInputNode()?.value;
|
305
|
+
if (value != null && value !== '') {
|
306
|
+
this.handleTagCreation(value);
|
307
|
+
}
|
308
|
+
return true;
|
367
309
|
}
|
368
|
-
|
369
|
-
|
370
|
-
value: function onRemoveTag(tagToRemove) {
|
371
|
-
var _this2 = this;
|
372
|
-
return Promise.resolve(this.props.onRemoveTag({
|
373
|
-
tag: tagToRemove
|
374
|
-
})).then(function () {
|
375
|
-
var tags = _this2.state.tags.filter(function (tag) {
|
376
|
-
return tag !== tagToRemove;
|
377
|
-
});
|
378
|
-
if (_this2.node) {
|
379
|
-
_this2.setState({
|
380
|
-
tags
|
381
|
-
});
|
382
|
-
_this2.focusInput();
|
383
|
-
}
|
384
|
-
return tags;
|
385
|
-
}, this.focusInput);
|
310
|
+
if (this.select?._popup?.isVisible()) {
|
311
|
+
return true;
|
386
312
|
}
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
activeIndex = _this$state.activeIndex;
|
394
|
-
var _this$props = this.props,
|
395
|
-
disabled = _this$props.disabled,
|
396
|
-
canNotBeEmpty = _this$props.canNotBeEmpty,
|
397
|
-
allowAddNewTags = _this$props.allowAddNewTags,
|
398
|
-
filter = _this$props.filter,
|
399
|
-
size = _this$props.size,
|
400
|
-
labelType = _this$props.labelType,
|
401
|
-
_this$props$height = _this$props.height,
|
402
|
-
height = _this$props$height === void 0 ? this.context : _this$props$height,
|
403
|
-
label = _this$props.label;
|
404
|
-
var classes = classNames(modules_5aa8aaf3.tagsInput, [modules_88cfaf40["size".concat(size)]], [modules_88cfaf40["height".concat(height)]], {
|
405
|
-
[modules_5aa8aaf3.tagsInputDisabled]: disabled,
|
406
|
-
[modules_5aa8aaf3.tagsInputFocused]: focused
|
407
|
-
}, this.props.className);
|
408
|
-
return /*#__PURE__*/React.createElement("div", {
|
409
|
-
// it transfers focus to input
|
410
|
-
role: "presentation",
|
411
|
-
className: classes,
|
412
|
-
onKeyDown: this.handleKeyDown,
|
413
|
-
onClick: this.clickHandler,
|
414
|
-
ref: this.nodeRef
|
415
|
-
}, label && /*#__PURE__*/React.createElement(ControlLabel, {
|
416
|
-
htmlFor: this.id,
|
417
|
-
disabled: disabled,
|
418
|
-
type: labelType
|
419
|
-
}, label), /*#__PURE__*/React.createElement(TagsList, {
|
420
|
-
tags: tags,
|
421
|
-
activeIndex: activeIndex,
|
422
|
-
disabled: disabled,
|
423
|
-
canNotBeEmpty: canNotBeEmpty,
|
424
|
-
handleRemove: this.handleRemove,
|
425
|
-
className: modules_5aa8aaf3.tagsList,
|
426
|
-
tagClassName: modules_5aa8aaf3.tag,
|
427
|
-
handleClick: this.handleClick,
|
428
|
-
customTagComponent: this.props.customTagComponent
|
429
|
-
}, /*#__PURE__*/React.createElement(Select, {
|
430
|
-
id: this.id,
|
431
|
-
ref: this.selectRef,
|
432
|
-
size: Select.Size.AUTO,
|
433
|
-
type: Select.Type.INPUT_WITHOUT_CONTROLS,
|
434
|
-
inputPlaceholder: this.props.placeholder,
|
435
|
-
data: this.state.suggestions,
|
436
|
-
className: classNames(modules_5aa8aaf3.tagsSelect),
|
437
|
-
onSelect: this.addTag,
|
438
|
-
onFocus: this._focusHandler,
|
439
|
-
onBlur: this._blurHandler,
|
440
|
-
renderOptimization: this.props.renderOptimization,
|
441
|
-
add: allowAddNewTags ? {
|
442
|
-
prefix: 'Add new tag'
|
443
|
-
} : undefined,
|
444
|
-
onAdd: allowAddNewTags ? this.handleTagCreation : undefined,
|
445
|
-
filter: filter,
|
446
|
-
maxHeight: this.props.maxPopupHeight,
|
447
|
-
minWidth: this.props.minPopupWidth,
|
448
|
-
top: POPUP_VERTICAL_SHIFT,
|
449
|
-
loading: this.state.loading,
|
450
|
-
onFilter: this.loadSuggestions,
|
451
|
-
onBeforeOpen: this.loadSuggestions,
|
452
|
-
onKeyDown: this.handleKeyDown,
|
453
|
-
disabled: this.props.disabled,
|
454
|
-
loadingMessage: this.props.loadingMessage,
|
455
|
-
notFoundMessage: this.props.notFoundMessage,
|
456
|
-
hint: this.props.hint
|
457
|
-
})));
|
313
|
+
if (key === 'ArrowLeft') {
|
314
|
+
if (this.getInputNode() && this.caret != null && Number(this.caret.getPosition()) > 0) {
|
315
|
+
return true;
|
316
|
+
}
|
317
|
+
this.selectTag();
|
318
|
+
return false;
|
458
319
|
}
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
if (tags != null && tags !== prevTags) {
|
468
|
-
Object.assign(nextState, {
|
469
|
-
tags,
|
470
|
-
activeIndex: tags.length
|
471
|
-
});
|
320
|
+
if (key === 'ArrowRight' && !isInputFocused()) {
|
321
|
+
if (this.state.activeIndex === this.state.tags.length - 1) {
|
322
|
+
if (!this.props.disabled) {
|
323
|
+
this.getInputNode()?.focus();
|
324
|
+
this.setActiveIndex();
|
325
|
+
}
|
326
|
+
} else {
|
327
|
+
this.selectTag(true);
|
472
328
|
}
|
473
|
-
return
|
329
|
+
return false;
|
474
330
|
}
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
onAddTag: PropTypes.func,
|
488
|
-
onRemoveTag: PropTypes.func,
|
489
|
-
customTagComponent: PropTypes.instanceOf(Component),
|
490
|
-
maxPopupHeight: PropTypes.number,
|
491
|
-
minPopupWidth: PropTypes.number,
|
492
|
-
placeholder: PropTypes.string,
|
493
|
-
canNotBeEmpty: PropTypes.bool,
|
494
|
-
disabled: PropTypes.bool,
|
495
|
-
autoOpen: PropTypes.bool,
|
496
|
-
renderOptimization: PropTypes.bool,
|
497
|
-
filter: PropTypes.oneOfType([PropTypes.bool, PropTypes.shape({
|
498
|
-
fn: PropTypes.func
|
499
|
-
})]),
|
500
|
-
size: PropTypes.string,
|
501
|
-
height: PropTypes.string,
|
502
|
-
label: PropTypes.node,
|
503
|
-
loadingMessage: PropTypes.string,
|
504
|
-
notFoundMessage: PropTypes.string,
|
505
|
-
hint: PropTypes.node,
|
506
|
-
allowAddNewTags: PropTypes.bool
|
507
|
-
});
|
508
|
-
_defineProperty(TagsInput, "defaultProps", {
|
509
|
-
dataSource: noop,
|
510
|
-
onAddTag: noop,
|
511
|
-
onRemoveTag: noop,
|
512
|
-
customTagComponent: null,
|
513
|
-
maxPopupHeight: 500,
|
514
|
-
minPopupWidth: 360,
|
515
|
-
canNotBeEmpty: false,
|
516
|
-
disabled: false,
|
517
|
-
autoOpen: false,
|
518
|
-
renderOptimization: true,
|
519
|
-
allowAddNewTags: false,
|
520
|
-
filter: {
|
521
|
-
fn: function fn() {
|
522
|
-
return true;
|
331
|
+
if (!this.props.disabled) {
|
332
|
+
if (key === 'Backspace' && !this.getInputNode()?.value) {
|
333
|
+
event.preventDefault();
|
334
|
+
const tagsLength = this.state.tags.length;
|
335
|
+
this.select?._hidePopup(true); // otherwise confirmation may be overlapped by popup
|
336
|
+
this.onRemoveTag(this.state.tags[tagsLength - 1]);
|
337
|
+
return false;
|
338
|
+
}
|
339
|
+
if ((key === 'Delete' || key === 'Backspace') && this.state.activeIndex != null && this.state.tags[this.state.activeIndex]) {
|
340
|
+
this.onRemoveTag(this.state.tags[this.state.activeIndex]).then(() => this.selectTag(true));
|
341
|
+
return false;
|
342
|
+
}
|
523
343
|
}
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
344
|
+
return true;
|
345
|
+
};
|
346
|
+
handleClick = memoize(tag => () => {
|
347
|
+
this.setActiveIndex(this.state.tags.indexOf(tag));
|
348
|
+
});
|
349
|
+
handleRemove = memoize(tag => () => this.onRemoveTag(tag));
|
350
|
+
handleTagCreation = label => {
|
351
|
+
this.addTag({
|
352
|
+
key: label,
|
353
|
+
label
|
354
|
+
});
|
355
|
+
};
|
356
|
+
select;
|
357
|
+
selectRef = el => {
|
358
|
+
this.select = el;
|
359
|
+
};
|
360
|
+
render() {
|
361
|
+
const {
|
362
|
+
focused,
|
363
|
+
tags,
|
364
|
+
activeIndex
|
365
|
+
} = this.state;
|
366
|
+
const {
|
367
|
+
disabled,
|
368
|
+
canNotBeEmpty,
|
369
|
+
allowAddNewTags,
|
370
|
+
filter,
|
371
|
+
size,
|
372
|
+
labelType,
|
373
|
+
height = this.context,
|
374
|
+
label
|
375
|
+
} = this.props;
|
376
|
+
const classes = classNames(modules_5aa8aaf3.tagsInput, [modules_88cfaf40[`size${size}`]], [modules_88cfaf40[`height${height}`]], {
|
377
|
+
[modules_5aa8aaf3.tagsInputDisabled]: disabled,
|
378
|
+
[modules_5aa8aaf3.tagsInputFocused]: focused
|
379
|
+
}, this.props.className);
|
380
|
+
return /*#__PURE__*/React.createElement("div", {
|
381
|
+
// it transfers focus to input
|
382
|
+
role: "presentation",
|
383
|
+
className: classes,
|
384
|
+
onKeyDown: this.handleKeyDown,
|
385
|
+
onClick: this.clickHandler,
|
386
|
+
ref: this.nodeRef
|
387
|
+
}, label && /*#__PURE__*/React.createElement(ControlLabel, {
|
388
|
+
htmlFor: this.id,
|
389
|
+
disabled: disabled,
|
390
|
+
type: labelType
|
391
|
+
}, label), /*#__PURE__*/React.createElement(TagsList, {
|
392
|
+
tags: tags,
|
393
|
+
activeIndex: activeIndex,
|
394
|
+
disabled: disabled,
|
395
|
+
canNotBeEmpty: canNotBeEmpty,
|
396
|
+
handleRemove: this.handleRemove,
|
397
|
+
className: modules_5aa8aaf3.tagsList,
|
398
|
+
tagClassName: modules_5aa8aaf3.tag,
|
399
|
+
handleClick: this.handleClick,
|
400
|
+
customTagComponent: this.props.customTagComponent
|
401
|
+
}, /*#__PURE__*/React.createElement(Select, {
|
402
|
+
id: this.id,
|
403
|
+
ref: this.selectRef,
|
404
|
+
size: Select.Size.AUTO,
|
405
|
+
type: Select.Type.INPUT_WITHOUT_CONTROLS,
|
406
|
+
inputPlaceholder: this.props.placeholder,
|
407
|
+
data: this.state.suggestions,
|
408
|
+
className: classNames(modules_5aa8aaf3.tagsSelect),
|
409
|
+
onSelect: this.addTag,
|
410
|
+
onFocus: this._focusHandler,
|
411
|
+
onBlur: this._blurHandler,
|
412
|
+
renderOptimization: this.props.renderOptimization,
|
413
|
+
add: allowAddNewTags ? {
|
414
|
+
prefix: 'Add new tag'
|
415
|
+
} : undefined,
|
416
|
+
onAdd: allowAddNewTags ? this.handleTagCreation : undefined,
|
417
|
+
filter: filter,
|
418
|
+
maxHeight: this.props.maxPopupHeight,
|
419
|
+
minWidth: this.props.minPopupWidth,
|
420
|
+
top: POPUP_VERTICAL_SHIFT,
|
421
|
+
loading: this.state.loading,
|
422
|
+
onFilter: this.loadSuggestions,
|
423
|
+
onBeforeOpen: this.loadSuggestions,
|
424
|
+
onKeyDown: this.handleKeyDown,
|
425
|
+
disabled: this.props.disabled,
|
426
|
+
loadingMessage: this.props.loadingMessage,
|
427
|
+
notFoundMessage: this.props.notFoundMessage,
|
428
|
+
hint: this.props.hint
|
429
|
+
})));
|
430
|
+
}
|
431
|
+
}
|
432
|
+
const RerenderableTagsInput = rerenderHOC(TagsInput);
|
531
433
|
|
532
434
|
export { RerenderableTagsInput, TagsInput as default };
|