@jetbrains/ring-ui 5.0.126 → 5.0.128

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 (305) hide show
  1. package/components/alert/alert.js +2 -1
  2. package/components/alert/container.js +2 -1
  3. package/components/auth/auth__core.js +2 -1
  4. package/components/auth/request-builder.js +2 -1
  5. package/components/auth/response-parser.js +2 -1
  6. package/components/auth/token-validator.js +2 -1
  7. package/components/auth-dialog/auth-dialog.js +2 -1
  8. package/components/avatar/avatar.js +2 -1
  9. package/components/badge/badge.js +2 -1
  10. package/components/button/button.js +2 -1
  11. package/components/button-group/button-group.js +2 -1
  12. package/components/button-group/caption.js +2 -1
  13. package/components/button-set/button-set.js +2 -1
  14. package/components/button-toolbar/button-toolbar.js +2 -1
  15. package/components/caret/caret.js +2 -1
  16. package/components/checkbox/checkbox.js +2 -1
  17. package/components/code/code.js +2 -1
  18. package/components/confirm/confirm.js +2 -1
  19. package/components/content-layout/content-layout.js +2 -1
  20. package/components/content-layout/sidebar.js +2 -1
  21. package/components/data-list/data-list.js +2 -1
  22. package/components/data-list/item.js +2 -1
  23. package/components/date-picker/date-input.js +2 -1
  24. package/components/date-picker/date-picker.js +2 -1
  25. package/components/date-picker/date-popup.js +2 -1
  26. package/components/date-picker/day.js +2 -1
  27. package/components/date-picker/month-slider.js +2 -1
  28. package/components/date-picker/years.js +2 -1
  29. package/components/dialog/dialog.d.ts +4 -16
  30. package/components/dialog/dialog.js +6 -3
  31. package/components/dropdown/dropdown.js +2 -1
  32. package/components/editable-heading/editable-heading.css +2 -0
  33. package/components/error-bubble/error-bubble.js +2 -1
  34. package/components/error-message/error-message.js +2 -1
  35. package/components/footer/footer.js +1 -0
  36. package/components/global/react-dom-renderer.js +2 -1
  37. package/components/grid/col.js +2 -1
  38. package/components/grid/grid.js +2 -1
  39. package/components/grid/row.js +2 -1
  40. package/components/group/group.js +2 -1
  41. package/components/header/logo.js +2 -1
  42. package/components/header/profile.js +2 -1
  43. package/components/header/services-link.js +2 -1
  44. package/components/header/services.js +2 -1
  45. package/components/header/smart-profile.js +2 -1
  46. package/components/header/smart-services.js +2 -1
  47. package/components/header/tray-icon.js +2 -1
  48. package/components/header/tray.js +2 -1
  49. package/components/hub-source/hub-source.js +2 -1
  50. package/components/icon/icon.js +2 -1
  51. package/components/input/input.js +2 -1
  52. package/components/island/island.js +2 -1
  53. package/components/island-legacy/content-legacy.js +2 -1
  54. package/components/island-legacy/header-legacy.js +2 -1
  55. package/components/island-legacy/island-legacy.js +2 -1
  56. package/components/link/clickableLink.js +2 -1
  57. package/components/list/list.js +2 -1
  58. package/components/list/list__hint.js +2 -1
  59. package/components/list/list__users-groups-source.js +2 -1
  60. package/components/loader/loader.js +2 -1
  61. package/components/loader/loader__core.js +2 -1
  62. package/components/loader-screen/loader-screen.js +2 -1
  63. package/components/login-dialog/login-dialog.js +2 -1
  64. package/components/message/message.js +2 -1
  65. package/components/pager/pager.js +2 -1
  66. package/components/panel/panel.js +2 -1
  67. package/components/permissions/permissions.js +2 -1
  68. package/components/permissions/permissions__cache.js +2 -1
  69. package/components/popup/popup.js +2 -1
  70. package/components/popup-menu/popup-menu.js +2 -1
  71. package/components/progress-bar/progress-bar.js +2 -1
  72. package/components/query-assist/query-assist.js +4 -3
  73. package/components/radio/radio.js +2 -1
  74. package/components/radio/radio__item.js +2 -1
  75. package/components/select/select.js +3 -2
  76. package/components/select/select__filter.js +2 -1
  77. package/components/select/select__popup.js +4 -2
  78. package/components/shortcuts/shortcuts.js +2 -1
  79. package/components/storage/storage__fallback.js +2 -1
  80. package/components/tab-trap/tab-trap.js +2 -1
  81. package/components/table/cell.js +2 -1
  82. package/components/table/header-cell.js +2 -1
  83. package/components/table/header.js +2 -1
  84. package/components/table/multitable.js +2 -1
  85. package/components/table/row.js +3 -2
  86. package/components/table/table.js +4 -2
  87. package/components/tabs/smart-tabs.js +2 -1
  88. package/components/tabs/tab.js +2 -1
  89. package/components/tag/tag.js +2 -1
  90. package/components/tags-input/tags-input.d.ts +1 -1
  91. package/components/tags-input/tags-input.js +3 -2
  92. package/components/tags-list/tags-list.js +2 -1
  93. package/components/text/text.js +2 -1
  94. package/components/tooltip/tooltip.js +2 -1
  95. package/components/user-agreement/user-agreement.js +2 -1
  96. package/components/user-card/card.js +2 -1
  97. package/components/user-card/smart-user-card-tooltip.d.ts +1 -1
  98. package/components/user-card/smart-user-card-tooltip.js +2 -1
  99. package/components/user-card/tooltip.js +2 -1
  100. package/dist/_helpers/_rollupPluginBabelHelpers.js +1 -29
  101. package/dist/_helpers/anchor.js +1 -1
  102. package/dist/_helpers/card.js +44 -47
  103. package/dist/_helpers/footer.js +1 -0
  104. package/dist/_helpers/select__filter.js +10 -13
  105. package/dist/_helpers/services-link.js +10 -10
  106. package/dist/_helpers/sidebar.js +34 -37
  107. package/dist/_helpers/theme.js +1 -1
  108. package/dist/_helpers/title.js +12 -16
  109. package/dist/alert/alert.js +63 -66
  110. package/dist/alert/container.js +5 -5
  111. package/dist/alert-service/alert-service.js +5 -7
  112. package/dist/analytics/analytics.js +1 -2
  113. package/dist/analytics/analytics__custom-plugin.js +6 -8
  114. package/dist/auth/auth.js +1 -1
  115. package/dist/auth/auth__core.js +26 -26
  116. package/dist/auth/background-flow.js +4 -5
  117. package/dist/auth/iframe-flow.js +12 -12
  118. package/dist/auth/landing.js +1 -1
  119. package/dist/auth/request-builder.js +3 -5
  120. package/dist/auth/response-parser.js +5 -6
  121. package/dist/auth/storage.js +12 -12
  122. package/dist/auth/token-validator.js +13 -16
  123. package/dist/auth/window-flow.js +18 -19
  124. package/dist/auth-dialog/auth-dialog.js +54 -57
  125. package/dist/auth-dialog-service/auth-dialog-service.js +1 -1
  126. package/dist/auth-ng/auth-ng.js +1 -1
  127. package/dist/avatar/avatar.js +30 -33
  128. package/dist/avatar-ng/avatar-ng.js +1 -1
  129. package/dist/badge/badge.js +10 -10
  130. package/dist/badge-ng/badge-ng.js +1 -1
  131. package/dist/breadcrumb-ng/breadcrumb-ng.js +0 -1
  132. package/dist/button/button.js +24 -27
  133. package/dist/button-group/button-group.js +5 -5
  134. package/dist/button-group/caption.js +4 -4
  135. package/dist/button-ng/button-ng.js +68 -69
  136. package/dist/button-set/button-set.js +6 -6
  137. package/dist/button-toolbar/button-toolbar.js +6 -6
  138. package/dist/caret/caret.js +2 -4
  139. package/dist/checkbox/checkbox.js +27 -30
  140. package/dist/checkbox-ng/checkbox-ng.js +0 -1
  141. package/dist/code/code.js +17 -21
  142. package/dist/confirm/confirm.js +31 -34
  143. package/dist/confirm-ng/confirm-ng.js +1 -1
  144. package/dist/confirm-service/confirm-service.js +1 -1
  145. package/dist/content-layout/content-layout.js +17 -20
  146. package/dist/contenteditable/contenteditable.js +11 -11
  147. package/dist/data-list/data-list.js +49 -55
  148. package/dist/data-list/item.js +64 -67
  149. package/dist/data-list/selection.js +0 -1
  150. package/dist/data-list/title.js +1 -1
  151. package/dist/data-list-ng/data-list-ng.js +1 -1
  152. package/dist/date-picker/date-input.js +39 -42
  153. package/dist/date-picker/date-picker.js +162 -165
  154. package/dist/date-picker/date-popup.js +119 -119
  155. package/dist/date-picker/day.js +34 -38
  156. package/dist/date-picker/month-names.js +11 -14
  157. package/dist/date-picker/month-slider.js +24 -28
  158. package/dist/date-picker/month.js +1 -1
  159. package/dist/date-picker/months.js +1 -1
  160. package/dist/date-picker/years.js +9 -13
  161. package/dist/dialog/dialog.d.ts +4 -16
  162. package/dist/dialog/dialog.js +68 -65
  163. package/dist/dialog-ng/dialog-ng.js +21 -22
  164. package/dist/docked-panel-ng/docked-panel-ng.js +0 -1
  165. package/dist/dropdown/dropdown.js +101 -104
  166. package/dist/dropdown-menu/dropdown-menu.js +1 -1
  167. package/dist/editable-heading/editable-heading.js +1 -1
  168. package/dist/error-bubble/error-bubble.js +6 -6
  169. package/dist/error-message/error-message.js +10 -10
  170. package/dist/error-message-ng/error-message-ng.js +0 -1
  171. package/dist/footer-ng/footer-ng.js +19 -21
  172. package/dist/global/angular-component-factory.js +2 -3
  173. package/dist/global/dom.js +1 -5
  174. package/dist/global/focus-sensor-hoc.js +58 -61
  175. package/dist/global/listeners.js +1 -5
  176. package/dist/global/react-dom-renderer.js +8 -12
  177. package/dist/global/rerender-hoc.js +1 -5
  178. package/dist/global/ring-angular-component.js +1 -3
  179. package/dist/grid/col.js +13 -14
  180. package/dist/grid/grid.js +5 -5
  181. package/dist/grid/row.js +16 -17
  182. package/dist/group/group.js +5 -5
  183. package/dist/header/header.js +10 -10
  184. package/dist/header/logo.js +9 -9
  185. package/dist/header/profile.js +58 -58
  186. package/dist/header/services.js +19 -22
  187. package/dist/header/smart-profile.js +40 -43
  188. package/dist/header/smart-services.js +28 -31
  189. package/dist/header/tray-icon.js +6 -6
  190. package/dist/header/tray.js +5 -5
  191. package/dist/heading/heading.js +1 -1
  192. package/dist/heading-ng/heading-ng.js +1 -1
  193. package/dist/http/http.js +111 -107
  194. package/dist/http/http.mock.js +3 -4
  195. package/dist/hub-source/hub-source.js +7 -9
  196. package/dist/hub-source/hub-source__user.js +0 -1
  197. package/dist/hub-source/hub-source__users-groups.js +4 -5
  198. package/dist/icon/icon.js +18 -18
  199. package/dist/icon/icon__svg.js +1 -1
  200. package/dist/icon-ng/icon-ng.js +0 -1
  201. package/dist/input/input.js +35 -38
  202. package/dist/input-ng/input-ng.js +25 -26
  203. package/dist/island/adaptive-island-hoc.js +21 -25
  204. package/dist/island/content.js +62 -65
  205. package/dist/island/header.js +11 -11
  206. package/dist/island/island.js +8 -8
  207. package/dist/island-legacy/content-legacy.js +5 -5
  208. package/dist/island-legacy/header-legacy.js +5 -5
  209. package/dist/island-legacy/island-legacy.js +5 -5
  210. package/dist/link/clickableLink.js +27 -30
  211. package/dist/link/link.js +16 -16
  212. package/dist/list/list.js +389 -391
  213. package/dist/list/list__custom.js +6 -10
  214. package/dist/list/list__hint.js +3 -4
  215. package/dist/list/list__item.js +4 -7
  216. package/dist/list/list__link.js +1 -1
  217. package/dist/list/list__users-groups-source.js +3 -3
  218. package/dist/loader/loader.js +16 -19
  219. package/dist/loader/loader__core.js +62 -62
  220. package/dist/loader-inline/loader-inline.js +6 -6
  221. package/dist/loader-ng/loader-ng.js +3 -4
  222. package/dist/loader-screen/loader-screen.js +6 -6
  223. package/dist/loader-screen-ng/loader-screen-ng.js +0 -1
  224. package/dist/login-dialog/login-dialog.js +55 -58
  225. package/dist/login-dialog/service.js +1 -1
  226. package/dist/markdown/code.js +0 -1
  227. package/dist/markdown/markdown.js +1 -1
  228. package/dist/message/message.js +22 -25
  229. package/dist/old-browsers-message/white-list.js +2 -2
  230. package/dist/pager/pager.js +55 -58
  231. package/dist/pager-ng/pager-ng.js +1 -1
  232. package/dist/panel/panel.js +5 -5
  233. package/dist/panel-ng/panel-ng.js +0 -1
  234. package/dist/permissions/permissions.js +14 -16
  235. package/dist/permissions/permissions__cache.js +4 -6
  236. package/dist/permissions-ng/permissions-ng.js +1 -1
  237. package/dist/place-under-ng/place-under-ng.js +0 -1
  238. package/dist/popup/popup.js +118 -121
  239. package/dist/popup/popup.target.js +1 -1
  240. package/dist/popup/position.js +0 -1
  241. package/dist/popup-menu/popup-menu.js +19 -22
  242. package/dist/progress-bar/progress-bar.js +41 -44
  243. package/dist/progress-bar-ng/progress-bar-ng.js +1 -1
  244. package/dist/promised-click-ng/promised-click-ng.js +0 -1
  245. package/dist/query-assist/query-assist.js +507 -501
  246. package/dist/query-assist/query-assist__suggestions.js +1 -1
  247. package/dist/query-assist-ng/query-assist-ng.js +1 -1
  248. package/dist/radio/radio.js +10 -13
  249. package/dist/radio/radio__item.js +19 -22
  250. package/dist/select/select.js +351 -350
  251. package/dist/select/select__popup.js +148 -152
  252. package/dist/select-ng/select-ng.js +1 -1
  253. package/dist/select-ng/select-ng__lazy.js +4 -4
  254. package/dist/select-ng/select-ng__options.js +14 -15
  255. package/dist/shortcuts/core.js +35 -36
  256. package/dist/shortcuts/shortcuts-hoc.js +7 -11
  257. package/dist/shortcuts/shortcuts.js +10 -11
  258. package/dist/shortcuts-hint-ng/shortcuts-hint-ng.js +0 -1
  259. package/dist/shortcuts-ng/shortcuts-ng.js +0 -1
  260. package/dist/sidebar-ng/sidebar-ng.js +0 -1
  261. package/dist/storage/storage.js +1 -1
  262. package/dist/storage/storage__fallback.js +8 -10
  263. package/dist/storage/storage__local.js +2 -2
  264. package/dist/style.css +1 -1
  265. package/dist/tab-trap/tab-trap.js +84 -86
  266. package/dist/table/cell.js +6 -6
  267. package/dist/table/disable-hover-hoc.js +23 -25
  268. package/dist/table/header-cell.js +28 -31
  269. package/dist/table/header.js +58 -61
  270. package/dist/table/multitable.js +91 -95
  271. package/dist/table/row-with-focus-sensor.js +15 -18
  272. package/dist/table/row.js +51 -54
  273. package/dist/table/selection-shortcuts-hoc.js +145 -147
  274. package/dist/table/selection.js +7 -9
  275. package/dist/table/smart-table.js +21 -24
  276. package/dist/table/table.js +103 -109
  277. package/dist/table-legacy-ng/table-legacy-ng.js +1 -1
  278. package/dist/table-legacy-ng/table-legacy-ng__pager.js +1 -1
  279. package/dist/table-legacy-ng/table-legacy-ng__selection.js +1 -3
  280. package/dist/table-legacy-ng/table-legacy-ng__toolbar.js +0 -1
  281. package/dist/table-ng/smart-table-ng.js +1 -1
  282. package/dist/table-ng/table-ng.js +1 -1
  283. package/dist/tabs/collapsible-more.js +1 -1
  284. package/dist/tabs/collapsible-tab.js +1 -1
  285. package/dist/tabs/dumb-tabs.js +46 -49
  286. package/dist/tabs/smart-tabs.js +10 -10
  287. package/dist/tabs/tab.js +7 -8
  288. package/dist/tag/tag.js +42 -45
  289. package/dist/tags-input/tags-input.d.ts +1 -1
  290. package/dist/tags-input/tags-input.js +214 -213
  291. package/dist/tags-input-ng/tags-input-ng.js +1 -1
  292. package/dist/tags-list/tags-list.js +20 -20
  293. package/dist/template-ng/template-ng.js +25 -26
  294. package/dist/text/text.js +6 -6
  295. package/dist/toggle/toggle.js +19 -19
  296. package/dist/toggle-ng/toggle-ng.js +1 -1
  297. package/dist/tooltip/tooltip.js +86 -89
  298. package/dist/tooltip-ng/tooltip-ng.js +1 -1
  299. package/dist/user-agreement/service.js +207 -205
  300. package/dist/user-agreement/user-agreement.js +39 -42
  301. package/dist/user-card/smart-user-card-tooltip.d.ts +1 -1
  302. package/dist/user-card/smart-user-card-tooltip.js +32 -35
  303. package/dist/user-card/tooltip.js +26 -26
  304. package/dist/user-card-ng/user-card-ng.js +1 -1
  305. package/package.json +15 -15
