@jetbrains/ring-ui 4.2.4 → 4.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (315) hide show
  1. package/package.json +2 -2
  2. package/dist/_helpers/_rollupPluginBabelHelpers.js +0 -34
  3. package/dist/_helpers/anchor.js +0 -33
  4. package/dist/_helpers/badge.js +0 -3
  5. package/dist/_helpers/button-group.js +0 -3
  6. package/dist/_helpers/button-set.js +0 -3
  7. package/dist/_helpers/button-toolbar.js +0 -3
  8. package/dist/_helpers/button__classes.js +0 -39
  9. package/dist/_helpers/card.js +0 -75
  10. package/dist/_helpers/checkbox.js +0 -3
  11. package/dist/_helpers/date-picker.js +0 -3
  12. package/dist/_helpers/dialog__body-scroll-preventer.js +0 -58
  13. package/dist/_helpers/error-message.js +0 -3
  14. package/dist/_helpers/footer.js +0 -121
  15. package/dist/_helpers/grid.js +0 -3
  16. package/dist/_helpers/group.js +0 -3
  17. package/dist/_helpers/header.js +0 -3
  18. package/dist/_helpers/icon.js +0 -3
  19. package/dist/_helpers/inject-styles.js +0 -22
  20. package/dist/_helpers/input.js +0 -3
  21. package/dist/_helpers/island.js +0 -3
  22. package/dist/_helpers/link.js +0 -3
  23. package/dist/_helpers/list.js +0 -3
  24. package/dist/_helpers/loader-screen.js +0 -3
  25. package/dist/_helpers/panel.js +0 -3
  26. package/dist/_helpers/query-assist__suggestions.js +0 -95
  27. package/dist/_helpers/radio.js +0 -3
  28. package/dist/_helpers/select__filter.js +0 -77
  29. package/dist/_helpers/services-link.js +0 -40
  30. package/dist/_helpers/sidebar.js +0 -126
  31. package/dist/_helpers/table.js +0 -3
  32. package/dist/_helpers/tabs.js +0 -3
  33. package/dist/_helpers/title.js +0 -100
  34. package/dist/alert/alert.js +0 -262
  35. package/dist/alert/container.js +0 -48
  36. package/dist/alert-service/alert-service.js +0 -173
  37. package/dist/analytics/analytics.js +0 -118
  38. package/dist/analytics/analytics__custom-plugin.js +0 -128
  39. package/dist/analytics/analytics__fus-plugin.js +0 -102
  40. package/dist/analytics/analytics__ga-plugin.js +0 -75
  41. package/dist/analytics/analytics__plugin-utils.js +0 -80
  42. package/dist/analytics-ng/analytics-ng.js +0 -95
  43. package/dist/auth/auth.js +0 -96
  44. package/dist/auth/auth__core.js +0 -1059
  45. package/dist/auth/background-flow.js +0 -123
  46. package/dist/auth/down-notification.js +0 -117
  47. package/dist/auth/iframe-flow.js +0 -153
  48. package/dist/auth/landing-entry.js +0 -5
  49. package/dist/auth/landing.js +0 -90
  50. package/dist/auth/request-builder.js +0 -76
  51. package/dist/auth/response-parser.js +0 -118
  52. package/dist/auth/storage.js +0 -283
  53. package/dist/auth/token-validator.js +0 -178
  54. package/dist/auth/window-flow.js +0 -134
  55. package/dist/auth-dialog/auth-dialog.js +0 -180
  56. package/dist/auth-dialog-service/auth-dialog-service.js +0 -71
  57. package/dist/auth-ng/auth-ng.js +0 -206
  58. package/dist/auth-ng/auth-ng.mock.js +0 -33
  59. package/dist/autofocus-ng/autofocus-ng.js +0 -51
  60. package/dist/avatar/avatar-example-datauri.js +0 -4
  61. package/dist/avatar/avatar.js +0 -163
  62. package/dist/avatar/fallback-avatar.js +0 -142
  63. package/dist/avatar-editor-ng/avatar-editor-ng.js +0 -167
  64. package/dist/avatar-editor-ng/avatar-editor-ng__template.js +0 -3
  65. package/dist/avatar-ng/avatar-ng.js +0 -21
  66. package/dist/badge/badge.js +0 -51
  67. package/dist/badge-ng/badge-ng.js +0 -18
  68. package/dist/breadcrumb-ng/breadcrumb-ng.js +0 -37
  69. package/dist/button/button.js +0 -125
  70. package/dist/button/button__classes.js +0 -5
  71. package/dist/button-group/button-group.js +0 -30
  72. package/dist/button-group/caption.js +0 -24
  73. package/dist/button-group-ng/button-group-ng.js +0 -39
  74. package/dist/button-ng/button-ng.js +0 -217
  75. package/dist/button-set/button-set.js +0 -26
  76. package/dist/button-set-ng/button-set-ng.js +0 -19
  77. package/dist/button-toolbar/button-toolbar.js +0 -29
  78. package/dist/button-toolbar-ng/button-toolbar-ng.js +0 -24
  79. package/dist/caret/caret.js +0 -266
  80. package/dist/checkbox/checkbox.js +0 -110
  81. package/dist/checkbox-ng/checkbox-ng.js +0 -38
  82. package/dist/code/code.js +0 -137
  83. package/dist/compiler-ng/compiler-ng.js +0 -53
  84. package/dist/confirm/confirm.js +0 -127
  85. package/dist/confirm-ng/confirm-ng.js +0 -69
  86. package/dist/confirm-service/confirm-service.js +0 -117
  87. package/dist/content-layout/content-layout.js +0 -66
  88. package/dist/content-layout/sidebar.js +0 -7
  89. package/dist/contenteditable/contenteditable.js +0 -78
  90. package/dist/data-list/data-list.js +0 -208
  91. package/dist/data-list/data-list.mock.js +0 -191
  92. package/dist/data-list/item.js +0 -229
  93. package/dist/data-list/selection.js +0 -102
  94. package/dist/data-list/title.js +0 -20
  95. package/dist/data-list-ng/data-list-ng.js +0 -62
  96. package/dist/date-picker/consts.js +0 -69
  97. package/dist/date-picker/date-input.js +0 -175
  98. package/dist/date-picker/date-picker.js +0 -367
  99. package/dist/date-picker/date-popup.js +0 -483
  100. package/dist/date-picker/day.js +0 -120
  101. package/dist/date-picker/formats.js +0 -3
  102. package/dist/date-picker/month-names.js +0 -100
  103. package/dist/date-picker/month-slider.js +0 -84
  104. package/dist/date-picker/month.js +0 -55
  105. package/dist/date-picker/months.js +0 -122
  106. package/dist/date-picker/weekdays.js +0 -32
  107. package/dist/date-picker/years.js +0 -110
  108. package/dist/dialog/dialog.js +0 -202
  109. package/dist/dialog/dialog__body-scroll-preventer.js +0 -3
  110. package/dist/dialog-ng/dialog-ng.js +0 -604
  111. package/dist/dialog-ng/dialog-ng__template.js +0 -3
  112. package/dist/docked-panel-ng/docked-panel-ng.js +0 -171
  113. package/dist/dropdown/anchor.js +0 -19
  114. package/dist/dropdown/dropdown.js +0 -236
  115. package/dist/dropdown-menu/dropdown-menu.js +0 -177
  116. package/dist/error-bubble/error-bubble.js +0 -59
  117. package/dist/error-message/error-message.js +0 -57
  118. package/dist/error-message-ng/error-message-ng.js +0 -35
  119. package/dist/footer/footer.js +0 -12
  120. package/dist/footer-ng/footer-ng.js +0 -64
  121. package/dist/form-ng/form-ng.js +0 -167
  122. package/dist/global/angular-component-factory.js +0 -84
  123. package/dist/global/compose.js +0 -9
  124. package/dist/global/composeRefs.js +0 -15
  125. package/dist/global/conic-gradient.js +0 -35
  126. package/dist/global/create-stateful-context.js +0 -55
  127. package/dist/global/data-tests.js +0 -24
  128. package/dist/global/dom.js +0 -125
  129. package/dist/global/focus-sensor-hoc.js +0 -146
  130. package/dist/global/fuzzy-highlight.js +0 -67
  131. package/dist/global/get-event-key.js +0 -111
  132. package/dist/global/get-uid.js +0 -15
  133. package/dist/global/inject-styles.js +0 -15
  134. package/dist/global/linear-function.js +0 -17
  135. package/dist/global/listeners.js +0 -44
  136. package/dist/global/memoize.js +0 -20
  137. package/dist/global/normalize-indent.js +0 -30
  138. package/dist/global/promise-with-timeout.js +0 -17
  139. package/dist/global/radial-gradient-mask.js +0 -38
  140. package/dist/global/react-dom-renderer.js +0 -46
  141. package/dist/global/react-render-adapter.js +0 -41
  142. package/dist/global/rerender-hoc.js +0 -55
  143. package/dist/global/ring-angular-component.js +0 -24
  144. package/dist/global/schedule-raf.js +0 -31
  145. package/dist/global/sniffer.js +0 -6
  146. package/dist/global/supports-css.js +0 -22
  147. package/dist/global/theme.js +0 -54
  148. package/dist/global/trivial-template-tag.js +0 -17
  149. package/dist/global/url.js +0 -165
  150. package/dist/global/variables_dark.js +0 -57
  151. package/dist/grid/col.js +0 -60
  152. package/dist/grid/grid.js +0 -33
  153. package/dist/grid/row.js +0 -64
  154. package/dist/group/group.js +0 -31
  155. package/dist/group-ng/group-ng.js +0 -11
  156. package/dist/header/header.js +0 -150
  157. package/dist/header/logo.js +0 -40
  158. package/dist/header/profile.js +0 -219
  159. package/dist/header/services-link.js +0 -12
  160. package/dist/header/services.js +0 -138
  161. package/dist/header/smart-profile.js +0 -233
  162. package/dist/header/smart-services.js +0 -163
  163. package/dist/header/tray-icon.js +0 -47
  164. package/dist/header/tray.js +0 -31
  165. package/dist/heading/heading.js +0 -73
  166. package/dist/http/http.js +0 -218
  167. package/dist/http/http.mock.js +0 -67
  168. package/dist/hub-source/hub-source.js +0 -130
  169. package/dist/hub-source/hub-source__user.js +0 -30
  170. package/dist/hub-source/hub-source__users-groups.js +0 -63
  171. package/dist/icon/icon.js +0 -105
  172. package/dist/icon/icon__constants.js +0 -33
  173. package/dist/icon/icon__svg.js +0 -83
  174. package/dist/icon/index.js +0 -12
  175. package/dist/icon-ng/icon-ng.js +0 -91
  176. package/dist/input/input.js +0 -230
  177. package/dist/input-ng/input-ng.js +0 -111
  178. package/dist/island/adaptive-island-hoc.js +0 -48
  179. package/dist/island/content.js +0 -160
  180. package/dist/island/header.js +0 -84
  181. package/dist/island/island.js +0 -51
  182. package/dist/island-legacy/content-legacy.js +0 -26
  183. package/dist/island-legacy/header-legacy.js +0 -28
  184. package/dist/island-legacy/island-legacy.js +0 -28
  185. package/dist/island-ng/island-content-ng.js +0 -42
  186. package/dist/island-ng/island-header-ng.js +0 -26
  187. package/dist/island-ng/island-ng-class-fixer.js +0 -11
  188. package/dist/island-ng/island-ng.js +0 -25
  189. package/dist/link/clickableLink.js +0 -64
  190. package/dist/link/link.js +0 -115
  191. package/dist/link-ng/link-ng.js +0 -22
  192. package/dist/list/consts.js +0 -26
  193. package/dist/list/list.js +0 -818
  194. package/dist/list/list__custom.js +0 -86
  195. package/dist/list/list__hint.js +0 -26
  196. package/dist/list/list__item.js +0 -206
  197. package/dist/list/list__link.js +0 -65
  198. package/dist/list/list__separator.js +0 -30
  199. package/dist/list/list__title.js +0 -39
  200. package/dist/list/list__users-groups-source.js +0 -130
  201. package/dist/loader/loader.js +0 -71
  202. package/dist/loader/loader__core.js +0 -273
  203. package/dist/loader-inline/inject-styles.js +0 -13
  204. package/dist/loader-inline/loader-inline.js +0 -58
  205. package/dist/loader-inline-ng/loader-inline-ng.js +0 -44
  206. package/dist/loader-ng/loader-ng.js +0 -44
  207. package/dist/loader-screen/loader-screen.js +0 -44
  208. package/dist/loader-screen-ng/loader-screen-ng.js +0 -95
  209. package/dist/login-dialog/login-dialog.js +0 -188
  210. package/dist/login-dialog/service.js +0 -72
  211. package/dist/markdown/code.js +0 -31
  212. package/dist/markdown/heading.js +0 -23
  213. package/dist/markdown/link.js +0 -31
  214. package/dist/markdown/markdown.js +0 -74
  215. package/dist/message/message.js +0 -235
  216. package/dist/message-bundle-ng/message-bundle-ng.js +0 -111
  217. package/dist/old-browsers-message/old-browsers-message.js +0 -101
  218. package/dist/old-browsers-message/old-browsers-message__stop.js +0 -5
  219. package/dist/old-browsers-message/white-list.js +0 -34
  220. package/dist/pager/pager.js +0 -365
  221. package/dist/pager-ng/pager-ng.js +0 -100
  222. package/dist/panel/panel.js +0 -31
  223. package/dist/panel-ng/panel-ng.js +0 -17
  224. package/dist/permissions/permissions.js +0 -200
  225. package/dist/permissions/permissions__cache.js +0 -272
  226. package/dist/permissions-ng/permissions-ng.js +0 -277
  227. package/dist/place-under-ng/place-under-ng.js +0 -158
  228. package/dist/popup/popup.consts.js +0 -41
  229. package/dist/popup/popup.js +0 -396
  230. package/dist/popup/popup.target.js +0 -26
  231. package/dist/popup/position.js +0 -280
  232. package/dist/popup-menu/popup-menu.js +0 -117
  233. package/dist/progress-bar/progress-bar.js +0 -114
  234. package/dist/progress-bar-ng/progress-bar-ng.js +0 -17
  235. package/dist/promised-click-ng/promised-click-ng.js +0 -128
  236. package/dist/proxy-attrs/proxy-attrs.js +0 -21
  237. package/dist/query-assist/query-assist.js +0 -1096
  238. package/dist/query-assist/query-assist__suggestions.js +0 -49
  239. package/dist/query-assist-ng/query-assist-ng.js +0 -86
  240. package/dist/radio/radio.js +0 -42
  241. package/dist/radio/radio__item.js +0 -78
  242. package/dist/radio-ng/radio-ng.js +0 -47
  243. package/dist/save-field-ng/save-field-ng.js +0 -337
  244. package/dist/save-field-ng/save-field-ng__template.js +0 -3
  245. package/dist/select/select.js +0 -1357
  246. package/dist/select/select__filter.js +0 -56
  247. package/dist/select/select__popup.js +0 -553
  248. package/dist/select-ng/select-ng.js +0 -637
  249. package/dist/select-ng/select-ng__lazy.js +0 -169
  250. package/dist/select-ng/select-ng__options.js +0 -145
  251. package/dist/shortcuts/core.js +0 -245
  252. package/dist/shortcuts/shortcut-title.js +0 -51
  253. package/dist/shortcuts/shortcuts-hoc.js +0 -42
  254. package/dist/shortcuts/shortcuts.js +0 -72
  255. package/dist/shortcuts-hint-ng/shortcuts-hint-ng.js +0 -123
  256. package/dist/shortcuts-hint-ng/shortcuts-hint-ng__template.js +0 -3
  257. package/dist/shortcuts-ng/shortcuts-ng.js +0 -262
  258. package/dist/sidebar-ng/sidebar-ng.js +0 -113
  259. package/dist/sidebar-ng/sidebar-ng__button-template.js +0 -3
  260. package/dist/sidebar-ng/sidebar-ng__template.js +0 -3
  261. package/dist/storage/storage.js +0 -59
  262. package/dist/storage/storage__fallback.js +0 -215
  263. package/dist/storage/storage__local.js +0 -154
  264. package/dist/style.css +0 -1
  265. package/dist/tab-trap/tab-trap.js +0 -177
  266. package/dist/table/cell.js +0 -26
  267. package/dist/table/disable-hover-hoc.js +0 -54
  268. package/dist/table/header-cell.js +0 -92
  269. package/dist/table/header.js +0 -193
  270. package/dist/table/multitable.js +0 -141
  271. package/dist/table/row-with-focus-sensor.js +0 -83
  272. package/dist/table/row.js +0 -273
  273. package/dist/table/selection-adapter.js +0 -16
  274. package/dist/table/selection-shortcuts-hoc.js +0 -215
  275. package/dist/table/selection.js +0 -223
  276. package/dist/table/smart-table.js +0 -125
  277. package/dist/table/table.js +0 -406
  278. package/dist/table-legacy-ng/table-legacy-ng.js +0 -468
  279. package/dist/table-legacy-ng/table-legacy-ng__pager.js +0 -120
  280. package/dist/table-legacy-ng/table-legacy-ng__selection-navigate-actions.js +0 -123
  281. package/dist/table-legacy-ng/table-legacy-ng__selection.js +0 -179
  282. package/dist/table-legacy-ng/table-legacy-ng__toolbar.js +0 -57
  283. package/dist/table-ng/smart-table-ng.js +0 -68
  284. package/dist/table-ng/table-ng.js +0 -67
  285. package/dist/tabs/collapsible-more.js +0 -198
  286. package/dist/tabs/collapsible-tab.js +0 -91
  287. package/dist/tabs/collapsible-tabs.js +0 -362
  288. package/dist/tabs/custom-item.js +0 -13
  289. package/dist/tabs/dumb-tabs.js +0 -164
  290. package/dist/tabs/smart-tabs.js +0 -106
  291. package/dist/tabs/tab-link.js +0 -42
  292. package/dist/tabs/tab.js +0 -33
  293. package/dist/tabs/tabs.js +0 -71
  294. package/dist/tabs-ng/tabs-ng.js +0 -194
  295. package/dist/tabs-ng/tabs-ng__template.js +0 -3
  296. package/dist/tag/tag.js +0 -197
  297. package/dist/tags-input/tags-input.js +0 -482
  298. package/dist/tags-input-ng/tags-input-ng.js +0 -93
  299. package/dist/tags-list/tags-list.js +0 -95
  300. package/dist/template-ng/template-ng.js +0 -71
  301. package/dist/text/text.js +0 -36
  302. package/dist/theme-ng/theme-ng.js +0 -45
  303. package/dist/title-ng/title-ng.js +0 -114
  304. package/dist/toggle/toggle.js +0 -78
  305. package/dist/toggle-ng/toggle-ng.js +0 -18
  306. package/dist/tooltip/tooltip.js +0 -209
  307. package/dist/tooltip-ng/tooltip-ng.js +0 -104
  308. package/dist/user-agreement/service.js +0 -412
  309. package/dist/user-agreement/toolbox.eula.js +0 -3
  310. package/dist/user-agreement/user-agreement.js +0 -169
  311. package/dist/user-card/card.js +0 -19
  312. package/dist/user-card/smart-user-card-tooltip.js +0 -114
  313. package/dist/user-card/tooltip.js +0 -95
  314. package/dist/user-card/user-card.js +0 -51
  315. package/dist/user-card-ng/user-card-ng.js +0 -62
