@jetbrains/ring-ui 5.0.156 → 5.0.158

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