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