@@ -1,1357 +0,0 @@
1
- import { _ as _defineProperty, a as _extends } from '../_helpers/_rollupPluginBabelHelpers.js';
2
- import 'core-js/modules/web.dom-collections.iterator.js';
3
- import 'core-js/modules/es.string.replace.js';
4
- import React, { Component, Fragment } from 'react';
5
- import classNames from 'classnames';
6
- import PropTypes from 'prop-types';
7
- import chevronDown from '@jetbrains/icons/chevron-10px';
8
- import closeIcon from '@jetbrains/icons/close';
9
- import deepEqual from 'deep-equal';
10
- import '../dropdown/dropdown.js';
11
- import Avatar, { Size as Size$1 } from '../avatar/avatar.js';
12
- import Popup from '../popup/popup.js';
13
- import List, { ActiveItemContext } from '../list/list.js';
14
- import Input, { Size } from '../input/input.js';
15
- import Shortcuts from '../shortcuts/shortcuts.js';
16
- import Button from '../button/button.js';
17
- import joinDataTestAttributes from '../global/data-tests.js';
18
- import getUID from '../global/get-uid.js';
19
- import rerenderHOC from '../global/rerender-hoc.js';
20
- import fuzzyHighlight from '../global/fuzzy-highlight.js';
21
- import Theme from '../global/theme.js';
22
- import memoize from '../global/memoize.js';
23
- import SelectPopup from './select__popup.js';
24
- import { A as Anchor } from '../_helpers/anchor.js';
25
- import '../icon/icon.js';
26
- import 'util-deprecate';
27
- import '../icon/icon__constants.js';
28
- import '../_helpers/icon.js';
29
- import '../icon/icon__svg.js';
30
- import 'focus-visible';
31
- import '../link/clickableLink.js';
32
- import '../_helpers/button__classes.js';
33
- import '../global/url.js';
34
- import '../global/dom.js';
35
- import '../avatar/fallback-avatar.js';
36
- import 'react-dom';
37
- import '../global/schedule-raf.js';
38
- import '../tab-trap/tab-trap.js';
39
- import '../popup/position.js';
40
- import '../popup/popup.consts.js';
41
- import '../popup/popup.target.js';
42
- import '../shortcuts/core.js';
43
- import 'combokeys';
44
- import '../global/sniffer.js';
45
- import 'sniffr';
46
- import 'react-virtualized/dist/es/List';
47
- import 'react-virtualized/dist/es/AutoSizer';
48
- import 'react-virtualized/dist/es/WindowScroller';
49
- import 'react-virtualized/dist/es/CellMeasurer';
50
- import 'memoize-one';
51
- import '../global/create-stateful-context.js';
52
- import '../list/list__link.js';
53
- import '../link/link.js';
54
- import '../_helpers/link.js';
55
- import '../_helpers/list.js';
56
- import '../list/list__item.js';
57
- import '../checkbox/checkbox.js';
58
- import '@jetbrains/icons/checkmark';
59
- import '@jetbrains/icons/remove-10px';
60
- import '../_helpers/checkbox.js';
61
- import '../list/list__custom.js';
62
- import '../global/get-event-key.js';
63
- import '../list/list__title.js';
64
- import '../list/list__separator.js';
65
- import '../list/list__hint.js';
66
- import '../list/consts.js';
67
- import '../_helpers/input.js';
68
- import '../global/react-render-adapter.js';
69
- import '../global/composeRefs.js';
70
- import '@jetbrains/icons/search';
71
- import '../loader-inline/loader-inline.js';
72
- import '../_helpers/inject-styles.js';
73
- import '../global/conic-gradient.js';
74
- import 'conic-gradient';
75
- import '../global/supports-css.js';
76
- import '../global/inject-styles.js';
77
- import '../global/radial-gradient-mask.js';
78
- import '../shortcuts/shortcuts-hoc.js';
79
- import '../tags-list/tags-list.js';
80
- import '../tag/tag.js';
81
- import '../caret/caret.js';
82
- import '../text/text.js';
83
- import '../_helpers/select__filter.js';
84
-
85
- var modules_9d0de074 = {"unit":"8px","select":"select_rui_11de","value":"value_rui_11de ellipsis_rui_8bff font_rui_8bff","icons":"icons_rui_11de","toolbar":"toolbar_rui_11de","button":"button_rui_11de","buttonSpaced":"buttonSpaced_rui_11de","inputMode":"inputMode_rui_11de","buttonMode":"buttonMode_rui_11de","selectedIcon":"selectedIcon_rui_11de resetButton_rui_8bff","clearIcon":"clearIcon_rui_11de","sizeS":"sizeS_rui_11de","sizeM":"sizeM_rui_11de","sizeL":"sizeL_rui_11de","sizeFULL":"sizeFULL_rui_11de","sizeAUTO":"sizeAUTO_rui_11de","materialMode":"materialMode_rui_11de","open":"open_rui_11de","buttonContainer":"buttonContainer_rui_11de","buttonValue":"buttonValue_rui_11de ellipsis_rui_8bff","buttonValueOpen":"buttonValueOpen_rui_11de","label":"label_rui_11de","disabled":"disabled_rui_11de","selectedLabel":"selectedLabel_rui_11de","avatar":"avatar_rui_11de","popup":"popup_rui_11de","chevron":"chevron_rui_11de","chevronIcon":"chevronIcon_rui_11de"};
86
-
87
- /**
88
- * @name Select
89
- */
90
-
91
- function noop() {}
92
- /**
93
- * @enum {number}
94
- */
95
-
96
-
97
- const Type = {
98
- BUTTON: 'BUTTON',
99
- INPUT: 'INPUT',
100
- CUSTOM: 'CUSTOM',
101
- INLINE: 'INLINE',
102
- MATERIAL: 'MATERIAL',
103
- INPUT_WITHOUT_CONTROLS: 'INPUT_WITHOUT_CONTROLS'
104
- };
105
- const ICON_WIDTH = 20;
106
- const getStyle = memoize(iconsLength => ({
107
- paddingRight: iconsLength * ICON_WIDTH
108
- }));
109
-
110
- const isInputMode = type => type === Type.INPUT || type === Type.INPUT_WITHOUT_CONTROLS;
111
-
112
- function getLowerCaseLabel(item) {
113
- if (List.isItemType(List.ListProps.Type.SEPARATOR, item) || List.isItemType(List.ListProps.Type.HINT, item) || item.label == null) {
114
- return null;
115
- }
116
-
117
- return item.label.toLowerCase();
118
- }
119
-
120
- function doesLabelMatch(itemToCheck, fn) {
121
- const lowerCaseLabel = getLowerCaseLabel(itemToCheck);
122
-
123
- if (lowerCaseLabel == null) {
124
- return true;
125
- }
126
-
127
- return fn(lowerCaseLabel);
128
- }
129
-
130
- function getFilterFn(filter) {
131
- if (filter.fn) {
132
- return filter.fn;
133
- }
134
-
135
- if (filter.fuzzy) {
136
- return (itemToCheck, checkString) => doesLabelMatch(itemToCheck, lowerCaseLabel => fuzzyHighlight(checkString, lowerCaseLabel).matched);
137
- }
138
-
139
- return (itemToCheck, checkString) => doesLabelMatch(itemToCheck, lowerCaseLabel => lowerCaseLabel.indexOf(checkString) >= 0);
140
- }
141
-
142
- const buildMultipleMap = selected => selected.reduce((acc, item) => {
143
- acc[item.key] = true;
144
- return acc;
145
- }, {});
146
-
147
- function getListItems(props, state, rawFilterString) {
148
- let data = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : props.data;
149
- let filterString = rawFilterString.trim();
150
-
151
- if (isInputMode(props.type) && state.selected && filterString === state.selected.label) {
152
- filterString = ''; // ignore multiple if it is exactly the selected item
153
- }
154
-
155
- const lowerCaseString = filterString.toLowerCase();
156
- const filteredData = [];
157
- let exactMatch = false;
158
- const check = getFilterFn(props.filter);
159
-
160
- for (let i = 0; i < data.length; i++) {
161
- const item = { ...data[i]
162
- };
163
-
164
- if (check(item, lowerCaseString, data)) {
165
- exactMatch = item.label === filterString;
166
-
167
- if (props.multiple && !props.multiple.removeSelectedItems) {
168
- item.checkbox = !!state.multipleMap[item.key];
169
- }
170
-
171
- if (props.multiple && props.multiple.limit) {
172
- item.disabled = props.multiple.limit === state.selected.length && !state.selected.find(selectedItem => selectedItem.key === item.key);
173
- } // Ignore item if it's multiple and is already selected
174
-
175
-
176
- if (!(props.multiple && props.multiple.removeSelectedItems && state.multipleMap[item.key])) {
177
- filteredData.push(item);
178
- }
179
- }
180
- }
181
-
182
- let addButton = null;
183
- const {
184
- add
185
- } = props;
186
-
187
- if (add && filterString && !exactMatch || add && add.alwaysVisible) {
188
- if (!(add.regexp && !add.regexp.test(filterString)) && !(add.minlength && filterString.length < +add.minlength) || add.alwaysVisible) {
189
- let label;
190
-
191
- if (add.label) {
192
- label = typeof add.label === 'function' ? add.label(filterString) : add.label;
193
- } else {
194
- label = filterString;
195
- }
196
-
197
- addButton = {
198
- prefix: add.prefix,
199
- label,
200
- delayed: add.hasOwnProperty('delayed') ? add.delayed : true
201
- };
202
- }
203
- }
204
-
205
- return {
206
- filteredData,
207
- addButton
208
- };
209
- }
210
-
211
- function getSelectedIndex(selected, data, multiple) {
212
- const firstSelected = multiple ? selected[0] : selected;
213
-
214
- if (firstSelected == null) {
215
- return null;
216
- }
217
-
218
- for (let i = 0; i < data.length; i++) {
219
- const item = data[i];
220
-
221
- if (item.key === undefined) {
222
- continue;
223
- }
224
-
225
- if (item.key === firstSelected.key) {
226
- return i;
227
- }
228
- }
229
-
230
- return null;
231
- }
232
-
233
- const getItemLabel = _ref => {
234
- let {
235
- selectedLabel,
236
- label
237
- } = _ref;
238
- return selectedLabel != null ? selectedLabel : label;
239
- };
240
-
241
- const getValueForFilter = (selected, type, filterValue) => selected && isInputMode(type) ? getItemLabel(selected) : filterValue;
242
-
243
- function isSameSelected(prevSelected, selected) {
244
- if (!prevSelected || !selected || prevSelected.length !== selected.length) {
245
- return false;
246
- }
247
-
248
- const keysMap = selected.reduce((result, item) => {
249
- result[item.key] = true;
250
- return result;
251
- }, {});
252
- return prevSelected.every(it => keysMap[it.key]);
253
- }
254
- /**
255
- * @name Select
256
- * @constructor
257
- * @extends {Component}
258
- */
259
-
260
- /**
261
- * Displays a select.
262
- */
263
-
264
-
265
- class Select extends Component {
266
- constructor() {
267
- var _this;
268
-
269
- super(...arguments);
270
- _this = this;
271
-
272
- _defineProperty(this, "state", {
273
- data: [],
274
- shownData: [],
275
- selected: this.props.multiple ? [] : null,
276
- selectedIndex: null,
277
- filterValue: this.props.filter && this.props.filter.value || '',
278
- shortcutsEnabled: false,
279
- popupShortcuts: false,
280
- showPopup: false,
281
- prevData: this.props.data,
282
- prevSelected: null,
283
- prevMultiple: this.props.multiple,
284
- multipleMap: {},
285
- addButton: null
286
- });
287
-
288
- _defineProperty(this, "id", getUID('select-'));
289
-
290
- _defineProperty(this, "shortcutsScope", this.id);
291
-
292
- _defineProperty(this, "listId", "".concat(this.id, ":list"));
293
-
294
- _defineProperty(this, "_focusHandler", () => {
295
- this.props.onFocus();
296
- this.setState({
297
- shortcutsEnabled: true,
298
- focused: true
299
- });
300
- });
301
-
302
- _defineProperty(this, "_blurHandler", () => {
303
- this.props.onBlur();
304
-
305
- if (this._popup && this._popup.isVisible() && !this._popup.isClickingPopup) {
306
- window.setTimeout(() => {
307
- this.setState({
308
- showPopup: false
309
- });
310
- });
311
- }
312
-
313
- if (!this._popup.isClickingPopup) {
314
- this.setState({
315
- shortcutsEnabled: false,
316
- focused: false
317
- });
318
- }
319
- });
320
-
321
- _defineProperty(this, "nodeRef", el => {
322
- this.node = el;
323
- });
324
-
325
- _defineProperty(this, "_popup", null);
326
-
327
- _defineProperty(this, "onEmptyPopupEnter", () => {
328
- if (this.state.addButton) {
329
- this.addHandler();
330
- }
331
- });
332
-
333
- _defineProperty(this, "_onEnter", () => {
334
- if (this.state.addButton && this.state.shownData.length === 0) {
335
- this.addHandler();
336
- }
337
-
338
- this.props.onDone();
339
-
340
- if (!this._popup.isVisible() && this.props.allowAny) {
341
- return true;
342
- }
343
-
344
- return undefined;
345
- });
346
-
347
- _defineProperty(this, "_onEsc", event => {
348
- if (!this._popup.isVisible()) {
349
- return true;
350
- } else if (this.props.multiple || !this.props.getInitial) {
351
- return false;
352
- }
353
-
354
- const selected = {
355
- key: Math.random(),
356
- label: this.props.getInitial()
357
- };
358
- this.setState({
359
- selected,
360
- filterValue: this.getValueForFilter(selected)
361
- }, () => {
362
- this.props.onChange(selected, event);
363
- this.props.onReset();
364
- });
365
- return undefined;
366
- });
367
-
368
- _defineProperty(this, "_inputShortcutHandler", () => {
369
- if (this.state.focused && this._popup && !this._popup.isVisible()) {
370
- this._clickHandler();
371
- }
372
- });
373
-
374
- _defineProperty(this, "addHandler", () => {
375
- const value = this.filterValue();
376
-
377
- this._hidePopup();
378
-
379
- this.props.onAdd(value);
380
- });
381
-
382
- _defineProperty(this, "getLowerCaseLabel", getLowerCaseLabel);
383
-
384
- _defineProperty(this, "doesLabelMatch", doesLabelMatch);
385
-
386
- _defineProperty(this, "_clickHandler", () => {
387
- if (!this.props.disabled) {
388
- if (this.state.showPopup) {
389
- this._hidePopup();
390
- } else {
391
- this.props.onBeforeOpen();
392
-
393
- this._showPopup();
394
- }
395
- }
396
- });
397
-
398
- _defineProperty(this, "_openPopupIfClosed", () => {
399
- if (this.props.disabled || this.state.showPopup) {
400
- return;
401
- }
402
-
403
- this.props.onBeforeOpen();
404
-
405
- this._showPopup();
406
- });
407
-
408
- _defineProperty(this, "_filterChangeHandler", e => {
409
- this._setFilter(e.target.value, e);
410
- });
411
-
412
- _defineProperty(this, "_setFilter", function (value) {
413
- let event = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
414
-
415
- if (_this.isInputMode() && !_this.state.focused) {
416
- return;
417
- }
418
-
419
- if (value === _this.state.filterValue) {
420
- return;
421
- }
422
-
423
- const filterValue = value.replace(/^\s+/g, '');
424
-
425
- _this.props.onFilter(filterValue);
426
-
427
- if (_this.props.allowAny) {
428
- const fakeSelected = {
429
- key: Math.random(),
430
- label: filterValue
431
- };
432
-
433
- _this.setState({
434
- selected: filterValue === '' ? null : fakeSelected,
435
- selectedIndex: null
436
- }, () => {
437
- _this.props.onSelect(fakeSelected, event);
438
-
439
- _this.props.onChange(fakeSelected, event);
440
- });
441
- }
442
-
443
- !_this._popup.isVisible() && _this.props.onBeforeOpen();
444
-
445
- _this.setState({
446
- filterValue
447
- }, () => {
448
- _this._showPopup();
449
- });
450
- });
451
-
452
- _defineProperty(this, "_redrawPopup", () => {
453
- if (this.props.multiple) {
454
- setTimeout(() => {
455
- //setTimeout solves events order and bubbling issue
456
- this.isInputMode() && this.clearFilter();
457
-
458
- this._showPopup();
459
- }, 0);
460
- }
461
- });
462
-
463
- _defineProperty(this, "_listSelectHandler", function (selected, event) {
464
- let opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
465
- const isItem = List.isItemType.bind(null, List.ListProps.Type.ITEM);
466
- const isCustomItem = List.isItemType.bind(null, List.ListProps.Type.CUSTOM);
467
- const isSelectItemEvent = event && (event.type === 'select' || event.type === 'keydown');
468
-
469
- if (isSelectItemEvent) {
470
- event.preventDefault();
471
- }
472
-
473
- if (!isItem(selected) && !isCustomItem(selected) || selected.disabled || selected.isResetItem) {
474
- return;
475
- }
476
-
477
- if (!_this.props.multiple) {
478
- _this._hidePopup(isSelectItemEvent);
479
-
480
- _this.setState({
481
- selected,
482
- selectedIndex: _this._getSelectedIndex(selected, _this.props.data)
483
- }, () => {
484
- const newFilterValue = _this.isInputMode() && !_this.props.hideSelected ? getItemLabel(selected) : '';
485
-
486
- _this.filterValue(newFilterValue);
487
-
488
- _this.props.onFilter(newFilterValue);
489
-
490
- _this.props.onSelect(selected, event);
491
-
492
- _this.props.onChange(selected, event);
493
- });
494
- } else {
495
- const {
496
- tryKeepOpen
497
- } = opts;
498
-
499
- if (!tryKeepOpen) {
500
- _this._hidePopup(isSelectItemEvent);
501
- }
502
-
503
- if (selected.key == null) {
504
- throw new Error('Multiple selection requires each item to have the "key" property');
505
- }
506
-
507
- _this.setState(prevState => {
508
- const currentSelection = prevState.selected;
509
- let nextSelection;
510
-
511
- if (!prevState.multipleMap[selected.key]) {
512
- nextSelection = currentSelection.concat(selected);
513
- _this.props.onSelect && _this.props.onSelect(selected, event);
514
- } else {
515
- nextSelection = currentSelection.filter(item => item.key !== selected.key);
516
- _this.props.onDeselect && _this.props.onDeselect(selected);
517
- }
518
-
519
- _this.props.onChange(nextSelection, event);
520
-
521
- const nextState = {
522
- selected: nextSelection,
523
- selectedIndex: _this._getSelectedIndex(selected, _this.props.data)
524
- };
525
-
526
- if (_this.props.multiple.limit && nextSelection.length === _this.props.multiple.limit) {
527
- nextState.shownData = prevState.shownData.map(item => nextSelection.find(selectedItem => selectedItem.key === item.key) ? item : { ...item,
528
- disabled: true
529
- });
530
- }
531
-
532
- if (!prevState.multipleMap[selected.key]) {
533
- nextState.multipleMap = { ...prevState.multipleMap,
534
- [selected.key]: true
535
- };
536
- } else {
537
- const {
538
- [selected.key]: _,
539
- ...restMultipleMap
540
- } = prevState.multipleMap;
541
- nextState.multipleMap = restMultipleMap;
542
- }
543
-
544
- return nextState;
545
- }, () => {
546
- if (tryKeepOpen) {
547
- _this._redrawPopup();
548
- }
549
- });
550
- }
551
- });
552
-
553
- _defineProperty(this, "_listSelectAllHandler", function () {
554
- let isSelectAll = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
555
- const isItem = List.isItemType.bind(null, List.ListProps.Type.ITEM);
556
- const isCustomItem = List.isItemType.bind(null, List.ListProps.Type.CUSTOM);
557
-
558
- _this.setState(prevState => {
559
- const currentSelection = prevState.selected;
560
- let nextSelection;
561
-
562
- if (isSelectAll) {
563
- nextSelection = _this.props.data.filter(item => (isItem(item) || isCustomItem(item)) && !item.disabled);
564
- nextSelection.filter(item => !_this.props.selected.find(selectedItem => item.key === selectedItem.key)).forEach(item => {
565
- _this.props.onSelect && _this.props.onSelect(item);
566
- });
567
- } else {
568
- nextSelection = [];
569
- currentSelection.forEach(item => {
570
- _this.props.onDeselect && _this.props.onDeselect(item);
571
- });
572
- }
573
-
574
- _this.props.onChange(nextSelection, event);
575
-
576
- return {
577
- filterValue: '',
578
- selected: nextSelection,
579
- selectedIndex: isSelectAll ? _this._getSelectedIndex(nextSelection, _this.props.data) : null,
580
- shownData: prevState.shownData.map(item => ({ ...item,
581
- checkbox: isSelectAll
582
- })),
583
- multipleMap: isSelectAll ? buildMultipleMap(_this.props.data.filter(item => !item.disabled)) : {}
584
- };
585
- }, _this._redrawPopup);
586
- });
587
-
588
- _defineProperty(this, "_onCloseAttempt", (event, isEsc) => {
589
- if (this.isInputMode()) {
590
- if (!this.props.allowAny) {
591
- if (this.props.hideSelected || !this.state.selected || this.props.multiple) {
592
- this.clearFilter();
593
- } else if (this.state.selected) {
594
- this.filterValue(getItemLabel(this.state.selected));
595
- }
596
- }
597
- }
598
-
599
- const isTagRemoved = this.props.tags && event && event.target && event.target.matches('[data-test="ring-tag-remove"]');
600
-
601
- if (!isTagRemoved) {
602
- this._hidePopup(isEsc);
603
- }
604
- });
605
-
606
- _defineProperty(this, "clearFilter", e => {
607
- this._setFilter('', e);
608
- });
609
-
610
- _defineProperty(this, "clear", event => {
611
- if (event) {
612
- event.stopPropagation();
613
- }
614
-
615
- const empty = Select._getEmptyValue(this.props.multiple);
616
-
617
- this.setState({
618
- selected: empty,
619
- selectedIndex: null,
620
- filterValue: ''
621
- }, () => {
622
- if (this.props.onChange) {
623
- this.props.onChange(empty, event);
624
- }
625
- });
626
- return false;
627
- });
628
-
629
- _defineProperty(this, "popupRef", el => {
630
- this._popup = el;
631
- });
632
-
633
- _defineProperty(this, "buttonRef", el => {
634
- this.button = el;
635
- });
636
-
637
- _defineProperty(this, "filterRef", el => {
638
- this.filter = el;
639
- });
640
- }
641
-
642
- static _getEmptyValue(multiple) {
643
- return multiple ? [] : null;
644
- }
645
-
646
- static getDerivedStateFromProps(nextProps, prevState) {
647
- const {
648
- multiple,
649
- data,
650
- type
651
- } = nextProps;
652
- const {
653
- prevSelected,
654
- prevData,
655
- prevMultiple,
656
- filterValue
657
- } = prevState;
658
- const nextState = {
659
- prevData: data,
660
- prevSelected: nextProps.selected,
661
- prevMultiple: multiple
662
- };
663
-
664
- if ('data' in nextProps && data !== prevData) {
665
- const {
666
- filteredData,
667
- addButton
668
- } = getListItems(nextProps, prevState, filterValue, data);
669
- Object.assign(nextState, {
670
- shownData: filteredData,
671
- addButton
672
- });
673
-
674
- if (prevState.selected) {
675
- Object.assign(nextState, {
676
- selectedIndex: getSelectedIndex(prevState.selected, data, multiple),
677
- prevFilterValue: getValueForFilter(prevState.selected, type, filterValue)
678
- });
679
- }
680
- }
681
-
682
- if ('selected' in nextProps && nextProps.selected !== prevSelected) {
683
- const selected = nextProps.selected || Select._getEmptyValue(multiple);
684
-
685
- const selectedIndex = getSelectedIndex(selected, data || prevData, multiple);
686
- Object.assign(nextState, {
687
- selected,
688
- prevFilterValue: getValueForFilter(selected, type, filterValue)
689
- });
690
-
691
- if (!multiple || !isSameSelected(prevSelected, selected)) {
692
- Object.assign(nextState, {
693
- selectedIndex
694
- });
695
- }
696
- }
697
-
698
- if (prevMultiple !== multiple && !deepEqual(prevMultiple, multiple)) {
699
- nextState.selected = Select._getEmptyValue(multiple);
700
- }
701
-
702
- if (multiple && !nextState.selected) {
703
- nextState.selected = prevState.selected;
704
- }
705
-
706
- const {
707
- selected
708
- } = { ...prevState,
709
- ...nextState
710
- };
711
-
712
- if (selected && multiple) {
713
- nextState.multipleMap = buildMultipleMap(selected);
714
- const {
715
- filteredData,
716
- addButton
717
- } = getListItems(nextProps, nextState, filterValue, data);
718
- Object.assign(nextState, {
719
- shownData: filteredData,
720
- addButton
721
- });
722
- }
723
-
724
- return nextState;
725
- }
726
-
727
- componentDidUpdate(prevProps, prevState) {
728
- const {
729
- showPopup,
730
- selected
731
- } = this.state;
732
- const {
733
- onClose,
734
- onOpen,
735
- onChange,
736
- multiple
737
- } = this.props;
738
-
739
- if (prevState.showPopup && !showPopup) {
740
- onClose(selected);
741
- } else if (!prevState.showPopup && showPopup) {
742
- onOpen();
743
- }
744
-
745
- if (multiple !== prevProps.multiple && !deepEqual(multiple, prevProps.multiple)) {
746
- onChange(selected);
747
- }
748
- }
749
-
750
- getValueForFilter(selected) {
751
- return getValueForFilter(selected, this.props.type, this.state.filterValue);
752
- }
753
-
754
- _getSelectedIndex(selected, data) {
755
- return getSelectedIndex(selected, data, this.props.multiple);
756
- }
757
-
758
- _getResetOption() {
759
- const isOptionsSelected = this.state.selected && this.state.selected.length;
760
- const hasTagsResetProp = this.props.tags && this.props.tags.reset;
761
-
762
- if (!isOptionsSelected || !hasTagsResetProp) {
763
- return null;
764
- }
765
-
766
- const {
767
- reset
768
- } = this.props.tags;
769
-
770
- const resetHandler = (item, event) => {
771
- this.clear(event);
772
- this.clearFilter();
773
- this.props.onFilter('');
774
- this.setState(prevState => ({
775
- shownData: prevState.shownData.slice(reset.separator ? 2 : 1),
776
- multipleMap: {}
777
- }));
778
-
779
- this._redrawPopup();
780
- };
781
-
782
- return {
783
- isResetItem: true,
784
- separator: reset.separator,
785
- key: reset.label,
786
- rgItemType: List.ListProps.Type.CUSTOM,
787
- template: /*#__PURE__*/React.createElement(Button, {
788
- text: true,
789
- className: modules_9d0de074.button,
790
- "data-test": "ring-select-reset-tags-button"
791
- }, reset.label),
792
- glyph: reset.glyph,
793
- onClick: resetHandler
794
- };
795
- }
796
-
797
- _prependResetOption(shownData) {
798
- const resetOption = this._getResetOption();
799
-
800
- const margin = {
801
- rgItemType: List.ListProps.Type.MARGIN
802
- };
803
-
804
- if (resetOption) {
805
- const resetItems = [margin, resetOption, margin];
806
-
807
- if (resetOption.separator) {
808
- resetItems.push({
809
- rgItemType: List.ListProps.Type.SEPARATOR
810
- });
811
- }
812
-
813
- return resetItems.concat(shownData);
814
- }
815
-
816
- return shownData;
817
- }
818
-
819
- _renderPopup() {
820
- const anchorElement = this.props.targetElement || this.node;
821
- const {
822
- showPopup,
823
- shownData
824
- } = this.state;
825
-
826
- const _shownData = this._prependResetOption(shownData);
827
-
828
- let message = null;
829
-
830
- if (this.props.loading) {
831
- message = this.props.loadingMessage;
832
- } else if (!shownData.length) {
833
- message = this.props.notFoundMessage;
834
- }
835
-
836
- return /*#__PURE__*/React.createElement(SelectPopup, {
837
- data: _shownData,
838
- message: message,
839
- toolbar: showPopup && this.getToolbar(),
840
- loading: this.props.loading,
841
- activeIndex: this.state.selectedIndex,
842
- hidden: !showPopup,
843
- ref: this.popupRef,
844
- maxHeight: this.props.maxHeight,
845
- minWidth: this.props.minWidth,
846
- directions: this.props.directions,
847
- className: this.props.popupClassName,
848
- style: this.props.popupStyle,
849
- top: this.props.top,
850
- left: this.props.left,
851
- filter: this.isInputMode() ? false : this.props.filter // disable popup filter in INPUT mode
852
- ,
853
- multiple: this.props.multiple,
854
- filterValue: this.state.filterValue,
855
- anchorElement: anchorElement,
856
- onCloseAttempt: this._onCloseAttempt,
857
- onSelect: this._listSelectHandler,
858
- onSelectAll: this._listSelectAllHandler,
859
- onFilter: this._filterChangeHandler,
860
- onClear: this.clearFilter,
861
- onLoadMore: this.props.onLoadMore,
862
- isInputMode: this.isInputMode(),
863
- selected: this.state.selected,
864
- tags: this.props.tags,
865
- compact: this.props.compact,
866
- renderOptimization: this.props.renderOptimization,
867
- ringPopupTarget: this.props.ringPopupTarget,
868
- disableMoveOverflow: this.props.disableMoveOverflow,
869
- disableScrollToActive: this.props.disableScrollToActive,
870
- dir: this.props.dir,
871
- onEmptyPopupEnter: this.onEmptyPopupEnter,
872
- listId: this.listId
873
- });
874
- }
875
-
876
- _showPopup() {
877
- if (!this.node) {
878
- return;
879
- }
880
-
881
- const shownData = this.getListItems(this.filterValue());
882
- this.setState({
883
- showPopup: !!shownData.length || !this.props.allowAny,
884
- shownData
885
- });
886
- }
887
-
888
- _hidePopup(tryFocusAnchor) {
889
- if (this.node && this.state.showPopup) {
890
- this.setState({
891
- showPopup: false,
892
- filterValue: ''
893
- });
894
-
895
- if (tryFocusAnchor) {
896
- const focusableSelectExists = this.node && this.node.querySelector('[data-test~=ring-select__focus]');
897
- const restoreFocusNode = this.props.targetElement || focusableSelectExists;
898
-
899
- if (restoreFocusNode) {
900
- restoreFocusNode.focus();
901
- }
902
- }
903
- }
904
- }
905
-
906
- getToolbar() {
907
- const {
908
- hint,
909
- renderBottomToolbar
910
- } = this.props;
911
- const {
912
- prefix,
913
- label,
914
- delayed
915
- } = this.state.addButton || {};
916
- const isToolbarHasElements = this.state.addButton || hint || renderBottomToolbar;
917
-
918
- if (!isToolbarHasElements) {
919
- return null;
920
- }
921
-
922
- return /*#__PURE__*/React.createElement("div", {
923
- className: classNames({
924
- [modules_9d0de074.toolbar]: Boolean(this.state.addButton || renderBottomToolbar)
925
- }),
926
- "data-test": "ring-select-toolbar"
927
- }, renderBottomToolbar && renderBottomToolbar(), this.state.addButton && /*#__PURE__*/React.createElement(Button, {
928
- text: true,
929
- delayed: delayed,
930
- className: classNames(modules_9d0de074.button, modules_9d0de074.buttonSpaced),
931
- onClick: this.addHandler,
932
- "data-test": "ring-select-toolbar-button"
933
- }, prefix ? "".concat(prefix, " ").concat(label) : label), hint && /*#__PURE__*/React.createElement(List.ListHint, {
934
- label: hint,
935
- "data-test": "ring-select-toolbar-hint"
936
- }));
937
- }
938
-
939
- getFilterFn() {
940
- return getFilterFn(this.props.filter);
941
- }
942
-
943
- getListItems(rawFilterString, data) {
944
- const {
945
- filteredData,
946
- addButton
947
- } = getListItems(this.props, this.state, rawFilterString, data);
948
- this.setState({
949
- addButton
950
- });
951
- return filteredData;
952
- }
953
-
954
- filterValue(setValue) {
955
- if (typeof setValue === 'string' || typeof setValue === 'number') {
956
- this.setState({
957
- filterValue: setValue
958
- });
959
- } else {
960
- return this.state.filterValue;
961
- }
962
-
963
- return undefined;
964
- }
965
-
966
- isInputMode() {
967
- return isInputMode(this.props.type);
968
- }
969
-
970
- _rebuildMultipleMap(selected, multiple) {
971
- if (selected && multiple) {
972
- this.setState({
973
- multipleMap: buildMultipleMap(selected)
974
- });
975
- }
976
- }
977
-
978
- _selectionIsEmpty() {
979
- return this.props.multiple && !this.state.selected.length || !this.state.selected;
980
- }
981
-
982
- _getLabel() {
983
- return this.props.label || this.props.selectedLabel || 'Select an option';
984
- }
985
-
986
- _getSelectedString() {
987
- if (this.props.multiple) {
988
- const labels = [];
989
-
990
- for (let i = 0; i < this.state.selected.length; i++) {
991
- labels.push(getItemLabel(this.state.selected[i]));
992
- }
993
-
994
- return labels.filter(Boolean).join(', ');
995
- } else {
996
- return getItemLabel(this.state.selected);
997
- }
998
- }
999
-
1000
- _getIcons() {
1001
- const {
1002
- selected
1003
- } = this.state;
1004
- const {
1005
- disabled,
1006
- clear,
1007
- hideArrow
1008
- } = this.props;
1009
- const icons = [];
1010
-
1011
- if (selected !== null && selected !== void 0 && selected.icon) {
1012
- icons.push( /*#__PURE__*/React.createElement("button", {
1013
- title: "Toggle options popup",
1014
- type: "button",
1015
- className: modules_9d0de074.selectedIcon,
1016
- key: "selected",
1017
- disabled: this.props.disabled,
1018
- onClick: this._clickHandler,
1019
- style: {
1020
- backgroundImage: "url(".concat(selected.icon, ")")
1021
- }
1022
- }));
1023
- }
1024
-
1025
- if (clear && !disabled && !this._selectionIsEmpty()) {
1026
- icons.push( /*#__PURE__*/React.createElement(Button, {
1027
- title: "Clear selection",
1028
- "data-test": "ring-clear-select",
1029
- className: modules_9d0de074.clearIcon,
1030
- key: "close",
1031
- disabled: this.props.disabled,
1032
- onClick: this.clear,
1033
- icon: closeIcon
1034
- }));
1035
- }
1036
-
1037
- if (!hideArrow) {
1038
- icons.push( /*#__PURE__*/React.createElement(Button, {
1039
- title: "Toggle options popup",
1040
- className: modules_9d0de074.chevron,
1041
- iconClassName: modules_9d0de074.chevronIcon,
1042
- icon: chevronDown,
1043
- key: "hide",
1044
- disabled: this.props.disabled,
1045
- onClick: this._clickHandler
1046
- }));
1047
- }
1048
-
1049
- return icons;
1050
- }
1051
-
1052
- _getAvatar() {
1053
- return this.state.selected && (this.state.selected.avatar || this.state.selected.showGeneratedAvatar) && /*#__PURE__*/React.createElement(Avatar, {
1054
- className: modules_9d0de074.avatar,
1055
- url: this.state.selected.avatar,
1056
- username: this.state.selected.username,
1057
- size: Size$1.Size20
1058
- });
1059
- }
1060
-
1061
- getShortcutsMap() {
1062
- return {
1063
- enter: this._onEnter,
1064
- esc: this._onEsc,
1065
- up: this._inputShortcutHandler,
1066
- down: this._inputShortcutHandler,
1067
- right: noop,
1068
- left: noop,
1069
- 'shift+up': noop,
1070
- 'shift+down': noop,
1071
- space: noop
1072
- };
1073
- }
1074
-
1075
- renderSelect(activeItemId) {
1076
- var _this$_popup, _this$_popup$list;
1077
-
1078
- const dataTest = this.props['data-test'];
1079
- const {
1080
- shortcutsEnabled
1081
- } = this.state;
1082
- const classes = classNames(modules_9d0de074.select, 'ring-js-shortcuts', this.props.className, {
1083
- [modules_9d0de074["size".concat(this.props.size)]]: this.props.type !== Type.INLINE,
1084
- [modules_9d0de074.disabled]: this.props.disabled
1085
- });
1086
-
1087
- const icons = this._getIcons();
1088
-
1089
- const style = getStyle(icons.length);
1090
- const iconsNode = /*#__PURE__*/React.createElement("span", {
1091
- className: modules_9d0de074.icons
1092
- }, icons);
1093
- const ariaProps = this.state.showPopup ? {
1094
- 'aria-owns': this.listId,
1095
- 'aria-activedescendant': activeItemId
1096
- } : {};
1097
-
1098
- switch (this.props.type) {
1099
- case Type.INPUT_WITHOUT_CONTROLS:
1100
- case Type.INPUT:
1101
- return /*#__PURE__*/React.createElement("div", {
1102
- ref: this.nodeRef,
1103
- className: classNames(classes, modules_9d0de074.inputMode),
1104
- "data-test": joinDataTestAttributes('ring-select', dataTest)
1105
- }, shortcutsEnabled && /*#__PURE__*/React.createElement(Shortcuts, {
1106
- map: this.getShortcutsMap(),
1107
- scope: this.shortcutsScope
1108
- }), /*#__PURE__*/React.createElement(Input, _extends({}, ariaProps, {
1109
- autoComplete: "off",
1110
- id: this.props.id,
1111
- onClick: this._clickHandler,
1112
- inputRef: this.filterRef,
1113
- disabled: this.props.disabled,
1114
- value: this.state.filterValue,
1115
- borderless: this.props.type === Type.INPUT_WITHOUT_CONTROLS,
1116
- style: style,
1117
- size: Size.FULL,
1118
- onChange: this._filterChangeHandler,
1119
- onFocus: this._focusHandler,
1120
- onBlur: this._blurHandler,
1121
- label: this.props.type === Type.INPUT ? this._getLabel() : null,
1122
- placeholder: this.props.inputPlaceholder,
1123
- onKeyDown: this.props.onKeyDown,
1124
- "data-test": "ring-select__focus",
1125
- enableShortcuts: shortcutsEnabled ? Object.keys({ ...this.getShortcutsMap(),
1126
- ...((_this$_popup = this._popup) === null || _this$_popup === void 0 ? void 0 : (_this$_popup$list = _this$_popup.list) === null || _this$_popup$list === void 0 ? void 0 : _this$_popup$list.shortcutsMap)
1127
- }) : undefined
1128
- })), this.props.type === Type.INPUT && iconsNode, this._renderPopup());
1129
-
1130
- case Type.BUTTON:
1131
- return /*#__PURE__*/React.createElement("div", {
1132
- ref: this.nodeRef,
1133
- className: classNames(classes, modules_9d0de074.buttonMode),
1134
- "data-test": joinDataTestAttributes('ring-select', dataTest)
1135
- }, shortcutsEnabled && /*#__PURE__*/React.createElement(Shortcuts, {
1136
- map: this.getShortcutsMap(),
1137
- scope: this.shortcutsScope
1138
- }), /*#__PURE__*/React.createElement("div", {
1139
- className: modules_9d0de074.buttonContainer
1140
- }, /*#__PURE__*/React.createElement(Button, _extends({}, ariaProps, {
1141
- id: this.props.id,
1142
- onClick: this._clickHandler,
1143
- className: classNames(this.props.buttonClassName, modules_9d0de074.buttonValue, {
1144
- [modules_9d0de074.buttonValueOpen]: this.state.showPopup
1145
- }),
1146
- disabled: this.props.disabled,
1147
- style: style,
1148
- "data-test": "ring-select__button ring-select__focus"
1149
- }), this._getAvatar(), this._selectionIsEmpty() ? this._getLabel() : this._getSelectedString()), iconsNode), this._renderPopup());
1150
-
1151
- case Type.MATERIAL:
1152
- return /*#__PURE__*/React.createElement("div", {
1153
- ref: this.nodeRef,
1154
- className: classNames(classes, modules_9d0de074.materialMode),
1155
- "data-test": joinDataTestAttributes('ring-select', dataTest)
1156
- }, shortcutsEnabled && /*#__PURE__*/React.createElement(Shortcuts, {
1157
- map: this.getShortcutsMap(),
1158
- scope: this.shortcutsScope
1159
- }), !this._selectionIsEmpty() && this.props.selectedLabel && /*#__PURE__*/React.createElement("span", {
1160
- className: modules_9d0de074.selectedLabel
1161
- }, this.props.selectedLabel), /*#__PURE__*/React.createElement("button", _extends({}, ariaProps, {
1162
- id: this.props.id,
1163
- onClick: this._clickHandler,
1164
- type: "button",
1165
- disabled: this.props.disabled,
1166
- className: classNames(this.props.buttonClassName, modules_9d0de074.value, {
1167
- [modules_9d0de074.open]: this.state.showPopup,
1168
- [modules_9d0de074.label]: this._selectionIsEmpty()
1169
- }),
1170
- "aria-label": this._getLabel(),
1171
- style: style,
1172
- "data-test": "ring-select__focus",
1173
- ref: this.buttonRef
1174
- }), this._getAvatar(), this._selectionIsEmpty() ? this._getLabel() : this._getSelectedString()), iconsNode, this._renderPopup());
1175
-
1176
- case Type.INLINE:
1177
- return /*#__PURE__*/React.createElement("div", {
1178
- className: classes,
1179
- ref: this.nodeRef,
1180
- "data-test": joinDataTestAttributes('ring-select', dataTest)
1181
- }, shortcutsEnabled && /*#__PURE__*/React.createElement(Shortcuts, {
1182
- map: this.getShortcutsMap(),
1183
- scope: this.shortcutsScope
1184
- }), /*#__PURE__*/React.createElement(Anchor, _extends({}, ariaProps, {
1185
- id: this.props.id,
1186
- onClick: this._clickHandler,
1187
- "data-test": "ring-select__focus",
1188
- disabled: this.props.disabled,
1189
- active: this.state.showPopup
1190
- }), this._selectionIsEmpty() ? this._getLabel() : this._getSelectedString()), this._renderPopup());
1191
-
1192
- default:
1193
- if (this.props.customAnchor) {
1194
- return /*#__PURE__*/React.createElement(Fragment, null, shortcutsEnabled && /*#__PURE__*/React.createElement(Shortcuts, {
1195
- map: this.getShortcutsMap(),
1196
- scope: this.shortcutsScope
1197
- }), this.props.customAnchor({
1198
- wrapperProps: {
1199
- ref: this.nodeRef,
1200
- 'data-test': joinDataTestAttributes('ring-select', dataTest)
1201
- },
1202
- buttonProps: { ...ariaProps,
1203
- id: this.props.id,
1204
- onClick: this._clickHandler,
1205
- disabled: this.props.disabled,
1206
- children: this._selectionIsEmpty() ? this._getLabel() : this._getSelectedString(),
1207
- 'data-test': 'ring-select_focus'
1208
- },
1209
- popup: this._renderPopup()
1210
- }));
1211
- }
1212
-
1213
- return /*#__PURE__*/React.createElement("span", {
1214
- id: this.props.id,
1215
- ref: this.nodeRef,
1216
- "data-test": "ring-select"
1217
- }, this._renderPopup());
1218
- }
1219
- }
1220
-
1221
- render() {
1222
- return /*#__PURE__*/React.createElement(ActiveItemContext.Provider, null, /*#__PURE__*/React.createElement(ActiveItemContext.ValueContext.Consumer, null, activeItemId => this.renderSelect(activeItemId)));
1223
- }
1224
-
1225
- }
1226
-
1227
- _defineProperty(Select, "propTypes", {
1228
- className: PropTypes.string,
1229
- buttonClassName: PropTypes.string,
1230
- id: PropTypes.string,
1231
- multiple: PropTypes.oneOfType([PropTypes.bool, PropTypes.object]),
1232
- allowAny: PropTypes.bool,
1233
- filter: PropTypes.oneOfType([PropTypes.bool, PropTypes.object]),
1234
- getInitial: PropTypes.func,
1235
- onClose: PropTypes.func,
1236
- onOpen: PropTypes.func,
1237
- onDone: PropTypes.func,
1238
- onFilter: PropTypes.func,
1239
- onChange: PropTypes.func,
1240
- onReset: PropTypes.func,
1241
- onLoadMore: PropTypes.func,
1242
- onAdd: PropTypes.func,
1243
- onBeforeOpen: PropTypes.func,
1244
- onSelect: PropTypes.func,
1245
- onDeselect: PropTypes.func,
1246
- onFocus: PropTypes.func,
1247
- onBlur: PropTypes.func,
1248
- onKeyDown: PropTypes.func,
1249
- selected: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
1250
- data: PropTypes.array,
1251
- tags: PropTypes.object,
1252
- targetElement: PropTypes.object,
1253
- loading: PropTypes.bool,
1254
- loadingMessage: PropTypes.string,
1255
- notFoundMessage: PropTypes.string,
1256
- maxHeight: PropTypes.number,
1257
- minWidth: PropTypes.number,
1258
- directions: PropTypes.array,
1259
- popupClassName: PropTypes.string,
1260
- popupStyle: PropTypes.object,
1261
- top: PropTypes.number,
1262
- left: PropTypes.number,
1263
- renderOptimization: PropTypes.bool,
1264
- ringPopupTarget: PropTypes.string,
1265
- hint: List.ListHint.propTypes.label,
1266
- add: PropTypes.object,
1267
- type: PropTypes.oneOf(Object.values(Type)),
1268
- disabled: PropTypes.bool,
1269
- hideSelected: PropTypes.bool,
1270
- label: PropTypes.string,
1271
- renderBottomToolbar: PropTypes.func,
1272
- selectedLabel: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.node), PropTypes.node]),
1273
- inputPlaceholder: PropTypes.string,
1274
- clear: PropTypes.bool,
1275
- hideArrow: PropTypes.bool,
1276
- compact: PropTypes.bool,
1277
- size: PropTypes.oneOf(Object.values(Size)),
1278
- theme: PropTypes.string,
1279
- customAnchor: PropTypes.func,
1280
- disableMoveOverflow: PropTypes.bool,
1281
- disableScrollToActive: PropTypes.bool,
1282
- dir: PropTypes.oneOf(['ltr', 'rtl']),
1283
- 'data-test': PropTypes.string
1284
- });
1285
-
1286
- _defineProperty(Select, "defaultProps", {
1287
- data: [],
1288
- filter: false,
1289
- // enable filter (not in INPUT modes)
1290
- multiple: false,
1291
- // multiple can be an object - see demo for more information
1292
- clear: false,
1293
- // enable clear button that clears the "selected" state
1294
- loading: false,
1295
- // show a loading indicator while data is loading
1296
- disabled: false,
1297
- // disable select
1298
- loadingMessage: 'Loading...',
1299
- notFoundMessage: 'No options found',
1300
- type: Type.MATERIAL,
1301
- size: Size.M,
1302
- targetElement: null,
1303
- // element to bind the popup to (select BUTTON or INPUT by default)
1304
- hideSelected: false,
1305
- // INPUT mode: clears the input after an option is selected (useful when the selection is displayed in some custom way elsewhere)
1306
- allowAny: false,
1307
- // INPUT mode: allows any value to be entered, hides the dropdown icon
1308
- hideArrow: false,
1309
- // hide dropdown arrow icon
1310
- maxHeight: 600,
1311
- // height of the options list, including the filter and the 'Add' button
1312
- directions: [Popup.PopupProps.Directions.BOTTOM_RIGHT, Popup.PopupProps.Directions.BOTTOM_LEFT, Popup.PopupProps.Directions.TOP_LEFT, Popup.PopupProps.Directions.TOP_RIGHT],
1313
- selected: null,
1314
- // current selection (item / array of items)
1315
- label: '',
1316
- // BUTTON or INPUT label (nothing selected)
1317
- selectedLabel: '',
1318
- // BUTTON or INPUT label (something selected)
1319
- inputPlaceholder: '',
1320
- // Placeholder for input modes
1321
- hint: null,
1322
- // hint text to display under the list
1323
- shortcutsEnabled: false,
1324
- onBeforeOpen: noop,
1325
- onLoadMore: noop,
1326
- onOpen: noop,
1327
- onClose: noop,
1328
- onFilter: noop,
1329
- // search string as first argument
1330
- onFocus: noop,
1331
- onBlur: noop,
1332
- onKeyDown: noop,
1333
- onSelect: noop,
1334
- // single + multi
1335
- onDeselect: noop,
1336
- // multi
1337
- onChange: noop,
1338
- // multi
1339
- onAdd: noop,
1340
- // search string as first argument
1341
- onDone: noop,
1342
- onReset: noop,
1343
- tags: null,
1344
- onRemoveTag: noop,
1345
- ringPopupTarget: null,
1346
- dir: 'ltr'
1347
- });
1348
-
1349
- _defineProperty(Select, "Type", Type);
1350
-
1351
- _defineProperty(Select, "Size", Size);
1352
-
1353
- _defineProperty(Select, "Theme", Theme);
1354
-
1355
- const RerenderableSelect = rerenderHOC(Select);
1356
-
1357
- export { RerenderableSelect, Select as default };