@jetbrains/ring-ui-built 7.0.66 → 7.0.71
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/anchor.js +12 -17
- package/components/_helpers/avatar-info.js +4 -5
- package/components/_helpers/button.classes.js +20 -21
- package/components/_helpers/caption.js +3 -3
- package/components/_helpers/card.js +26 -32
- package/components/_helpers/dialog-body-scroll-preventer.js +1 -2
- package/components/_helpers/icon-svg.js +9 -12
- package/components/_helpers/input.js +78 -86
- package/components/_helpers/loader-core.js +260 -0
- package/components/_helpers/query-assist-suggestions.js +0 -1
- package/components/_helpers/select-filter.js +19 -26
- package/components/_helpers/services-link.js +9 -12
- package/components/_helpers/sidebar.js +36 -44
- package/components/_helpers/tab-link.js +9 -11
- package/components/_helpers/theme.js +20 -24
- package/components/_helpers/title.js +12 -17
- package/components/alert/alert.js +41 -49
- package/components/alert/container.js +9 -12
- package/components/alert-service/alert-service.js +23 -32
- package/components/analytics/analytics-custom-plugin.js +12 -17
- package/components/analytics/analytics.js +1 -3
- package/components/auth/auth-core.js +128 -170
- package/components/auth/auth.js +3 -10
- package/components/auth/background-flow.js +5 -8
- package/components/auth/down-notification.js +9 -17
- package/components/auth/iframe-flow.js +13 -19
- package/components/auth/request-builder.js +4 -9
- package/components/auth/response-parser.js +9 -12
- package/components/auth/storage.js +12 -18
- package/components/auth/token-validator.js +19 -30
- package/components/auth/window-flow.js +22 -27
- package/components/auth-dialog/auth-dialog.js +40 -48
- package/components/auth-dialog-service/auth-dialog-service.js +10 -13
- package/components/avatar/avatar.figma.js +6 -6
- package/components/avatar/avatar.js +58 -59
- package/components/avatar/fallback-avatar.js +8 -11
- package/components/avatar-stack/avatar-stack.figma.js +10 -11
- package/components/avatar-stack/avatar-stack.js +25 -31
- package/components/banner/banner.js +0 -6
- package/components/breadcrumbs/breadcrumbs.figma.js +8 -6
- package/components/breadcrumbs/breadcrumbs.js +4 -5
- package/components/button/button.figma.js +15 -10
- package/components/button/button.js +59 -64
- package/components/button-group/button-group.js +11 -15
- package/components/button-group/caption.js +0 -1
- package/components/button-set/button-set.js +9 -12
- package/components/button-toolbar/button-toolbar.js +8 -11
- package/components/caret/caret.js +20 -28
- package/components/checkbox/checkbox-group.figma.js +8 -10
- package/components/checkbox/checkbox.figma.js +5 -5
- package/components/checkbox/checkbox.js +27 -35
- package/components/clipboard/clipboard-fallback.js +3 -3
- package/components/clipboard/clipboard.js +3 -16
- package/components/code/code.js +8 -14
- package/components/collapse/collapse-content.js +10 -15
- package/components/collapse/collapse-control.js +5 -7
- package/components/collapse/collapse.js +9 -11
- package/components/collapse/utils.js +1 -1
- package/components/confirm/confirm.js +17 -26
- package/components/confirm-service/confirm-service.js +30 -31
- package/components/content-layout/content-layout.js +21 -28
- package/components/content-layout/sidebar.js +0 -2
- package/components/contenteditable/contenteditable.js +23 -28
- package/components/control-help/control-help.js +8 -10
- package/components/control-label/control-label.js +12 -17
- package/components/data-list/data-list.js +57 -65
- package/components/data-list/data-list.mock.js +0 -4
- package/components/data-list/item.js +65 -72
- package/components/data-list/selection.js +11 -19
- package/components/data-list/title.js +0 -4
- package/components/date-picker/consts.js +3 -4
- package/components/date-picker/date-input.js +25 -33
- package/components/date-picker/date-picker.js +179 -193
- package/components/date-picker/date-popup.js +135 -127
- package/components/date-picker/day.d.ts +1 -1
- package/components/date-picker/day.js +24 -30
- package/components/date-picker/month-names.js +7 -12
- package/components/date-picker/month-slider.js +16 -22
- package/components/date-picker/month.js +3 -5
- package/components/date-picker/months.js +6 -6
- package/components/date-picker/weekdays.js +0 -1
- package/components/date-picker/years.js +20 -26
- package/components/dialog/dialog-body-scroll-preventer.js +0 -1
- package/components/dialog/dialog.js +73 -83
- package/components/dropdown/anchor.js +0 -4
- package/components/dropdown/dropdown.js +98 -114
- package/components/dropdown-menu/dropdown-menu.js +80 -79
- package/components/editable-heading/editable-heading.js +48 -54
- package/components/error-bubble/error-bubble.figma.js +4 -4
- package/components/error-bubble/error-bubble.js +9 -13
- package/components/error-message/error-message.js +1 -6
- package/components/footer/footer.js +11 -15
- package/components/global/compose-refs.js +1 -4
- package/components/global/compose.js +1 -4
- package/components/global/configuration.js +3 -3
- package/components/global/controls-height.js +0 -1
- package/components/global/create-stateful-context.js +10 -14
- package/components/global/data-tests.js +2 -10
- package/components/global/dom.js +6 -19
- package/components/global/focus-sensor-hoc.js +74 -87
- package/components/global/fuzzy-highlight.js +3 -8
- package/components/global/get-uid.js +1 -1
- package/components/global/inject-styles.js +5 -6
- package/components/global/listeners.js +2 -11
- package/components/global/memoize.js +0 -2
- package/components/global/normalize-indent.js +2 -6
- package/components/global/promise-with-timeout.js +4 -5
- package/components/global/react-dom-renderer.js +4 -9
- package/components/global/rerender-hoc.js +8 -11
- package/components/global/schedule-raf.js +1 -2
- package/components/global/theme.js +0 -5
- package/components/global/trivial-template-tag.js +1 -6
- package/components/global/url.js +2 -6
- package/components/global/use-event-callback.js +2 -3
- package/components/grid/col.js +7 -18
- package/components/grid/grid.js +9 -14
- package/components/grid/row.js +7 -11
- package/components/group/group.js +9 -12
- package/components/header/header-icon.js +8 -13
- package/components/header/header.js +16 -27
- package/components/header/links.js +7 -10
- package/components/header/logo.js +12 -16
- package/components/header/profile.js +73 -83
- package/components/header/services-link.js +0 -2
- package/components/header/services.js +32 -43
- package/components/header/smart-profile.js +44 -59
- package/components/header/smart-services.js +33 -45
- package/components/header/tray.js +8 -10
- package/components/heading/heading.js +27 -27
- package/components/http/http.js +120 -125
- package/components/http/http.mock.js +6 -10
- package/components/hub-source/hub-source-user.js +6 -13
- package/components/hub-source/hub-source-users-groups.js +8 -12
- package/components/hub-source/hub-source.js +8 -10
- package/components/i18n/i18n-context.js +4 -7
- package/components/i18n/i18n.js +5 -5
- package/components/icon/icon-svg.js +0 -4
- package/components/icon/icon.js +28 -32
- package/components/icon/index.js +0 -4
- package/components/input/input.figma.js +8 -8
- package/components/input/input.js +0 -4
- package/components/island/adaptive-island-hoc.js +19 -23
- package/components/island/content.js +70 -75
- package/components/island/header.js +21 -21
- package/components/island/island.js +11 -14
- package/components/link/clickable-link.js +30 -37
- package/components/link/link.js +27 -29
- package/components/list/list-custom.js +6 -11
- package/components/list/list-item.js +49 -56
- package/components/list/list-separator.js +0 -1
- package/components/list/list-title.js +0 -1
- package/components/list/list-users-groups-source.js +14 -22
- package/components/list/list.classes.js +8 -9
- package/components/list/list.js +387 -404
- package/components/loader/loader-core.js +2 -265
- package/components/loader/loader.d.ts +8 -0
- package/components/loader/loader.js +43 -29
- package/components/loader-inline/loader-inline.js +9 -12
- package/components/loader-screen/loader-screen.js +10 -14
- package/components/login-dialog/login-dialog.js +46 -54
- package/components/login-dialog/service.js +13 -15
- package/components/message/message.js +65 -79
- package/components/old-browsers-message/old-browsers-message-stop.js +0 -3
- package/components/old-browsers-message/old-browsers-message.js +1 -4
- package/components/old-browsers-message/white-list.js +5 -7
- package/components/pager/pager.js +73 -88
- package/components/panel/panel.js +9 -12
- package/components/permissions/permissions-cache.js +6 -8
- package/components/permissions/permissions.js +19 -21
- package/components/popup/popup.js +136 -145
- package/components/popup/popup.target.js +8 -10
- package/components/popup/position-css.js +19 -27
- package/components/popup/position.js +22 -28
- package/components/popup-menu/popup-menu.js +27 -37
- package/components/progress-bar/progress-bar.js +26 -32
- package/components/query-assist/query-assist-suggestions.js +0 -6
- package/components/query-assist/query-assist.js +432 -468
- package/components/radio/radio-item.js +30 -40
- package/components/radio/radio.js +6 -10
- package/components/scrollable-section/scrollable-section.js +7 -10
- package/components/select/select-filter.js +0 -6
- package/components/select/select-popup.js +155 -174
- package/components/select/select.js +464 -479
- package/components/shortcuts/core.js +40 -45
- package/components/shortcuts/shortcut-title.js +0 -1
- package/components/shortcuts/shortcuts-hoc.js +9 -15
- package/components/shortcuts/shortcuts.js +3 -5
- package/components/slider/slider.js +53 -66
- package/components/slider/slider.utils.js +1 -4
- package/components/storage/storage-local.js +2 -8
- package/components/storage/storage.js +0 -5
- package/components/style.css +1 -1
- package/components/tab-trap/tab-trap.js +21 -30
- package/components/table/cell.js +3 -4
- package/components/table/disable-hover-hoc.js +24 -28
- package/components/table/header-cell.js +30 -38
- package/components/table/header.js +20 -28
- package/components/table/multitable.js +81 -101
- package/components/table/row-with-focus-sensor.js +17 -28
- package/components/table/row.js +89 -99
- package/components/table/selection-adapter.js +0 -2
- package/components/table/selection-shortcuts-hoc.js +159 -161
- package/components/table/selection.js +23 -31
- package/components/table/simple-table.js +16 -22
- package/components/table/smart-table.js +19 -26
- package/components/table/table.js +137 -146
- package/components/tabs/collapsible-more.js +34 -47
- package/components/tabs/collapsible-tab.js +28 -33
- package/components/tabs/collapsible-tabs.js +16 -24
- package/components/tabs/custom-item.js +3 -6
- package/components/tabs/dumb-tabs.js +48 -64
- package/components/tabs/smart-tabs.js +14 -23
- package/components/tabs/tab-link.js +0 -2
- package/components/tabs/tab.js +0 -1
- package/components/tabs/tabs.js +0 -7
- package/components/tag/tag.js +30 -35
- package/components/tags-input/tags-input.js +192 -218
- package/components/tags-list/tags-list.js +26 -31
- package/components/text/text.js +16 -19
- package/components/toggle/toggle.js +19 -23
- package/components/tooltip/tooltip.js +110 -121
- package/components/upload/upload.js +19 -28
- package/components/user-agreement/service.js +247 -252
- package/components/user-agreement/toolbox.eula.js +160 -1
- package/components/user-agreement/user-agreement.js +23 -32
- package/components/user-card/card.js +0 -5
- package/components/user-card/smart-user-card-tooltip.js +41 -50
- package/components/user-card/tooltip.js +32 -38
- package/components/user-card/user-card.js +0 -5
- package/package.json +9 -3
- package/components/_helpers/_rollupPluginBabelHelpers.js +0 -72
package/components/tag/tag.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { _ as _defineProperty, b as _objectSpread2 } from '../_helpers/_rollupPluginBabelHelpers.js';
|
|
2
|
-
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
3
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
4
2
|
import { PureComponent } from 'react';
|
|
5
3
|
import classNames from 'classnames';
|
|
@@ -11,8 +9,6 @@ import { ControlsHeight } from '../global/configuration.js';
|
|
|
11
9
|
import 'util-deprecate';
|
|
12
10
|
import '../icon/icon.constants.js';
|
|
13
11
|
import '../_helpers/icon-svg.js';
|
|
14
|
-
import 'core-js/modules/es.regexp.exec.js';
|
|
15
|
-
import 'core-js/modules/es.string.replace.js';
|
|
16
12
|
import '../global/memoize.js';
|
|
17
13
|
import '@jetbrains/icons/chevron-down';
|
|
18
14
|
import '@jetbrains/icons/chevron-12px-down';
|
|
@@ -34,23 +30,23 @@ var TagType;
|
|
|
34
30
|
* @name Tag
|
|
35
31
|
*/
|
|
36
32
|
class Tag extends PureComponent {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
33
|
+
static defaultProps = {
|
|
34
|
+
onClick: () => {},
|
|
35
|
+
readOnly: false,
|
|
36
|
+
disabled: false,
|
|
37
|
+
focused: false,
|
|
38
|
+
interactive: true,
|
|
39
|
+
render: (props, interactive) => interactive ? jsx("button", {
|
|
40
|
+
type: 'button',
|
|
41
|
+
...props
|
|
42
|
+
}) : jsx("span", {
|
|
43
|
+
...props
|
|
44
|
+
}),
|
|
45
|
+
tagType: TagType.DEFAULT
|
|
46
|
+
};
|
|
47
|
+
state = {
|
|
48
|
+
focused: false
|
|
49
|
+
};
|
|
54
50
|
componentDidUpdate(prevProps) {
|
|
55
51
|
if (this.props.focused !== prevProps.focused) {
|
|
56
52
|
this.setState({
|
|
@@ -58,8 +54,7 @@ class Tag extends PureComponent {
|
|
|
58
54
|
});
|
|
59
55
|
}
|
|
60
56
|
if (this.state.focused) {
|
|
61
|
-
|
|
62
|
-
(_this$tagNode = this.tagNode) === null || _this$tagNode === void 0 || _this$tagNode.focus();
|
|
57
|
+
this.tagNode?.focus();
|
|
63
58
|
}
|
|
64
59
|
this.setDocumentClickListener(this.state.focused);
|
|
65
60
|
}
|
|
@@ -69,6 +64,18 @@ class Tag extends PureComponent {
|
|
|
69
64
|
focused: false
|
|
70
65
|
});
|
|
71
66
|
}
|
|
67
|
+
static Type = TagType;
|
|
68
|
+
onDocumentClick = event => {
|
|
69
|
+
if (this.tagNode) {
|
|
70
|
+
this.setState({
|
|
71
|
+
focused: this.tagNode === event.target
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
tagNode;
|
|
76
|
+
tagRef = el => {
|
|
77
|
+
this.tagNode = el;
|
|
78
|
+
};
|
|
72
79
|
setDocumentClickListener(setListener) {
|
|
73
80
|
if (setListener) {
|
|
74
81
|
document.addEventListener('click', this.onDocumentClick);
|
|
@@ -164,17 +171,5 @@ class Tag extends PureComponent {
|
|
|
164
171
|
});
|
|
165
172
|
}
|
|
166
173
|
}
|
|
167
|
-
_defineProperty(Tag, "defaultProps", {
|
|
168
|
-
onClick: () => {},
|
|
169
|
-
readOnly: false,
|
|
170
|
-
disabled: false,
|
|
171
|
-
focused: false,
|
|
172
|
-
interactive: true,
|
|
173
|
-
render: (props, interactive) => interactive ? jsx("button", _objectSpread2({
|
|
174
|
-
type: 'button'
|
|
175
|
-
}, props)) : jsx("span", _objectSpread2({}, props)),
|
|
176
|
-
tagType: TagType.DEFAULT
|
|
177
|
-
});
|
|
178
|
-
_defineProperty(Tag, "Type", TagType);
|
|
179
174
|
|
|
180
175
|
export { TagType, Tag as default };
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { _ as _defineProperty } from '../_helpers/_rollupPluginBabelHelpers.js';
|
|
2
|
-
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
3
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
4
2
|
import { PureComponent } from 'react';
|
|
5
3
|
import classNames from 'classnames';
|
|
@@ -13,13 +11,9 @@ import { S as Size, i as inputStyles } from '../_helpers/input.js';
|
|
|
13
11
|
import { ControlsHeightContext } from '../global/controls-height.js';
|
|
14
12
|
import getUID from '../global/get-uid.js';
|
|
15
13
|
import { ControlLabel } from '../control-label/control-label.js';
|
|
16
|
-
import 'core-js/modules/es.regexp.exec.js';
|
|
17
|
-
import 'core-js/modules/es.string.replace.js';
|
|
18
|
-
import 'core-js/modules/es.string.trim.js';
|
|
19
14
|
import '@jetbrains/icons/chevron-down';
|
|
20
15
|
import '@jetbrains/icons/close-12px';
|
|
21
16
|
import 'dequal';
|
|
22
|
-
import '../dropdown/dropdown.js';
|
|
23
17
|
import '../global/data-tests.js';
|
|
24
18
|
import '../global/typescript-utils.js';
|
|
25
19
|
import '../_helpers/anchor.js';
|
|
@@ -48,12 +42,10 @@ import '../global/sniffer.js';
|
|
|
48
42
|
import 'sniffr';
|
|
49
43
|
import '../tab-trap/tab-trap.js';
|
|
50
44
|
import '../popup/position.js';
|
|
51
|
-
import 'core-js/modules/es.array.sort.js';
|
|
52
45
|
import '../popup/popup.consts.js';
|
|
53
46
|
import '../popup/popup.target.js';
|
|
54
47
|
import '../popup/position-css.js';
|
|
55
48
|
import '../list/list.js';
|
|
56
|
-
import 'core-js/modules/es.symbol.description.js';
|
|
57
49
|
import 'react-virtualized/dist/es/List';
|
|
58
50
|
import 'react-virtualized/dist/es/AutoSizer';
|
|
59
51
|
import 'react-virtualized/dist/es/WindowScroller';
|
|
@@ -94,218 +86,74 @@ function noop() {}
|
|
|
94
86
|
*/
|
|
95
87
|
const POPUP_VERTICAL_SHIFT = 2;
|
|
96
88
|
class TagsInput extends PureComponent {
|
|
89
|
+
static defaultProps = {
|
|
90
|
+
dataSource: noop,
|
|
91
|
+
onAddTag: noop,
|
|
92
|
+
onRemoveTag: noop,
|
|
93
|
+
customTagComponent: null,
|
|
94
|
+
maxPopupHeight: 500,
|
|
95
|
+
minPopupWidth: 360,
|
|
96
|
+
canNotBeEmpty: false,
|
|
97
|
+
disabled: false,
|
|
98
|
+
autoOpen: false,
|
|
99
|
+
renderOptimization: true,
|
|
100
|
+
allowAddNewTags: false,
|
|
101
|
+
filter: {
|
|
102
|
+
fn: () => true
|
|
103
|
+
},
|
|
104
|
+
placeholder: 'Select an option',
|
|
105
|
+
size: Size.M
|
|
106
|
+
};
|
|
97
107
|
constructor(props) {
|
|
98
|
-
var _this;
|
|
99
108
|
super(props);
|
|
100
|
-
_this = this;
|
|
101
|
-
_defineProperty(this, "state", {
|
|
102
|
-
tags: [],
|
|
103
|
-
prevTags: null,
|
|
104
|
-
suggestions: [],
|
|
105
|
-
loading: true,
|
|
106
|
-
focused: false,
|
|
107
|
-
query: '',
|
|
108
|
-
activeIndex: 0
|
|
109
|
-
});
|
|
110
|
-
_defineProperty(this, "ngModelStateField", void 0);
|
|
111
|
-
_defineProperty(this, "id", this.props.id || getUID('ring-tags-list-'));
|
|
112
|
-
_defineProperty(this, "node", void 0);
|
|
113
|
-
_defineProperty(this, "nodeRef", node => {
|
|
114
|
-
this.node = node;
|
|
115
|
-
});
|
|
116
|
-
_defineProperty(this, "input", void 0);
|
|
117
|
-
_defineProperty(this, "caret", void 0);
|
|
118
|
-
_defineProperty(this, "focusInput", () => {
|
|
119
|
-
var _this$getInputNode;
|
|
120
|
-
(_this$getInputNode = this.getInputNode()) === null || _this$getInputNode === void 0 || _this$getInputNode.focus();
|
|
121
|
-
});
|
|
122
|
-
_defineProperty(this, "focus", () => {
|
|
123
|
-
this.focusInput();
|
|
124
|
-
});
|
|
125
|
-
_defineProperty(this, "addTag", tag => {
|
|
126
|
-
var _this$select, _this$select2;
|
|
127
|
-
if (tag === null) {
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
const isUniqueTag = this.state.tags.filter(item => tag.key === item.key).length === 0;
|
|
131
|
-
(_this$select = this.select) === null || _this$select === void 0 || _this$select.clear();
|
|
132
|
-
(_this$select2 = this.select) === null || _this$select2 === void 0 || _this$select2.filterValue('');
|
|
133
|
-
if (isUniqueTag) {
|
|
134
|
-
this.setState(prevState => ({
|
|
135
|
-
tags: prevState.tags.concat([tag])
|
|
136
|
-
}));
|
|
137
|
-
this.props.onAddTag({
|
|
138
|
-
tag
|
|
139
|
-
});
|
|
140
|
-
this.setActiveIndex();
|
|
141
|
-
}
|
|
142
|
-
});
|
|
143
|
-
_defineProperty(this, "clickHandler", event => {
|
|
144
|
-
var _this$select3;
|
|
145
|
-
if (event.target !== this.node && event.target.parentElement !== this.node) {
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
// eslint-disable-next-line no-underscore-dangle
|
|
149
|
-
(_this$select3 = this.select) === null || _this$select3 === void 0 || _this$select3._clickHandler();
|
|
150
|
-
});
|
|
151
|
-
_defineProperty(this, "filterExistingTags", suggestions => {
|
|
152
|
-
const tagsMap = new Map(this.state.tags.map(tag => [tag.key, tag]));
|
|
153
|
-
return suggestions.filter(suggestion => !tagsMap.has(suggestion.key));
|
|
154
|
-
});
|
|
155
|
-
_defineProperty(this, "loadSuggestions", function () {
|
|
156
|
-
let query = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
157
|
-
return _this.setState({
|
|
158
|
-
loading: true,
|
|
159
|
-
query
|
|
160
|
-
}, async () => {
|
|
161
|
-
try {
|
|
162
|
-
const suggestionsResult = _this.props.dataSource({
|
|
163
|
-
query
|
|
164
|
-
});
|
|
165
|
-
const allSuggestions = Array.isArray(suggestionsResult) ? suggestionsResult : await suggestionsResult;
|
|
166
|
-
const suggestions = _this.filterExistingTags(allSuggestions);
|
|
167
|
-
if (_this.node && query === _this.state.query) {
|
|
168
|
-
_this.setState({
|
|
169
|
-
suggestions,
|
|
170
|
-
loading: false
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
} catch (e) {
|
|
174
|
-
_this.setState({
|
|
175
|
-
loading: false
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
});
|
|
179
|
-
});
|
|
180
|
-
_defineProperty(this, "_focusHandler", () => {
|
|
181
|
-
this.setActiveIndex(null);
|
|
182
|
-
this.setState({
|
|
183
|
-
focused: true
|
|
184
|
-
});
|
|
185
|
-
});
|
|
186
|
-
_defineProperty(this, "_blurHandler", () => {
|
|
187
|
-
this.setState({
|
|
188
|
-
focused: false
|
|
189
|
-
});
|
|
190
|
-
});
|
|
191
|
-
_defineProperty(this, "selectTag", moveForward => {
|
|
192
|
-
const activeIndex = typeof this.state.activeIndex === 'number' ? this.state.activeIndex : this.state.tags.length + 1;
|
|
193
|
-
let newActiveIndex = activeIndex + (moveForward ? 1 : -1);
|
|
194
|
-
if (newActiveIndex >= this.state.tags.length) {
|
|
195
|
-
newActiveIndex = this.state.tags.length - 1;
|
|
196
|
-
} else if (newActiveIndex < 0) {
|
|
197
|
-
newActiveIndex = 0;
|
|
198
|
-
}
|
|
199
|
-
if (this.state.activeIndex !== newActiveIndex) {
|
|
200
|
-
this.setActiveIndex(newActiveIndex);
|
|
201
|
-
}
|
|
202
|
-
});
|
|
203
|
-
// eslint-disable-next-line complexity
|
|
204
|
-
_defineProperty(this, "handleKeyDown", event => {
|
|
205
|
-
var _this$select4;
|
|
206
|
-
const key = getEventKey(event);
|
|
207
|
-
const isInputFocused = () => {
|
|
208
|
-
var _this$getInputNode$ta, _this$getInputNode2;
|
|
209
|
-
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 : '');
|
|
210
|
-
};
|
|
211
|
-
if (key === ' ' && this.props.allowAddNewTags) {
|
|
212
|
-
var _this$getInputNode3;
|
|
213
|
-
event.stopPropagation();
|
|
214
|
-
const value = (_this$getInputNode3 = this.getInputNode()) === null || _this$getInputNode3 === void 0 ? void 0 : _this$getInputNode3.value;
|
|
215
|
-
if (value) {
|
|
216
|
-
this.handleTagCreation(value);
|
|
217
|
-
}
|
|
218
|
-
return true;
|
|
219
|
-
}
|
|
220
|
-
// eslint-disable-next-line no-underscore-dangle
|
|
221
|
-
if ((_this$select4 = this.select) !== null && _this$select4 !== void 0 && (_this$select4 = _this$select4._popup) !== null && _this$select4 !== void 0 && _this$select4.isVisible()) {
|
|
222
|
-
return true;
|
|
223
|
-
}
|
|
224
|
-
if (key === 'ArrowLeft') {
|
|
225
|
-
var _this$caret;
|
|
226
|
-
if (this.getInputNode() && this.caret && Number((_this$caret = this.caret) === null || _this$caret === void 0 ? void 0 : _this$caret.getPosition()) > 0) {
|
|
227
|
-
return true;
|
|
228
|
-
}
|
|
229
|
-
this.selectTag();
|
|
230
|
-
return false;
|
|
231
|
-
}
|
|
232
|
-
if (key === 'ArrowRight' && !isInputFocused()) {
|
|
233
|
-
if (this.state.activeIndex === this.state.tags.length - 1) {
|
|
234
|
-
if (!this.props.disabled) {
|
|
235
|
-
var _this$getInputNode4;
|
|
236
|
-
(_this$getInputNode4 = this.getInputNode()) === null || _this$getInputNode4 === void 0 || _this$getInputNode4.focus();
|
|
237
|
-
this.setActiveIndex();
|
|
238
|
-
}
|
|
239
|
-
} else {
|
|
240
|
-
this.selectTag(true);
|
|
241
|
-
}
|
|
242
|
-
return false;
|
|
243
|
-
}
|
|
244
|
-
if (!this.props.disabled) {
|
|
245
|
-
var _this$getInputNode5;
|
|
246
|
-
if (key === 'Backspace' && !((_this$getInputNode5 = this.getInputNode()) !== null && _this$getInputNode5 !== void 0 && _this$getInputNode5.value)) {
|
|
247
|
-
var _this$select5;
|
|
248
|
-
event.preventDefault();
|
|
249
|
-
const tagsLength = this.state.tags.length;
|
|
250
|
-
// eslint-disable-next-line no-underscore-dangle
|
|
251
|
-
(_this$select5 = this.select) === null || _this$select5 === void 0 || _this$select5._hidePopup(true); // otherwise confirmation may be overlapped by popup
|
|
252
|
-
this.onRemoveTag(this.state.tags[tagsLength - 1]);
|
|
253
|
-
return false;
|
|
254
|
-
}
|
|
255
|
-
if ((key === 'Delete' || key === 'Backspace') && this.state.activeIndex && this.state.tags[this.state.activeIndex]) {
|
|
256
|
-
this.onRemoveTag(this.state.tags[this.state.activeIndex]).then(() => this.selectTag(true));
|
|
257
|
-
return false;
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
return true;
|
|
261
|
-
});
|
|
262
|
-
_defineProperty(this, "handleClick", memoize(tag => () => {
|
|
263
|
-
this.setActiveIndex(this.state.tags.indexOf(tag));
|
|
264
|
-
}));
|
|
265
|
-
_defineProperty(this, "handleRemove", memoize(tag => () => this.onRemoveTag(tag)));
|
|
266
|
-
_defineProperty(this, "handleTagCreation", label => {
|
|
267
|
-
this.addTag({
|
|
268
|
-
key: label,
|
|
269
|
-
label
|
|
270
|
-
});
|
|
271
|
-
});
|
|
272
|
-
_defineProperty(this, "select", void 0);
|
|
273
|
-
_defineProperty(this, "selectRef", el => {
|
|
274
|
-
this.select = el;
|
|
275
|
-
});
|
|
276
109
|
this.ngModelStateField = TagsInput.ngModelStateField;
|
|
277
110
|
}
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
111
|
+
state = {
|
|
112
|
+
tags: [],
|
|
113
|
+
prevTags: null,
|
|
114
|
+
suggestions: [],
|
|
115
|
+
loading: true,
|
|
116
|
+
focused: false,
|
|
117
|
+
query: '',
|
|
118
|
+
activeIndex: 0
|
|
119
|
+
};
|
|
120
|
+
static getDerivedStateFromProps({
|
|
121
|
+
tags
|
|
122
|
+
}, {
|
|
123
|
+
prevTags
|
|
124
|
+
}) {
|
|
285
125
|
const nextState = {
|
|
286
126
|
prevTags: tags
|
|
287
127
|
};
|
|
288
128
|
if (tags && tags !== prevTags) {
|
|
289
129
|
Object.assign(nextState, {
|
|
290
130
|
tags,
|
|
291
|
-
activeIndex: tags
|
|
131
|
+
activeIndex: tags?.length
|
|
292
132
|
});
|
|
293
133
|
}
|
|
294
134
|
return nextState;
|
|
295
135
|
}
|
|
296
136
|
componentDidMount() {
|
|
297
137
|
if (this.props.autoOpen && !this.props.disabled) {
|
|
298
|
-
var _this$select6;
|
|
299
138
|
this.focusInput();
|
|
300
139
|
this.loadSuggestions();
|
|
301
140
|
// eslint-disable-next-line no-underscore-dangle
|
|
302
|
-
|
|
141
|
+
this.select?._showPopup();
|
|
303
142
|
}
|
|
304
143
|
}
|
|
144
|
+
static ngModelStateField = 'tags';
|
|
145
|
+
ngModelStateField;
|
|
146
|
+
static contextType = ControlsHeightContext;
|
|
147
|
+
id = this.props.id || getUID('ring-tags-list-');
|
|
148
|
+
node;
|
|
149
|
+
nodeRef = node => {
|
|
150
|
+
this.node = node;
|
|
151
|
+
};
|
|
152
|
+
input;
|
|
153
|
+
caret;
|
|
305
154
|
getInputNode() {
|
|
306
155
|
if (!this.input) {
|
|
307
|
-
|
|
308
|
-
this.input = (_this$select7 = this.select) === null || _this$select7 === void 0 ? void 0 : _this$select7.filter;
|
|
156
|
+
this.input = this.select?.filter;
|
|
309
157
|
if (this.input) {
|
|
310
158
|
this.caret = new Caret(this.input);
|
|
311
159
|
}
|
|
@@ -317,6 +165,29 @@ class TagsInput extends PureComponent {
|
|
|
317
165
|
activeIndex
|
|
318
166
|
});
|
|
319
167
|
}
|
|
168
|
+
focusInput = () => {
|
|
169
|
+
this.getInputNode()?.focus();
|
|
170
|
+
};
|
|
171
|
+
focus = () => {
|
|
172
|
+
this.focusInput();
|
|
173
|
+
};
|
|
174
|
+
addTag = tag => {
|
|
175
|
+
if (tag === null) {
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
const isUniqueTag = this.state.tags.filter(item => tag.key === item.key).length === 0;
|
|
179
|
+
this.select?.clear();
|
|
180
|
+
this.select?.filterValue('');
|
|
181
|
+
if (isUniqueTag) {
|
|
182
|
+
this.setState(prevState => ({
|
|
183
|
+
tags: prevState.tags.concat([tag])
|
|
184
|
+
}));
|
|
185
|
+
this.props.onAddTag({
|
|
186
|
+
tag
|
|
187
|
+
});
|
|
188
|
+
this.setActiveIndex();
|
|
189
|
+
}
|
|
190
|
+
};
|
|
320
191
|
onRemoveTag(tagToRemove) {
|
|
321
192
|
return Promise.resolve(this.props.onRemoveTag({
|
|
322
193
|
tag: tagToRemove
|
|
@@ -331,6 +202,129 @@ class TagsInput extends PureComponent {
|
|
|
331
202
|
return tags;
|
|
332
203
|
}, this.focusInput);
|
|
333
204
|
}
|
|
205
|
+
clickHandler = event => {
|
|
206
|
+
if (event.target !== this.node && event.target.parentElement !== this.node) {
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
210
|
+
this.select?._clickHandler();
|
|
211
|
+
};
|
|
212
|
+
filterExistingTags = suggestions => {
|
|
213
|
+
const tagsMap = new Map(this.state.tags.map(tag => [tag.key, tag]));
|
|
214
|
+
return suggestions.filter(suggestion => !tagsMap.has(suggestion.key));
|
|
215
|
+
};
|
|
216
|
+
loadSuggestions = (query = '') => this.setState({
|
|
217
|
+
loading: true,
|
|
218
|
+
query
|
|
219
|
+
}, async () => {
|
|
220
|
+
try {
|
|
221
|
+
const suggestionsResult = this.props.dataSource({
|
|
222
|
+
query
|
|
223
|
+
});
|
|
224
|
+
const allSuggestions = Array.isArray(suggestionsResult) ? suggestionsResult : await suggestionsResult;
|
|
225
|
+
const suggestions = this.filterExistingTags(allSuggestions);
|
|
226
|
+
if (this.node && query === this.state.query) {
|
|
227
|
+
this.setState({
|
|
228
|
+
suggestions,
|
|
229
|
+
loading: false
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
} catch (e) {
|
|
233
|
+
this.setState({
|
|
234
|
+
loading: false
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
_focusHandler = () => {
|
|
239
|
+
this.setActiveIndex(null);
|
|
240
|
+
this.setState({
|
|
241
|
+
focused: true
|
|
242
|
+
});
|
|
243
|
+
};
|
|
244
|
+
_blurHandler = () => {
|
|
245
|
+
this.setState({
|
|
246
|
+
focused: false
|
|
247
|
+
});
|
|
248
|
+
};
|
|
249
|
+
selectTag = moveForward => {
|
|
250
|
+
const activeIndex = typeof this.state.activeIndex === 'number' ? this.state.activeIndex : this.state.tags.length + 1;
|
|
251
|
+
let newActiveIndex = activeIndex + (moveForward ? 1 : -1);
|
|
252
|
+
if (newActiveIndex >= this.state.tags.length) {
|
|
253
|
+
newActiveIndex = this.state.tags.length - 1;
|
|
254
|
+
} else if (newActiveIndex < 0) {
|
|
255
|
+
newActiveIndex = 0;
|
|
256
|
+
}
|
|
257
|
+
if (this.state.activeIndex !== newActiveIndex) {
|
|
258
|
+
this.setActiveIndex(newActiveIndex);
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
// eslint-disable-next-line complexity
|
|
262
|
+
handleKeyDown = event => {
|
|
263
|
+
const key = getEventKey(event);
|
|
264
|
+
const isInputFocused = () => {
|
|
265
|
+
var _this$getInputNode$ta;
|
|
266
|
+
return event.target instanceof Element && event.target.matches((_this$getInputNode$ta = this.getInputNode()?.tagName) !== null && _this$getInputNode$ta !== void 0 ? _this$getInputNode$ta : '');
|
|
267
|
+
};
|
|
268
|
+
if (key === ' ' && this.props.allowAddNewTags) {
|
|
269
|
+
event.stopPropagation();
|
|
270
|
+
const value = this.getInputNode()?.value;
|
|
271
|
+
if (value) {
|
|
272
|
+
this.handleTagCreation(value);
|
|
273
|
+
}
|
|
274
|
+
return true;
|
|
275
|
+
}
|
|
276
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
277
|
+
if (this.select?._popup?.isVisible()) {
|
|
278
|
+
return true;
|
|
279
|
+
}
|
|
280
|
+
if (key === 'ArrowLeft') {
|
|
281
|
+
if (this.getInputNode() && this.caret && Number(this.caret?.getPosition()) > 0) {
|
|
282
|
+
return true;
|
|
283
|
+
}
|
|
284
|
+
this.selectTag();
|
|
285
|
+
return false;
|
|
286
|
+
}
|
|
287
|
+
if (key === 'ArrowRight' && !isInputFocused()) {
|
|
288
|
+
if (this.state.activeIndex === this.state.tags.length - 1) {
|
|
289
|
+
if (!this.props.disabled) {
|
|
290
|
+
this.getInputNode()?.focus();
|
|
291
|
+
this.setActiveIndex();
|
|
292
|
+
}
|
|
293
|
+
} else {
|
|
294
|
+
this.selectTag(true);
|
|
295
|
+
}
|
|
296
|
+
return false;
|
|
297
|
+
}
|
|
298
|
+
if (!this.props.disabled) {
|
|
299
|
+
if (key === 'Backspace' && !this.getInputNode()?.value) {
|
|
300
|
+
event.preventDefault();
|
|
301
|
+
const tagsLength = this.state.tags.length;
|
|
302
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
303
|
+
this.select?._hidePopup(true); // otherwise confirmation may be overlapped by popup
|
|
304
|
+
this.onRemoveTag(this.state.tags[tagsLength - 1]);
|
|
305
|
+
return false;
|
|
306
|
+
}
|
|
307
|
+
if ((key === 'Delete' || key === 'Backspace') && this.state.activeIndex !== null && this.state.activeIndex !== undefined && this.state.tags[this.state.activeIndex]) {
|
|
308
|
+
this.onRemoveTag(this.state.tags[this.state.activeIndex]).then(() => this.selectTag(true));
|
|
309
|
+
return false;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
return true;
|
|
313
|
+
};
|
|
314
|
+
handleClick = memoize(tag => () => {
|
|
315
|
+
this.setActiveIndex(this.state.tags.indexOf(tag));
|
|
316
|
+
});
|
|
317
|
+
handleRemove = memoize(tag => () => this.onRemoveTag(tag));
|
|
318
|
+
handleTagCreation = label => {
|
|
319
|
+
this.addTag({
|
|
320
|
+
key: label,
|
|
321
|
+
label
|
|
322
|
+
});
|
|
323
|
+
};
|
|
324
|
+
select;
|
|
325
|
+
selectRef = el => {
|
|
326
|
+
this.select = el;
|
|
327
|
+
};
|
|
334
328
|
render() {
|
|
335
329
|
const {
|
|
336
330
|
focused,
|
|
@@ -347,7 +341,7 @@ class TagsInput extends PureComponent {
|
|
|
347
341
|
height = typeof this.context === 'function' ? this.context() : this.context,
|
|
348
342
|
label
|
|
349
343
|
} = this.props;
|
|
350
|
-
const classes = classNames(styles.tagsInput, [inputStyles[
|
|
344
|
+
const classes = classNames(styles.tagsInput, [inputStyles[`size${size}`]], [inputStyles[`height${height}`]], {
|
|
351
345
|
[styles.tagsInputDisabled]: disabled,
|
|
352
346
|
[styles.tagsInputFocused]: focused
|
|
353
347
|
}, this.props.className);
|
|
@@ -406,26 +400,6 @@ class TagsInput extends PureComponent {
|
|
|
406
400
|
});
|
|
407
401
|
}
|
|
408
402
|
}
|
|
409
|
-
_defineProperty(TagsInput, "defaultProps", {
|
|
410
|
-
dataSource: noop,
|
|
411
|
-
onAddTag: noop,
|
|
412
|
-
onRemoveTag: noop,
|
|
413
|
-
customTagComponent: null,
|
|
414
|
-
maxPopupHeight: 500,
|
|
415
|
-
minPopupWidth: 360,
|
|
416
|
-
canNotBeEmpty: false,
|
|
417
|
-
disabled: false,
|
|
418
|
-
autoOpen: false,
|
|
419
|
-
renderOptimization: true,
|
|
420
|
-
allowAddNewTags: false,
|
|
421
|
-
filter: {
|
|
422
|
-
fn: () => true
|
|
423
|
-
},
|
|
424
|
-
placeholder: 'Select an option',
|
|
425
|
-
size: Size.M
|
|
426
|
-
});
|
|
427
|
-
_defineProperty(TagsInput, "ngModelStateField", 'tags');
|
|
428
|
-
_defineProperty(TagsInput, "contextType", ControlsHeightContext);
|
|
429
403
|
const RerenderableTagsInput = rerenderHOC(TagsInput);
|
|
430
404
|
|
|
431
405
|
export { RerenderableTagsInput, TagsInput as default };
|
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
import { _ as _defineProperty, b as _objectSpread2, a as _objectWithoutProperties } from '../_helpers/_rollupPluginBabelHelpers.js';
|
|
2
1
|
import { jsxs } from 'react/jsx-runtime';
|
|
3
2
|
import { Component, createElement } from 'react';
|
|
4
3
|
import classNames from 'classnames';
|
|
5
4
|
import Tag from '../tag/tag.js';
|
|
6
|
-
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
7
5
|
import '@jetbrains/icons/close-12px';
|
|
8
6
|
import '../icon/icon.js';
|
|
9
7
|
import 'util-deprecate';
|
|
10
8
|
import '../icon/icon.constants.js';
|
|
11
9
|
import '../_helpers/icon-svg.js';
|
|
12
|
-
import 'core-js/modules/es.regexp.exec.js';
|
|
13
|
-
import 'core-js/modules/es.string.replace.js';
|
|
14
10
|
import '../global/memoize.js';
|
|
15
11
|
import '../button/button.js';
|
|
16
12
|
import '@jetbrains/icons/chevron-down';
|
|
@@ -20,19 +16,26 @@ import '../global/controls-height.js';
|
|
|
20
16
|
import '../global/configuration.js';
|
|
21
17
|
import '../_helpers/button.classes.js';
|
|
22
18
|
|
|
23
|
-
const _excluded = ["children", "className", "customTagComponent", "canNotBeEmpty", "handleClick", "tagClassName", "handleRemove", "tags", "activeIndex"];
|
|
24
19
|
function noop() {}
|
|
25
20
|
/**
|
|
26
21
|
* @name Tags List
|
|
27
22
|
*/
|
|
28
23
|
class TagsList extends Component {
|
|
24
|
+
static defaultProps = {
|
|
25
|
+
customTagComponent: null,
|
|
26
|
+
canNotBeEmpty: false,
|
|
27
|
+
disabled: false,
|
|
28
|
+
handleClick: () => noop,
|
|
29
|
+
handleRemove: () => noop
|
|
30
|
+
};
|
|
29
31
|
renderTag(tag, focusTag) {
|
|
30
32
|
const TagComponent = this.props.customTagComponent || Tag;
|
|
31
33
|
const readOnly = this.props.disabled || tag.readOnly || this.props.canNotBeEmpty && this.props.tags.length === 1;
|
|
32
34
|
const {
|
|
33
35
|
tagClassName
|
|
34
36
|
} = this.props;
|
|
35
|
-
return /*#__PURE__*/createElement(TagComponent,
|
|
37
|
+
return /*#__PURE__*/createElement(TagComponent, {
|
|
38
|
+
...tag,
|
|
36
39
|
key: tag.key,
|
|
37
40
|
readOnly: readOnly,
|
|
38
41
|
disabled: this.props.disabled || tag.disabled,
|
|
@@ -40,38 +43,30 @@ class TagsList extends Component {
|
|
|
40
43
|
onClick: this.props.handleClick(tag),
|
|
41
44
|
onRemove: this.props.handleRemove(tag),
|
|
42
45
|
className: tagClassName
|
|
43
|
-
}
|
|
46
|
+
}, tag.label);
|
|
44
47
|
}
|
|
45
48
|
render() {
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
props = _objectWithoutProperties(_this$props, _excluded);
|
|
49
|
+
const {
|
|
50
|
+
children,
|
|
51
|
+
className,
|
|
52
|
+
customTagComponent,
|
|
53
|
+
canNotBeEmpty,
|
|
54
|
+
handleClick,
|
|
55
|
+
tagClassName,
|
|
56
|
+
handleRemove,
|
|
57
|
+
tags,
|
|
58
|
+
activeIndex,
|
|
59
|
+
...props
|
|
60
|
+
} = this.props;
|
|
59
61
|
const classes = classNames('ring-js-shortcuts', className);
|
|
60
62
|
const tagsList = (this.props.tags || []).map((tag, index) => this.renderTag(tag, this.props.activeIndex === index));
|
|
61
|
-
return jsxs("div",
|
|
63
|
+
return jsxs("div", {
|
|
62
64
|
"data-test": 'ring-tags-list',
|
|
63
|
-
className: classes
|
|
64
|
-
|
|
65
|
+
className: classes,
|
|
66
|
+
...props,
|
|
65
67
|
children: [tagsList, children]
|
|
66
|
-
})
|
|
68
|
+
});
|
|
67
69
|
}
|
|
68
70
|
}
|
|
69
|
-
_defineProperty(TagsList, "defaultProps", {
|
|
70
|
-
customTagComponent: null,
|
|
71
|
-
canNotBeEmpty: false,
|
|
72
|
-
disabled: false,
|
|
73
|
-
handleClick: () => noop,
|
|
74
|
-
handleRemove: () => noop
|
|
75
|
-
});
|
|
76
71
|
|
|
77
72
|
export { TagsList as default };
|