@@ -1,5 +1,4 @@
1
- import { _ as _defineProperty } from '../_helpers/_rollupPluginBabelHelpers.js';
2
- import React, { Component, PureComponent } from 'react';
1
+ import React, { PureComponent, Component } from 'react';
3
2
  import PropTypes from 'prop-types';
4
3
  import classNames from 'classnames';
5
4
  import getEventKey from '../global/get-event-key.js';
@@ -12,6 +11,7 @@ import { Size } from '../input/input.js';
12
11
  import { ControlsHeightContext } from '../global/controls-height.js';
13
12
  import getUID from '../global/get-uid.js';
14
13
  import { m as modules_88cfaf40 } from '../_helpers/input.js';
14
+ import '../_helpers/_rollupPluginBabelHelpers.js';
15
15
  import '@jetbrains/icons/chevron-down';
16
16
  import '@jetbrains/icons/close-12px';
17
17
  import 'deep-equal';
@@ -88,171 +88,67 @@ function noop() {}
88
88
  */
89
89
  const POPUP_VERTICAL_SHIFT = 2;
90
90
  class TagsInput extends PureComponent {
91
+ static propTypes = {
92
+ className: PropTypes.string,
93
+ tags: PropTypes.array,
94
+ /**
95
+ * Datasource should return array(or promise) of suggestions.
96
+ * Each suggestion should contain key and label fields.
97
+ * DataSource should handle caching and response racing (when later request
98
+ * responded earlier) by himself.
99
+ */
100
+ dataSource: PropTypes.func,
101
+ onAddTag: PropTypes.func,
102
+ onRemoveTag: PropTypes.func,
103
+ customTagComponent: PropTypes.instanceOf(Component),
104
+ maxPopupHeight: PropTypes.number,
105
+ minPopupWidth: PropTypes.number,
106
+ placeholder: PropTypes.string,
107
+ canNotBeEmpty: PropTypes.bool,
108
+ disabled: PropTypes.bool,
109
+ autoOpen: PropTypes.bool,
110
+ renderOptimization: PropTypes.bool,
111
+ filter: PropTypes.oneOfType([PropTypes.bool, PropTypes.shape({
112
+ fn: PropTypes.func
113
+ })]),
114
+ size: PropTypes.string,
115
+ height: PropTypes.string,
116
+ label: PropTypes.node,
117
+ loadingMessage: PropTypes.string,
118
+ notFoundMessage: PropTypes.string,
119
+ allowAddNewTags: PropTypes.bool
120
+ };
121
+ static defaultProps = {
122
+ dataSource: noop,
123
+ onAddTag: noop,
124
+ onRemoveTag: noop,
125
+ customTagComponent: null,
126
+ maxPopupHeight: 500,
127
+ minPopupWidth: 360,
128
+ canNotBeEmpty: false,
129
+ disabled: false,
130
+ autoOpen: false,
131
+ renderOptimization: true,
132
+ allowAddNewTags: false,
133
+ filter: {
134
+ fn: () => true
135
+ },
136
+ placeholder: 'Select an option',
137
+ size: Size.M
138
+ };
91
139
  constructor(props) {
92
- var _this;
93
140
  super(props);
94
- _this = this;
95
- _defineProperty(this, "state", {
96
- tags: [],
97
- prevTags: null,
98
- suggestions: [],
99
- loading: true,
100
- focused: false,
101
- query: '',
102
- activeIndex: 0
103
- });
104
- _defineProperty(this, "ngModelStateField", void 0);
105
- _defineProperty(this, "id", getUID('ring-tags-list-'));
106
- _defineProperty(this, "node", void 0);
107
- _defineProperty(this, "nodeRef", node => {
108
- this.node = node;
109
- });
110
- _defineProperty(this, "input", void 0);
111
- _defineProperty(this, "caret", void 0);
112
- _defineProperty(this, "focusInput", () => {
113
- this.getInputNode()?.focus();
114
- });
115
- _defineProperty(this, "addTag", tag => {
116
- if (tag == null) {
117
- return;
118
- }
119
- const isUniqueTag = this.state.tags.filter(item => tag.key === item.key).length === 0;
120
- this.select?.clear();
121
- this.select?.filterValue('');
122
- if (isUniqueTag) {
123
- this.setState(prevState => ({
124
- tags: prevState.tags.concat([tag])
125
- }));
126
- this.props.onAddTag({
127
- tag
128
- });
129
- this.setActiveIndex();
130
- }
131
- });
132
- _defineProperty(this, "clickHandler", event => {
133
- if (event.target !== this.node && event.target.parentElement !== this.node) {
134
- return;
135
- }
136
- this.select?._clickHandler();
137
- });
138
- _defineProperty(this, "filterExistingTags", suggestions => {
139
- const tagsMap = new Map(this.state.tags.map(tag => [tag.key, tag]));
140
- return suggestions.filter(suggestion => !tagsMap.has(suggestion.key));
141
- });
142
- _defineProperty(this, "loadSuggestions", function () {
143
- let query = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
144
- return _this.setState({
145
- loading: true,
146
- query
147
- }, async () => {
148
- try {
149
- const suggestionsResult = _this.props.dataSource({
150
- query
151
- });
152
- const allSuggestions = Array.isArray(suggestionsResult) ? suggestionsResult : await suggestionsResult;
153
- const suggestions = _this.filterExistingTags(allSuggestions);
154
- if (_this.node && query === _this.state.query) {
155
- _this.setState({
156
- suggestions,
157
- loading: false
158
- });
159
- }
160
- } catch (e) {
161
- _this.setState({
162
- loading: false
163
- });
164
- }
165
- });
166
- });
167
- _defineProperty(this, "_focusHandler", () => {
168
- this.setActiveIndex(null);
169
- this.setState({
170
- focused: true
171
- });
172
- });
173
- _defineProperty(this, "_blurHandler", () => {
174
- this.setState({
175
- focused: false
176
- });
177
- });
178
- _defineProperty(this, "selectTag", moveForward => {
179
- const activeIndex = typeof this.state.activeIndex === 'number' ? this.state.activeIndex : this.state.tags.length + 1;
180
- let newActiveIndex = activeIndex + (moveForward ? 1 : -1);
181
- if (newActiveIndex >= this.state.tags.length) {
182
- newActiveIndex = this.state.tags.length - 1;
183
- } else if (newActiveIndex < 0) {
184
- newActiveIndex = 0;
185
- }
186
- if (this.state.activeIndex !== newActiveIndex) {
187
- this.setActiveIndex(newActiveIndex);
188
- }
189
- });
190
- _defineProperty(this, "handleKeyDown", event => {
191
- const key = getEventKey(event);
192
- const isInputFocused = () => {
193
- var _this$getInputNode$ta;
194
- return event.target instanceof Element && event.target.matches((_this$getInputNode$ta = this.getInputNode()?.tagName) !== null && _this$getInputNode$ta !== void 0 ? _this$getInputNode$ta : '');
195
- };
196
- if (key === ' ' && this.props.allowAddNewTags) {
197
- event.stopPropagation();
198
- const value = this.getInputNode()?.value;
199
- if (value != null && value !== '') {
200
- this.handleTagCreation(value);
201
- }
202
- return true;
203
- }
204
- if (this.select?._popup?.isVisible()) {
205
- return true;
206
- }
207
- if (key === 'ArrowLeft') {
208
- if (this.getInputNode() && this.caret != null && this.caret.getPosition() > 0) {
209
- return true;
210
- }
211
- this.selectTag();
212
- return false;
213
- }
214
- if (key === 'ArrowRight' && !isInputFocused()) {
215
- if (this.state.activeIndex === this.state.tags.length - 1) {
216
- if (!this.props.disabled) {
217
- this.getInputNode()?.focus();
218
- this.setActiveIndex();
219
- }
220
- } else {
221
- this.selectTag(true);
222
- }
223
- return false;
224
- }
225
- if (!this.props.disabled) {
226
- if (key === 'Backspace' && !this.getInputNode()?.value) {
227
- event.preventDefault();
228
- const tagsLength = this.state.tags.length;
229
- this.select?._hidePopup(true); // otherwise confirmation may be overlapped by popup
230
- this.onRemoveTag(this.state.tags[tagsLength - 1]);
231
- return false;
232
- }
233
- if ((key === 'Delete' || key === 'Backspace') && this.state.activeIndex != null && this.state.tags[this.state.activeIndex]) {
234
- this.onRemoveTag(this.state.tags[this.state.activeIndex]).then(() => this.selectTag(true));
235
- return false;
236
- }
237
- }
238
- return true;
239
- });
240
- _defineProperty(this, "handleClick", memoize(tag => () => {
241
- this.setActiveIndex(this.state.tags.indexOf(tag));
242
- }));
243
- _defineProperty(this, "handleRemove", memoize(tag => () => this.onRemoveTag(tag)));
244
- _defineProperty(this, "handleTagCreation", label => {
245
- this.addTag({
246
- key: label,
247
- label
248
- });
249
- });
250
- _defineProperty(this, "select", void 0);
251
- _defineProperty(this, "selectRef", el => {
252
- this.select = el;
253
- });
254
141
  this.ngModelStateField = TagsInput.ngModelStateField;
255
142
  }
143
+ state = {
144
+ tags: [],
145
+ prevTags: null,
146
+ suggestions: [],
147
+ loading: true,
148
+ focused: false,
149
+ query: '',
150
+ activeIndex: 0
151
+ };
256
152
  static getDerivedStateFromProps(_ref, _ref2) {
257
153
  let {
258
154
  tags
@@ -278,6 +174,16 @@ class TagsInput extends PureComponent {
278
174
  this.select?._showPopup();
279
175
  }
280
176
  }
177
+ static ngModelStateField = 'tags';
178
+ ngModelStateField;
179
+ static contextType = ControlsHeightContext;
180
+ id = getUID('ring-tags-list-');
181
+ node;
182
+ nodeRef = node => {
183
+ this.node = node;
184
+ };
185
+ input;
186
+ caret;
281
187
  getInputNode() {
282
188
  if (!this.input) {
283
189
  this.input = this.select?.filter;
@@ -292,6 +198,26 @@ class TagsInput extends PureComponent {
292
198
  activeIndex
293
199
  });
294
200
  }
201
+ focusInput = () => {
202
+ this.getInputNode()?.focus();
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])
214
+ }));
215
+ this.props.onAddTag({
216
+ tag
217
+ });
218
+ this.setActiveIndex();
219
+ }
220
+ };
295
221
  onRemoveTag(tagToRemove) {
296
222
  return Promise.resolve(this.props.onRemoveTag({
297
223
  tag: tagToRemove
@@ -306,6 +232,131 @@ class TagsInput extends PureComponent {
306
232
  return tags;
307
233
  }, this.focusInput);
308
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] : '';
249
+ return _this.setState({
250
+ loading: true,
251
+ query
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
+ });
264
+ }
265
+ } catch (e) {
266
+ _this.setState({
267
+ loading: false
268
+ });
269
+ }
270
+ });
271
+ };
272
+ })();
273
+ _focusHandler = () => {
274
+ this.setActiveIndex(null);
275
+ this.setState({
276
+ focused: true
277
+ });
278
+ };
279
+ _blurHandler = () => {
280
+ this.setState({
281
+ focused: false
282
+ });
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;
291
+ }
292
+ if (this.state.activeIndex !== newActiveIndex) {
293
+ this.setActiveIndex(newActiveIndex);
294
+ }
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;
309
+ }
310
+ if (this.select?._popup?.isVisible()) {
311
+ return true;
312
+ }
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;
319
+ }
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);
328
+ }
329
+ return false;
330
+ }
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
+ }
343
+ }
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
+ };
309
360
  render() {
310
361
  const {
311
362
  focused,
@@ -376,56 +427,6 @@ class TagsInput extends PureComponent {
376
427
  })));
