@jetbrains/ring-ui 4.2.4 → 4.2.5

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 (315) hide show
  1. package/package.json +2 -2
  2. package/dist/_helpers/_rollupPluginBabelHelpers.js +0 -34
  3. package/dist/_helpers/anchor.js +0 -33
  4. package/dist/_helpers/badge.js +0 -3
  5. package/dist/_helpers/button-group.js +0 -3
  6. package/dist/_helpers/button-set.js +0 -3
  7. package/dist/_helpers/button-toolbar.js +0 -3
  8. package/dist/_helpers/button__classes.js +0 -39
  9. package/dist/_helpers/card.js +0 -75
  10. package/dist/_helpers/checkbox.js +0 -3
  11. package/dist/_helpers/date-picker.js +0 -3
  12. package/dist/_helpers/dialog__body-scroll-preventer.js +0 -58
  13. package/dist/_helpers/error-message.js +0 -3
  14. package/dist/_helpers/footer.js +0 -121
  15. package/dist/_helpers/grid.js +0 -3
  16. package/dist/_helpers/group.js +0 -3
  17. package/dist/_helpers/header.js +0 -3
  18. package/dist/_helpers/icon.js +0 -3
  19. package/dist/_helpers/inject-styles.js +0 -22
  20. package/dist/_helpers/input.js +0 -3
  21. package/dist/_helpers/island.js +0 -3
  22. package/dist/_helpers/link.js +0 -3
  23. package/dist/_helpers/list.js +0 -3
  24. package/dist/_helpers/loader-screen.js +0 -3
  25. package/dist/_helpers/panel.js +0 -3
  26. package/dist/_helpers/query-assist__suggestions.js +0 -95
  27. package/dist/_helpers/radio.js +0 -3
  28. package/dist/_helpers/select__filter.js +0 -77
  29. package/dist/_helpers/services-link.js +0 -40
  30. package/dist/_helpers/sidebar.js +0 -126
  31. package/dist/_helpers/table.js +0 -3
  32. package/dist/_helpers/tabs.js +0 -3
  33. package/dist/_helpers/title.js +0 -100
  34. package/dist/alert/alert.js +0 -262
  35. package/dist/alert/container.js +0 -48
  36. package/dist/alert-service/alert-service.js +0 -173
  37. package/dist/analytics/analytics.js +0 -118
  38. package/dist/analytics/analytics__custom-plugin.js +0 -128
  39. package/dist/analytics/analytics__fus-plugin.js +0 -102
  40. package/dist/analytics/analytics__ga-plugin.js +0 -75
  41. package/dist/analytics/analytics__plugin-utils.js +0 -80
  42. package/dist/analytics-ng/analytics-ng.js +0 -95
  43. package/dist/auth/auth.js +0 -96
  44. package/dist/auth/auth__core.js +0 -1059
  45. package/dist/auth/background-flow.js +0 -123
  46. package/dist/auth/down-notification.js +0 -117
  47. package/dist/auth/iframe-flow.js +0 -153
  48. package/dist/auth/landing-entry.js +0 -5
  49. package/dist/auth/landing.js +0 -90
  50. package/dist/auth/request-builder.js +0 -76
  51. package/dist/auth/response-parser.js +0 -118
  52. package/dist/auth/storage.js +0 -283
  53. package/dist/auth/token-validator.js +0 -178
  54. package/dist/auth/window-flow.js +0 -134
  55. package/dist/auth-dialog/auth-dialog.js +0 -180
  56. package/dist/auth-dialog-service/auth-dialog-service.js +0 -71
  57. package/dist/auth-ng/auth-ng.js +0 -206
  58. package/dist/auth-ng/auth-ng.mock.js +0 -33
  59. package/dist/autofocus-ng/autofocus-ng.js +0 -51
  60. package/dist/avatar/avatar-example-datauri.js +0 -4
  61. package/dist/avatar/avatar.js +0 -163
  62. package/dist/avatar/fallback-avatar.js +0 -142
  63. package/dist/avatar-editor-ng/avatar-editor-ng.js +0 -167
  64. package/dist/avatar-editor-ng/avatar-editor-ng__template.js +0 -3
  65. package/dist/avatar-ng/avatar-ng.js +0 -21
  66. package/dist/badge/badge.js +0 -51
  67. package/dist/badge-ng/badge-ng.js +0 -18
  68. package/dist/breadcrumb-ng/breadcrumb-ng.js +0 -37
  69. package/dist/button/button.js +0 -125
  70. package/dist/button/button__classes.js +0 -5
  71. package/dist/button-group/button-group.js +0 -30
  72. package/dist/button-group/caption.js +0 -24
  73. package/dist/button-group-ng/button-group-ng.js +0 -39
  74. package/dist/button-ng/button-ng.js +0 -217
  75. package/dist/button-set/button-set.js +0 -26
  76. package/dist/button-set-ng/button-set-ng.js +0 -19
  77. package/dist/button-toolbar/button-toolbar.js +0 -29
  78. package/dist/button-toolbar-ng/button-toolbar-ng.js +0 -24
  79. package/dist/caret/caret.js +0 -266
  80. package/dist/checkbox/checkbox.js +0 -110
  81. package/dist/checkbox-ng/checkbox-ng.js +0 -38
  82. package/dist/code/code.js +0 -137
  83. package/dist/compiler-ng/compiler-ng.js +0 -53
  84. package/dist/confirm/confirm.js +0 -127
  85. package/dist/confirm-ng/confirm-ng.js +0 -69
  86. package/dist/confirm-service/confirm-service.js +0 -117
  87. package/dist/content-layout/content-layout.js +0 -66
  88. package/dist/content-layout/sidebar.js +0 -7
  89. package/dist/contenteditable/contenteditable.js +0 -78
  90. package/dist/data-list/data-list.js +0 -208
  91. package/dist/data-list/data-list.mock.js +0 -191
  92. package/dist/data-list/item.js +0 -229
  93. package/dist/data-list/selection.js +0 -102
  94. package/dist/data-list/title.js +0 -20
  95. package/dist/data-list-ng/data-list-ng.js +0 -62
  96. package/dist/date-picker/consts.js +0 -69
  97. package/dist/date-picker/date-input.js +0 -175
  98. package/dist/date-picker/date-picker.js +0 -367
  99. package/dist/date-picker/date-popup.js +0 -483
  100. package/dist/date-picker/day.js +0 -120
  101. package/dist/date-picker/formats.js +0 -3
  102. package/dist/date-picker/month-names.js +0 -100
  103. package/dist/date-picker/month-slider.js +0 -84
  104. package/dist/date-picker/month.js +0 -55
  105. package/dist/date-picker/months.js +0 -122
  106. package/dist/date-picker/weekdays.js +0 -32
  107. package/dist/date-picker/years.js +0 -110
  108. package/dist/dialog/dialog.js +0 -202
  109. package/dist/dialog/dialog__body-scroll-preventer.js +0 -3
  110. package/dist/dialog-ng/dialog-ng.js +0 -604
  111. package/dist/dialog-ng/dialog-ng__template.js +0 -3
  112. package/dist/docked-panel-ng/docked-panel-ng.js +0 -171
  113. package/dist/dropdown/anchor.js +0 -19
  114. package/dist/dropdown/dropdown.js +0 -236
  115. package/dist/dropdown-menu/dropdown-menu.js +0 -177
  116. package/dist/error-bubble/error-bubble.js +0 -59
  117. package/dist/error-message/error-message.js +0 -57
  118. package/dist/error-message-ng/error-message-ng.js +0 -35
  119. package/dist/footer/footer.js +0 -12
  120. package/dist/footer-ng/footer-ng.js +0 -64
  121. package/dist/form-ng/form-ng.js +0 -167
  122. package/dist/global/angular-component-factory.js +0 -84
  123. package/dist/global/compose.js +0 -9
  124. package/dist/global/composeRefs.js +0 -15
  125. package/dist/global/conic-gradient.js +0 -35
  126. package/dist/global/create-stateful-context.js +0 -55
  127. package/dist/global/data-tests.js +0 -24
  128. package/dist/global/dom.js +0 -125
  129. package/dist/global/focus-sensor-hoc.js +0 -146
  130. package/dist/global/fuzzy-highlight.js +0 -67
  131. package/dist/global/get-event-key.js +0 -111
  132. package/dist/global/get-uid.js +0 -15
  133. package/dist/global/inject-styles.js +0 -15
  134. package/dist/global/linear-function.js +0 -17
  135. package/dist/global/listeners.js +0 -44
  136. package/dist/global/memoize.js +0 -20
  137. package/dist/global/normalize-indent.js +0 -30
  138. package/dist/global/promise-with-timeout.js +0 -17
  139. package/dist/global/radial-gradient-mask.js +0 -38
  140. package/dist/global/react-dom-renderer.js +0 -46
  141. package/dist/global/react-render-adapter.js +0 -41
  142. package/dist/global/rerender-hoc.js +0 -55
  143. package/dist/global/ring-angular-component.js +0 -24
  144. package/dist/global/schedule-raf.js +0 -31
  145. package/dist/global/sniffer.js +0 -6
  146. package/dist/global/supports-css.js +0 -22
  147. package/dist/global/theme.js +0 -54
  148. package/dist/global/trivial-template-tag.js +0 -17
  149. package/dist/global/url.js +0 -165
  150. package/dist/global/variables_dark.js +0 -57
  151. package/dist/grid/col.js +0 -60
  152. package/dist/grid/grid.js +0 -33
  153. package/dist/grid/row.js +0 -64
  154. package/dist/group/group.js +0 -31
  155. package/dist/group-ng/group-ng.js +0 -11
  156. package/dist/header/header.js +0 -150
  157. package/dist/header/logo.js +0 -40
  158. package/dist/header/profile.js +0 -219
  159. package/dist/header/services-link.js +0 -12
  160. package/dist/header/services.js +0 -138
  161. package/dist/header/smart-profile.js +0 -233
  162. package/dist/header/smart-services.js +0 -163
  163. package/dist/header/tray-icon.js +0 -47
  164. package/dist/header/tray.js +0 -31
  165. package/dist/heading/heading.js +0 -73
  166. package/dist/http/http.js +0 -218
  167. package/dist/http/http.mock.js +0 -67
  168. package/dist/hub-source/hub-source.js +0 -130
  169. package/dist/hub-source/hub-source__user.js +0 -30
  170. package/dist/hub-source/hub-source__users-groups.js +0 -63
  171. package/dist/icon/icon.js +0 -105
  172. package/dist/icon/icon__constants.js +0 -33
  173. package/dist/icon/icon__svg.js +0 -83
  174. package/dist/icon/index.js +0 -12
  175. package/dist/icon-ng/icon-ng.js +0 -91
  176. package/dist/input/input.js +0 -230
  177. package/dist/input-ng/input-ng.js +0 -111
  178. package/dist/island/adaptive-island-hoc.js +0 -48
  179. package/dist/island/content.js +0 -160
  180. package/dist/island/header.js +0 -84
  181. package/dist/island/island.js +0 -51
  182. package/dist/island-legacy/content-legacy.js +0 -26
  183. package/dist/island-legacy/header-legacy.js +0 -28
  184. package/dist/island-legacy/island-legacy.js +0 -28
  185. package/dist/island-ng/island-content-ng.js +0 -42
  186. package/dist/island-ng/island-header-ng.js +0 -26
  187. package/dist/island-ng/island-ng-class-fixer.js +0 -11
  188. package/dist/island-ng/island-ng.js +0 -25
  189. package/dist/link/clickableLink.js +0 -64
  190. package/dist/link/link.js +0 -115
  191. package/dist/link-ng/link-ng.js +0 -22
  192. package/dist/list/consts.js +0 -26
  193. package/dist/list/list.js +0 -818
  194. package/dist/list/list__custom.js +0 -86
  195. package/dist/list/list__hint.js +0 -26
  196. package/dist/list/list__item.js +0 -206
  197. package/dist/list/list__link.js +0 -65
  198. package/dist/list/list__separator.js +0 -30
  199. package/dist/list/list__title.js +0 -39
  200. package/dist/list/list__users-groups-source.js +0 -130
  201. package/dist/loader/loader.js +0 -71
  202. package/dist/loader/loader__core.js +0 -273
  203. package/dist/loader-inline/inject-styles.js +0 -13
  204. package/dist/loader-inline/loader-inline.js +0 -58
  205. package/dist/loader-inline-ng/loader-inline-ng.js +0 -44
  206. package/dist/loader-ng/loader-ng.js +0 -44
  207. package/dist/loader-screen/loader-screen.js +0 -44
  208. package/dist/loader-screen-ng/loader-screen-ng.js +0 -95
  209. package/dist/login-dialog/login-dialog.js +0 -188
  210. package/dist/login-dialog/service.js +0 -72
  211. package/dist/markdown/code.js +0 -31
  212. package/dist/markdown/heading.js +0 -23
  213. package/dist/markdown/link.js +0 -31
  214. package/dist/markdown/markdown.js +0 -74
  215. package/dist/message/message.js +0 -235
  216. package/dist/message-bundle-ng/message-bundle-ng.js +0 -111
  217. package/dist/old-browsers-message/old-browsers-message.js +0 -101
  218. package/dist/old-browsers-message/old-browsers-message__stop.js +0 -5
  219. package/dist/old-browsers-message/white-list.js +0 -34
  220. package/dist/pager/pager.js +0 -365
  221. package/dist/pager-ng/pager-ng.js +0 -100
  222. package/dist/panel/panel.js +0 -31
  223. package/dist/panel-ng/panel-ng.js +0 -17
  224. package/dist/permissions/permissions.js +0 -200
  225. package/dist/permissions/permissions__cache.js +0 -272
  226. package/dist/permissions-ng/permissions-ng.js +0 -277
  227. package/dist/place-under-ng/place-under-ng.js +0 -158
  228. package/dist/popup/popup.consts.js +0 -41
  229. package/dist/popup/popup.js +0 -396
  230. package/dist/popup/popup.target.js +0 -26
  231. package/dist/popup/position.js +0 -280
  232. package/dist/popup-menu/popup-menu.js +0 -117
  233. package/dist/progress-bar/progress-bar.js +0 -114
  234. package/dist/progress-bar-ng/progress-bar-ng.js +0 -17
  235. package/dist/promised-click-ng/promised-click-ng.js +0 -128
  236. package/dist/proxy-attrs/proxy-attrs.js +0 -21
  237. package/dist/query-assist/query-assist.js +0 -1096
  238. package/dist/query-assist/query-assist__suggestions.js +0 -49
  239. package/dist/query-assist-ng/query-assist-ng.js +0 -86
  240. package/dist/radio/radio.js +0 -42
  241. package/dist/radio/radio__item.js +0 -78
  242. package/dist/radio-ng/radio-ng.js +0 -47
  243. package/dist/save-field-ng/save-field-ng.js +0 -337
  244. package/dist/save-field-ng/save-field-ng__template.js +0 -3
  245. package/dist/select/select.js +0 -1357
  246. package/dist/select/select__filter.js +0 -56
  247. package/dist/select/select__popup.js +0 -553
  248. package/dist/select-ng/select-ng.js +0 -637
  249. package/dist/select-ng/select-ng__lazy.js +0 -169
  250. package/dist/select-ng/select-ng__options.js +0 -145
  251. package/dist/shortcuts/core.js +0 -245
  252. package/dist/shortcuts/shortcut-title.js +0 -51
  253. package/dist/shortcuts/shortcuts-hoc.js +0 -42
  254. package/dist/shortcuts/shortcuts.js +0 -72
  255. package/dist/shortcuts-hint-ng/shortcuts-hint-ng.js +0 -123
  256. package/dist/shortcuts-hint-ng/shortcuts-hint-ng__template.js +0 -3
  257. package/dist/shortcuts-ng/shortcuts-ng.js +0 -262
  258. package/dist/sidebar-ng/sidebar-ng.js +0 -113
  259. package/dist/sidebar-ng/sidebar-ng__button-template.js +0 -3
  260. package/dist/sidebar-ng/sidebar-ng__template.js +0 -3
  261. package/dist/storage/storage.js +0 -59
  262. package/dist/storage/storage__fallback.js +0 -215
  263. package/dist/storage/storage__local.js +0 -154
  264. package/dist/style.css +0 -1
  265. package/dist/tab-trap/tab-trap.js +0 -177
  266. package/dist/table/cell.js +0 -26
  267. package/dist/table/disable-hover-hoc.js +0 -54
  268. package/dist/table/header-cell.js +0 -92
  269. package/dist/table/header.js +0 -193
  270. package/dist/table/multitable.js +0 -141
  271. package/dist/table/row-with-focus-sensor.js +0 -83
  272. package/dist/table/row.js +0 -273
  273. package/dist/table/selection-adapter.js +0 -16
  274. package/dist/table/selection-shortcuts-hoc.js +0 -215
  275. package/dist/table/selection.js +0 -223
  276. package/dist/table/smart-table.js +0 -125
  277. package/dist/table/table.js +0 -406
  278. package/dist/table-legacy-ng/table-legacy-ng.js +0 -468
  279. package/dist/table-legacy-ng/table-legacy-ng__pager.js +0 -120
  280. package/dist/table-legacy-ng/table-legacy-ng__selection-navigate-actions.js +0 -123
  281. package/dist/table-legacy-ng/table-legacy-ng__selection.js +0 -179
  282. package/dist/table-legacy-ng/table-legacy-ng__toolbar.js +0 -57
  283. package/dist/table-ng/smart-table-ng.js +0 -68
  284. package/dist/table-ng/table-ng.js +0 -67
  285. package/dist/tabs/collapsible-more.js +0 -198
  286. package/dist/tabs/collapsible-tab.js +0 -91
  287. package/dist/tabs/collapsible-tabs.js +0 -362
  288. package/dist/tabs/custom-item.js +0 -13
  289. package/dist/tabs/dumb-tabs.js +0 -164
  290. package/dist/tabs/smart-tabs.js +0 -106
  291. package/dist/tabs/tab-link.js +0 -42
  292. package/dist/tabs/tab.js +0 -33
  293. package/dist/tabs/tabs.js +0 -71
  294. package/dist/tabs-ng/tabs-ng.js +0 -194
  295. package/dist/tabs-ng/tabs-ng__template.js +0 -3
  296. package/dist/tag/tag.js +0 -197
  297. package/dist/tags-input/tags-input.js +0 -482
  298. package/dist/tags-input-ng/tags-input-ng.js +0 -93
  299. package/dist/tags-list/tags-list.js +0 -95
  300. package/dist/template-ng/template-ng.js +0 -71
  301. package/dist/text/text.js +0 -36
  302. package/dist/theme-ng/theme-ng.js +0 -45
  303. package/dist/title-ng/title-ng.js +0 -114
  304. package/dist/toggle/toggle.js +0 -78
  305. package/dist/toggle-ng/toggle-ng.js +0 -18
  306. package/dist/tooltip/tooltip.js +0 -209
  307. package/dist/tooltip-ng/tooltip-ng.js +0 -104
  308. package/dist/user-agreement/service.js +0 -412
  309. package/dist/user-agreement/toolbox.eula.js +0 -3
  310. package/dist/user-agreement/user-agreement.js +0 -169
  311. package/dist/user-card/card.js +0 -19
  312. package/dist/user-card/smart-user-card-tooltip.js +0 -114
  313. package/dist/user-card/tooltip.js +0 -95
  314. package/dist/user-card/user-card.js +0 -51
  315. package/dist/user-card-ng/user-card-ng.js +0 -62
