@jetbrains/ring-ui 7.0.0-beta.9 → 7.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (251) 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 +31 -24
  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.js +3 -3
  37. package/components/collapse/collapse-context.js +1 -1
  38. package/components/collapse/collapse-control.js +5 -3
  39. package/components/collapse/collapse.css +21 -20
  40. package/components/collapse/collapse.js +2 -2
  41. package/components/confirm/confirm.d.ts +2 -2
  42. package/components/confirm/confirm.js +2 -2
  43. package/components/confirm-service/confirm-service.d.ts +1 -1
  44. package/components/confirm-service/confirm-service.js +6 -6
  45. package/components/content-layout/content-layout.css +6 -5
  46. package/components/content-layout/content-layout.js +7 -6
  47. package/components/content-layout/sidebar.js +5 -5
  48. package/components/contenteditable/contenteditable.d.ts +1 -1
  49. package/components/contenteditable/contenteditable.js +3 -4
  50. package/components/control-label/control-label.js +5 -3
  51. package/components/data-list/data-list.css +3 -3
  52. package/components/data-list/data-list.d.ts +2 -2
  53. package/components/data-list/data-list.js +6 -7
  54. package/components/data-list/data-list.mock.js +57 -47
  55. package/components/data-list/item.js +14 -16
  56. package/components/data-list/selection.js +5 -7
  57. package/components/data-list/title.js +5 -6
  58. package/components/date-picker/consts.js +2 -2
  59. package/components/date-picker/date-input.js +4 -4
  60. package/components/date-picker/date-picker.css +23 -18
  61. package/components/date-picker/date-picker.d.ts +2 -1
  62. package/components/date-picker/date-picker.js +13 -19
  63. package/components/date-picker/date-popup.js +30 -36
  64. package/components/date-picker/day.js +6 -9
  65. package/components/date-picker/formats.js +647 -1
  66. package/components/date-picker/month-names.js +6 -8
  67. package/components/date-picker/month-slider.js +2 -2
  68. package/components/date-picker/month.js +1 -3
  69. package/components/date-picker/months.js +2 -6
  70. package/components/date-picker/weekdays.js +2 -3
  71. package/components/date-picker/years.js +3 -3
  72. package/components/dialog/dialog.d.ts +1 -0
  73. package/components/dialog/dialog.js +20 -13
  74. package/components/dialog/dialog__body-scroll-preventer.js +1 -1
  75. package/components/dropdown/dropdown.css +2 -4
  76. package/components/dropdown/dropdown.d.ts +2 -2
  77. package/components/dropdown/dropdown.js +5 -5
  78. package/components/dropdown-menu/dropdown-menu.js +5 -5
  79. package/components/editable-heading/editable-heading.css +5 -2
  80. package/components/editable-heading/editable-heading.js +21 -19
  81. package/components/error-bubble/error-bubble.js +1 -1
  82. package/components/error-message/error-message.js +2 -4
  83. package/components/footer/footer.js +11 -15
  84. package/components/form/form.stories.js +45 -63
  85. package/components/global/create-stateful-context.js +2 -4
  86. package/components/global/data-tests.js +5 -6
  87. package/components/global/dom.js +8 -11
  88. package/components/global/focus-sensor-hoc.js +5 -6
  89. package/components/global/fuzzy-highlight.js +1 -1
  90. package/components/global/get-event-key.js +2 -2
  91. package/components/global/global.css +0 -3
  92. package/components/global/linear-function.js +1 -1
  93. package/components/global/normalize-indent.js +2 -6
  94. package/components/global/react-dom-renderer.js +2 -3
  95. package/components/global/theme.js +9 -10
  96. package/components/global/url.js +8 -8
  97. package/components/global/variables.css +1 -8
  98. package/components/global/variables_dark.css +0 -1
  99. package/components/grid/col.js +6 -6
  100. package/components/grid/grid.css +174 -173
  101. package/components/grid/grid.js +1 -1
  102. package/components/grid/row.js +13 -6
  103. package/components/group/group.js +1 -1
  104. package/components/header/header-icon.js +2 -2
  105. package/components/header/header.css +19 -15
  106. package/components/header/header.js +3 -5
  107. package/components/header/links.js +1 -1
  108. package/components/header/logo.js +1 -1
  109. package/components/header/profile.d.ts +2 -2
  110. package/components/header/profile.js +9 -9
  111. package/components/header/services-link.js +1 -1
  112. package/components/header/services.js +4 -5
  113. package/components/header/smart-profile.js +4 -3
  114. package/components/header/smart-services.js +9 -5
  115. package/components/header/tray.js +1 -1
  116. package/components/heading/heading.css +0 -1
  117. package/components/heading/heading.js +2 -2
  118. package/components/http/http.d.ts +3 -3
  119. package/components/http/http.js +25 -29
  120. package/components/http/http.mock.js +9 -6
  121. package/components/hub-source/hub-source.js +5 -7
  122. package/components/hub-source/hub-source__user.js +1 -1
  123. package/components/hub-source/hub-source__users-groups.js +6 -7
  124. package/components/i18n/README.md +3 -4
  125. package/components/i18n/i18n-context.js +2 -4
  126. package/components/icon/icon.js +7 -9
  127. package/components/icon/icon__svg.js +6 -6
  128. package/components/input/input.js +11 -14
  129. package/components/input-size/input-size.stories.js +42 -22
  130. package/components/island/adaptive-island-hoc.js +1 -1
  131. package/components/island/content.js +4 -6
  132. package/components/island/header.js +8 -10
  133. package/components/island/island.css +5 -5
  134. package/components/island/island.js +1 -1
  135. package/components/link/clickableLink.js +3 -1
  136. package/components/link/link.js +5 -3
  137. package/components/list/consts.js +1 -1
  138. package/components/list/list.d.ts +1 -1
  139. package/components/list/list.js +35 -57
  140. package/components/list/list__custom.js +3 -5
  141. package/components/list/list__hint.js +3 -1
  142. package/components/list/list__item.js +11 -9
  143. package/components/list/list__link.js +1 -1
  144. package/components/list/list__separator.js +2 -2
  145. package/components/list/list__title.js +7 -3
  146. package/components/list/list__users-groups-source.js +6 -8
  147. package/components/loader/loader.js +1 -1
  148. package/components/loader/loader__core.js +5 -5
  149. package/components/loader-inline/loader-inline.css +0 -3
  150. package/components/loader-inline/loader-inline.js +5 -7
  151. package/components/loader-screen/loader-screen.js +1 -1
  152. package/components/login-dialog/login-dialog.js +4 -4
  153. package/components/login-dialog/service.js +5 -5
  154. package/components/markdown/markdown.css +6 -6
  155. package/components/markdown/markdown.d.ts +2 -2
  156. package/components/markdown/markdown.js +4 -6
  157. package/components/message/message.css +2 -1
  158. package/components/message/message.js +30 -21
  159. package/components/old-browsers-message/old-browsers-message.js +2 -2
  160. package/components/old-browsers-message/white-list.js +2 -3
  161. package/components/pager/pager.js +28 -29
  162. package/components/permissions/permissions.js +8 -13
  163. package/components/permissions/permissions__cache.js +6 -7
  164. package/components/popup/popup.consts.js +8 -2
  165. package/components/popup/popup.js +27 -33
  166. package/components/popup/popup.target.js +4 -4
  167. package/components/popup/position.js +21 -28
  168. package/components/popup-menu/popup-menu.js +1 -1
  169. package/components/progress-bar/progress-bar.css +10 -8
  170. package/components/progress-bar/progress-bar.d.ts +2 -2
  171. package/components/progress-bar/progress-bar.js +2 -2
  172. package/components/query-assist/query-assist.css +0 -3
  173. package/components/query-assist/query-assist.js +73 -84
  174. package/components/query-assist/query-assist__suggestions.js +10 -9
  175. package/components/radio/radio.css +6 -2
  176. package/components/radio/radio.js +1 -3
  177. package/components/scrollable-section/scrollable-section.css +5 -6
  178. package/components/scrollable-section/scrollable-section.js +1 -1
  179. package/components/select/select.css +5 -5
  180. package/components/select/select.d.ts +1 -1
  181. package/components/select/select.js +96 -110
  182. package/components/select/select__filter.js +1 -1
  183. package/components/select/select__popup.js +40 -51
  184. package/components/shortcuts/core.js +10 -7
  185. package/components/shortcuts/shortcut-title.js +6 -6
  186. package/components/shortcuts/shortcuts.js +1 -1
  187. package/components/sidebar/sidebar.css +3 -1
  188. package/components/slider/slider.css +14 -14
  189. package/components/slider/slider.js +7 -7
  190. package/components/tab-trap/tab-trap.js +7 -9
  191. package/components/table/cell.js +3 -1
  192. package/components/table/disable-hover-hoc.js +2 -2
  193. package/components/table/header-cell.js +5 -3
  194. package/components/table/header.d.ts +1 -2
  195. package/components/table/header.js +10 -12
  196. package/components/table/multitable.js +5 -3
  197. package/components/table/row.d.ts +0 -1
  198. package/components/table/row.js +20 -27
  199. package/components/table/selection-adapter.js +1 -1
  200. package/components/table/selection-shortcuts-hoc.js +2 -2
  201. package/components/table/selection.d.ts +2 -3
  202. package/components/table/selection.js +4 -5
  203. package/components/table/simple-table.js +4 -4
  204. package/components/table/smart-table.js +5 -5
  205. package/components/table/table.css +8 -9
  206. package/components/table/table.d.ts +0 -1
  207. package/components/table/table.js +22 -23
  208. package/components/table/table.stories.json +45 -16
  209. package/components/tabs/collapsible-more.d.ts +1 -1
  210. package/components/tabs/collapsible-more.js +13 -16
  211. package/components/tabs/collapsible-tab.js +2 -2
  212. package/components/tabs/collapsible-tabs.d.ts +2 -2
  213. package/components/tabs/collapsible-tabs.js +13 -22
  214. package/components/tabs/dumb-tabs.js +6 -9
  215. package/components/tabs/smart-tabs.js +4 -4
  216. package/components/tabs/tab-link.js +1 -3
  217. package/components/tabs/tabs.css +7 -9
  218. package/components/tag/tag.css +6 -6
  219. package/components/tag/tag.d.ts +1 -1
  220. package/components/tag/tag.js +9 -12
  221. package/components/tags-input/tags-input.js +15 -19
  222. package/components/tags-list/tags-list.d.ts +2 -2
  223. package/components/tags-list/tags-list.js +6 -5
  224. package/components/text/text.js +5 -3
  225. package/components/toggle/toggle.css +12 -10
  226. package/components/toggle/toggle.d.ts +2 -2
  227. package/components/toggle/toggle.js +4 -3
  228. package/components/tooltip/tooltip.js +13 -8
  229. package/components/user-agreement/service.js +15 -13
  230. package/components/user-agreement/user-agreement.js +3 -5
  231. package/components/user-card/card.js +10 -9
  232. package/components/user-card/smart-user-card-tooltip.js +5 -7
  233. package/components/user-card/tooltip.js +4 -4
  234. package/components/user-card/user-card.css +4 -0
  235. package/jslint-xml.js +20 -19
  236. package/package.json +59 -50
  237. package/postcss.config.js +3 -4
  238. package/typings.d.ts +2 -4
  239. package/webpack.config.js +20 -25
  240. package/components/badge/badge.css +0 -42
  241. package/components/badge/badge.d.ts +0 -14
  242. package/components/badge/badge.js +0 -29
  243. package/components/island-legacy/content-legacy.d.ts +0 -5
  244. package/components/island-legacy/content-legacy.js +0 -12
  245. package/components/island-legacy/header-legacy.d.ts +0 -5
  246. package/components/island-legacy/header-legacy.js +0 -14
  247. package/components/island-legacy/island-legacy.css +0 -98
  248. package/components/island-legacy/island-legacy.d.ts +0 -7
  249. package/components/island-legacy/island-legacy.js +0 -14
  250. package/components/table-legacy/table-legacy.css +0 -346
  251. package/components/table-legacy/table-legacy__toolbar.css +0 -25