377
428
  }
378
429
  }
379
- _defineProperty(TagsInput, "propTypes", {
380
- className: PropTypes.string,
381
- tags: PropTypes.array,
382
- /**
383
- * Datasource should return array(or promise) of suggestions.
384
- * Each suggestion should contain key and label fields.
385
- * DataSource should handle caching and response racing (when later request
386
- * responded earlier) by himself.
387
- */
388
- dataSource: PropTypes.func,
389
- onAddTag: PropTypes.func,
390
- onRemoveTag: PropTypes.func,
391
- customTagComponent: PropTypes.instanceOf(Component),
392
- maxPopupHeight: PropTypes.number,
393
- minPopupWidth: PropTypes.number,
394
- placeholder: PropTypes.string,
395
- canNotBeEmpty: PropTypes.bool,
396
- disabled: PropTypes.bool,
397
- autoOpen: PropTypes.bool,
398
- renderOptimization: PropTypes.bool,
399
- filter: PropTypes.oneOfType([PropTypes.bool, PropTypes.shape({
400
- fn: PropTypes.func
401
- })]),
402
- size: PropTypes.string,
403
- height: PropTypes.string,
404
- label: PropTypes.node,
405
- loadingMessage: PropTypes.string,
406
- notFoundMessage: PropTypes.string,
407
- allowAddNewTags: PropTypes.bool
408
- });
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
430
  const RerenderableTagsInput = rerenderHOC(TagsInput);
