@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.
Files changed (234) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +17 -15
  3. package/babel.config.js +3 -2
  4. package/components/alert/alert.js +9 -3
  5. package/components/alert/alert.test.js +21 -48
  6. package/components/alert/container.css +1 -1
  7. package/components/alert/container.test.js +3 -13
  8. package/components/alert-service/alert-service.examples.css +18 -0
  9. package/components/alert-service/alert-service.examples.js +21 -0
  10. package/components/alert-service/alert-service.js +10 -3
  11. package/components/analytics/analytics__fus-plugin.js +3 -3
  12. package/components/analytics/analytics__ga-plugin.js +2 -2
  13. package/components/auth/auth.test.js +14 -7
  14. package/components/auth/auth__core.js +64 -33
  15. package/components/auth-dialog/auth-dialog.css +2 -3
  16. package/components/auth-dialog/auth-dialog.js +4 -1
  17. package/components/auth-dialog/auth-dialog.test.js +3 -19
  18. package/components/avatar/avatar.css +4 -1
  19. package/components/avatar/avatar.examples.js +3 -2
  20. package/components/avatar/avatar.js +34 -6
  21. package/components/avatar/avatar.test.js +20 -17
  22. package/components/avatar/fallback-avatar.js +136 -0
  23. package/components/avatar-editor-ng/avatar-editor-ng.css +2 -2
  24. package/components/avatar-editor-ng/avatar-editor-ng.js +2 -1
  25. package/components/avatar-editor-ng/{avatar-editor-ng.html → avatar-editor-ng__template.js} +2 -2
  26. package/components/badge/badge.test.js +13 -20
  27. package/components/button/button.css +2 -2
  28. package/components/button/button.js +4 -1
  29. package/components/button/button.test.js +32 -33
  30. package/components/button-group/button-group.js +1 -1
  31. package/components/button-group/caption.js +1 -1
  32. package/components/button-ng/button-ng.js +1 -1
  33. package/components/button-set-ng/button-set-ng.js +3 -1
  34. package/components/checkbox/checkbox.css +1 -1
  35. package/components/code/code.js +2 -5
  36. package/components/confirm/confirm.js +1 -0
  37. package/components/confirm-service/confirm-service.js +5 -5
  38. package/components/content-layout/content-layout.css +1 -1
  39. package/components/data-list/data-list.css +1 -1
  40. package/components/date-picker/date-input.js +5 -4
  41. package/components/date-picker/date-picker.css +34 -22
  42. package/components/date-picker/date-picker.js +16 -14
  43. package/components/date-picker/date-popup.js +22 -7
  44. package/components/date-picker/month-names.js +8 -5
  45. package/components/date-picker/month.js +6 -2
  46. package/components/date-picker/weekdays.js +10 -2
  47. package/components/dialog/dialog.examples.js +3 -1
  48. package/components/dialog/dialog.js +10 -5
  49. package/components/dialog/dialog.test.js +1 -1
  50. package/components/dialog/dialog__body-scroll-preventer.js +51 -31
  51. package/components/dialog-ng/dialog-ng.js +10 -10
  52. package/components/dialog-ng/{dialog-ng.html → dialog-ng__template.js} +2 -2
  53. package/components/dropdown/dropdown.examples.js +36 -1
  54. package/components/dropdown/dropdown.test.js +2 -2
  55. package/components/dropdown-menu/dropdown-menu.examples.js +47 -0
  56. package/components/dropdown-menu/dropdown-menu.js +117 -0
  57. package/components/dropdown-menu/dropdown-menu.test.js +76 -0
  58. package/components/error-bubble/error-bubble-legacy.css +1 -1
  59. package/components/error-bubble/error-bubble.css +1 -1
  60. package/components/error-bubble/error-bubble.examples.js +1 -1
  61. package/components/error-page/error-page.css +2 -2
  62. package/components/footer-ng/footer-ng.js +13 -3
  63. package/components/form/form.css +2 -2
  64. package/components/form-ng/form-ng.js +3 -1
  65. package/components/global/global.css +1 -1
  66. package/components/global/theme.js +1 -1
  67. package/components/global/variables.css +8 -1
  68. package/components/grid/grid.css +10 -9
  69. package/components/header/header.css +1 -1
  70. package/components/header/header.examples.js +7 -8
  71. package/components/header/profile.js +10 -11
  72. package/components/http/http.js +1 -1
  73. package/components/icon/icon.css +5 -4
  74. package/components/input/input-legacy.css +7 -7
  75. package/components/island/header.js +2 -2
  76. package/components/island/island.css +8 -3
  77. package/components/island-legacy/island-legacy.css +3 -1
  78. package/components/list/list.js +6 -1
  79. package/components/list/list__custom.js +9 -3
  80. package/components/list/list__item.js +8 -2
  81. package/components/list/list__link.js +2 -1
  82. package/components/loader-inline/loader-inline.css +1 -1
  83. package/components/loader-screen/loader-screen.css +1 -1
  84. package/components/message/message.css +1 -1
  85. package/components/message/message.examples.js +8 -7
  86. package/components/pager/pager.js +5 -3
  87. package/components/permissions/permissions.js +1 -1
  88. package/components/popup/popup.js +1 -1
  89. package/components/popup/popup.test.js +15 -13
  90. package/components/progress-bar/progress-bar.css +1 -1
  91. package/components/progress-bar/progress-bar.examples.js +3 -3
  92. package/components/progress-bar/progress-bar.js +5 -2
  93. package/components/progress-bar/progress-bar.test.js +12 -13
  94. package/components/progress-bar-ng/progress-bar-ng.examples.js +3 -3
  95. package/components/query-assist/query-assist.css +13 -3
  96. package/components/query-assist/query-assist.examples.js +3 -4
  97. package/components/query-assist/query-assist.js +56 -12
  98. package/components/query-assist/query-assist.test.js +37 -5
  99. package/components/save-field-ng/save-field-ng.css +0 -3
  100. package/components/save-field-ng/save-field-ng.js +3 -1
  101. package/components/save-field-ng/{save-field-ng.html → save-field-ng__template.js} +2 -2
  102. package/components/select/select.css +12 -7
  103. package/components/select/select.examples.js +13 -0
  104. package/components/select/select.js +30 -43
  105. package/components/select/select.test.js +4 -5
  106. package/components/select/select__popup.js +1 -0
  107. package/components/shortcuts-hint-ng/shortcuts-hint-ng.css +1 -1
  108. package/components/shortcuts-hint-ng/shortcuts-hint-ng.js +1 -1
  109. package/components/shortcuts-hint-ng/{shortcuts-hint-ng.html → shortcuts-hint-ng__template.js} +2 -2
  110. package/components/sidebar/sidebar.css +1 -0
  111. package/components/sidebar-ng/sidebar-ng.js +6 -2
  112. package/components/sidebar-ng/{sidebar-ng__button.html → sidebar-ng__button-template.js} +2 -2
  113. package/components/sidebar-ng/{sidebar-ng.html → sidebar-ng__template.js} +2 -2
  114. package/components/table/header.js +9 -1
  115. package/components/table/row.js +2 -1
  116. package/components/table/table.css +2 -1
  117. package/components/table-legacy/table-legacy.css +2 -2
  118. package/components/table-legacy/table-legacy__toolbar.css +2 -2
  119. package/components/table-legacy-ng/table-legacy-ng.js +38 -5
  120. package/components/table-legacy-ng/table-legacy-ng__pager.js +7 -1
  121. package/components/tabs/collapsible-tab.js +2 -2
  122. package/components/tabs/collapsible-tabs.js +5 -9
  123. package/components/tabs/tab-link.js +4 -2
  124. package/components/tabs/tabs.css +32 -5
  125. package/components/tabs-ng/tabs-ng.js +4 -2
  126. package/components/tabs-ng/{tabs-ng.html → tabs-ng__template.js} +6 -2
  127. package/components/tag/tag.css +5 -2
  128. package/components/tag/tag.examples.js +3 -0
  129. package/components/tag/tag.js +19 -16
  130. package/components/tags-input/tag-input.examples.js +1 -1
  131. package/components/tags-input/tags-input.js +5 -2
  132. package/components/template-ng/template-ng.js +1 -1
  133. package/components/tooltip/tooltip.js +7 -2
  134. package/components/user-agreement/user-agreement.css +1 -5
  135. package/components/user-agreement/user-agreement.examples.js +7 -6
  136. package/components/user-agreement/user-agreement.js +11 -3
  137. package/package.json +85 -83
  138. package/webpack.config.js +14 -10
  139. package/components/button-set-ng/button-set-ng.html +0 -1
  140. package/components/footer-ng/footer-ng.html +0 -13
  141. package/components/form-ng/form-ng__error-bubble.html +0 -3
  142. package/components/table-legacy-ng/table-legacy-ng.html +0 -4
  143. package/components/table-legacy-ng/table-legacy-ng__column.html +0 -12
  144. package/components/table-legacy-ng/table-legacy-ng__header.html +0 -4
  145. package/components/table-legacy-ng/table-legacy-ng__pager.html +0 -7
  146. package/components/table-legacy-ng/table-legacy-ng__row.html +0 -12
  147. package/components/table-legacy-ng/table-legacy-ng__title.html +0 -9
  148. package/dist/_helpers/_rollupPluginBabelHelpers.js +0 -123
  149. package/dist/_helpers/background-flow.js +0 -232
  150. package/dist/_helpers/badge.js +0 -3
  151. package/dist/_helpers/button.js +0 -145
  152. package/dist/_helpers/clickableLink.js +0 -65
  153. package/dist/_helpers/data-tests.js +0 -15
  154. package/dist/_helpers/disable-hover-hoc.js +0 -407
  155. package/dist/_helpers/dom.js +0 -101
  156. package/dist/_helpers/get-uid.js +0 -15
  157. package/dist/_helpers/linear-function.js +0 -17
  158. package/dist/_helpers/list.js +0 -1327
  159. package/dist/_helpers/logo.js +0 -36
  160. package/dist/_helpers/memoize.js +0 -17
  161. package/dist/_helpers/popup.js +0 -691
  162. package/dist/_helpers/popup.target.js +0 -27
  163. package/dist/_helpers/rerender-hoc.js +0 -49
  164. package/dist/_helpers/schedule-raf.js +0 -31
  165. package/dist/_helpers/sniffer.js +0 -6
  166. package/dist/_helpers/theme.js +0 -40
  167. package/dist/_helpers/url.js +0 -125
  168. package/dist/alert-service.js +0 -149
  169. package/dist/alert.js +0 -284
  170. package/dist/analytics.js +0 -116
  171. package/dist/auth-dialog-service.js +0 -56
  172. package/dist/auth-dialog.js +0 -122
  173. package/dist/auth.js +0 -1744
  174. package/dist/avatar.js +0 -152
  175. package/dist/badge.js +0 -52
  176. package/dist/button-group.js +0 -48
  177. package/dist/button-set.js +0 -27
  178. package/dist/button-toolbar.js +0 -30
  179. package/dist/button.js +0 -12
  180. package/dist/caret.js +0 -262
  181. package/dist/checkbox.js +0 -108
  182. package/dist/confirm-service.js +0 -102
  183. package/dist/confirm.js +0 -113
  184. package/dist/content-layout.js +0 -184
  185. package/dist/contenteditable.js +0 -81
  186. package/dist/data-list.js +0 -466
  187. package/dist/date-picker.js +0 -1398
  188. package/dist/dialog.js +0 -223
  189. package/dist/dropdown.js +0 -250
  190. package/dist/error-bubble.js +0 -56
  191. package/dist/error-message.js +0 -53
  192. package/dist/footer.js +0 -124
  193. package/dist/grid.js +0 -148
  194. package/dist/group.js +0 -34
  195. package/dist/header.js +0 -658
  196. package/dist/heading.js +0 -76
  197. package/dist/http.js +0 -207
  198. package/dist/hub-source.js +0 -130
  199. package/dist/icon.js +0 -211
  200. package/dist/input.js +0 -228
  201. package/dist/island.js +0 -314
  202. package/dist/link.js +0 -117
  203. package/dist/list.js +0 -29
  204. package/dist/loader-inline.js +0 -165
  205. package/dist/loader-screen.js +0 -45
  206. package/dist/loader.js +0 -338
  207. package/dist/login-dialog.js +0 -173
  208. package/dist/logo.js +0 -8
  209. package/dist/message.js +0 -226
  210. package/dist/old-browsers-message.js +0 -129
  211. package/dist/pager.js +0 -325
  212. package/dist/panel.js +0 -34
  213. package/dist/permissions.js +0 -466
  214. package/dist/popup-menu.js +0 -93
  215. package/dist/popup.js +0 -16
  216. package/dist/progress-bar.js +0 -111
  217. package/dist/proxy-attrs.js +0 -19
  218. package/dist/query-assist.js +0 -1081
  219. package/dist/radio.js +0 -112
  220. package/dist/select.js +0 -1920
  221. package/dist/selection.js +0 -213
  222. package/dist/shortcuts.js +0 -307
  223. package/dist/storage.js +0 -373
  224. package/dist/style.css +0 -1
  225. package/dist/tab-trap.js +0 -174
  226. package/dist/table.js +0 -903
  227. package/dist/tabs.js +0 -721
  228. package/dist/tag.js +0 -187
  229. package/dist/tags-input.js +0 -440
  230. package/dist/tags-list.js +0 -91
  231. package/dist/text.js +0 -38
  232. package/dist/toggle.js +0 -80
  233. package/dist/tooltip.js +0 -202
  234. package/dist/user-card.js +0 -218
