@jetbrains/ring-ui-built 6.0.32 → 6.0.34

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