430
431
 
431
432
  export { RerenderableTagsInput, TagsInput as default };
@@ -1,6 +1,5 @@
1
1
  import angularComponentFactory from '../global/angular-component-factory.js';
2
2
  import TagsInput from '../tags-input/tags-input.js';
3
- import '../_helpers/_rollupPluginBabelHelpers.js';
4
3
  import 'angular';
5
4
  import 'react';
6
5
  import '../global/react-render-adapter.js';
@@ -11,6 +10,7 @@ import 'prop-types';
11
10
  import 'classnames';
12
11
  import '../global/get-event-key.js';
13
12
  import '../select/select.js';
13
+ import '../_helpers/_rollupPluginBabelHelpers.js';
14
14
  import '@jetbrains/icons/chevron-down';
15
15
  import '@jetbrains/icons/close-12px';
16
16
  import 'deep-equal';
@@ -1,4 +1,4 @@
1
- import { _ as _defineProperty, a as _extends } from '../_helpers/_rollupPluginBabelHelpers.js';
1
+ import { _ as _extends } from '../_helpers/_rollupPluginBabelHelpers.js';
2
2
  import React, { Component } from 'react';
3
3
  import PropTypes from 'prop-types';
4
4
  import classNames from 'classnames';
@@ -22,6 +22,25 @@ function noop() {}
22
22
  * @name Tags List