package/dist/tag.js DELETED
@@ -1,187 +0,0 @@
1
- import { b as _defineProperty } from './_helpers/_rollupPluginBabelHelpers.js';
2
- import React, { PureComponent } from 'react';
3
- import PropTypes from 'prop-types';
4
- import classNames from 'classnames';
5
- import closeIcon from '@jetbrains/icons/close';
6
- import Icon from './icon.js';
7
- import { B as Button } from './_helpers/button.js';
8
- import 'util-deprecate';
9
- import './_helpers/memoize.js';
10
- import 'focus-visible';
11
- import '@jetbrains/icons/chevron-10px';
12
- import './_helpers/theme.js';
13
- import './_helpers/clickableLink.js';
14
-
15
- var modules_2f9be069 = {"unit":"8px","resetButton":"global_resetButton__0f8f4370","background-color":"var(--ring-tag-background-color)","max-height":"20px","tag":"tag_tag__e2972246 global_resetButton__0f8f4370","withRemove":"tag_withRemove__e2972246","container":"tag_container__e2972246","focused":"tag_focused__e2972246","tagAngled":"tag_tagAngled__e2972246","content":"tag_content__e2972246 global_ellipsis__0f8f4370","disabled":"tag_disabled__e2972246","remove":"tag_remove__e2972246","removeIcon":"tag_removeIcon__e2972246","icon":"tag_icon__e2972246","avatarContainer":"tag_avatarContainer__e2972246","customIcon":"tag_customIcon__e2972246","avatarIcon":"tag_avatarIcon__e2972246"};
16
-
17
- /**
18
- * @name Tag
19
- */
20
-
21
- class Tag extends PureComponent {
22
- constructor(...args) {
23
- super(...args);
24
-
25
- _defineProperty(this, "state", {
26
- focused: false
27
- });
28
-
29
- _defineProperty(this, "onDocumentClick", event => {
30
- if (this.tagNode) {
31
- this.setState({
32
- focused: this.tagNode === event.target
33
- });
34
- }
35
- });
36
-
37
- _defineProperty(this, "tagRef", el => {
38
- this.tagNode = el;
39
- });
40
- }
41
-
42
- componentDidUpdate(prevProps) {
43
- if (this.props.focused !== prevProps.focused) {
44
- // eslint-disable-next-line react/no-did-update-set-state
45
- this.setState({
46
- focused: this.props.focused
47
- });
48
- }
49
-
50
- if (this.state.focused) {
51
- this.tagNode.focus();
52
- }
53
-
54
- this.setDocumentClickListener(this.state.focused);
55
- }
56
-
57
- componentWillUnmount() {
58
- this.setDocumentClickListener(false);
59
- this.setState({
60
- focused: false
61
- });
62
- }
63
-
64
- setDocumentClickListener(setListener) {
65
- if (setListener) {
66
- document.addEventListener('click', this.onDocumentClick);
67
- } else {
68
- document.removeEventListener('click', this.onDocumentClick);
69
- }
70
- }
71
-
72
- renderCustomIcon() {
73
- if (this.props.rgTagIcon) {
74
- return /*#__PURE__*/React.createElement(Icon, {
75
- className: modules_2f9be069.icon,
76
- title: this.props.rgTagTitle,
77
- glyph: this.props.rgTagIcon
78
- });
79
- }
80
-
81
- return null;
82
- }
83
-
84
- _renderImageElement(avatarSrc) {
85
- const classes = classNames({
86
- [modules_2f9be069.customIcon]: this.props.icon,
87
- [modules_2f9be069.avatarIcon]: avatarSrc
88
- });
89
- return /*#__PURE__*/React.createElement("img", {
90
- alt: avatarSrc ? 'Avatar' : 'Icon',
91
- className: classes,
92
- src: avatarSrc || this.props.icon
93
- });
94
- }
95
-
96
- renderImage() {
97
- if (this.props.icon && !this.props.avatar) {
98
- return this._renderImageElement();
99
- }
100
-
101
- return null;
102
- }
103
-
104
- renderAvatar() {
105
- if (this.props.avatar) {
106
- return /*#__PURE__*/React.createElement("span", {
107
- className: modules_2f9be069.avatarContainer
108
- }, this._renderImageElement(this.props.avatar));
109
- }
110
-
111
- return null;
112
- }
113
-
114
- renderRemoveIcon() {
115
- if (!this.props.readOnly) {
116
- return /*#__PURE__*/React.createElement(Button, {
117
- title: "Remove",
118
- icon: closeIcon,
119
- "data-test": "ring-tag-remove",
120
- className: modules_2f9be069.remove,
121
- iconClassName: modules_2f9be069.removeIcon,
122
- onClick: this.props.onRemove,
123
- style: {
124
- '--ring-icon-secondary-color': this.props.textColor
125
- }
126
- });
127
- }
128
-
129
- return null;
130
- }
131
-
132
- render() {
133
- const classes = classNames('ring-js-shortcuts', modules_2f9be069.tag, {
134
- [modules_2f9be069.focused]: this.state.focused,
135
- [modules_2f9be069.disabled]: this.props.disabled,
136
- [modules_2f9be069.tagAngled]: this.props.angled,
137
- [modules_2f9be069.withRemove]: !this.props.readOnly
138
- }, this.props.className);
139
- const {
140
- backgroundColor,
141
- textColor
142
- } = this.props;
143
- return /*#__PURE__*/React.createElement("span", {
144
- className: modules_2f9be069.container
145
- }, /*#__PURE__*/React.createElement("button", {
146
- type: "button",
147
- "data-test": "ring-tag",
148
- className: classes,
149
- ref: this.tagRef,
150
- onClick: this.props.onClick,
151
- style: {
152
- backgroundColor,
153
- color: textColor
154
- }
155
- }, this.renderAvatar(), this.renderCustomIcon(), this.renderImage(), /*#__PURE__*/React.createElement("span", {
156
- className: modules_2f9be069.content
157
- }, this.props.children)), this.renderRemoveIcon());
158
- }
159
-
160
- }
161
-
162
- _defineProperty(Tag, "propTypes", {
163
- onRemove: PropTypes.func,
164
- onClick: PropTypes.func,
165
- rgTagIcon: PropTypes.oneOfType([PropTypes.string, PropTypes.elementType]),
166
- icon: PropTypes.string,
167
- avatar: PropTypes.string,
168
- rgTagTitle: PropTypes.string,
169
- readOnly: PropTypes.bool,
170
- disabled: PropTypes.bool,
171
- focused: PropTypes.bool,
172
- angled: PropTypes.bool,
173
- backgroundColor: PropTypes.string,
174
- textColor: PropTypes.string,
175
- children: PropTypes.node,
176
- className: PropTypes.string
177
- });
178
-
179
- _defineProperty(Tag, "defaultProps", {
180
- onRemove: () => {},
181
- onClick: () => {},
182
- readOnly: false,
183
- disabled: false,
184
- focused: false
185
- });
186
-
187
- export default Tag;
@@ -1,440 +0,0 @@
1
- import { b as _defineProperty } from './_helpers/_rollupPluginBabelHelpers.js';
2
- import React, { PureComponent, Component } from 'react';
3
- import PropTypes from 'prop-types';
4
- import classNames from 'classnames';
5
- import { g as getEventKey } from './_helpers/list.js';
6
- import Select from './select.js';
7
- import TagsList from './tags-list.js';
8
- import Caret from './caret.js';
9
- import { m as memoize } from './_helpers/memoize.js';
10
- import { r as rerenderHOC } from './_helpers/rerender-hoc.js';
11
- import 'react-virtualized/dist/es/List';
12
- import 'react-virtualized/dist/es/AutoSizer';
13
- import 'react-virtualized/dist/es/WindowScroller';
14
- import 'react-virtualized/dist/es/CellMeasurer';
15
- import 'util-deprecate';
16
- import 'memoize-one';
17
- import './_helpers/data-tests.js';
18
- import './_helpers/get-uid.js';
19
- import './_helpers/schedule-raf.js';
20
- import './_helpers/dom.js';
21
- import './shortcuts.js';
22
- import 'combokeys';
23
- import './_helpers/sniffer.js';
24
- import 'sniffr';
25
- import './link.js';
26
- import 'focus-visible';
27
- import './_helpers/clickableLink.js';
28
- import './avatar.js';
29
- import './_helpers/url.js';
30
- import './checkbox.js';
31
- import '@jetbrains/icons/checkmark';
32
- import '@jetbrains/icons/remove-10px';
33
- import './icon.js';
34
- import '@jetbrains/icons/chevron-10px';
35
- import '@jetbrains/icons/close';
36
- import 'deep-equal';
37
- import './dropdown.js';
38
- import './_helpers/button.js';
39
- import './_helpers/theme.js';
40
- import './_helpers/popup.js';
41
- import 'react-dom';
42
- import './tab-trap.js';
43
- import './_helpers/popup.target.js';
44
- import './input.js';
45
- import '@jetbrains/icons/search';
46
- import './loader-inline.js';
47
- import 'conic-gradient';
48
- import './text.js';
49
- import './tag.js';
50
-
51
- var modules_5aa8aaf3 = {"tagsInput":"tagsInput_tagsInput__3bf16b19","tagsInputLegacyMode":"tagsInput_tagsInputLegacyMode__3bf16b19","tagsList":"tagsInput_tagsList__3bf16b19","tag":"tagsInput_tag__3bf16b19","tagsInputDisabled":"tagsInput_tagsInputDisabled__3bf16b19","underline":"tagsInput_underline__3bf16b19","tagsInputFocused":"tagsInput_tagsInputFocused__3bf16b19","tagsSelect":"tagsInput_tagsSelect__3bf16b19","focusUnderline":"tagsInput_focusUnderline__3bf16b19"};
52
-
53
- function noop() {}
54
- /**
55
- * @name Tags Input
56
- */
57
-
58
-
59
- const POPUP_VERTICAL_SHIFT = 2;
60
- class TagsInput extends PureComponent {
61
- constructor(...args) {
62
- super(...args);
63
-
64
- _defineProperty(this, "state", {
65
- tags: [],
66
- prevTags: null,
67
- suggestions: [],
68
- loading: true,
69
- focused: false,
70
- query: '',
71
- activeIndex: 0
72
- });
73
-
74
- _defineProperty(this, "nodeRef", node => {
75
- this.node = node;
76
- });
77
-
78
- _defineProperty(this, "ngModelStateField", TagsInput.ngModelStateField);
79
-
80
- _defineProperty(this, "focusInput", () => {
81
- this.getInputNode().focus();
82
- });
83
-
84
- _defineProperty(this, "addTag", tag => {
85
- const isUniqueTag = this.state.tags.filter(item => tag.key === item.key).length === 0;
86
- this.select.clear();
87
- this.select.filterValue('');
88
-
89
- if (isUniqueTag) {
90
- this.setState(prevState => ({
91
- tags: prevState.tags.concat([tag])
92
- }));
93
- this.props.onAddTag({
94
- tag
95
- });
96
- this.setActiveIndex();
97
- }
98
- });
99
-
100
- _defineProperty(this, "clickHandler", event => {
101
- if (event.target !== this.node) {
102
- return;
103
- }
104
-
105
- this.loadSuggestions(this.getInputNode().value);
106
- this.focusInput();
107
- });
108
-
109
- _defineProperty(this, "filterExistingTags", suggestions => {
110
- const tagsMap = new Map(this.state.tags.map(tag => [tag.key, tag]));
111
- return suggestions.filter(suggestion => !tagsMap.has(suggestion.key));
112
- });
113
-
114
- _defineProperty(this, "loadSuggestions", (query = '') => this.setState({
115
- loading: true,
116
- query
117
- }, async () => {
118
- try {
119
- let allSuggestions = this.props.dataSource({
120
- query
121
- });
122
-
123
- if (typeof allSuggestions.then === 'function') {
124
- allSuggestions = await allSuggestions;
125
- }
126
-
127
- const suggestions = this.filterExistingTags(allSuggestions);
128
-
129
- if (this.node && query === this.state.query) {
130
- this.setState({
131
- suggestions,
132
- loading: false
133
- });
134
- }
135
- } catch (e) {
136
- this.setState({
137
- loading: false
138
- });
139
- }
140
- }));
141
-
142
- _defineProperty(this, "_focusHandler", () => {
143
- this.setActiveIndex(null);
144
- this.setState({
145
- focused: true
146
- });
147
- });
148
-
149
- _defineProperty(this, "_blurHandler", () => {
150
- this.setState({
151
- focused: false
152
- });
153
- });
154
-
155
- _defineProperty(this, "selectTag", moveForward => {
156
- const activeIndex = typeof this.state.activeIndex === 'number' ? this.state.activeIndex : this.state.tags.length + 1;
157
- let newActiveIndex = activeIndex + (moveForward ? 1 : -1);
158
-
159
- if (newActiveIndex >= this.state.tags.length) {
160
- newActiveIndex = this.state.tags.length - 1;
161
- } else if (newActiveIndex < 0) {
162
- newActiveIndex = 0;
163
- }
164
-
165
- if (this.state.activeIndex !== newActiveIndex) {
166
- this.setActiveIndex(newActiveIndex);
167
- }
168
- });
169
-
170
- _defineProperty(this, "handleKeyDown", event => {
171
- const key = getEventKey(event);
172
-
173
- const isInputFocused = () => event.target.matches(this.getInputNode().tagName);
174
-
175
- if (key === ' ' && this.props.allowAddNewTags) {
176
- event.stopPropagation();
177
- const value = this.getInputNode().value;
178
-
179
- if (value !== '') {
180
- this.handleTagCreation(value);
181
- }
182
-
183
- return true;
184
- }
185
-
186
- if (this.select._popup.isVisible()) {
187
- return true;
188
- }
189
-
190
- if (key === 'ArrowLeft') {
191
- if (this.getInputNode() && this.caret.getPosition() > 0) {
192
- return true;
193
- }
194
-
195
- this.selectTag();
196
- return false;
197
- }
198
-
199
- if (key === 'ArrowRight' && !isInputFocused()) {
200
- if (this.state.activeIndex === this.state.tags.length - 1) {
201
- if (!this.props.disabled) {
202
- this.getInputNode().focus();
203
- this.setActiveIndex();
204
- }
205
- } else {
206
- this.selectTag(true);
207
- }
208
-
209
- return false;
210
- }
211
-
212
- if (!this.props.disabled) {
213
- if (key === 'Backspace' && !this.getInputNode().value) {
214
- event.preventDefault();
215
- const tagsLength = this.state.tags.length;
216
-
217
- this.select._hidePopup(true); // otherwise confirmation may be overlapped by popup
218
-
219
-
220
- this.onRemoveTag(this.state.tags[tagsLength - 1]);
221
- return false;
222
- }
223
-
224
- if ((key === 'Delete' || key === 'Backspace') && this.state.tags[this.state.activeIndex]) {
225
- this.onRemoveTag(this.state.tags[this.state.activeIndex]).then(() => this.selectTag(true));
226
- return false;
227
- }
228
- }
229
-
230
- return true;
231
- });
232
-
233
- _defineProperty(this, "handleClick", memoize(tag => () => {
234
- this.setActiveIndex(this.state.tags.indexOf(tag));
235
- }));
236
-
237
- _defineProperty(this, "handleRemove", memoize(tag => () => this.onRemoveTag(tag)));
238
-
239
- _defineProperty(this, "handleTagCreation", label => {
240
- this.addTag({
241
- key: label,
242
- label
243
- });
244
- });
245
-
246
- _defineProperty(this, "selectRef", el => {
247
- this.select = el;
248
- });
249
- }
250
-
251
- static getDerivedStateFromProps({
252
- tags
253
- }, {
254
- prevTags
255
- }) {
256
- const nextState = {
257
- prevTags: tags
258
- };
259
-
260
- if (tags != null && tags !== prevTags) {
261
- Object.assign(nextState, {
262
- tags,
263
- activeIndex: tags.length
264
- });
265
- }
266
-
267
- return nextState;
268
- }
269
-
270
- componentDidMount() {
271
- if (this.props.autoOpen && !this.props.disabled) {
272
- this.focusInput();
273
- this.loadSuggestions();
274
-
275
- this.select._showPopup();
276
- }
277
- }
278
-
279
- getInputNode() {
280
- if (!this.input) {
281
- this.input = this.select.filter;
282
- this.caret = new Caret(this.input);
283
- }
284
-
285
- return this.input;
286
- }
287
-
288
- setActiveIndex(activeIndex) {
289
- this.setState({
290
- activeIndex
291
- });
292
- }
293
-
294
- onRemoveTag(tagToRemove) {
295
- return Promise.resolve(this.props.onRemoveTag({
296
- tag: tagToRemove
297
- })).then(() => {
298
- const tags = this.state.tags.filter(tag => tag !== tagToRemove);
299
-
300
- if (this.node) {
301
- this.setState({
302
- tags
303
- });
304
- this.focusInput();
305
- }
306
-
307
- return tags;
308
- }, this.focusInput);
309
- }
310
-
311
- render() {
312
- const {
313
- focused,
314
- tags,
315
- activeIndex
316
- } = this.state;
317
- const {
318
- legacyMode,
319
- disabled,
320
- canNotBeEmpty,
321
- allowAddNewTags,
322
- filter
323
- } = this.props;
324
- const classes = classNames(modules_5aa8aaf3.tagsInput, {
325
- [modules_5aa8aaf3.tagsInputDisabled]: disabled,
326
- [modules_5aa8aaf3.tagsInputFocused]: focused,
327
- [modules_5aa8aaf3.tagsInputLegacyMode]: legacyMode
328
- }, this.props.className);
329
- return /*#__PURE__*/React.createElement("div", {
330
- // it transfers focus to input
331
- role: "presentation",
332
- className: classes,
333
- onKeyDown: this.handleKeyDown,
334
- onClick: this.clickHandler,
335
- ref: this.nodeRef
336
- }, /*#__PURE__*/React.createElement(TagsList, {
337
- tags: tags,
338
- activeIndex: activeIndex,
339
- disabled: disabled,
340
- canNotBeEmpty: canNotBeEmpty,
341
- handleRemove: this.handleRemove,
342
- className: modules_5aa8aaf3.tagsList,
343
- tagClassName: modules_5aa8aaf3.tag,
344
- handleClick: this.handleClick
345
- }, /*#__PURE__*/React.createElement(Select, {
346
- ref: this.selectRef,
347
- size: Select.Size.AUTO,
348
- type: Select.Type.INPUT_WITHOUT_CONTROLS,
349
- inputPlaceholder: this.props.placeholder,
350
- data: this.state.suggestions,
351
- className: classNames(modules_5aa8aaf3.tagsSelect),
352
- onSelect: this.addTag,
353
- onFocus: this._focusHandler,
354
- onBlur: this._blurHandler,
355
- renderOptimization: this.props.renderOptimization,
356
- add: allowAddNewTags ? {
357
- prefix: 'Add new tag'
358
- } : undefined,
359
- onAdd: allowAddNewTags ? this.handleTagCreation : undefined,
360
- filter: filter,
361
- maxHeight: this.props.maxPopupHeight,
362
- minWidth: this.props.minPopupWidth,
363
- top: POPUP_VERTICAL_SHIFT,
364
- loading: this.state.loading,
365
- onFilter: this.loadSuggestions,
366
- onBeforeOpen: this.loadSuggestions,
367
- onKeyDown: this.handleKeyDown,
368
- disabled: this.props.disabled,
369
- loadingMessage: this.props.loadingMessage,
370
- notFoundMessage: this.props.notFoundMessage
371
- })), !legacyMode && /*#__PURE__*/React.createElement("div", {
372
- className: modules_5aa8aaf3.underline
373
- }), !legacyMode && /*#__PURE__*/React.createElement("div", {
374
- className: modules_5aa8aaf3.focusUnderline
375
- }));
376
- }
377
-
378
- }
379
-
380
- _defineProperty(TagsInput, "propTypes", {
381
- className: PropTypes.string,
382
- tags: PropTypes.array,
383
-
384
- /**
385
- * Datasource should return array(or promise) of suggestions.
386
- * Each suggestion should contain key and label fields.
387
- * DataSource should handle caching and response racing (when later request
388
- * responded earlier) by himself.
389
- */
390
- dataSource: PropTypes.func,
391
- onAddTag: PropTypes.func,
392
- onRemoveTag: PropTypes.func,
393
- customTagComponent: (props, propName, componentName) => {
394
- if (props[propName] && !props[propName].prototype instanceof Component) {
395
- return new Error(`Invalid prop ${propName} supplied to ${componentName}. Validation failed.`);
396
- }
397
-
398
- return null;
399
- },
400
- maxPopupHeight: PropTypes.number,
401
- minPopupWidth: PropTypes.number,
402
- placeholder: PropTypes.string,
403
- canNotBeEmpty: PropTypes.bool,
404
- disabled: PropTypes.bool,
405
- autoOpen: PropTypes.bool,
406
- renderOptimization: PropTypes.bool,
407
- legacyMode: PropTypes.bool,
408
- filter: PropTypes.oneOfType([PropTypes.bool, PropTypes.shape({
409
- fn: PropTypes.func
410
- })]),
411
- loadingMessage: PropTypes.string,
412
- notFoundMessage: PropTypes.string,
413
- allowAddNewTags: PropTypes.bool
414
- });
415
-
416
- _defineProperty(TagsInput, "defaultProps", {
417
- dataSource: noop,
418
- onAddTag: noop,
419
- onRemoveTag: noop,
420
- customTagComponent: null,
421
- maxPopupHeight: 500,
422
- minPopupWidth: 360,
423
- canNotBeEmpty: false,
424
- disabled: false,
425
- autoOpen: false,
426
- renderOptimization: true,
427
- legacyMode: false,
428
- allowAddNewTags: false,
429
- filter: {
430
- fn: () => true
431
- },
432
- placeholder: 'Select an option'
433
- });
434
-
435
- _defineProperty(TagsInput, "ngModelStateField", 'tags');
436
-
437
- const RerenderableTagsInput = rerenderHOC(TagsInput);
438
-
439
- export default TagsInput;
440
- export { RerenderableTagsInput };
package/dist/tags-list.js DELETED
@@ -1,91 +0,0 @@
1
- import { a as _extends, _ as _objectWithoutProperties, b as _defineProperty } from './_helpers/_rollupPluginBabelHelpers.js';
2
- import React, { Component } from 'react';
3
- import PropTypes from 'prop-types';
4
- import classNames from 'classnames';
5
- import Tag from './tag.js';
6
- import '@jetbrains/icons/close';
7
- import './icon.js';
8
- import 'util-deprecate';
9
- import './_helpers/memoize.js';
10
- import './_helpers/button.js';
11
- import 'focus-visible';
12
- import '@jetbrains/icons/chevron-10px';
13
- import './_helpers/theme.js';
14
- import './_helpers/clickableLink.js';
15
-
16
- function noop() {}
17
- /**
18
- * @name Tags List
19
- */
20
-
21
-
22
- class TagsList extends Component {
23
- renderTag(tag, focusTag) {
24
- const TagComponent = this.props.customTagComponent || Tag;
25
- const readOnly = this.props.disabled || tag.readOnly || this.props.canNotBeEmpty && this.props.tags.length === 1;
26
- const {
27
- tagClassName
28
- } = this.props;
29
- return /*#__PURE__*/React.createElement(TagComponent, _extends({}, tag, {
30
- readOnly: readOnly,
31
- disabled: this.props.disabled || tag.disabled,
32
- focused: focusTag,
33
- onClick: this.props.handleClick(tag),
34
- onRemove: this.props.handleRemove(tag),
35
- className: tagClassName
36
- }), tag.label);
37
- }
38
-
39
- render() {
40
- const _this$props = this.props,
41
- {
42
- children,
43
- className,
44
- customTagComponent,
45
- canNotBeEmpty,
46
- handleClick,
47
- tagClassName,
48
- handleRemove,
49
- tags,
50
- activeIndex
51
- } = _this$props,
52
- props = _objectWithoutProperties(_this$props, ["children", "className", "customTagComponent", "canNotBeEmpty", "handleClick", "tagClassName", "handleRemove", "tags", "activeIndex"]);
53
-
54
- const classes = classNames('ring-js-shortcuts', className);
55
- const tagsList = (this.props.tags || []).map((tag, index) => this.renderTag(tag, this.props.activeIndex === index));
56
- return /*#__PURE__*/React.createElement("div", _extends({
57
- "data-test": "ring-tags-list",
58
- className: classes
59
- }, props), tagsList, children);
60
- }
61
-
62
- }
63
-
64
- _defineProperty(TagsList, "propTypes", {
65
- children: PropTypes.node,
66
- tags: PropTypes.array,
67
- customTagComponent: (props, propName, componentName) => {
68
- if (props[propName] && !props[propName].prototype instanceof Component) {
69
- return new Error(`Invalid prop ${propName} supplied to ${componentName}. Validation failed.`);
70
- }
71
-
72
- return null;
73
- },
74
- activeIndex: PropTypes.number,
75
- canNotBeEmpty: PropTypes.bool,
76
- disabled: PropTypes.bool,
77
- handleClick: PropTypes.func,
78
- handleRemove: PropTypes.func,
79
- className: PropTypes.string,
80
- tagClassName: PropTypes.string
81
- });
82
-
83
- _defineProperty(TagsList, "defaultProps", {
84
- customTagComponent: null,
85
- canNotBeEmpty: false,
86
- disabled: false,
87
- handleClick: noop,
88
- handleRemove: noop
89
- });
90
-
91
- export default TagsList;