@jetbrains/ring-ui 7.0.0-beta.8 → 7.0.0

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 (256) hide show
  1. package/babel.config.js +20 -14
  2. package/components/alert/alert.css +7 -7
  3. package/components/alert/alert.d.ts +2 -2
  4. package/components/alert/alert.js +10 -12
  5. package/components/alert/container.js +1 -1
  6. package/components/alert-service/alert-service.js +4 -2
  7. package/components/analytics/analytics__custom-plugin.js +1 -1
  8. package/components/auth/auth.js +1 -1
  9. package/components/auth/auth__core.js +36 -36
  10. package/components/auth/background-flow.js +2 -2
  11. package/components/auth/down-notification.js +3 -1
  12. package/components/auth/iframe-flow.js +4 -2
  13. package/components/auth/request-builder.js +5 -5
  14. package/components/auth/storage.js +10 -9
  15. package/components/auth/token-validator.js +8 -15
  16. package/components/auth-dialog/auth-dialog.js +8 -8
  17. package/components/auth-dialog-service/auth-dialog-service.js +4 -4
  18. package/components/avatar/avatar.js +9 -7
  19. package/components/avatar/fallback-avatar.js +15 -12
  20. package/components/button/button.css +36 -25
  21. package/components/button/button.js +9 -9
  22. package/components/button/button__classes.d.ts +1 -1
  23. package/components/button/button__classes.js +3 -4
  24. package/components/button-group/button-group.css +25 -13
  25. package/components/button-group/caption.js +1 -1
  26. package/components/button-toolbar/button-toolbar.d.ts +1 -1
  27. package/components/button-toolbar/button-toolbar.js +2 -2
  28. package/components/caret/caret.js +8 -8
  29. package/components/checkbox/checkbox.css +8 -5
  30. package/components/checkbox/checkbox.js +1 -1
  31. package/components/clipboard/clipboard-fallback.js +2 -6
  32. package/components/clipboard/clipboard.js +5 -5
  33. package/components/code/code.d.ts +1 -1
  34. package/components/code/code.js +2 -2
  35. package/components/code/highlight.css +3 -1
  36. package/components/collapse/collapse-content.d.ts +1 -2
  37. package/components/collapse/collapse-content.js +25 -14
  38. package/components/collapse/collapse-context.js +1 -1
  39. package/components/collapse/collapse-control.js +5 -3
  40. package/components/collapse/collapse.css +21 -20
  41. package/components/collapse/collapse.js +2 -2
  42. package/components/confirm/confirm.d.ts +2 -2
  43. package/components/confirm/confirm.js +2 -2
  44. package/components/confirm-service/confirm-service.d.ts +1 -1
  45. package/components/confirm-service/confirm-service.js +6 -6
  46. package/components/content-layout/content-layout.css +6 -5
  47. package/components/content-layout/content-layout.js +7 -6
  48. package/components/content-layout/sidebar.js +5 -5
  49. package/components/contenteditable/contenteditable.d.ts +1 -1
  50. package/components/contenteditable/contenteditable.js +3 -4
  51. package/components/control-label/control-label.js +5 -3
  52. package/components/data-list/data-list.css +3 -3
  53. package/components/data-list/data-list.d.ts +2 -2
  54. package/components/data-list/data-list.js +6 -7
  55. package/components/data-list/data-list.mock.js +57 -47
  56. package/components/data-list/item.js +14 -16
  57. package/components/data-list/selection.js +5 -7
  58. package/components/data-list/title.js +5 -6
  59. package/components/date-picker/consts.js +2 -2
  60. package/components/date-picker/date-input.js +4 -4
  61. package/components/date-picker/date-picker.css +23 -18
  62. package/components/date-picker/date-picker.d.ts +2 -1
  63. package/components/date-picker/date-picker.js +13 -19
  64. package/components/date-picker/date-popup.js +30 -36
  65. package/components/date-picker/day.js +6 -9
  66. package/components/date-picker/formats.js +647 -1
  67. package/components/date-picker/month-names.js +6 -8
  68. package/components/date-picker/month-slider.js +2 -2
  69. package/components/date-picker/month.js +1 -3
  70. package/components/date-picker/months.js +2 -6
  71. package/components/date-picker/weekdays.js +2 -3
  72. package/components/date-picker/years.js +3 -3
  73. package/components/dialog/dialog.d.ts +1 -0
  74. package/components/dialog/dialog.js +20 -13
  75. package/components/dialog/dialog__body-scroll-preventer.js +1 -1
  76. package/components/dropdown/dropdown.css +2 -4
  77. package/components/dropdown/dropdown.d.ts +2 -2
  78. package/components/dropdown/dropdown.js +5 -5
  79. package/components/dropdown-menu/dropdown-menu.js +5 -5
  80. package/components/editable-heading/editable-heading.css +5 -2
  81. package/components/editable-heading/editable-heading.js +21 -19
  82. package/components/error-bubble/error-bubble.js +1 -1
  83. package/components/error-message/error-message.js +2 -4
  84. package/components/footer/footer.js +11 -15
  85. package/components/form/form.stories.js +45 -63
  86. package/components/global/create-stateful-context.js +2 -4
  87. package/components/global/data-tests.js +5 -6
  88. package/components/global/dom.js +8 -11
  89. package/components/global/focus-sensor-hoc.js +5 -6
  90. package/components/global/fuzzy-highlight.js +1 -1
  91. package/components/global/get-event-key.js +2 -2
  92. package/components/global/global.css +0 -3
  93. package/components/global/linear-function.js +1 -1
  94. package/components/global/normalize-indent.js +2 -6
  95. package/components/global/react-dom-renderer.js +2 -3
  96. package/components/global/theme.d.ts +4 -2
  97. package/components/global/theme.js +14 -12
  98. package/components/global/url.js +8 -8
  99. package/components/global/variables.css +1 -8
  100. package/components/global/variables_dark.css +0 -1
  101. package/components/grid/col.js +6 -6
  102. package/components/grid/grid.css +174 -173
  103. package/components/grid/grid.js +1 -1
  104. package/components/grid/row.js +13 -6
  105. package/components/group/group.js +1 -1
  106. package/components/header/header-icon.js +2 -2
  107. package/components/header/header.css +19 -15
  108. package/components/header/header.js +3 -5
  109. package/components/header/links.js +1 -1
  110. package/components/header/logo.js +1 -1
  111. package/components/header/profile.d.ts +2 -2
  112. package/components/header/profile.js +9 -9
  113. package/components/header/services-link.js +1 -1
  114. package/components/header/services.js +4 -5
  115. package/components/header/smart-profile.js +4 -3
  116. package/components/header/smart-services.js +9 -5
  117. package/components/header/tray.js +1 -1
  118. package/components/heading/heading.css +0 -1
  119. package/components/heading/heading.js +2 -2
  120. package/components/http/http.d.ts +3 -3
  121. package/components/http/http.js +25 -29
  122. package/components/http/http.mock.js +9 -6
  123. package/components/hub-source/hub-source.js +5 -7
  124. package/components/hub-source/hub-source__user.js +1 -1
  125. package/components/hub-source/hub-source__users-groups.js +6 -7
  126. package/components/i18n/README.md +3 -4
  127. package/components/i18n/i18n-context.js +2 -4
  128. package/components/icon/icon.css +1 -1
  129. package/components/icon/icon.js +7 -9
  130. package/components/icon/icon__svg.js +6 -6
  131. package/components/input/input.css +1 -1
  132. package/components/input/input.js +11 -14
  133. package/components/input-size/input-size.stories.js +42 -22
  134. package/components/island/adaptive-island-hoc.js +1 -1
  135. package/components/island/content.js +4 -6
  136. package/components/island/header.js +8 -10
  137. package/components/island/island.css +5 -5
  138. package/components/island/island.js +1 -1
  139. package/components/link/clickableLink.js +3 -1
  140. package/components/link/link.js +5 -3
  141. package/components/list/consts.js +1 -1
  142. package/components/list/list.d.ts +1 -1
  143. package/components/list/list.js +35 -57
  144. package/components/list/list__custom.js +3 -5
  145. package/components/list/list__hint.js +3 -1
  146. package/components/list/list__item.js +11 -9
  147. package/components/list/list__link.js +1 -1
  148. package/components/list/list__separator.js +2 -2
  149. package/components/list/list__title.js +7 -3
  150. package/components/list/list__users-groups-source.js +6 -8
  151. package/components/loader/loader.js +1 -1
  152. package/components/loader/loader__core.js +5 -5
  153. package/components/loader-inline/loader-inline.css +0 -3
  154. package/components/loader-inline/loader-inline.js +5 -7
  155. package/components/loader-screen/loader-screen.js +1 -1
  156. package/components/login-dialog/login-dialog.js +4 -4
  157. package/components/login-dialog/service.js +5 -5
  158. package/components/markdown/markdown.css +6 -6
  159. package/components/markdown/markdown.d.ts +2 -2
  160. package/components/markdown/markdown.js +4 -6
  161. package/components/message/message.css +2 -1
  162. package/components/message/message.js +30 -21
  163. package/components/old-browsers-message/old-browsers-message.js +2 -2
  164. package/components/old-browsers-message/white-list.js +2 -3
  165. package/components/pager/pager.js +28 -29
  166. package/components/permissions/permissions.js +8 -13
  167. package/components/permissions/permissions__cache.js +6 -7
  168. package/components/popup/popup.consts.js +8 -2
  169. package/components/popup/popup.js +27 -33
  170. package/components/popup/popup.target.js +4 -4
  171. package/components/popup/position.js +21 -28
  172. package/components/popup-menu/popup-menu.js +1 -1
  173. package/components/progress-bar/progress-bar.css +10 -8
  174. package/components/progress-bar/progress-bar.d.ts +2 -2
  175. package/components/progress-bar/progress-bar.js +2 -2
  176. package/components/query-assist/query-assist.css +0 -3
  177. package/components/query-assist/query-assist.js +73 -84
  178. package/components/query-assist/query-assist__suggestions.js +10 -9
  179. package/components/radio/radio.css +6 -2
  180. package/components/radio/radio.js +1 -3
  181. package/components/scrollable-section/scrollable-section.css +5 -6
  182. package/components/scrollable-section/scrollable-section.js +1 -1
  183. package/components/select/select.css +5 -7
  184. package/components/select/select.d.ts +1 -1
  185. package/components/select/select.js +96 -110
  186. package/components/select/select__filter.js +1 -1
  187. package/components/select/select__popup.js +40 -51
  188. package/components/shortcuts/core.js +8 -6
  189. package/components/shortcuts/shortcut-title.js +6 -6
  190. package/components/shortcuts/shortcuts.js +1 -1
  191. package/components/sidebar/sidebar.css +3 -1
  192. package/components/slider/slider.css +14 -14
  193. package/components/slider/slider.js +7 -7
  194. package/components/tab-trap/tab-trap.js +7 -9
  195. package/components/table/cell.js +3 -1
  196. package/components/table/disable-hover-hoc.js +2 -2
  197. package/components/table/header-cell.js +5 -3
  198. package/components/table/header.d.ts +2 -10
  199. package/components/table/header.js +10 -12
  200. package/components/table/multitable.js +5 -3
  201. package/components/table/row.d.ts +0 -1
  202. package/components/table/row.js +20 -27
  203. package/components/table/selection-adapter.js +1 -1
  204. package/components/table/selection-shortcuts-hoc.js +2 -2
  205. package/components/table/selection.d.ts +2 -3
  206. package/components/table/selection.js +4 -5
  207. package/components/table/simple-table.js +4 -4
  208. package/components/table/smart-table.js +5 -5
  209. package/components/table/table.css +8 -9
  210. package/components/table/table.d.ts +0 -1
  211. package/components/table/table.js +22 -23
  212. package/components/table/table.stories.json +45 -16
  213. package/components/tabs/collapsible-more.d.ts +1 -1
  214. package/components/tabs/collapsible-more.js +13 -16
  215. package/components/tabs/collapsible-tab.js +2 -2
  216. package/components/tabs/collapsible-tabs.d.ts +2 -2
  217. package/components/tabs/collapsible-tabs.js +13 -22
  218. package/components/tabs/dumb-tabs.js +6 -9
  219. package/components/tabs/smart-tabs.js +4 -4
  220. package/components/tabs/tab-link.js +1 -3
  221. package/components/tabs/tabs.css +7 -9
  222. package/components/tag/tag.css +7 -7
  223. package/components/tag/tag.d.ts +1 -1
  224. package/components/tag/tag.js +9 -12
  225. package/components/tags-input/tags-input.js +15 -19
  226. package/components/tags-list/tags-list.d.ts +2 -2
  227. package/components/tags-list/tags-list.js +6 -5
  228. package/components/text/text.js +5 -3
  229. package/components/toggle/toggle.css +12 -10
  230. package/components/toggle/toggle.d.ts +2 -2
  231. package/components/toggle/toggle.js +4 -3
  232. package/components/tooltip/tooltip.d.ts +4 -1
  233. package/components/tooltip/tooltip.js +19 -10
  234. package/components/user-agreement/service.js +15 -13
  235. package/components/user-agreement/user-agreement.js +3 -5
  236. package/components/user-card/card.js +10 -9
  237. package/components/user-card/smart-user-card-tooltip.js +5 -7
  238. package/components/user-card/tooltip.js +4 -4
  239. package/components/user-card/user-card.css +4 -0
  240. package/jslint-xml.js +20 -19
  241. package/package.json +66 -58
  242. package/postcss.config.js +3 -4
  243. package/typings.d.ts +2 -4
  244. package/webpack.config.js +20 -25
  245. package/components/badge/badge.css +0 -42
  246. package/components/badge/badge.d.ts +0 -14
  247. package/components/badge/badge.js +0 -29
  248. package/components/island-legacy/content-legacy.d.ts +0 -5
  249. package/components/island-legacy/content-legacy.js +0 -12
  250. package/components/island-legacy/header-legacy.d.ts +0 -5
  251. package/components/island-legacy/header-legacy.js +0 -14
  252. package/components/island-legacy/island-legacy.css +0 -98
  253. package/components/island-legacy/island-legacy.d.ts +0 -7
  254. package/components/island-legacy/island-legacy.js +0 -14
  255. package/components/table-legacy/table-legacy.css +0 -346
  256. package/components/table-legacy/table-legacy__toolbar.css +0 -25