23
23
  */
24
24
  class TagsList extends Component {
25
+ static propTypes = {
26
+ children: PropTypes.node,
27
+ tags: PropTypes.array,
28
+ customTagComponent: PropTypes.elementType,
29
+ activeIndex: PropTypes.number,
30
+ canNotBeEmpty: PropTypes.bool,
31
+ disabled: PropTypes.bool,
32
+ handleClick: PropTypes.func,
33
+ handleRemove: PropTypes.func,
34
+ className: PropTypes.string,
35
+ tagClassName: PropTypes.string
36
+ };
37
+ static defaultProps = {
38
+ customTagComponent: null,
39
+ canNotBeEmpty: false,
40
+ disabled: false,
41
+ handleClick: noop,
42
+ handleRemove: noop
43
+ };
25
44
  renderTag(tag, focusTag) {
26
45
  const TagComponent = this.props.customTagComponent || Tag;
27
46
  const readOnly = this.props.disabled || tag.readOnly || this.props.canNotBeEmpty && this.props.tags.length === 1;
@@ -58,24 +77,5 @@ class TagsList extends Component {
58
77
  }, props), tagsList, children);
59
78
  }
60
79
  }
61
- _defineProperty(TagsList, "propTypes", {
62
- children: PropTypes.node,
63
- tags: PropTypes.array,
64
- customTagComponent: PropTypes.elementType,
65
- activeIndex: PropTypes.number,
66
- canNotBeEmpty: PropTypes.bool,
67
- disabled: PropTypes.bool,
68
- handleClick: PropTypes.func,
69
- handleRemove: PropTypes.func,
70
- className: PropTypes.string,
71
- tagClassName: PropTypes.string
72
- });
73
- _defineProperty(TagsList, "defaultProps", {
74
- customTagComponent: null,
75
- canNotBeEmpty: false,
76
- disabled: false,
77
- handleClick: noop,
78
- handleRemove: noop
79
- });
80
80
 