@@ -5,12 +5,12 @@ function getScrollingCoordinates(container) {
5
5
  if (container !== null) {
6
6
  return {
7
7
  top: container.scrollTop,
8
- left: container.scrollLeft
8
+ left: container.scrollLeft,
9
9
  };
10
10
  }
11
11
  return {
12
12
  top: getDocumentScrollTop(),
13
- left: getDocumentScrollLeft()
13
+ left: getDocumentScrollLeft(),
14
14
  };
15
15
  }
16
16
  function getPositionStyles(popup, anchorRect, anchorLeft, anchorTop, offset) {
@@ -36,13 +36,11 @@ function getPositionStyles(popup, anchorRect, anchorLeft, anchorTop, offset) {
36
36
  [Directions.LEFT_CENTER]: { left: popupLeft - offset, top: popupVerticalCenter },
37
37
  [Directions.RIGHT_BOTTOM]: { left: anchorRight + offset, top: anchorTop },
38
38
  [Directions.RIGHT_TOP]: { left: anchorRight + offset, top: popupBottomToTop },
39
- [Directions.RIGHT_CENTER]: { left: anchorRight + offset, top: popupVerticalCenter }
39
+ [Directions.RIGHT_CENTER]: { left: anchorRight + offset, top: popupVerticalCenter },
40
40
  };
41
41
  }