@@ -1,4 +1,4 @@
1
- import { Component, Fragment } from 'react';
1
+ import { Component, Fragment, } from 'react';
2
2
  import * as React from 'react';
3
3
  import classNames from 'classnames';
4
4
  import chevronDownIcon from '@jetbrains/icons/chevron-down';
@@ -42,7 +42,7 @@ export var Type;
42
42
  const ICONS_OFFSET = 5;
43
43
  const ICON_WIDTH = 20;
44
44
  const getStyle = memoize((iconsLength) => ({
45
- paddingRight: ICONS_OFFSET + iconsLength * ICON_WIDTH
45
+ paddingRight: ICONS_OFFSET + iconsLength * ICON_WIDTH,
46
46
  }));
47
47
  const isInputMode = (type) => type === Type.INPUT || type === Type.INPUT_WITHOUT_CONTROLS;
48
48
  function getLowerCaseLabel(item) {
@@ -79,8 +79,11 @@ function buildMultipleMap(selected) {
79
79
  }
80
80
  function getListItems(props, state, rawFilterString, data = props.data) {
81
81
  let filterString = rawFilterString.trim();
82
- if (isInputMode(props.type) && !props.allowAny && state.selected &&
83
- !Array.isArray(state.selected) && filterString === state.selected.label) {
82
+ if (isInputMode(props.type) &&
83
+ !props.allowAny &&
84
+ state.selected &&
85
+ !Array.isArray(state.selected) &&
86
+ filterString === state.selected.label) {
84
87
  filterString = ''; // ignore multiple if it is exactly the selected item
85
88
  }
86
89
  const lowerCaseString = filterString.toLowerCase();
@@ -90,17 +93,17 @@ function getListItems(props, state, rawFilterString, data = props.data) {
90
93
  for (let i = 0; i < data.length; i++) {
91
94
  const item = { ...data[i] };
92
95
  if (check(item, lowerCaseString, data)) {
93
- exactMatch = (item.label === filterString);
94
- if (props.multiple &&
95
- !(typeof props.multiple === 'object' && props.multiple.removeSelectedItems)) {
96
+ exactMatch = item.label === filterString;
97
+ if (props.multiple && !(typeof props.multiple === 'object' && props.multiple.removeSelectedItems)) {
96
98
  item.checkbox = !!state.multipleMap?.[item.key];
97
99
  }
98
100
  if (props.multiple &&
99
101
  typeof props.multiple === 'object' &&
100
102
  props.multiple.limit &&
101
103
  Array.isArray(state.selected)) {
102
- item.disabled = props.multiple.limit === state.selected.length &&
103
- !state.selected.find(selectedItem => selectedItem.key === item.key);
104
+ item.disabled =
105
+ props.multiple.limit === state.selected.length &&
106
+ !state.selected.find(selectedItem => selectedItem.key === item.key);
104
107
  }
105
108
  // Ignore item if it's multiple and is already selected
106
109
  if (!(props.multiple &&
@@ -113,14 +116,12 @@ function getListItems(props, state, rawFilterString, data = props.data) {
113
116
  }
114
117
  let addButton = null;
115
118
  const { add } = props;
116
- if ((add && filterString && !exactMatch) ||
117
- (add && add.alwaysVisible)) {
118
- if (!(add.regexp && !add.regexp.test(filterString)) &&
119
- !(add.minlength && filterString.length < +add.minlength) ||
119
+ if ((add && filterString && !exactMatch) || (add && add.alwaysVisible)) {
120
+ if ((!(add.regexp && !add.regexp.test(filterString)) && !(add.minlength && filterString.length < +add.minlength)) ||
120
121
  add.alwaysVisible) {
121
122
  let label;
122
123
  if (add.label) {
123
- label = (typeof add.label === 'function') ? add.label(filterString) : add.label;
124
+ label = typeof add.label === 'function' ? add.label(filterString) : add.label;
124
125
  }
125
126
  else {
126
127
  label = filterString;
@@ -128,7 +129,7 @@ function getListItems(props, state, rawFilterString, data = props.data) {
128
129
  addButton = {
129
130
  prefix: add.prefix,
130
131
  label,
131
- delayed: add.delayed ?? true
132
+ delayed: add.delayed ?? true,
132
133
  };
133
134
  }
134
135
  }
@@ -156,9 +157,7 @@ const getItemLabel = ({ selectedLabel, label }) => {
156
157
  }
157
158
  return typeof label === 'string' ? label : '';
158
159
  };
159
- const getValueForFilter = (selected, type, filterValue) => (selected && !isArray(selected) && isInputMode(type)
160
- ? getItemLabel(selected)
161
- : filterValue);
160
+ const getValueForFilter = (selected, type, filterValue) => (selected && !isArray(selected) && isInputMode(type) ? getItemLabel(selected) : filterValue);
162
161
  function isSameSelected(prevSelected, selected) {
163
162
  if (!prevSelected || !selected || prevSelected.length !== selected.length) {
164
163
  return false;
@@ -199,7 +198,7 @@ export default class Select extends Component {
199
198
  Popup.PopupProps.Directions.BOTTOM_RIGHT,
200
199
  Popup.PopupProps.Directions.BOTTOM_LEFT,
201
200
  Popup.PopupProps.Directions.TOP_LEFT,
202
- Popup.PopupProps.Directions.TOP_RIGHT
201
+ Popup.PopupProps.Directions.TOP_RIGHT,
203
202
  ],
204
203
  selected: null, // current selection (item / array of items)
205
204
  label: null, // BUTTON or INPUT label (nothing selected)
@@ -225,7 +224,7 @@ export default class Select extends Component {
225
224
  tags: null,
226
225
  ringPopupTarget: null,
227
226
  dir: 'ltr',
228
- offset: 4
227
+ offset: 4,
229
228
  };
230
229
  static getDerivedStateFromProps(nextProps, prevState) {
231
230
  const { multiple, data, type } = nextProps;
@@ -233,7 +232,7 @@ export default class Select extends Component {
233
232
  const nextState = {
234
233
  prevData: data,
235
234
  prevSelected: nextProps.selected,
236
- prevMultiple: multiple
235
+ prevMultiple: multiple,
237
236
  };
238
237
  if ('data' in nextProps && data !== prevData) {
239
238
  const { filteredData, addButton } = getListItems(nextProps, prevState, filterValue, data);
@@ -241,7 +240,7 @@ export default class Select extends Component {
241
240
  if (prevState.selected) {
242
241
  Object.assign(nextState, {
243
242
  selectedIndex: getSelectedIndex(prevState.selected, data),
244
- filterValue: getValueForFilter(prevState.selected, type, filterValue)
243
+ filterValue: getValueForFilter(prevState.selected, type, filterValue),
245
244
  });
246
245
  }
247
246
  }
@@ -250,10 +249,9 @@ export default class Select extends Component {
250
249
  const selectedIndex = getSelectedIndex(selected, data || prevData);
251
250
  Object.assign(nextState, {
252
251
  selected,
253
- filterValue: getValueForFilter(selected, type, filterValue)
252
+ filterValue: getValueForFilter(selected, type, filterValue),
254
253
  });
255
- if (!Array.isArray(prevSelected) || !Array.isArray(selected) ||
256
- !isSameSelected(prevSelected, selected)) {
254
+ if (!Array.isArray(prevSelected) || !Array.isArray(selected) || !isSameSelected(prevSelected, selected)) {
257
255
  Object.assign(nextState, { selectedIndex });
258
256
  }
259
257
  }
@@ -274,10 +272,9 @@ export default class Select extends Component {
274
272
  state = {
275
273
  data: [],
276
274
  shownData: [],
277
- selected: (this.props.multiple ? [] : null),
275
+ selected: this.props.multiple ? [] : null,
278
276
  selectedIndex: null,
279
- filterValue: this.props.filter && typeof this.props.filter === 'object' &&
280
- this.props.filter.value || '',
277
+ filterValue: (this.props.filter && typeof this.props.filter === 'object' && this.props.filter.value) || '',
281
278
  shortcutsEnabled: false,
282
279
  popupShortcuts: false,
283
280
  showPopup: this.props.showPopup,
@@ -285,7 +282,7 @@ export default class Select extends Component {
285
282
  prevSelected: null,
286
283
  prevMultiple: this.props.multiple,
287
284
  multipleMap: {},
288
- addButton: null
285
+ addButton: null,
289
286
  };
290
287
  componentDidUpdate(prevProps, prevState) {
291
288
  const { showPopup, selected } = this.state;
@@ -310,7 +307,7 @@ export default class Select extends Component {
310
307
  this.props.onFocus(e);
311
308
  this.setState({
312
309
  shortcutsEnabled: true,
313
- focused: true
310
+ focused: true,
314
311
  });
315
312
  };
316
313
  isClickingSelect = false;
@@ -322,8 +319,7 @@ export default class Select extends Component {
322
319
  };
323
320
  _blurHandler = () => {
324
321
  this.props.onBlur();
325
- if (this._popup && this._popup.isVisible() && !this._popup.isClickingPopup &&
326
- !this.isClickingSelect) {
322
+ if (this._popup && this._popup.isVisible() && !this._popup.isClickingPopup && !this.isClickingSelect) {
327
323
  window.setTimeout(() => {
328
324
  this.setState({ showPopup: false });
329
325
  });
@@ -331,7 +327,7 @@ export default class Select extends Component {
331
327
  if (!this._popup?.isClickingPopup) {
332
328
  this.setState({
333
329
  shortcutsEnabled: false,
334
- focused: false
330
+ focused: false,
335
331
  });
336
332
  }
337
333
  };
@@ -369,11 +365,11 @@ export default class Select extends Component {
369
365
  }
370
366
  const selected = {
371
367
  key: Math.random(),
372
- label: this.props.getInitial()
368
+ label: this.props.getInitial(),
373
369
  };
374
370
  this.setState({
375
371
  selected,
376
- filterValue: this.getValueForFilter(selected)
372
+ filterValue: this.getValueForFilter(selected),
377
373
  }, () => {
378
374
  this.props.onChange(selected, event);
379
375
  this.props.onReset();
@@ -396,9 +392,7 @@ export default class Select extends Component {
396
392
  };
397
393
  _getResetOption() {
398
394
  const isOptionsSelected = Array.isArray(this.state.selected) && this.state.selected.length;
399
- const reset = this.props.tags && typeof this.props.tags === 'object'
400
- ? this.props.tags.reset
401
- : null;
395
+ const reset = this.props.tags && typeof this.props.tags === 'object' ? this.props.tags.reset : null;
402
396
  if (!isOptionsSelected || !reset) {
403
397
  return null;
404
398
  }
@@ -408,7 +402,7 @@ export default class Select extends Component {
408
402
  this.props.onFilter('');
409
403
  this.setState(prevState => ({
410
404
  shownData: prevState.shownData.slice(reset.separator ? 2 : 1),
411
- multipleMap: {}
405
+ multipleMap: {},
412
406
  }));
413
407
  this._redrawPopup();
414
408
  };
@@ -421,7 +415,7 @@ export default class Select extends Component {
421
415
  {reset.label}
422
416
  </Button>),
423
417
  glyph: reset.glyph,
424
- onClick: resetHandler
418
+ onClick: resetHandler,
425
419
  };
426
420
  }
427
421
  _prependResetOption(shownData) {
@@ -430,7 +424,7 @@ export default class Select extends Component {
430
424
  const resetItems = [resetOption];
431
425
  if (resetOption.separator) {
432
426
  resetItems.push({
433
- rgItemType: List.ListProps.Type.SEPARATOR
427
+ rgItemType: List.ListProps.Type.SEPARATOR,
434
428
  });
435
429
  }
436
430
  return resetItems.concat(shownData);
@@ -462,14 +456,14 @@ export default class Select extends Component {
462
456
  const shownData = this.getListItems(this.filterValue());
463
457
  this.setState({
464
458
  showPopup: true,
465
- shownData
459
+ shownData,
466
460
  });
467
461
  };
468
462
  _hidePopup = (tryFocusAnchor) => {
469
463
  if (this.node && this.state.showPopup) {
470
464
  this.setState(prevState => ({
471
465
  showPopup: false,
472
- filterValue: this.props.allowAny ? prevState.filterValue : ''
466
+ filterValue: this.props.allowAny ? prevState.filterValue : '',
473
467
  }));
474
468
  if (tryFocusAnchor) {
475
469
  this.focus();
@@ -489,13 +483,13 @@ export default class Select extends Component {
489
483
  return null;
490
484
  }
491
485
  return (<div className={classNames({
492
- [styles.toolbar]: Boolean(this.state.addButton || renderBottomToolbar)
486
+ [styles.toolbar]: Boolean(this.state.addButton || renderBottomToolbar),
493
487
  })} data-test="ring-select-toolbar">
494
488
  {renderBottomToolbar && renderBottomToolbar()}
495
489
  {this.state.addButton && (<Button text delayed={delayed} className={classNames(styles.button, styles.buttonSpaced)} onClick={this.addHandler} data-test="ring-select-toolbar-button">
496
490
  {prefix ? `${prefix} ${label}` : label}
497
491
  </Button>)}
498
- {hint && (<List.ListHint label={hint} data-test="ring-select-toolbar-hint"/>)}
492
+ {hint && <List.ListHint label={hint} data-test="ring-select-toolbar-hint"/>}
499
493
  </div>);
500
494
  }
501
495
  getTopbar() {
@@ -556,11 +550,11 @@ export default class Select extends Component {
556
550
  if (this.props.allowAny) {
557
551
  const fakeSelected = {
558
552
  key: Math.random(),
559
- label: filterValue
553
+ label: filterValue,
560
554
  };
561
555
  this.setState({
562
556
  selected: filterValue === '' ? null : fakeSelected,
563
- selectedIndex: null
557
+ selectedIndex: null,
564
558
  }, () => {
565
559
  this.props.onSelect(fakeSelected, event);
566
560
  this.props.onChange(fakeSelected, event);
@@ -581,6 +575,7 @@ export default class Select extends Component {
581
575
  _redrawPopup = () => {
582
576
  if (this.props.multiple) {
583
577
  setTimeout(() => {
578
+ //setTimeout solves events order and bubbling issue
584
579
  if (this.isInputMode()) {
585
580
  this.clearFilter();
586
581
  }
@@ -595,9 +590,7 @@ export default class Select extends Component {
595
590
  if (isSelectItemEvent) {
596
591
  event.preventDefault();
597
592
  }
598
- if ((!isItem(selected) && !isCustomItem(selected)) ||
599
- selected.disabled ||
600
- selected.isResetItem) {
593
+ if ((!isItem(selected) && !isCustomItem(selected)) || selected.disabled || selected.isResetItem) {
601
594
  return;
602
595
  }
603
596
  const tryKeepOpen = this.props.tryKeepOpen ?? opts.tryKeepOpen;
@@ -607,11 +600,9 @@ export default class Select extends Component {
607
600
  }
608
601
  this.setState({
609
602
  selected,
610
- selectedIndex: this._getSelectedIndex(selected, this.props.data)
603
+ selectedIndex: this._getSelectedIndex(selected, this.props.data),
611
604
  }, () => {
612
- const newFilterValue = this.isInputMode() && !this.props.hideSelected
613
- ? getItemLabel(selected)
614
- : '';
605
+ const newFilterValue = this.isInputMode() && !this.props.hideSelected ? getItemLabel(selected) : '';
615
606
  this.filterValue(newFilterValue);
616
607
  this.props.onFilter(newFilterValue);
617
608
  this.props.onSelect(selected, event);
@@ -637,14 +628,12 @@ export default class Select extends Component {
637
628
  const nextState = {
638
629
  filterValue: '',
639
630
  selected: nextSelection,
640
- selectedIndex: this._getSelectedIndex(selected, this.props.data)
631
+ selectedIndex: this._getSelectedIndex(selected, this.props.data),
641
632
  };
642
- if (typeof this.props.multiple === 'object' && this.props.multiple.limit &&
633
+ if (typeof this.props.multiple === 'object' &&
634
+ this.props.multiple.limit &&
643
635
  nextSelection.length === this.props.multiple.limit) {
644
- nextState.shownData = prevState.shownData.
645
- map(item => (nextSelection.find(selectedItem => selectedItem.key === item.key)
646
- ? item
647
- : { ...item, disabled: true }));
636
+ nextState.shownData = prevState.shownData.map(item => nextSelection.find(selectedItem => selectedItem.key === item.key) ? item : { ...item, disabled: true });
648
637
  }
649
638
  if (!prevState.multipleMap[selected.key]) {
650
639
  nextState.multipleMap = { ...prevState.multipleMap, [selected.key]: true };
@@ -675,19 +664,16 @@ export default class Select extends Component {
675
664
  const currentSelection = prevState.selected;
676
665
  let nextSelection;
677
666
  if (isSelectAll) {
678
- nextSelection = this.props.data.filter(item => (isItem(item) || isCustomItem(item)) &&
679
- !item.disabled);
680
- nextSelection.
681
- filter(item => !this.props.selected.
682
- find(selectedItem => item.key === selectedItem.key)).
683
- forEach(item => {
667
+ nextSelection = this.props.data.filter(item => (isItem(item) || isCustomItem(item)) && !item.disabled);
668
+ nextSelection
669
+ .filter(item => !this.props.selected.find(selectedItem => item.key === selectedItem.key))
670
+ .forEach(item => {
684
671
  this.props.onSelect?.(item);
685
672
  });
686
673
  }
687
674
  else {
688
675
  nextSelection = [];
689
- currentSelection.
690
- forEach(item => {
676
+ currentSelection.forEach(item => {
691
677
  this.props.onDeselect?.(item);
692
678
  });
693
679
  }
@@ -695,13 +681,9 @@ export default class Select extends Component {
695
681
  return {
696
682
  filterValue: '',
697
683
  selected: nextSelection,
698
- selectedIndex: isSelectAll
699
- ? this._getSelectedIndex(nextSelection, this.props.data)
700
- : null,
684
+ selectedIndex: isSelectAll ? this._getSelectedIndex(nextSelection, this.props.data) : null,
701
685
  shownData: prevState.shownData.map(item => ({ ...item, checkbox: isSelectAll })),
702
- multipleMap: isSelectAll
703
- ? buildMultipleMap(this.props.data.filter(item => !item.disabled))
704
- : {}
686
+ multipleMap: isSelectAll ? buildMultipleMap(this.props.data.filter(item => !item.disabled)) : {},
705
687
  };
706
688
  }, this._redrawPopup);
707
689
  };
@@ -716,7 +698,9 @@ export default class Select extends Component {
716
698
  }
717
699
  }
718
700
  }
719
- const isTagRemoved = this.props.tags && event && event.target &&
701
+ const isTagRemoved = this.props.tags &&
702
+ event &&
703
+ event.target &&
720
704
  event.target instanceof Element &&
721
705
  event.target.matches('[data-test="ring-tag-remove"]');
722
706
  if (!isTagRemoved) {
@@ -734,7 +718,7 @@ export default class Select extends Component {
734
718
  this.setState({
735
719
  selected: empty,
736
720
  selectedIndex: null,
737
- filterValue: ''
721
+ filterValue: '',
738
722
  }, () => {
739
723
  if (this.props.onChange) {
740
724
  this.props.onChange(empty, event);
@@ -743,8 +727,7 @@ export default class Select extends Component {
743
727
  return false;
744
728
  };
745
729
  _selectionIsEmpty() {
746
- return (Array.isArray(this.state.selected) && !this.state.selected.length) ||
747
- !this.state.selected;
730
+ return (Array.isArray(this.state.selected) && !this.state.selected.length) || !this.state.selected;
748
731
  }
749
732
  _getLabel() {
750
733
  return this.props.label ?? this.props.selectedLabel ?? 'Select an option';
@@ -784,8 +767,8 @@ export default class Select extends Component {
784
767
  return icons;
785
768
  }
786
769
  _getAvatar() {
787
- return !Array.isArray(this.state.selected) &&
788
- (this.state.selected?.avatar || this.state.selected?.showGeneratedAvatar) && (<Avatar className={styles.avatar} url={this.state.selected.avatar} username={this.state.selected.username} size={AvatarSize.Size20}/>);
770
+ return (!Array.isArray(this.state.selected) &&
771
+ (this.state.selected?.avatar || this.state.selected?.showGeneratedAvatar) && (<Avatar className={styles.avatar} url={this.state.selected.avatar} username={this.state.selected.username} size={AvatarSize.Size20}/>));
789
772
  }
790
773
  filter;
791
774
  filterRef = (el) => {
@@ -802,7 +785,7 @@ export default class Select extends Component {
802
785
  left: noop,
803
786
  'shift+up': noop,
804
787
  'shift+down': noop,
805
- space: noop
788
+ space: noop,
806
789
  };
807
790
  }
808
791
  renderSelect(activeItemId) {
@@ -811,7 +794,7 @@ export default class Select extends Component {
811
794
  const { shortcutsEnabled } = this.state;
812
795
  const classes = classNames(styles.select, 'ring-js-shortcuts', this.props.className, styles[`height${this.props.height || this.context}`], {
813
796
  [styles[`size${this.props.size}`]]: this.props.type !== Type.INLINE,
814
- [styles.disabled]: this.props.disabled
797
+ [styles.disabled]: this.props.disabled,
815
798
  });
816
799
  let style;
817
800
  let iconsNode;
@@ -824,39 +807,42 @@ export default class Select extends Component {
824
807
  ? {
825
808
  'aria-owns': this.listId,
826
809
  'aria-activedescendant': activeItemId,
827
- 'aria-label': this.props.label ?? undefined
810
+ 'aria-label': this.props.label ?? undefined,
828
811
  }
829
812
  : {
830
- 'aria-label': this.props.label ?? undefined
813
+ 'aria-label': this.props.label ?? undefined,
831
814
  };
832
815
  switch (this.props.type) {
833
816
  case Type.INPUT_WITHOUT_CONTROLS:
834
- case Type.INPUT: return (<>
835
- <div ref={this.nodeRef} className={classNames(classes, styles.inputMode)} data-test={dataTests('ring-select', dataTest)} role="presentation" // has interactive elements inside
836
- onMouseDown={this.mouseDownHandler} onMouseUp={this.mouseUpHandler}>
837
- {shortcutsEnabled && (<Shortcuts map={this.getShortcutsMap()} scope={this.shortcutsScope}/>)}
838
- <Input {...ariaProps} height={this.props.height} autoComplete="off" id={this.props.id} onClick={this._clickHandler} inputRef={this.composedFilterRef(this.filterRef, this.props.filterRef)} disabled={this.props.disabled} value={this.state.filterValue} borderless={this.props.type === Type.INPUT_WITHOUT_CONTROLS} style={style} size={Size.FULL} onChange={this._filterChangeHandler} onFocus={this._focusHandler} onBlur={this._blurHandler}
839
- // Input with error style without description
840
- error={this.props.error != null ? '' : null} label={this.props.type === Type.INPUT ? this._getLabel() : null} placeholder={this.props.inputPlaceholder} onKeyDown={this.props.onKeyDown} data-test="ring-select__focus" enableShortcuts={shortcutsEnabled
841
- ? Object.keys({
842
- ...this.getShortcutsMap(),
843
- ...this._popup?.list?.shortcutsMap
844
- })
845
- : undefined} icon={this.props.filterIcon} afterInput={iconsNode}/>
846
- {this._renderPopup()}
847
- </div>
848
- {this.props.error && (<div className={classNames(inputStyles.errorText, inputStyles[`size${this.props.size}`])}>
849
- {this.props.error}
850
- </div>)}
851
- </>);
817
+ case Type.INPUT:
818
+ return (<>
819
+ <div ref={this.nodeRef} className={classNames(classes, styles.inputMode)} data-test={dataTests('ring-select', dataTest)} role="presentation" // has interactive elements inside
820
+ onMouseDown={this.mouseDownHandler} onMouseUp={this.mouseUpHandler}>
821
+ {shortcutsEnabled && <Shortcuts map={this.getShortcutsMap()} scope={this.shortcutsScope}/>}
822
+ <Input {...ariaProps} height={this.props.height} autoComplete="off" id={this.props.id} onClick={this._clickHandler} inputRef={this.composedFilterRef(this.filterRef, this.props.filterRef)} disabled={this.props.disabled} value={this.state.filterValue} borderless={this.props.type === Type.INPUT_WITHOUT_CONTROLS} style={style} size={Size.FULL} onChange={this._filterChangeHandler} onFocus={this._focusHandler} onBlur={this._blurHandler}
823
+ // Input with error style without description
824
+ error={this.props.error != null ? '' : null} label={this.props.type === Type.INPUT ? this._getLabel() : null} placeholder={this.props.inputPlaceholder} onKeyDown={this.props.onKeyDown} data-test="ring-select__focus" enableShortcuts={shortcutsEnabled
825
+ ? Object.keys({
826
+ ...this.getShortcutsMap(),
827
+ ...this._popup?.list?.shortcutsMap,
828
+ })
829
+ : undefined} icon={this.props.filterIcon} afterInput={iconsNode}/>
830
+ {this._renderPopup()}
831
+ </div>
832
+ {this.props.error && (<div className={classNames(inputStyles.errorText, inputStyles[`size${this.props.size}`])}>
833
+ {this.props.error}
834
+ </div>)}
835
+ </>);
852
836
  case Type.BUTTON:
853
837
  return (<div ref={this.nodeRef} className={classNames(classes, styles.buttonMode)} data-test={dataTests('ring-select', dataTest)}>
854
- {selectedLabel && (<ControlLabel type={this.props.labelType} disabled={this.props.disabled} htmlFor={this.props.id}>{selectedLabel}</ControlLabel>)}
855
- {shortcutsEnabled && (<Shortcuts map={this.getShortcutsMap()} scope={this.shortcutsScope}/>)}
838
+ {selectedLabel && (<ControlLabel type={this.props.labelType} disabled={this.props.disabled} htmlFor={this.props.id}>
839
+ {selectedLabel}
840
+ </ControlLabel>)}
841
+ {shortcutsEnabled && <Shortcuts map={this.getShortcutsMap()} scope={this.shortcutsScope}/>}
856
842
  <div className={styles.buttonContainer}>
857
843
  <Button {...ariaProps} height={this.props.height} id={this.props.id} onClick={this._clickHandler} className={classNames(this.props.buttonClassName, styles.buttonValue, {
858
844
  [styles.buttonValueOpen]: this.state.showPopup,
859
- [styles.buttonValueEmpty]: this._selectionIsEmpty()
845
+ [styles.buttonValueEmpty]: this._selectionIsEmpty(),
860
846
  })} disabled={this.props.disabled} style={style} data-test="ring-select__button ring-select__focus">
861
847
  {this._getAvatar()}
862
848
  {this._getPlaceholder()}
@@ -867,7 +853,7 @@ export default class Select extends Component {
867
853
  </div>);
868
854
  case Type.INLINE:
869
855
  return (<div className={classes} ref={this.nodeRef} data-test={dataTests('ring-select', dataTest)}>
870
- {shortcutsEnabled && (<Shortcuts map={this.getShortcutsMap()} scope={this.shortcutsScope}/>)}
856
+ {shortcutsEnabled && <Shortcuts map={this.getShortcutsMap()} scope={this.shortcutsScope}/>}
871
857
  <Anchor {...ariaProps} className={this.props.buttonClassName ?? undefined} id={this.props.id} onClick={this._clickHandler} data-test="ring-select__focus" disabled={this.props.disabled} active={this.state.showPopup}>
872
858
  {this._getPlaceholder()}
873
859
  </Anchor>
@@ -876,11 +862,11 @@ export default class Select extends Component {
876
862
  default:
877
863
  if (this.props.customAnchor) {
878
864
  return (<Fragment>
879
- {shortcutsEnabled && (<Shortcuts map={this.getShortcutsMap()} scope={this.shortcutsScope}/>)}
865
+ {shortcutsEnabled && <Shortcuts map={this.getShortcutsMap()} scope={this.shortcutsScope}/>}
880
866
  {this.props.customAnchor({
881
867
  wrapperProps: {
882
868
  ref: this.nodeRef,
883
- 'data-test': dataTests('ring-select', dataTest)
869
+ 'data-test': dataTests('ring-select', dataTest),
884
870
  },
885
871
  buttonProps: {
886
872
  ...ariaProps,
@@ -888,9 +874,9 @@ export default class Select extends Component {
888
874
  onClick: this._clickHandler,
889
875
  disabled: this.props.disabled,
890
876
  children: this._getPlaceholder(),
891
- 'data-test': 'ring-select__focus'
877
+ 'data-test': 'ring-select__focus',
892
878
  },
893
- popup: this._renderPopup()
879
+ popup: this._renderPopup(),
894
880
  })}
895
881
  </Fragment>);
896
882
  }
@@ -8,7 +8,7 @@ import styles from './select-popup.css';
8
8
  function noop() { }
9
9
  export default class SelectFilter extends Component {
10
10
  static defaultProps = {
11
- inputRef: noop
11
+ inputRef: noop,
12
12
  };
13
13
  componentWillUnmount() {
14
14
  this.blur();