81
81
  export { TagsList as default };
@@ -1,4 +1,3 @@
1
- import { _ as _defineProperty } from '../_helpers/_rollupPluginBabelHelpers.js';
2
1
  import angular from 'angular';
3
2
  import RingAngularComponent from '../global/ring-angular-component.js';
4
3
 
@@ -8,37 +7,37 @@ import RingAngularComponent from '../global/ring-angular-component.js';
8
7
 
9
8
  const angularModule = angular.module('Ring.template', []);
10
9
  class RgTemplateController extends RingAngularComponent {
10
+ currentScope = null;
11
11
  constructor() {
12
12
  super(...arguments);
13
- _defineProperty(this, "currentScope", null);
14
- _defineProperty(this, "render", template => {
15
- const {
16
- $scope,
17
- $element,
18
- $compile
19
- } = this.$inject;
20
- this.cleanup();
21
- this.currentScope = $scope.$new();
22
- this.currentScope.$evalAsync(() => {
23
- $element.html(template);
24
- this.addInnerClass();
25
- $compile($element.contents())(this.currentScope);
26
- });
27
- });
28
- _defineProperty(this, "addInnerClass", () => {
29
- const {
30
- rgTemplateClass
31
- } = this.$inject.$attrs;
32
- if (rgTemplateClass) {
33
- this.$inject.$element.contents().addClass(rgTemplateClass);
34
- }
35
- });
36
13
  const {
37
- $scope: _$scope,
14
+ $scope,
38
15
  $attrs
39
16
  } = this.$inject;
40
- _$scope.$watch($attrs.rgTemplate || $attrs.template, this.render);
17
+ $scope.$watch($attrs.rgTemplate || $attrs.template, this.render);
41
18
  }
19
+ render = template => {
20
+ const {
21
+ $scope,
22
+ $element,
23
+ $compile
24
+ } = this.$inject;
25
+ this.cleanup();
26
+ this.currentScope = $scope.$new();
27
+ this.currentScope.$evalAsync(() => {
28
+ $element.html(template);
29
+ this.addInnerClass();
30
+ $compile($element.contents())(this.currentScope);
31
+ });
32
+ };
33
+ addInnerClass = () => {
34
+ const {
35
+ rgTemplateClass
36
+ } = this.$inject.$attrs;
37
+ if (rgTemplateClass) {
38
+ this.$inject.$element.contents().addClass(rgTemplateClass);
39
+ }
40
+ };
42
41
  cleanup() {
43
42
  if (this.currentScope) {
44
43
  this.currentScope.$destroy();
package/dist/text/text.js CHANGED
@@ -1,4 +1,4 @@
1
- import { _ as _defineProperty, a as _extends } from '../_helpers/_rollupPluginBabelHelpers.js';
1
+ import { _ as _extends } from '../_helpers/_rollupPluginBabelHelpers.js';
2
2
  import React, { Component } from 'react';
3
3
  import PropTypes from 'prop-types';
4
4
  import classNames from 'classnames';
@@ -9,6 +9,11 @@ var modules_78d1bce6 = {"light":"light_rui_6f30","text":"text_rui_6f30","info":"
9
9
  * @name Text
10
10
  */
11
11
  class Text extends Component {
12
+ static propTypes = {
13
+ children: PropTypes.node,
14
+ info: PropTypes.bool,
15
+ className: PropTypes.string
16
+ };
12
17
  render() {
13
18
  const {
14
19
  children,
@@ -24,10 +29,5 @@ class Text extends Component {
24
29
  }, restProps), children);
25
30
  }
26
31
  }
27
- _defineProperty(Text, "propTypes", {
28
- children: PropTypes.node,
29
- info: PropTypes.bool,
30
- className: PropTypes.string
31
- });
32
32
 
33
33
  export { Text as default };
@@ -1,4 +1,4 @@
1
- import { _ as _defineProperty, a as _extends } from '../_helpers/_rollupPluginBabelHelpers.js';
1
+ import { _ as _extends } from '../_helpers/_rollupPluginBabelHelpers.js';
2
2
  import React, { PureComponent } from 'react';
3
3
  import PropTypes from 'prop-types';
4
4
  import classNames from 'classnames';
@@ -12,6 +12,24 @@ const Size = {
12
12
  Size20: modules_331c5aa7.size20
13
13
  };
14
14
  class Toggle extends PureComponent {
15
+ static propTypes = {
16
+ children: PropTypes.node,
17
+ name: PropTypes.string,
18
+ className: PropTypes.string,
19
+ title: PropTypes.string,
20
+ leftLabel: PropTypes.node,
21
+ defaultChecked: PropTypes.bool,
22
+ checked: PropTypes.bool,
23
+ disabled: PropTypes.bool,
24
+ pale: PropTypes.bool,
25
+ onChange: PropTypes.func,
26
+ onTransitionEnd: PropTypes.func,
27
+ size: PropTypes.oneOf(Object.values(Size)),
28
+ 'data-test': PropTypes.string
29
+ };
30
+ static defaultProps = {
31
+ size: Size.Size14
32
+ };
15
33
  render() {
16
34
  const {
17
35
  className,
@@ -48,23 +66,5 @@ class Toggle extends PureComponent {
48
66
  }, children));
49
67
  }
50
68
  }
51
- _defineProperty(Toggle, "propTypes", {
52
- children: PropTypes.node,
53
- name: PropTypes.string,
54
- className: PropTypes.string,
55
- title: PropTypes.string,
56
- leftLabel: PropTypes.node,
57
- defaultChecked: PropTypes.bool,
58
- checked: PropTypes.bool,
59
- disabled: PropTypes.bool,
60
- pale: PropTypes.bool,
61
- onChange: PropTypes.func,
62
- onTransitionEnd: PropTypes.func,
63
- size: PropTypes.oneOf(Object.values(Size)),
64
- 'data-test': PropTypes.string
65
- });
66
- _defineProperty(Toggle, "defaultProps", {
67
- size: Size.Size14
68
- });
69
69
 
70
70
  export { Size, Toggle as default };