42
42
  function verticalOverflow(styles, scrollingCoordinates, attrs) {
43
- const containerHeight = attrs.container !== null
44
- ? attrs.container.clientHeight
45
- : getWindowHeight();
43
+ const containerHeight = attrs.container !== null ? attrs.container.clientHeight : getWindowHeight();
46
44
  const viewportMinX = scrollingCoordinates.top + attrs.sidePadding;
47
45
  const viewportMaxX = scrollingCoordinates.top + containerHeight - attrs.sidePadding;
48
46
  const topOverflow = Math.max(viewportMinX - styles.top, 0);
@@ -70,13 +68,13 @@ export const positionPropKeys = [
70
68
  'left',
71
69
  'offset',
72
70
  'maxHeight',
73
- 'minWidth'
71
+ 'minWidth',
74
72
  ];
75
73
  const defaultcontainerRect = {
76
74
  top: 0,
77
- left: 0
75
+ left: 0,
78
76
  };
79
- function handleTopOffScreen({ sidePadding, styles, anchorRect, maxHeight, popupScrollHeight, direction, scroll }) {
77
+ function handleTopOffScreen({ sidePadding, styles, anchorRect, maxHeight, popupScrollHeight, direction, scroll, }) {
80
78
  const BORDER_COMPENSATION = 1;
81
79
  const { TOP_LEFT, TOP_RIGHT, TOP_CENTER, RIGHT_TOP, LEFT_TOP } = Directions;
82
80
  const openedToTop = direction != null && [TOP_LEFT, TOP_RIGHT, TOP_CENTER, RIGHT_TOP, LEFT_TOP].includes(direction);
@@ -84,10 +82,8 @@ function handleTopOffScreen({ sidePadding, styles, anchorRect, maxHeight, popupS
84
82
  return styles;
85
83
  }
86
84
  const isAttachedToAnchorTop = direction != null && [TOP_LEFT, TOP_CENTER, TOP_RIGHT].includes(direction);
87
- const attachingPointY = (isAttachedToAnchorTop ? anchorRect.top : anchorRect.bottom);
88
- const effectiveHeight = maxHeight && typeof maxHeight === 'number'
89
- ? Math.min(popupScrollHeight, maxHeight)
90
- : popupScrollHeight;
85
+ const attachingPointY = isAttachedToAnchorTop ? anchorRect.top : anchorRect.bottom;
86
+ const effectiveHeight = maxHeight && typeof maxHeight === 'number' ? Math.min(popupScrollHeight, maxHeight) : popupScrollHeight;
91
87
  const hypotheticalTop = attachingPointY - effectiveHeight;
92
88
  if (hypotheticalTop <= sidePadding) {
93
89
  styles.top = sidePadding + scroll.top;
@@ -99,9 +95,7 @@ export function maxHeightForDirection(direction, anchorNode, containerNode) {
99
95
  const container = containerNode || document.documentElement;
100
96
  const domRect = anchorNode.getBoundingClientRect();
101
97
  const containerRect = container.getBoundingClientRect();
102
- const containerTop = domRect.top < 0
103
- ? containerRect.top
104
- : Math.max(containerRect.top, 0);
98
+ const containerTop = domRect.top < 0 ? containerRect.top : Math.max(containerRect.top, 0);
105
99
  const topMaxHeight = Math.max(domRect.top - containerTop, 0);
106
100
  const containerHeight = Math.max(containerRect.height,
107
101
  // XXX
@@ -127,16 +121,16 @@ export function maxHeightForDirection(direction, anchorNode, containerNode) {
127
121
  return domRect.height + topMaxHeight;
128
122
  case Directions.RIGHT_CENTER:
129
123
  case Directions.LEFT_CENTER:
130
- return (domRect.height / 2) + Math.min(bottomMaxHeight / 2, topMaxHeight / 2);
124
+ return domRect.height / 2 + Math.min(bottomMaxHeight / 2, topMaxHeight / 2);
131
125
  default:
132
126
  return null;
133
127
  }
134
128
  }
135
129
  export default function position(attrs) {
136
- const { popup, anchor, container, directions, autoPositioning, sidePadding, top, left, offset, maxHeight, minWidth, autoCorrectTopOverflow = true } = attrs;
130
+ const { popup, anchor, container, directions, autoPositioning, sidePadding, top, left, offset, maxHeight, minWidth, autoCorrectTopOverflow = true, } = attrs;
137
131
  let styles = {
138
132
  top: 0,
139
- left: 0
133
+ left: 0,
140
134
  };
141
135
  let chosenDirection = null;
142
136
  const containerRect = container !== null ? getRect(container) : defaultcontainerRect;
@@ -153,15 +147,14 @@ export default function position(attrs) {
153
147
  chosenDirection = directions[0];
154
148
  }
155
149
  else {
156
- const sortedByIncreasingOverflow = directions.
150
+ const sortedByIncreasingOverflow = directions
157
151
  // Fall back to the first option
158
- concat(directions[0]).filter(direction => directionsMatrix[direction]).
159
- map(direction => ({ styles: directionsMatrix[direction], direction })).
160
- sort(({ styles: stylesA }, { styles: stylesB }) => {
161
- const overflowA = verticalOverflow(stylesA, scroll, overflowAttrs) +
162
- horizontalOverflow(stylesA, scroll, overflowAttrs);
163
- const overflowB = verticalOverflow(stylesB, scroll, overflowAttrs) +
164
- horizontalOverflow(stylesB, scroll, overflowAttrs);
152
+ .concat(directions[0])
153
+ .filter(direction => directionsMatrix[direction])
154
+ .map(direction => ({ styles: directionsMatrix[direction], direction }))
155
+ .sort(({ styles: stylesA }, { styles: stylesB }) => {
156
+ const overflowA = verticalOverflow(stylesA, scroll, overflowAttrs) + horizontalOverflow(stylesA, scroll, overflowAttrs);
157
+ const overflowB = verticalOverflow(stylesB, scroll, overflowAttrs) + horizontalOverflow(stylesB, scroll, overflowAttrs);
165
158
  return overflowA - overflowB;
166
159
  });
167
160
  styles = sortedByIncreasingOverflow[0].styles;
@@ -189,7 +182,7 @@ export default function position(attrs) {
189
182
  maxHeight,
190
183
  direction: chosenDirection,
191
184
  popupScrollHeight: popup?.scrollHeight ?? 0,
192
- scroll
185
+ scroll,
193
186
  });
194
187
  }
195
188
  if (minWidth === MinWidth.TARGET || minWidth === 'target') {
@@ -10,7 +10,7 @@ export default class PopupMenu extends Popup {
10
10
  ...List.defaultProps,
11
11
  ...Popup.defaultProps,
12
12
  renderOptimization: false,
13
- closeOnSelect: false
13
+ closeOnSelect: false,
14
14
  };
15
15
  onSelect = (item, event) => {
16
16
  if (this.props.closeOnSelect) {
@@ -1,13 +1,10 @@
1
1
  @import "../global/variables.css";
2
2
 
3
- @value dark from "../global/variables_dark.css";
4
-
5
3
  :root {
6
4
  --ring-progress-bar-background-color: rgba(0, 0, 0, 0.2);
7
5
  --ring-progress-bar-line-background-color: rgba(255, 255, 255, 0.6);
8
6
  }
9
7
 
10
- .dark,
11
8
  :global(.ring-ui-theme-dark) {
12
9
  --ring-progress-bar-background-color: rgba(255, 255, 255, 0.3);
13
10
  --ring-progress-bar-line-background-color: rgba(255, 255, 255, 0.4);
@@ -58,20 +55,25 @@
58
55
  left: 0;
59
56
 
60
57
  content: "";
61
- animation: progress-bar 2500ms linear infinite;
62
-
63
- background-image: linear-gradient(to right, rgba(0, 0, 0, 0), var(--ring-progress-bar-line-background-color), rgba(0, 0, 0, 0));
58
+ animation: progress-bar-animation 2500ms linear infinite;
59
+
60
+ background-image: linear-gradient(
61
+ to right,
62
+ rgba(0, 0, 0, 0),
63
+ var(--ring-progress-bar-line-background-color),
64
+ rgba(0, 0, 0, 0)
65
+ );
64
66
  background-repeat: no-repeat;
65
67
  }
66
68
 
67
- .staticLineColor &::after {
69
+ .staticLineColor &::after {
68
70
  animation: none;
69
71
 
70
72
  background-image: var(--ring-progress-bar-line-background-color);
71
73
  }
72
74
  }
73
75
 
74
- @keyframes progress-bar {
76
+ @keyframes progress-bar-animation {
75
77
  from {
76
78
  transform: translateX(-100%);
77
79
  }
@@ -41,9 +41,9 @@ export default class ProgressBar extends PureComponent<ProgressBarProps> {
41
41
  value: number;
42
42
  label: string;
43
43
  };
44
- progressbarWrapper?: (HTMLElement | null);
44
+ progressbarWrapper?: HTMLElement | null;
45
45
  progressbarWrapperRef: (el: HTMLElement | null) => void;
46
- progressbar?: (HTMLElement | null);
46
+ progressbar?: HTMLElement | null;
47
47
  progressbarRef: (el: HTMLElement | null) => void;
48
48
  render(): import("react").JSX.Element;
49
49
  }
@@ -19,7 +19,7 @@ export default class ProgressBar extends PureComponent {
19
19
  static defaultProps = {
20
20
  max: 1.0,
21
21
  value: 0,
22
- label: 'Progress'
22
+ label: 'Progress',
23
23
  };
24
24
  progressbarWrapper;
25
25
  progressbarWrapperRef = (el) => {
@@ -34,7 +34,7 @@ export default class ProgressBar extends PureComponent {
34
34
  const width = value ? `${ProgressBar.toPercent(value, max)}%` : undefined;
35
35
  const classes = classNames(styles.progressBar, className, {
36
36
  [styles.globalMode]: global,
37
- [styles.staticLineColor]: staticColor
37
+ [styles.staticLineColor]: staticColor,
38
38
  });
39
39
  return (<div {...otherProps} className={classes} ref={this.progressbarWrapperRef}>
40
40
  <div className={styles.line} ref={this.progressbarRef} role="progressbar" aria-label={label} aria-valuenow={value} aria-valuemin={0} aria-valuemax={max} style={{ width }}/>
@@ -1,9 +1,6 @@
1
1
  @import "../global/variables.css";
2
2
  @import "../button/button.css";
3
3
 
4
- @value overInputZIndex: 2;
5
- @value inputGap: calc(var(--ring-unit) * 3);
6
-
7
4
  .queryAssist {
8
5
  --ring-input-icon-offset: calc(var(--ring-unit) * 2.5);
9
6
  --ring-input-padding-inline: var(--ring-unit);
@@ -22,8 +22,7 @@ import inputStyles from '../input/input.css';
22
22
  import { I18nContext } from '../i18n/i18n-context';
23
23
  import QueryAssistSuggestions from './query-assist__suggestions';
24
24
  import styles from './query-assist.css';
25
- const POPUP_COMPENSATION = PopupMenu.ListProps.Dimension.ITEM_PADDING +
26
- PopupMenu.PopupProps.Dimension.BORDER_WIDTH;
25
+ const POPUP_COMPENSATION = PopupMenu.ListProps.Dimension.ITEM_PADDING + PopupMenu.PopupProps.Dimension.BORDER_WIDTH;
27
26
  const ngModelStateField = 'query';
28
27
  function noop() { }
29
28
  function cleanText(text) {
@@ -75,7 +74,7 @@ export default class QueryAssist extends Component {
75
74
  onApplySuggestion: noop,
76
75
  onClear: noop,
77
76
  onFocusChange: noop,
78
- size: Size.L
77
+ size: Size.L,
79
78
  };
80
79
  static getDerivedStateFromProps({ query }, { prevQuery }) {
81
80
  const nextState = { prevQuery: query };
@@ -90,10 +89,8 @@ export default class QueryAssist extends Component {
90
89
  const query = props.query || '';
91
90
  this.immediateState = {
92
91
  query,
93
- caret: typeof props.caret === 'number' && Number.isFinite(props.caret)
94
- ? props.caret
95
- : query.length,
96
- focus: Boolean(props.autoOpen || props.focus)
92
+ caret: typeof props.caret === 'number' && Number.isFinite(props.caret) ? props.caret : query.length,
93
+ focus: Boolean(props.autoOpen || props.focus),
97
94
  };
98
95
  }
99
96
  state = {
@@ -102,21 +99,18 @@ export default class QueryAssist extends Component {
102
99
  placeholderEnabled: !this.props.query,
103
100
  shortcuts: !!this.props.focus,
104
101
  suggestions: [],
105
- showPopup: false
102
+ showPopup: false,
106
103
  };
107
104
  componentDidMount() {
108
105
  const query = this.props.query || '';
109
106
  this.immediateState = {
110
107
  query,
111
- caret: typeof this.props.caret === 'number' && Number.isFinite(this.props.caret)
112
- ? this.props.caret
113
- : query.length,
114
- focus: Boolean(this.props.autoOpen || this.props.focus)
108
+ caret: typeof this.props.caret === 'number' && Number.isFinite(this.props.caret) ? this.props.caret : query.length,
109
+ focus: Boolean(this.props.autoOpen || this.props.focus),
115
110
  };
116
111
  this.setupRequestHandler(this.props.delay);
117
- if (this.props.autoOpen === 'force' || this.props.autoOpen && query.length > 0) {
118
- this.requestHandler().
119
- catch(noop);
112
+ if (this.props.autoOpen === 'force' || (this.props.autoOpen && query.length > 0)) {
113
+ this.requestHandler().catch(noop);
120
114
  }
121
115
  else {
122
116
  this.requestStyleRanges().catch(noop);
@@ -125,7 +119,7 @@ export default class QueryAssist extends Component {
125
119
  this._pushHistory(this.state);
126
120
  }
127
121
  shouldComponentUpdate(props, state) {
128
- return state.query !== this.state.query ||
122
+ return (state.query !== this.state.query ||
129
123
  state.dirty !== this.state.dirty ||
130
124
  state.loading !== this.state.loading ||
131
125
  state.showPopup !== this.state.showPopup ||
@@ -138,7 +132,8 @@ export default class QueryAssist extends Component {
138
132
  props.focus !== this.props.focus ||
139
133
  props.actions !== this.props.actions ||
140
134
  props.loader !== this.props.loader ||
141
- props.glass !== this.props.glass;
135
+ props.glass !== this.props.glass ||
136
+ props.className !== this.props.className);
142
137
  }
143
138
  componentDidUpdate(prevProps) {
144
139
  const { caret, delay, query } = this.props;
@@ -152,7 +147,7 @@ export default class QueryAssist extends Component {
152
147
  }
153
148
  if (typeof query === 'string' && queryChanged && query !== this.immediateState.query) {
154
149
  this.immediateState.query = query;
155
- if (query && (this.props.autoOpen === 'force' || prevProps.autoOpen && query.length > 0)) {
150
+ if (query && (this.props.autoOpen === 'force' || (prevProps.autoOpen && query.length > 0))) {
156
151
  this.requestData?.();
157
152
  }
158
153
  else if (query) {
@@ -200,17 +195,16 @@ export default class QueryAssist extends Component {
200
195
  }
201
196
  setCaretPosition = (params = {}) => {
202
197
  const queryLength = this.immediateState.query != null ? this.immediateState.query.length : 0;
203
- const newCaretPosition = this.immediateState.caret < queryLength
204
- ? this.immediateState.caret
205
- : queryLength;
198
+ const newCaretPosition = this.immediateState.caret < queryLength ? this.immediateState.caret : queryLength;
206
199
  if (params.fromContentEditable) {
207
200
  this.immediateState.selection = this.immediateState.selection
208
201
  ? this.immediateState.selection
209
- : this.state.query && this.state.query.length || null;
202
+ : (this.state.query && this.state.query.length) || null;
210
203
  }
211
204
  if (this.immediateState.focus && !this.props.disabled) {
212
205
  if (typeof this.immediateState.selection === 'number' &&
213
- Number.isInteger(this.immediateState.selection) && this.immediateState.selection > -1) {
206
+ Number.isInteger(this.immediateState.selection) &&
207
+ this.immediateState.selection > -1) {
214
208
  // Set to end of field value if newCaretPosition is inappropriate
215
209
  this.caret?.setPosition(newCaretPosition >= 0 ? newCaretPosition : -1);
216
210
  this.scrollInput();
@@ -227,8 +221,10 @@ export default class QueryAssist extends Component {
227
221
  };
228
222
  scrollInput() {
229
223
  const caretOffset = this.caret?.getOffset();
230
- if (this.input?.clientWidth !== this.input?.scrollWidth && caretOffset != null &&
231
- this.input?.clientWidth != null && caretOffset > this.input.clientWidth) {
224
+ if (this.input?.clientWidth !== this.input?.scrollWidth &&
225
+ caretOffset != null &&
226
+ this.input?.clientWidth != null &&
227
+ caretOffset > this.input.clientWidth) {
232
228
  this.input.scrollLeft += caretOffset;
233
229
  }
234
230
  }
@@ -254,10 +250,8 @@ export default class QueryAssist extends Component {
254
250
  const props = {
255
251
  dirty: true,
256
252
  query: this.getQuery(),
257
- caret: typeof currentCaret === 'number'
258
- ? currentCaret
259
- : currentCaret?.position ?? 0,
260
- focus: true
253
+ caret: typeof currentCaret === 'number' ? currentCaret : (currentCaret?.position ?? 0),
254
+ focus: true,
261
255
  };
262
256
  if (this.immediateState.query === props.query && !this.isComposing) {
263
257
  this.handleCaretMove(e);
@@ -275,12 +269,13 @@ export default class QueryAssist extends Component {
275
269
  const diff = this.immediateState.query.length - this.state.query.length;
276
270
  const originalIndex = this.immediateState.caret - diff;
277
271
  const ranges = [...(this.state.styleRanges ?? [])];
278
- const range = ranges.
279
- find(r => originalIndex >= r.start && originalIndex <= r.start + r.length);
272
+ const range = ranges.find(r => originalIndex >= r.start && originalIndex <= r.start + r.length);
280
273
  if (range) {
281
274
  range.length += diff;
282
275
  }
283
- ranges.filter(r => r.start > originalIndex).forEach(r => {
276
+ ranges
277
+ .filter(r => r.start > originalIndex)
278
+ .forEach(r => {
284
279
  r.start += diff;
285
280
  });
286
281
  }
@@ -323,7 +318,7 @@ export default class QueryAssist extends Component {
323
318
  if (queryIsSet && !queryIsSame) {
324
319
  this.historyStack.unshift({
325
320
  query: state.query,
326
- caret: this.caret?.getPosition({ avoidFocus: true }) ?? -1
321
+ caret: this.caret?.getPosition({ avoidFocus: true }) ?? -1,
327
322
  });
328
323
  }
329
324
  }
@@ -351,10 +346,8 @@ export default class QueryAssist extends Component {
351
346
  return;
352
347
  }
353
348
  const currentCaret = this.caret?.getPosition();
354
- const caret = typeof currentCaret === 'number'
355
- ? currentCaret
356
- : currentCaret?.position ?? 0;
357
- const popupHidden = (!this.state.showPopup) && e.type === 'click';
349
+ const caret = typeof currentCaret === 'number' ? currentCaret : (currentCaret?.position ?? 0);
350
+ const popupHidden = !this.state.showPopup && e.type === 'click';
358
351
  if (!this.props.disabled && (caret !== this.immediateState.caret || popupHidden)) {
359
352
  this.immediateState.prevCaret = this.immediateState.caret;
360
353
  this.immediateState.caret = caret;
@@ -370,8 +363,7 @@ export default class QueryAssist extends Component {
370
363
  handleStyleRangesResponse = ({ suggestions, ...restProps }) => this.handleResponse(restProps);
371
364
  handleResponse = ({ query = '', caret = 0, styleRanges, suggestions = [] }, afterCompletion = false) => new Promise((resolve, reject) => {
372
365
  if (query === this.getQuery() &&
373
- (caret === this.immediateState.caret ||
374
- this.immediateState.caret === undefined)) {
366
+ (caret === this.immediateState.caret || this.immediateState.caret === undefined)) {
375
367
  // Do not setState on unmounted component
376
368
  if (!this.node) {
377
369
  return;
@@ -382,7 +374,7 @@ export default class QueryAssist extends Component {
382
374
  placeholderEnabled: !query,
383
375
  query,
384
376
  suggestions,
385
- showPopup: !!suggestions.length && (this.props.autoOpen === 'force' || !afterCompletion)
377
+ showPopup: !!suggestions.length && (this.props.autoOpen === 'force' || !afterCompletion),
386
378
  };
387
379
  this.immediateState.suggestionsQuery = query;
388
380
  // Do not update deep equal styleRanges to simplify shouldComponentUpdate check
@@ -419,7 +411,7 @@ export default class QueryAssist extends Component {
419
411
  prevCaret: currentCaret,
420
412
  caret: suggestion.caret ?? 0,
421
413
  selection: suggestion.caret ?? 0,
422
- query: query.substr(0, suggestion.completionStart) + prefix + suggestion.option + suffix
414
+ query: query.substr(0, suggestion.completionStart) + prefix + suggestion.option + suffix,
423
415
  };
424
416
  if (typeof replace === 'boolean' && replace) {
425
417
  state.query += this.immediateState.query.substr(suggestion.completionEnd ?? 0);
@@ -434,7 +426,7 @@ export default class QueryAssist extends Component {
434
426
  if (state.query !== this.immediateState.query) {
435
427
  this.setState({
436
428
  placeholderEnabled: !state.query,
437
- query: state.query
429
+ query: state.query,
438
430
  });
439
431
  }
440
432
  this.immediateState = Object.assign(state, focusState);
@@ -449,18 +441,16 @@ export default class QueryAssist extends Component {
449
441
  if (!query) {
450
442
  return Promise.reject(new Error('Query is empty'));
451
443
  }
452
- return this.sendRequest({ query, caret, omitSuggestions: true }).
453
- then(this.handleStyleRangesResponse).
454
- catch(noop);
444
+ return this.sendRequest({ query, caret, omitSuggestions: true }).then(this.handleStyleRangesResponse).catch(noop);
455
445
  };
456
446
  requestHandler = (afterCompletion = false) => {
457
447
  if (this.props.disabled) {
458
448
  return Promise.reject(new Error('QueryAssist(@jetbrains/ring-ui): null exception'));
459
449
  }
460
450
  const { query, caret } = this.immediateState;
461
- return this.sendRequest({ query, caret }).
462
- then(data => this.handleResponse(data, afterCompletion)).
463
- catch(noop);
451
+ return this.sendRequest({ query, caret })
452
+ .then(data => this.handleResponse(data, afterCompletion))
453
+ .catch(noop);
464
454
  };
465
455
  sendRequest(params) {
466
456
  const value = this.props.dataSource(params);
@@ -470,16 +460,16 @@ export default class QueryAssist extends Component {
470
460
  const timeout = window.setTimeout(() => {
471
461
  if (this.node) {
472
462
  this.setState({
473
- loading: true
463
+ loading: true,
474
464
  });
475
465
  }
476
466
  if (params.query === this.immediateState.query) {
477
467
  this.closePopup();
478
468
  }
479
469
  }, CLOSE_POPUP_TIMEOUT);
480
- dataPromise.
481
- then(() => window.clearTimeout(timeout)).
482
- catch(() => {
470
+ dataPromise
471
+ .then(() => window.clearTimeout(timeout))
472
+ .catch(() => {
483
473
  window.clearTimeout(timeout);
484
474
  this.setState({ loading: false });
485
475
  });
@@ -494,16 +484,12 @@ export default class QueryAssist extends Component {
494
484
  // First suggestion should be enough?
495
485
  const suggestion = suggestions && suggestions[0];
496
486
  // Check if suggestion begins not from the end
497
- const completionStart = suggestion &&
498
- suggestion.completionStart !== suggestion.completionEnd &&
499
- suggestion.completionStart;
500
- const inputChildren = this.input.firstChild instanceof Element &&
501
- this.input.firstChild.children;
487
+ const completionStart = suggestion && suggestion.completionStart !== suggestion.completionEnd && suggestion.completionStart;
488
+ const inputChildren = this.input.firstChild instanceof Element && this.input.firstChild.children;
502
489
  const completionStartNode = inputChildren &&
503
490
  typeof completionStart === 'number' &&
504
491
  inputChildren[Math.min(completionStart, inputChildren.length - 1)];
505
- let offset = completionStartNode &&
506
- (getRect(completionStartNode).right - getRect(this.input).left);
492
+ let offset = completionStartNode && getRect(completionStartNode).right - getRect(this.input).left;
507
493
  if (!offset) {
508
494
  const caret = this.caret?.getOffset() ?? 0;
509
495
  // Do not compensate caret in the beginning of field
@@ -539,7 +525,7 @@ export default class QueryAssist extends Component {
539
525
  dirty: false,
540
526
  caret: 0,
541
527
  query: '',
542
- focus: true
528
+ focus: true,
543
529
  };
544
530
  this.props.onChange(state);
545
531
  this.props.onClear();
@@ -548,7 +534,7 @@ export default class QueryAssist extends Component {
548
534
  dirty: false,
549
535
  query: '',
550
536
  placeholderEnabled: true,
551
- loading: false
537
+ loading: false,
552
538
  });
553
539
  };
554
540
  blurInput() {
@@ -586,7 +572,7 @@ export default class QueryAssist extends Component {
586
572
  description,
587
573
  group,
588
574
  rgItemType: ITEM,
589
- data: suggestion
575
+ data: suggestion,
590
576
  };
591
577
  }
592
578
  renderSuggestions() {
@@ -612,16 +598,17 @@ export default class QueryAssist extends Component {
612
598
  }
613
599
  });
614
600
  }
615
- return query && Array.from(query).map((letter, index, letters) => {
616
- const className = classNames(styles.letter, classes[index] || LETTER_DEFAULT_CLASS);
617
- const dataTest = (letters.length - 1 === index)
618
- ? 'ring-query-assist-last-letter'
619
- : null;
620
- // \u00a0 === &nbsp;
621
- return (<span
622
- // eslint-disable-next-line react/no-array-index-key
623
- key={index + letter} className={className} data-test={dataTest}>{letter === ' ' ? '\u00a0' : letter}</span>);
624
- });
601
+ return (query &&
602
+ Array.from(query).map((letter, index, letters) => {
603
+ const className = classNames(styles.letter, classes[index] || LETTER_DEFAULT_CLASS);
604
+ const dataTest = letters.length - 1 === index ? 'ring-query-assist-last-letter' : null;
605
+ // \u00a0 === &nbsp;
606
+ return (<span
607
+ // eslint-disable-next-line react/no-array-index-key
608
+ key={index + letter} className={className} data-test={dataTest}>
609
+ {letter === ' ' ? '\u00a0' : letter}
610
+ </span>);
611
+ }));
625
612
  }
626
613
  setFocus(focus) {
627
614
  this.setState({ shortcuts: !!focus });
@@ -677,11 +664,11 @@ export default class QueryAssist extends Component {
677
664
  left: noop,
678
665
  space: noop,
679
666
  home: noop,
680
- end: noop
667
+ end: noop,
681
668
  };
682
669
  listShortcutsMap = {
683
670
  home: noop,
684
- end: noop
671
+ end: noop,
685
672
  };
686
673
  renderActions() {
687
674
  const actions = [...(this.props.actions || [])];
@@ -703,44 +690,46 @@ export default class QueryAssist extends Component {
703
690
  [styles.queryAssist]: true,
704
691
  [styles.withIcon]: (renderGlass && !huge) || renderLoader,
705
692
  [styles.huge]: huge,
706
- [styles.queryAssistDisabled]: this.props.disabled
693
+ [styles.queryAssistDisabled]: this.props.disabled,
707
694
  });
708
695
  const inputClasses = classNames(this.props.inputClassName, {
709
696
  [`${styles.input} ring-js-shortcuts`]: true,
710
- [styles.inputGap]: actions.length || this.isRenderingGlassOrLoader() && !glass,
697
+ [styles.inputGap]: actions.length || (this.isRenderingGlassOrLoader() && !glass),
711
698
  [styles.inputGap2]: actions.length === 2, // TODO: replace with flex-box layout
712
- [styles.inputRevertOrder]: !glass || huge
699
+ [styles.inputRevertOrder]: !glass || huge,
713
700
  });
714
701
  const placeholderStyles = classNames({
715
702
  [styles.placeholder]: true,
716
703
  [styles.hugePlaceholder]: huge,
717
- [styles.withoutGlass]: !glass || (!renderLoader && huge)
704
+ [styles.withoutGlass]: !glass || (!renderLoader && huge),
718
705
  });
719
706
  return (<ControlsHeightContext.Provider value={ControlsHeight.M}>
720
707
  <I18nContext.Consumer>
721
708
  {({ translate }) => (<div data-test={dataTests('ring-query-assist', dataTest)} className={containerClasses} role="presentation" ref={this.nodeRef}>
722
- {this.state.shortcuts && (<Shortcuts map={this.shortcutsMap} scope={this.shortcutsScope}/>)}
709
+ {this.state.shortcuts && <Shortcuts map={this.shortcutsMap} scope={this.shortcutsScope}/>}
723
710
 
724
711
  {renderGlass && !huge && (<Icon glyph={searchIcon} className={styles.icon} title={translations?.searchTitle ?? translate('searchTitle')} ref={this.glassRef} data-test="query-assist-search-icon"/>)}
725
712
 
726
713
  {renderLoader && (<div className={classNames(styles.icon, styles.loader, {
727
714
  [styles.loaderOnTheRight]: !glass && !huge,
728
- [styles.loaderActive]: renderLoader
715
+ [styles.loaderActive]: renderLoader,
729
716
  })} ref={this.loaderRef}>
730
717
  <LoaderInline />
731
718
  </div>)}
732
719
 
733
720
  <ContentEditable aria-label={translations?.searchTitle ?? translate('searchTitle')} className={inputClasses} data-test="ring-query-assist-input" inputRef={this.inputRef} disabled={this.props.disabled} onComponentUpdate={() => this.setCaretPosition({ fromContentEditable: true })} onBlur={this.handleFocusChange} onClick={this.handleCaretMove} onCompositionStart={this.trackCompositionState} onCompositionEnd={this.trackCompositionState} onFocus={this.handleFocusChange} onInput={this.handleInput} // To support IE use the same method
734
721
  onKeyUp={this.handleInput} // to handle input and key up
735
- onKeyDown={this.handleEnter} onPaste={this.handlePaste} spellCheck="false">{this.state.query && <span>{this.renderQuery()}</span>}</ContentEditable>
722
+ onKeyDown={this.handleEnter} onPaste={this.handlePaste} spellCheck="false">
723
+ {this.state.query && <span>{this.renderQuery()}</span>}
724
+ </ContentEditable>
736
725
 
737
726
  {renderPlaceholder && (<button type="button" className={placeholderStyles} ref={this.placeholderRef} onClick={this.handleCaretMove} data-test="query-assist-placeholder" disabled={this.props.disabled}>
738
727
  {this.props.placeholder}
739
728
  </button>)}
740
729
 
741
- {actions.length
742
- ? (<div data-test="ring-query-assist-actions" className={styles.actions}>{actions}</div>)
743
- : null}
730
+ {actions.length ? (<div data-test="ring-query-assist-actions" className={styles.actions}>
731
+ {actions}
732
+ </div>) : null}
744
733
 
745
734
  <PopupMenu hidden={!this.state.showPopup} onCloseAttempt={this.closePopup} ref={this.popupRef} anchorElement={this.node} keepMounted attached className={this.props.popupClassName} directions={[PopupMenu.PopupProps.Directions.BOTTOM_RIGHT]} data={useCustomItemRender ? this.state.suggestions : this.renderSuggestions()} data-test="ring-query-assist-popup" hint={this.props.hint} shortcutsMap={this.listShortcutsMap} hintOnSelection={this.props.hintOnSelection} left={this.getPopupOffset(this.state.suggestions)} maxHeight={PopupMenu.PopupProps.MaxHeight.SCREEN} onMouseDown={this.trackPopupMouseState} onMouseUp={this.trackPopupMouseState} onSelect={item => this.handleComplete(item)}/>
746
735