@@ -1,1096 +0,0 @@
1
- import { _ as _defineProperty } from '../_helpers/_rollupPluginBabelHelpers.js';
2
- import 'core-js/modules/es.string.replace.js';
3
- import 'core-js/modules/web.dom-collections.iterator.js';
4
- import React, { Component } from 'react';
5
- import PropTypes from 'prop-types';
6
- import debounce from 'just-debounce-it';
7
- import classNames from 'classnames';
8
- import deepEqual from 'deep-equal';
9
- import searchIcon from '@jetbrains/icons/search';
10
- import closeIcon from '@jetbrains/icons/close';
11
- import getUID from '../global/get-uid.js';
12
- import joinDataTestAttributes from '../global/data-tests.js';
13
- import { preventDefault, getRect } from '../global/dom.js';
14
- import Caret from '../caret/caret.js';
15
- import ContentEditable from '../contenteditable/contenteditable.js';
16
- import PopupMenu from '../popup-menu/popup-menu.js';
17
- import LoaderInline from '../loader-inline/loader-inline.js';
18
- import Shortcuts from '../shortcuts/shortcuts.js';
19
- import rerenderHOC from '../global/rerender-hoc.js';
20
- import Theme from '../global/theme.js';
21
- import Button from '../button/button.js';
22
- import { Q as QueryAssistSuggestions, m as modules_da7ab055 } from '../_helpers/query-assist__suggestions.js';
23
- import 'react-dom/server';
24
- import '../popup/popup.js';
25
- import 'react-dom';
26
- import '../global/schedule-raf.js';
27
- import '../tab-trap/tab-trap.js';
28
- import '../popup/position.js';
29
- import '../popup/popup.consts.js';
30
- import '../popup/popup.target.js';
31
- import '../shortcuts/core.js';
32
- import 'combokeys';
33
- import '../global/sniffer.js';
34
- import 'sniffr';
35
- import '../list/list.js';
36
- import 'react-virtualized/dist/es/List';
37
- import 'react-virtualized/dist/es/AutoSizer';
38
- import 'react-virtualized/dist/es/WindowScroller';
39
- import 'react-virtualized/dist/es/CellMeasurer';
40
- import 'util-deprecate';
41
- import 'memoize-one';
42
- import '../global/memoize.js';
43
- import '../global/create-stateful-context.js';
44
- import '../list/list__link.js';
45
- import '../link/link.js';
46
- import 'focus-visible';
47
- import '../link/clickableLink.js';
48
- import '../_helpers/link.js';
49
- import '../_helpers/list.js';
50
- import '../list/list__item.js';
51
- import '../avatar/avatar.js';
52
- import '../global/url.js';
53
- import '../avatar/fallback-avatar.js';
54
- import '../checkbox/checkbox.js';
55
- import '@jetbrains/icons/checkmark';
56
- import '@jetbrains/icons/remove-10px';
57
- import '../icon/icon.js';
58
- import '../icon/icon__constants.js';
59
- import '../_helpers/icon.js';
60
- import '../icon/icon__svg.js';
61
- import '../_helpers/checkbox.js';
62
- import '../list/list__custom.js';
63
- import '../global/get-event-key.js';
64
- import '../list/list__title.js';
65
- import '../list/list__separator.js';
66
- import '../list/list__hint.js';
67
- import '../list/consts.js';
68
- import '../_helpers/inject-styles.js';
69
- import '../global/conic-gradient.js';
70
- import 'conic-gradient';
71
- import '../global/supports-css.js';
72
- import '../global/inject-styles.js';
73
- import '../global/radial-gradient-mask.js';
74
- import '../global/react-render-adapter.js';
75
- import '../global/composeRefs.js';
76
- import '@jetbrains/icons/chevron-10px';
77
- import '../_helpers/button__classes.js';
78
-
79
- const POPUP_COMPENSATION = PopupMenu.ListProps.Dimension.ITEM_PADDING + PopupMenu.PopupProps.Dimension.BORDER_WIDTH;
80
- const ngModelStateField = 'query';
81
-
82
- function noop() {}
83
-
84
- function cleanText(text) {
85
- return text.replace(/([\n\r])+/g, ' ');
86
- }
87
- /**
88
- * @name Query Assist
89
- */
90
-
91
- /**
92
- * ## Data source function
93
-
94
- Component class calls a data source function when user input happens and passes an object with fields \`caret\`, \`focus\` and \`query\` as the only argument.
95
- The function must return an object with the fields described below. The object can be optionally wrapped in a Promise.
96
-
97
- ### Return object fields
98
-
99
- \`caret\` and \`query\` should just return server values provided to data source function.
100
- These fields allow the Query Assist component to recognise and drop earlier responses from the server.
101
-
102
- + __caret__ (\`string=0\`) Caret from request
103
- + __query__ (\`string=''\`) Query from request
104
- + __styleRanges__ (\`Array<suggestion>=\`) Array of \`styleRange\` objects, used to highlight the request in the input field
105
- + __suggestions__ (\`Array<styleRange>\`) Array of \`suggestion\` objects to show.
106
-
107
- ### **styleRange** object fields
108
-
109
- start \`number\` Range start (in characters)
110
- length \`number\` Range length (in characters)
111
- style \`string\` Style of the range. Possible values: \`text\`, \`field_value\`, \`field_name\`, \`operator\`
112
-
113
- ### **suggestion** object fields
114
-
115
- + __prefix__ \`string=\` Suggestion option prefix
116
- + __option__ \`string\` Suggestion option
117
- + __suffix__ \`string=\` Suggestion option suffix
118
- + __description__ \`string=\` Suggestion option description. Is not visible when a group is set
119
- + __matchingStart__ \`number\` (required when matchingEnd is set) Start of the highlighted part of an option in the suggestions list (in characters)
120
- + __matchingEnd__ \`number\` (required when matchingEnd is set) End of the highlighted part of an option in the suggestions list (in characters)
121
- + __caret__ \`number\` Caret position after option completion (in characters)
122
- + __completionStart__ \`number\` Where to start insertion (or replacement, when completing with the \`Tab\` key) of the completion option (in characters)
123
- + __completionEnd__ \`number\` Where to end insertion of the completion option (in characters)
124
- + __group__ \`string=\` Group title. Options with the same title are grouped under it
125
- + __icon__ \`string=\` Icon URI, Data URI is possible
126
- */
127
-
128
-
129
- class QueryAssist extends Component {
130
- constructor() {
131
- var _this;
132
-
133
- super(...arguments);
134
- _this = this;
135
-
136
- _defineProperty(this, "state", {
137
- dirty: !this.props.query,
138
- query: this.props.query,
139
- placeholderEnabled: !this.props.query,
140
- shortcuts: !!this.props.focus,
141
- suggestions: [],
142
- showPopup: false
143
- });
144
-
145
- _defineProperty(this, "ngModelStateField", ngModelStateField);
146
-
147
- _defineProperty(this, "historyStack", []);
148
-
149
- _defineProperty(this, "handleFocusChange", e => {
150
- // otherwise it's blur and false
151
- const focus = e.type === 'focus';
152
- this.immediateState.focus = focus;
153
-
154
- if (!focus) {
155
- this.blurInput(); // Close popup on blur by keyboard (mostly shift+tab)
156
-
157
- if (!this.mouseIsDownOnPopup) {
158
- this.closePopup();
159
- }
160
- } else {
161
- this.setCaretPosition();
162
- }
163
-
164
- if (!this.mouseIsDownOnPopup) {
165
- this.props.onFocusChange({
166
- focus
167
- });
168
- }
169
-
170
- this.setState({
171
- shortcuts: !!focus
172
- });
173
- });
174
-
175
- _defineProperty(this, "nodeRef", node => {
176
- this.node = node;
177
- });
178
-
179
- _defineProperty(this, "setCaretPosition", function () {
180
- let params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
181
- const queryLength = _this.immediateState.query != null && _this.immediateState.query.length;
182
- const newCaretPosition = _this.immediateState.caret < queryLength ? _this.immediateState.caret : queryLength;
183
-
184
- if (params.fromContentEditable) {
185
- _this.immediateState.selection = _this.immediateState.selection ? _this.immediateState.selection : _this.state.query && _this.state.query.length;
186
- }
187
-
188
- if (_this.immediateState.focus && !_this.props.disabled) {
189
- if (Number.isInteger(_this.immediateState.selection) && _this.immediateState.selection > -1) {
190
- // Set to end of field value if newCaretPosition is inappropriate
191
- _this.caret.setPosition(newCaretPosition >= 0 ? newCaretPosition : -1);
192
-
193
- _this.scrollInput();
194
- } else if (_this.immediateState.selection && _this.immediateState.selection.startOffset !== undefined) {
195
- _this.caret.setPosition(_this.immediateState.selection);
196
- } else if (!_this.immediateState.selection || params.forceSetCaret) {
197
- _this.caret.setPosition(-1);
198
- }
199
- }
200
- });
201
-
202
- _defineProperty(this, "togglePlaceholder", () => {
203
- const query = this.getQuery();
204
- const currentQueryIsEmpty = this.immediateState.query === '';
205
- const newQueryIsEmpty = query === '';
206
-
207
- if (newQueryIsEmpty !== currentQueryIsEmpty) {
208
- this.setState({
209
- placeholderEnabled: newQueryIsEmpty
210
- });
211
- }
212
- });
213
-
214
- _defineProperty(this, "handleInput", e => {
215
- this.togglePlaceholder();
216
- const currentCaret = this.caret.getPosition();
217
- const props = {
218
- dirty: true,
219
- query: this.getQuery(),
220
- caret: Number.isInteger(currentCaret) ? currentCaret : currentCaret.position,
221
- focus: true
222
- };
223
-
224
- if (this.immediateState.query === props.query && !this.isComposing) {
225
- this.handleCaretMove(e);
226
- return;
227
- }
228
-
229
- if (this.isComposing) {
230
- return;
231
- }
232
-
233
- this.immediateState = props;
234
- this.props.onChange(props);
235
-
236
- if (props.query.length > 0) {
237
- this.requestData();
238
- }
239
- });
240
-
241
- _defineProperty(this, "handleEnter", e => {
242
- if (e.key === 'Enter') {
243
- preventDefault(e);
244
- }
245
- });
246
-
247
- _defineProperty(this, "handleTab", e => {
248
- const list = this._popup && this._popup.list;
249
- const suggestion = list && (list.getSelected() || list.getFirst());
250
-
251
- if (suggestion && this.state.showPopup) {
252
- preventDefault(e);
253
-
254
- if (this.getQuery() !== this.immediateState.suggestionsQuery) {
255
- return false;
256
- }
257
-
258
- return this.handleComplete(suggestion, true);
259
- }
260
-
261
- if (this.state.loading) {
262
- preventDefault(e);
263
- return false;
264
- }
265
-
266
- return true;
267
- });
268
-
269
- _defineProperty(this, "setState", (state, resolve) => {
270
- super.setState(state, () => {
271
- this._pushHistory(state);
272
-
273
- resolve === null || resolve === void 0 ? void 0 : resolve();
274
- });
275
- });
276
-
277
- _defineProperty(this, "undo", e => {
278
- // eslint-disable-next-line no-unused-vars
279
- const [current, previous] = this.historyStack.splice(0, 2);
280
-
281
- if (!previous) {
282
- return;
283
- }
284
-
285
- this.setState({
286
- query: previous.query
287
- }, () => {
288
- this.caret.setPosition(previous.caret);
289
- this.handleInput(e);
290
- });
291
- });
292
-
293
- _defineProperty(this, "handlePaste", e => {
294
- const INSERT_COMMAND = 'insertText';
295
-
296
- if (e.clipboardData && document.queryCommandSupported(INSERT_COMMAND)) {
297
- preventDefault(e);
298
- const text = cleanText(e.clipboardData.getData('text/plain'));
299
- document.execCommand(INSERT_COMMAND, false, text);
300
- this.handleInput(e);
301
- }
302
- });
303
-
304
- _defineProperty(this, "handleCaretMove", e => {
305
- if (this.isComposing) {
306
- return;
307
- }
308
-
309
- const currentCaret = this.caret.getPosition();
310
- const caret = Number.isInteger(currentCaret) ? currentCaret : currentCaret.position;
311
- const popupHidden = !this.state.showPopup && e.type === 'click';
312
-
313
- if (!this.props.disabled && (caret !== this.immediateState.caret || popupHidden)) {
314
- this.immediateState.caret = caret;
315
- this.scrollInput();
316
-
317
- if (this.immediateState.query.length > 0) {
318
- this.requestData();
319
- }
320
- }
321
-
322
- if (this.immediateState.query.length < 1) {
323
- this.setState({
324
- showPopup: false
325
- });
326
- }
327
- });
328
-
329
- _defineProperty(this, "handleStyleRangesResponse", _ref => {
330
- let {
331
- suggestions,
332
- ...restProps
333
- } = _ref;
334
- return this.handleResponse(restProps);
335
- });
336
-
337
- _defineProperty(this, "handleResponse", function (_ref2) {
338
- let {
339
- query = '',
340
- caret = 0,
341
- styleRanges,
342
- suggestions = []
343
- } = _ref2;
344
- let afterCompletion = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
345
- return new Promise((resolve, reject) => {
346
- if (query === _this.getQuery() && (caret === _this.immediateState.caret || _this.immediateState.caret === undefined)) {
347
- // Do not setState on unmounted component
348
- if (!_this.node) {
349
- return;
350
- }
351
-
352
- const state = {
353
- dirty: _this.immediateState.dirty,
354
- loading: false,
355
- placeholderEnabled: !query,
356
- query,
357
- suggestions,
358
- showPopup: !!suggestions.length && !afterCompletion
359
- };
360
- _this.immediateState.suggestionsQuery = query; // Do not update deep equal styleRanges to simplify shouldComponentUpdate check
361
-
362
- if (!deepEqual(_this.state.styleRanges, styleRanges)) {
363
- state.styleRanges = styleRanges;
364
- }
365
-
366
- _this.immediateState.selection = _this.caret.getPosition({
367
- avoidFocus: true
368
- });
369
-
370
- _this.setState(state, resolve);
371
- } else {
372
- reject(new Error('Current and response queries mismatch'));
373
- }
374
- });
375
- });
376
-
377
- _defineProperty(this, "handleApply", () => {
378
- this.closePopup();
379
- this.immediateState.dirty = false; // Only set dirty to false when query is saved already
380
-
381
- if (this.immediateState.query === this.state.query) {
382
- this.setState({
383
- dirty: false
384
- });
385
- }
386
-
387
- return this.props.onApply(this.immediateState);
388
- });
389
-
390
- _defineProperty(this, "handleComplete", (data, replace) => {
391
- if (!data || !data.data) {
392
- this.handleApply();
393
- return;
394
- }
395
-
396
- const query = this.getQuery();
397
- const currentCaret = this.immediateState.caret;
398
- const suggestion = data.data;
399
- const prefix = suggestion.prefix || '';
400
- const suffix = suggestion.suffix || '';
401
- const state = {
402
- caret: suggestion.caret,
403
- selection: suggestion.caret,
404
- query: query.substr(0, suggestion.completionStart) + prefix + suggestion.option + suffix
405
- };
406
-
407
- if (typeof replace === 'boolean' && replace) {
408
- state.query += this.immediateState.query.substr(suggestion.completionEnd);
409
- } else {
410
- state.query += this.immediateState.query.substr(this.immediateState.caret);
411
- }
412
-
413
- this.props.onChange(state);
414
- this.props.onApplySuggestion(data.data, state);
415
- const focusState = {
416
- focus: true
417
- };
418
- this.props.onFocusChange(focusState);
419
-
420
- if (state.query !== this.immediateState.query) {
421
- this.setState({
422
- placeholderEnabled: !state.query,
423
- query: state.query
424
- });
425
- }
426
-
427
- this.immediateState = Object.assign(state, focusState);
428
-
429
- if (this.immediateState.caret !== currentCaret) {
430
- this.setCaretPosition();
431
- }
432
-
433
- this.closePopup();
434
- this.requestData(true);
435
- });
436
-
437
- _defineProperty(this, "requestStyleRanges", () => {
438
- const {
439
- query,
440
- caret
441
- } = this.immediateState;
442
-
443
- if (!query) {
444
- return Promise.reject(new Error('Query is empty'));
445
- }
446
-
447
- return this.sendRequest({
448
- query,
449
- caret,
450
- omitSuggestions: true
451
- }).then(this.handleStyleRangesResponse).catch(noop);
452
- });
453
-
454
- _defineProperty(this, "requestHandler", function () {
455
- let afterCompletion = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
456
-
457
- if (_this.props.disabled) {
458
- return Promise.reject(new Error('QueryAssist(@jetbrains/ring-ui): null exception'));
459
- }
460
-
461
- const {
462
- query,
463
- caret
464
- } = _this.immediateState;
465
- return _this.sendRequest({
466
- query,
467
- caret
468
- }).then(data => _this.handleResponse(data, afterCompletion)).catch(noop);
469
- });
470
-
471
- _defineProperty(this, "handleCtrlSpace", e => {
472
- preventDefault(e);
473
-
474
- if (!this.state.showPopup) {
475
- this.requestData();
476
- }
477
- });
478
-
479
- _defineProperty(this, "trackPopupMouseState", e => {
480
- this.mouseIsDownOnPopup = e.type === 'mousedown';
481
- });
482
-
483
- _defineProperty(this, "trackCompositionState", e => {
484
- this.isComposing = e.type !== 'compositionend';
485
- });
486
-
487
- _defineProperty(this, "closePopup", () => {
488
- if (this.node) {
489
- this.setState({
490
- showPopup: false
491
- });
492
- }
493
- });
494
-
495
- _defineProperty(this, "clearQuery", () => {
496
- const state = {
497
- dirty: false,
498
- caret: 0,
499
- query: '',
500
- focus: true
501
- };
502
- this.props.onChange(state);
503
- this.props.onClear();
504
- this.immediateState = state;
505
- this.setState({
506
- dirty: false,
507
- query: '',
508
- placeholderEnabled: true,
509
- loading: false
510
- });
511
- });
512
-
513
- _defineProperty(this, "inputRef", node => {
514
- if (!node) {
515
- return;
516
- }
517
-
518
- this.input = node;
519
- this.caret = new Caret(this.input);
520
- });
521
-
522
- _defineProperty(this, "popupRef", node => {
523
- this._popup = node;
524
- });
525
-
526
- _defineProperty(this, "placeholderRef", node => {
527
- this.placeholder = node;
528
- });
529
-
530
- _defineProperty(this, "glassRef", node => {
531
- this.glass = node;
532
- });
533
-
534
- _defineProperty(this, "loaderRef", node => {
535
- this.loader = node;
536
- });
537
-
538
- _defineProperty(this, "clearRef", node => {
539
- this.clear = node;
540
- });
541
-
542
- _defineProperty(this, "shortcutsScope", getUID('ring-query-assist-'));
543
-
544
- _defineProperty(this, "shortcutsMap", {
545
- del: noop,
546
- enter: this.handleComplete,
547
- 'command+enter': this.handleComplete,
548
- 'ctrl+enter': this.handleComplete,
549
- 'ctrl+space': this.handleCtrlSpace,
550
- tab: this.handleTab,
551
- 'meta+z': this.undo,
552
- right: noop,
553
- left: noop,
554
- space: noop,
555
- home: noop,
556
- end: noop
557
- });
558
- }
559
-
560
- static getDerivedStateFromProps(_ref3, _ref4) {
561
- let {
562
- query
563
- } = _ref3;
564
- let {
565
- prevQuery
566
- } = _ref4;
567
- const nextState = {
568
- prevQuery: query
569
- };
570
-
571
- if (typeof query === 'string' && query !== prevQuery) {
572
- nextState.query = query;
573
- nextState.placeholderEnabled = !query;
574
- }
575
-
576
- return nextState;
577
- }
578
-
579
- componentDidMount() {
580
- const query = this.props.query || '';
581
- this.immediateState = {
582
- query,
583
- caret: Number.isFinite(this.props.caret) ? this.props.caret : query.length,
584
- focus: Boolean(this.props.autoOpen || this.props.focus)
585
- };
586
- this.setupRequestHandler(this.props.delay);
587
-
588
- if (this.props.autoOpen && query.length > 0) {
589
- this.requestHandler().catch(noop);
590
- } else {
591
- this.requestStyleRanges().catch(noop);
592
- }
593
-
594
- this.setCaretPosition();
595
-
596
- this._pushHistory(this.state);
597
- }
598
-
599
- shouldComponentUpdate(props, state) {
600
- return state.query !== this.state.query || state.dirty !== this.state.dirty || state.loading !== this.state.loading || state.showPopup !== this.state.showPopup || state.suggestions !== this.state.suggestions || state.styleRanges !== this.state.styleRanges || state.placeholderEnabled !== this.state.placeholderEnabled || props.placeholder !== this.props.placeholder || props.disabled !== this.props.disabled || props.clear !== this.props.clear || props.focus !== this.props.focus || props.actions !== this.props.actions || props.loader !== this.props.loader || props.glass !== this.props.glass;
601
- }
602
-
603
- componentDidUpdate(prevProps) {
604
- const {
605
- caret,
606
- delay,
607
- query
608
- } = this.props;
609
- const queryChanged = query !== prevProps.query;
610
- this.updateFocus(prevProps);
611
- this.setupRequestHandler(delay);
612
- const shouldSetCaret = typeof caret === 'number' && caret !== prevProps.caret;
613
-
614
- if (shouldSetCaret) {
615
- this.immediateState.caret = caret;
616
- }
617
-
618
- if (typeof query === 'string' && queryChanged && query !== this.immediateState.query) {
619
- this.immediateState.query = query;
620
-
621
- if (query && prevProps.autoOpen && query.length > 0) {
622
- this.requestData();
623
- } else if (query) {
624
- this.requestStyleRanges();
625
- }
626
- }
627
- }
628
-
629
- updateFocus(_ref5) {
630
- let {
631
- focus,
632
- caret
633
- } = _ref5;
634
- const isCaretChanged = caret !== this.props.caret;
635
- const isFocusChanged = focus !== this.props.focus;
636
-
637
- if (isFocusChanged || isCaretChanged) {
638
- const focusValue = isFocusChanged ? this.props.focus : true;
639
- this.setFocus(focusValue);
640
- }
641
- }
642
-
643
- scrollInput() {
644
- const caretOffset = this.caret.getOffset();
645
-
646
- if (this.input.clientWidth !== this.input.scrollWidth && caretOffset > this.input.clientWidth) {
647
- this.input.scrollLeft += caretOffset;
648
- }
649
- }
650
-
651
- getQuery() {
652
- return this.input.textContent.replace(/\s/g, ' ');
653
- }
654
-
655
- isRenderingGlassOrLoader() {
656
- const renderLoader = this.props.loader !== false && this.state.loading;
657
- return this.props.glass || renderLoader;
658
- }
659
-
660
- _pushHistory(state) {
661
- var _this$historyStack$;
662
-
663
- const queryIsSet = ('query' in state);
664
- const queryIsSame = ((_this$historyStack$ = this.historyStack[0]) === null || _this$historyStack$ === void 0 ? void 0 : _this$historyStack$.query) === state.query;
665
-
666
- if (queryIsSet && !queryIsSame) {
667
- var _this$caret$getPositi, _this$caret;
668
-
669
- this.historyStack.unshift({
670
- query: state.query,
671
- caret: (_this$caret$getPositi = (_this$caret = this.caret) === null || _this$caret === void 0 ? void 0 : _this$caret.getPosition({
672
- avoidFocus: true
673
- })) !== null && _this$caret$getPositi !== void 0 ? _this$caret$getPositi : -1
674
- });
675
- }
676
- }
677
-
678
- sendRequest(params) {
679
- const value = this.props.dataSource(params);
680
- const dataPromise = Promise.resolve(value);
681
- const CLOSE_POPUP_TIMEOUT = 500; // Close popup after timeout between long requests
682
-
683
- const timeout = window.setTimeout(() => {
684
- if (this.node) {
685
- this.setState({
686
- loading: true
687
- });
688
- }
689
-
690
- if (params.query === this.immediateState.query) {
691
- this.closePopup();
692
- }
693
- }, CLOSE_POPUP_TIMEOUT);
694
- dataPromise.then(() => window.clearTimeout(timeout)).catch(() => {
695
- window.clearTimeout(timeout);
696
- this.setState({
697
- loading: false
698
- });
699
- });
700
- return dataPromise;
701
- }
702
-
703
- getPopupOffset(suggestions) {
704
- const ICON_SPACING = 12;
705
- const minOffset = this.isRenderingGlassOrLoader() ? ICON_SPACING : 0;
706
-
707
- if (!this.input) {
708
- return minOffset;
709
- } // First suggestion should be enough?
710
-
711
-
712
- const suggestion = suggestions && suggestions[0]; // Check if suggestion begins not from the end
713
-
714
- const completionStart = suggestion && suggestion.completionStart !== suggestion.completionEnd && suggestion.completionStart;
715
- const inputChildren = this.input.firstChild && this.input.firstChild.children;
716
- const completionStartNode = inputChildren && Number.isInteger(completionStart) && inputChildren[Math.min(completionStart, inputChildren.length - 1)];
717
- let offset = completionStartNode && getRect(completionStartNode).right - getRect(this.input).left;
718
-
719
- if (!offset) {
720
- const caret = this.caret.getOffset(); // Do not compensate caret in the beginning of field
721
-
722
- if (caret === 0) {
723
- return minOffset;
724
- } else {
725
- offset = caret;
726
- }
727
- }
728
-
729
- const result = offset - POPUP_COMPENSATION;
730
- return result < minOffset ? minOffset : result;
731
- }
732
-
733
- blurInput() {
734
- this.immediateState.selection = {};
735
-
736
- if (!this.props.focus) {
737
- this.caret.target.blur();
738
- }
739
- }
740
- /**
741
- * Optionally setup data request delay. For each component create a separate
742
- * instance of the delayed function. This may help reduce the load on the server
743
- * when the user quickly inputs data.
744
- */
745
-
746
-
747
- setupRequestHandler(delay) {
748
- const needDelay = typeof delay === 'number';
749
- const hasDelay = this.requestData !== this.requestHandler;
750
-
751
- if (!this.requestData || hasDelay !== needDelay) {
752
- if (needDelay) {
753
- this.requestData = debounce(this.requestHandler, delay);
754
- } else {
755
- this.requestData = this.requestHandler;
756
- }
757
- }
758
- }
759
-
760
- _renderSuggestion(suggestion) {
761
- const {
762
- ITEM
763
- } = PopupMenu.ListProps.Type;
764
- const {
765
- description,
766
- icon,
767
- group
768
- } = suggestion;
769
- const key = QueryAssistSuggestions.createKey(suggestion);
770
- const label = QueryAssistSuggestions.renderLabel(suggestion);
771
- return {
772
- key,
773
- icon,
774
- label,
775
- description,
776
- group,
777
- rgItemType: ITEM,
778
- data: suggestion
779
- };
780
- }
781
-
782
- renderSuggestions() {
783
- const {
784
- suggestions
785
- } = this.state;
786
-
787
- if (!suggestions || !suggestions.length) {
788
- return [];
789
- }
790
-
791
- return QueryAssistSuggestions.renderList(suggestions, this._renderSuggestion);
792
- }
793
-
794
- renderQuery() {
795
- const {
796
- dirty,
797
- styleRanges,
798
- query
799
- } = this.state;
800
- const classes = [];
801
- const LETTER_CLASS = 'letter';
802
- const LETTER_DEFAULT_CLASS = modules_da7ab055.letterDefault;
803
-
804
- if (styleRanges && styleRanges.length) {
805
- styleRanges.forEach((item, index) => {
806
- if (dirty && index === styleRanges.length - 1 && item.style === 'text') {
807
- return;
808
- }
809
-
810
- const styleName = "".concat(LETTER_CLASS, "-").concat(item.style.replace('_', '-'));
811
-
812
- for (let i = item.start; i < item.start + item.length; i++) {
813
- classes[i] = modules_da7ab055[styleName];
814
- }
815
- });
816
- }
817
-
818
- return Array.from(query).map((letter, index, letters) => {
819
- const className = classNames(modules_da7ab055.letter, classes[index] || LETTER_DEFAULT_CLASS);
820
- const dataTest = letters.length - 1 === index ? 'ring-query-assist-last-letter' : null; // \u00a0 === &nbsp;
821
-
822
- return /*#__PURE__*/React.createElement("span", {
823
- // eslint-disable-next-line react/no-array-index-key
824
- key: index + letter,
825
- className: className,
826
- "data-test": dataTest
827
- }, letter === ' ' ? '\u00a0' : letter);
828
- });
829
- }
830
-
831
- setFocus(focus) {
832
- this.setState({
833
- shortcuts: !!focus
834
- });
835
- const isComponentFocused = Boolean(this.immediateState.focus);
836
-
837
- if (focus === false && isComponentFocused) {
838
- this.immediateState.focus = focus;
839
- this.blurInput();
840
- } else if (focus === true && !isComponentFocused) {
841
- this.immediateState.focus = focus;
842
- this.setCaretPosition({
843
- forceSetCaret: true
844
- });
845
- }
846
- }
847
-
848
- renderActions() {
849
- const actions = [].concat(this.props.actions || []);
850
- const renderClear = this.props.clear && !!this.state.query;
851
-
852
- if (renderClear) {
853
- actions.push( /*#__PURE__*/React.createElement(Button, {
854
- icon: closeIcon,
855
- key: 'clearAction',
856
- className: modules_da7ab055.icon,
857
- iconClassName: modules_da7ab055.iconInner,
858
- title: this.props.translations.clearTitle,
859
- ref: this.clearRef,
860
- onClick: this.clearQuery,
861
- "data-test": "query-assist-clear-icon"
862
- }));
863
- }
864
-
865
- return actions;
866
- }
867
-
868
- render() {
869
- const {
870
- theme,
871
- glass,
872
- 'data-test': dataTest,
873
- className,
874
- useCustomItemRender
875
- } = this.props;
876
- const renderPlaceholder = !!this.props.placeholder && this.state.placeholderEnabled;
877
- const renderLoader = this.props.loader !== false && this.state.loading;
878
- const renderGlass = glass && !renderLoader;
879
- const renderUnderline = theme === Theme.DARK;
880
- const actions = this.renderActions();
881
- const inputClasses = classNames({
882
- ["".concat(modules_da7ab055.input, " ring-js-shortcuts")]: true,
883
- [modules_da7ab055.inputGap]: actions.length || this.isRenderingGlassOrLoader() && !glass,
884
- [modules_da7ab055.inputGap2]: actions.length === 2,
885
- // TODO: replace with flex-box layout
886
- [modules_da7ab055.inputLeftGap]: this.isRenderingGlassOrLoader() && glass,
887
- [modules_da7ab055.inputDisabled]: this.props.disabled
888
- });
889
- return /*#__PURE__*/React.createElement("div", {
890
- "data-test": joinDataTestAttributes('ring-query-assist', dataTest),
891
- className: classNames(className, modules_da7ab055.queryAssist, modules_da7ab055[theme]),
892
- role: "presentation",
893
- ref: this.nodeRef
894
- }, this.state.shortcuts && /*#__PURE__*/React.createElement(Shortcuts, {
895
- map: this.shortcutsMap,
896
- scope: this.shortcutsScope
897
- }), renderGlass && /*#__PURE__*/React.createElement(Button, {
898
- icon: searchIcon,
899
- className: modules_da7ab055.icon,
900
- iconClassName: modules_da7ab055.iconInner,
901
- title: this.props.translations.searchTitle,
902
- ref: this.glassRef,
903
- onClick: this.handleApply,
904
- "data-test": "query-assist-search-icon"
905
- }), renderLoader && /*#__PURE__*/React.createElement("div", {
906
- className: classNames(modules_da7ab055.icon, modules_da7ab055.loader, {
907
- [modules_da7ab055.loaderOnTheRight]: !glass
908
- }),
909
- ref: this.loaderRef
910
- }, /*#__PURE__*/React.createElement(LoaderInline, {
911
- theme: theme
912
- })), /*#__PURE__*/React.createElement(ContentEditable, {
913
- "aria-label": this.props.translations.searchTitle,
914
- className: inputClasses,
915
- "data-test": "ring-query-assist-input",
916
- inputRef: this.inputRef,
917
- disabled: this.props.disabled,
918
- onComponentUpdate: () => this.setCaretPosition({
919
- fromContentEditable: true
920
- }),
921
- onBlur: this.handleFocusChange,
922
- onClick: this.handleCaretMove,
923
- onCompositionStart: this.trackCompositionState,
924
- onCompositionEnd: this.trackCompositionState,
925
- onFocus: this.handleFocusChange,
926
- onInput: this.handleInput // To support IE use the same method
927
- ,
928
- onKeyUp: this.handleInput // to handle input and key up
929
- ,
930
- onKeyDown: this.handleEnter,
931
- onPaste: this.handlePaste,
932
- spellCheck: "false"
933
- }, this.state.query && /*#__PURE__*/React.createElement("span", null, this.renderQuery())), renderPlaceholder && /*#__PURE__*/React.createElement("button", {
934
- type: "button",
935
- className: classNames(modules_da7ab055.placeholder, {
936
- [modules_da7ab055.placeholderSpaced]: glass
937
- }),
938
- ref: this.placeholderRef,
939
- onClick: this.handleCaretMove,
940
- "data-test": "query-assist-placeholder"
941
- }, this.props.placeholder), renderUnderline && /*#__PURE__*/React.createElement("div", {
942
- className: modules_da7ab055.focusUnderline
943
- }), actions && /*#__PURE__*/React.createElement("div", {
944
- "data-test": "ring-query-assist-actions",
945
- className: modules_da7ab055.actions
946
- }, actions), /*#__PURE__*/React.createElement(PopupMenu, {
947
- hidden: !this.state.showPopup,
948
- onCloseAttempt: this.closePopup,
949
- ref: this.popupRef,
950
- anchorElement: this.node,
951
- keepMounted: true,
952
- attached: true,
953
- className: classNames(modules_da7ab055[theme], this.props.popupClassName),
954
- directions: [PopupMenu.PopupProps.Directions.BOTTOM_RIGHT],
955
- data: useCustomItemRender ? this.state.suggestions : this.renderSuggestions(),
956
- "data-test": "ring-query-assist-popup",
957
- hint: this.props.hint,
958
- hintOnSelection: this.props.hintOnSelection,
959
- left: this.getPopupOffset(this.state.suggestions),
960
- maxHeight: PopupMenu.PopupProps.MaxHeight.SCREEN,
961
- onMouseDown: this.trackPopupMouseState,
962
- onMouseUp: this.trackPopupMouseState,
963
- onSelect: this.handleComplete
964
- }));
965
- }
966
-
967
- }
968
-
969
- _defineProperty(QueryAssist, "propTypes", {
970
- theme: PropTypes.string,
971
-
972
- /**
973
- * Open suggestions popup during the initial render
974
- */
975
- autoOpen: PropTypes.bool,
976
-
977
- /**
978
- * Initial caret position
979
- */
980
- caret: PropTypes.number,
981
-
982
- /**
983
- * Show clickable "cross" icon on the right which clears the query
984
- */
985
- clear: PropTypes.bool,
986
-
987
- /**
988
- * Additional class for the component
989
- */
990
- className: PropTypes.string,
991
-
992
- /**
993
- * Additional class for the popup
994
- */
995
- popupClassName: PropTypes.string,
996
-
997
- /**
998
- * Data source function
999
- */
1000
- dataSource: PropTypes.func.isRequired,
1001
-
1002
- /**
1003
- * Input debounce delay
1004
- */
1005
- delay: PropTypes.number,
1006
-
1007
- /**
1008
- * Disable the component
1009
- */
1010
- disabled: PropTypes.bool,
1011
-
1012
- /**
1013
- * Initial focus
1014
- */
1015
- focus: PropTypes.bool,
1016
-
1017
- /**
1018
- * Hint under the suggestions list
1019
- */
1020
- hint: PropTypes.string,
1021
-
1022
- /**
1023
- * Hint under the suggestions list visible when a suggestion is selected
1024
- */
1025
- hintOnSelection: PropTypes.string,
1026
-
1027
- /**
1028
- * Show clickable "glass" icon on the right which applies the query
1029
- */
1030
- glass: PropTypes.bool,
1031
-
1032
- /**
1033
- * Show loader when a data request is in process
1034
- */
1035
- loader: PropTypes.bool,
1036
-
1037
- /**
1038
- * Field placeholder value
1039
- */
1040
- placeholder: PropTypes.string,
1041
-
1042
- /**
1043
- * Called when the query is applied. An object with fields `caret`, `focus` and `query` is passed as an argument
1044
- */
1045
- onApply: PropTypes.func,
1046
-
1047
- /**
1048
- * Called when the query is changed. An object with fields `caret` and `query` is passed as an argument
1049
- */
1050
- onChange: PropTypes.func,
1051
-
1052
- /**
1053
- * Called when the query is cleared. Called without arguments
1054
- */
1055
- onClear: PropTypes.func,
1056
-
1057
- /**
1058
- * Called when the suggestion is applied
1059
- */
1060
- onApplySuggestion: PropTypes.func,
1061
-
1062
- /**
1063
- * Called when the focus status is changed. An object with fields `focus` is passed as an argument
1064
- */
1065
- onFocusChange: PropTypes.func,
1066
-
1067
- /**
1068
- * Initial query
1069
- */
1070
- query: PropTypes.string,
1071
- useCustomItemRender: PropTypes.bool,
1072
- translations: PropTypes.object,
1073
- actions: PropTypes.array,
1074
- 'data-test': PropTypes.string
1075
- });
1076
-
1077
- _defineProperty(QueryAssist, "defaultProps", {
1078
- theme: Theme.LIGHT,
1079
- onApply: noop,
1080
- onChange: noop,
1081
- onApplySuggestion: noop,
1082
- onClear: noop,
1083
- onFocusChange: noop,
1084
- translations: {
1085
- searchTitle: 'Search',
1086
- clearTitle: 'Clear search input'
1087
- }
1088
- });
1089
-
1090
- _defineProperty(QueryAssist, "ngModelStateField", ngModelStateField);
1091
-
1092
- _defineProperty(QueryAssist, "Theme", Theme);
1093
-
1094
- const RerenderableQueryAssist = rerenderHOC(QueryAssist);
1095
-
1096
- export { RerenderableQueryAssist, QueryAssist as default };