@sap-ux/ui-components 1.8.2 → 1.8.4

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 (289) hide show
  1. package/dist/components/Icons.d.ts +140 -139
  2. package/dist/components/Icons.d.ts.map +1 -1
  3. package/dist/components/Icons.js +587 -582
  4. package/dist/components/Icons.js.map +1 -1
  5. package/dist/components/UIActionCallout/UIActionCallout.d.ts +61 -61
  6. package/dist/components/UIActionCallout/UIActionCallout.js +63 -63
  7. package/dist/components/UIActionCallout/UIActionCallout.scss +31 -31
  8. package/dist/components/UIActionCallout/index.d.ts +1 -1
  9. package/dist/components/UIActionCallout/index.js +17 -17
  10. package/dist/components/UIBreadcrumb/UIBreadcrumb.d.ts +23 -23
  11. package/dist/components/UIBreadcrumb/UIBreadcrumb.js +38 -38
  12. package/dist/components/UIBreadcrumb/index.d.ts +1 -1
  13. package/dist/components/UIBreadcrumb/index.js +17 -17
  14. package/dist/components/UIButton/UIActionButton.d.ts +23 -23
  15. package/dist/components/UIButton/UIActionButton.js +89 -89
  16. package/dist/components/UIButton/UIDefaultButton.d.ts +23 -23
  17. package/dist/components/UIButton/UIDefaultButton.js +229 -229
  18. package/dist/components/UIButton/UIIconButton.d.ts +37 -37
  19. package/dist/components/UIButton/UIIconButton.js +106 -106
  20. package/dist/components/UIButton/UISmallButton.d.ts +34 -34
  21. package/dist/components/UIButton/UISmallButton.js +115 -115
  22. package/dist/components/UIButton/UISplitButton.d.ts +36 -36
  23. package/dist/components/UIButton/UISplitButton.js +71 -71
  24. package/dist/components/UIButton/index.d.ts +7 -7
  25. package/dist/components/UIButton/index.js +21 -21
  26. package/dist/components/UICallout/UICallout.d.ts +37 -37
  27. package/dist/components/UICallout/UICallout.js +90 -90
  28. package/dist/components/UICallout/index.d.ts +1 -1
  29. package/dist/components/UICallout/index.js +17 -17
  30. package/dist/components/UICheckbox/UICheckbox.d.ts +34 -34
  31. package/dist/components/UICheckbox/UICheckbox.js +135 -135
  32. package/dist/components/UICheckbox/index.d.ts +1 -1
  33. package/dist/components/UICheckbox/index.js +17 -17
  34. package/dist/components/UIChoiceGroup/UIChoiceGroup.d.ts +28 -28
  35. package/dist/components/UIChoiceGroup/UIChoiceGroup.js +182 -182
  36. package/dist/components/UIChoiceGroup/index.d.ts +1 -1
  37. package/dist/components/UIChoiceGroup/index.js +17 -17
  38. package/dist/components/UIComboBox/Callout.scss +7 -7
  39. package/dist/components/UIComboBox/UIComboBox.d.ts +198 -198
  40. package/dist/components/UIComboBox/UIComboBox.js +516 -516
  41. package/dist/components/UIComboBox/UIComboBox.scss +268 -268
  42. package/dist/components/UIComboBox/_mixins.scss +32 -32
  43. package/dist/components/UIComboBox/index.d.ts +1 -1
  44. package/dist/components/UIComboBox/index.js +17 -17
  45. package/dist/components/UIContextualMenu/UIContextualMenu.d.ts +31 -31
  46. package/dist/components/UIContextualMenu/UIContextualMenu.js +123 -123
  47. package/dist/components/UIContextualMenu/UIContextualMenu.scss +211 -211
  48. package/dist/components/UIContextualMenu/UIHighlightMenuOption.d.ts +19 -19
  49. package/dist/components/UIContextualMenu/UIHighlightMenuOption.js +50 -50
  50. package/dist/components/UIContextualMenu/UIHighlightMenuOption.scss +23 -23
  51. package/dist/components/UIContextualMenu/_variables.scss +30 -30
  52. package/dist/components/UIContextualMenu/index.d.ts +2 -2
  53. package/dist/components/UIContextualMenu/index.js +18 -18
  54. package/dist/components/UIDatePicker/UIDatePicker.d.ts +49 -49
  55. package/dist/components/UIDatePicker/UIDatePicker.js +72 -72
  56. package/dist/components/UIDatePicker/UIDatePicker.scss +38 -38
  57. package/dist/components/UIDatePicker/index.d.ts +1 -1
  58. package/dist/components/UIDatePicker/index.js +17 -17
  59. package/dist/components/UIDialog/UIDialog.d.ts +116 -116
  60. package/dist/components/UIDialog/UIDialog.js +279 -279
  61. package/dist/components/UIDialog/index.d.ts +1 -1
  62. package/dist/components/UIDialog/index.js +17 -17
  63. package/dist/components/UIDropdown/UIDropdown.d.ts +90 -90
  64. package/dist/components/UIDropdown/UIDropdown.js +216 -216
  65. package/dist/components/UIDropdown/UIDropdown.scss +115 -115
  66. package/dist/components/UIDropdown/index.d.ts +2 -2
  67. package/dist/components/UIDropdown/index.js +18 -18
  68. package/dist/components/UIDropdown/utils.d.ts +8 -8
  69. package/dist/components/UIDropdown/utils.js +20 -20
  70. package/dist/components/UIFlexibleTable/RowActions.d.ts +16 -16
  71. package/dist/components/UIFlexibleTable/RowActions.js +73 -73
  72. package/dist/components/UIFlexibleTable/RowData.d.ts +16 -16
  73. package/dist/components/UIFlexibleTable/RowData.js +111 -111
  74. package/dist/components/UIFlexibleTable/UIFlexibleTable.d.ts +11 -11
  75. package/dist/components/UIFlexibleTable/UIFlexibleTable.js +280 -280
  76. package/dist/components/UIFlexibleTable/UIFlexibleTable.scss +433 -433
  77. package/dist/components/UIFlexibleTable/UIFlexibleTableActionButton.d.ts +20 -20
  78. package/dist/components/UIFlexibleTable/UIFlexibleTableActionButton.js +20 -20
  79. package/dist/components/UIFlexibleTable/UIFlexibleTableRow.d.ts +26 -26
  80. package/dist/components/UIFlexibleTable/UIFlexibleTableRow.js +165 -165
  81. package/dist/components/UIFlexibleTable/UIFlexibleTableRowActionButton.d.ts +20 -20
  82. package/dist/components/UIFlexibleTable/UIFlexibleTableRowActionButton.js +19 -19
  83. package/dist/components/UIFlexibleTable/UIFlexibleTableRowNoData.d.ts +15 -15
  84. package/dist/components/UIFlexibleTable/UIFlexibleTableRowNoData.js +28 -28
  85. package/dist/components/UIFlexibleTable/index.d.ts +5 -5
  86. package/dist/components/UIFlexibleTable/index.js +21 -21
  87. package/dist/components/UIFlexibleTable/types.d.ts +142 -142
  88. package/dist/components/UIFlexibleTable/types.js +14 -14
  89. package/dist/components/UIFlexibleTable/utils.d.ts +25 -25
  90. package/dist/components/UIFlexibleTable/utils.js +49 -49
  91. package/dist/components/UIFocusZone/UIFocusTrapZone.d.ts +22 -22
  92. package/dist/components/UIFocusZone/UIFocusTrapZone.js +33 -33
  93. package/dist/components/UIFocusZone/UIFocusZone.d.ts +23 -23
  94. package/dist/components/UIFocusZone/UIFocusZone.js +35 -35
  95. package/dist/components/UIFocusZone/index.d.ts +2 -2
  96. package/dist/components/UIFocusZone/index.js +18 -18
  97. package/dist/components/UIIcon/UIIcon.d.ts +24 -24
  98. package/dist/components/UIIcon/UIIcon.js +37 -37
  99. package/dist/components/UIIcon/UIIcon.scss +3 -3
  100. package/dist/components/UIIcon/index.d.ts +1 -1
  101. package/dist/components/UIIcon/index.js +17 -17
  102. package/dist/components/UIInput/UITextInput.d.ts +48 -48
  103. package/dist/components/UIInput/UITextInput.js +238 -238
  104. package/dist/components/UIInput/index.d.ts +1 -1
  105. package/dist/components/UIInput/index.js +17 -17
  106. package/dist/components/UILabel/UILabel.d.ts +30 -30
  107. package/dist/components/UILabel/UILabel.js +64 -64
  108. package/dist/components/UILabel/index.d.ts +1 -1
  109. package/dist/components/UILabel/index.js +17 -17
  110. package/dist/components/UILink/UILink.d.ts +25 -25
  111. package/dist/components/UILink/UILink.js +71 -71
  112. package/dist/components/UILink/index.d.ts +1 -1
  113. package/dist/components/UILink/index.js +17 -17
  114. package/dist/components/UIList/UIList.d.ts +31 -31
  115. package/dist/components/UIList/UIList.js +120 -120
  116. package/dist/components/UIList/UIList.scss +16 -16
  117. package/dist/components/UIList/index.d.ts +1 -1
  118. package/dist/components/UIList/index.js +17 -17
  119. package/dist/components/UILoader/UILoader.d.ts +27 -27
  120. package/dist/components/UILoader/UILoader.js +78 -78
  121. package/dist/components/UILoader/UILoader.scss +32 -32
  122. package/dist/components/UILoader/index.d.ts +1 -1
  123. package/dist/components/UILoader/index.js +17 -17
  124. package/dist/components/UIMessageBar/UIMessageBar.d.ts +25 -25
  125. package/dist/components/UIMessageBar/UIMessageBar.js +56 -56
  126. package/dist/components/UIMessageBar/index.d.ts +1 -1
  127. package/dist/components/UIMessageBar/index.js +17 -17
  128. package/dist/components/UIModal/UIModal.d.ts +23 -23
  129. package/dist/components/UIModal/UIModal.js +43 -43
  130. package/dist/components/UIModal/index.d.ts +1 -1
  131. package/dist/components/UIModal/index.js +17 -17
  132. package/dist/components/UIOverlay/UIOverlay.d.ts +22 -22
  133. package/dist/components/UIOverlay/UIOverlay.js +38 -38
  134. package/dist/components/UIOverlay/index.d.ts +1 -1
  135. package/dist/components/UIOverlay/index.js +17 -17
  136. package/dist/components/UIPersona/UIPersona.d.ts +27 -27
  137. package/dist/components/UIPersona/UIPersona.js +48 -48
  138. package/dist/components/UIPersona/index.d.ts +1 -1
  139. package/dist/components/UIPersona/index.js +17 -17
  140. package/dist/components/UISearchBox/UISearchBox.d.ts +22 -22
  141. package/dist/components/UISearchBox/UISearchBox.js +153 -153
  142. package/dist/components/UISearchBox/index.d.ts +3 -3
  143. package/dist/components/UISearchBox/index.js +17 -17
  144. package/dist/components/UISection/UISection.d.ts +34 -34
  145. package/dist/components/UISection/UISection.js +44 -44
  146. package/dist/components/UISection/UISection.scss +76 -76
  147. package/dist/components/UISection/UISections.d.ts +249 -249
  148. package/dist/components/UISection/UISections.js +707 -707
  149. package/dist/components/UISection/UISections.scss +62 -62
  150. package/dist/components/UISection/UISplitter.d.ts +96 -96
  151. package/dist/components/UISection/UISplitter.js +220 -220
  152. package/dist/components/UISection/UISplitter.scss +212 -212
  153. package/dist/components/UISection/_mixins.scss +14 -14
  154. package/dist/components/UISection/_variables.scss +1 -1
  155. package/dist/components/UISection/index.d.ts +3 -3
  156. package/dist/components/UISection/index.js +19 -19
  157. package/dist/components/UISeparator/UISeparator.d.ts +25 -25
  158. package/dist/components/UISeparator/UISeparator.js +65 -65
  159. package/dist/components/UISeparator/index.d.ts +1 -1
  160. package/dist/components/UISeparator/index.js +17 -17
  161. package/dist/components/UITable/UITable-helper.d.ts +79 -79
  162. package/dist/components/UITable/UITable-helper.js +259 -259
  163. package/dist/components/UITable/UITable.d.ts +212 -212
  164. package/dist/components/UITable/UITable.js +775 -775
  165. package/dist/components/UITable/UITable.scss +194 -194
  166. package/dist/components/UITable/index.d.ts +2 -2
  167. package/dist/components/UITable/index.js +18 -18
  168. package/dist/components/UITable/types.d.ts +77 -77
  169. package/dist/components/UITable/types.js +28 -28
  170. package/dist/components/UITabs/UITabs.d.ts +28 -28
  171. package/dist/components/UITabs/UITabs.js +70 -70
  172. package/dist/components/UITabs/index.d.ts +1 -1
  173. package/dist/components/UITabs/index.js +17 -17
  174. package/dist/components/UIToggle/UIToggle.d.ts +39 -39
  175. package/dist/components/UIToggle/UIToggle.js +181 -181
  176. package/dist/components/UIToggle/index.d.ts +1 -1
  177. package/dist/components/UIToggle/index.js +17 -17
  178. package/dist/components/UIToggleGroup/UIToggleGroup.d.ts +31 -31
  179. package/dist/components/UIToggleGroup/UIToggleGroup.js +136 -136
  180. package/dist/components/UIToggleGroup/UIToggleGroup.scss +13 -13
  181. package/dist/components/UIToggleGroup/UIToggleGroup.types.d.ts +22 -22
  182. package/dist/components/UIToggleGroup/UIToggleGroup.types.js +2 -2
  183. package/dist/components/UIToggleGroup/UIToggleGroupOption/UIToggleGroupOption.d.ts +25 -25
  184. package/dist/components/UIToggleGroup/UIToggleGroupOption/UIToggleGroupOption.js +77 -77
  185. package/dist/components/UIToggleGroup/UIToggleGroupOption/UIToggleGroupOption.scss +74 -74
  186. package/dist/components/UIToggleGroup/UIToggleGroupOption/UIToggleGroupOption.types.d.ts +10 -10
  187. package/dist/components/UIToggleGroup/UIToggleGroupOption/UIToggleGroupOption.types.js +2 -2
  188. package/dist/components/UIToggleGroup/UIToggleGroupOption/index.d.ts +2 -2
  189. package/dist/components/UIToggleGroup/UIToggleGroupOption/index.js +18 -18
  190. package/dist/components/UIToggleGroup/index.d.ts +2 -2
  191. package/dist/components/UIToggleGroup/index.js +18 -18
  192. package/dist/components/UIToolbar/UIToolbar.d.ts +36 -36
  193. package/dist/components/UIToolbar/UIToolbar.js +104 -104
  194. package/dist/components/UIToolbar/UIToolbar.scss +48 -48
  195. package/dist/components/UIToolbar/UIToolbarColumn.d.ts +7 -7
  196. package/dist/components/UIToolbar/UIToolbarColumn.js +33 -33
  197. package/dist/components/UIToolbar/UIToolbarDivider.d.ts +27 -27
  198. package/dist/components/UIToolbar/UIToolbarDivider.js +56 -56
  199. package/dist/components/UIToolbar/index.d.ts +3 -3
  200. package/dist/components/UIToolbar/index.js +19 -19
  201. package/dist/components/UITooltip/UITooltip.d.ts +29 -29
  202. package/dist/components/UITooltip/UITooltip.js +77 -77
  203. package/dist/components/UITooltip/UITooltipUtils.d.ts +17 -17
  204. package/dist/components/UITooltip/UITooltipUtils.js +45 -45
  205. package/dist/components/UITooltip/index.d.ts +2 -2
  206. package/dist/components/UITooltip/index.js +18 -18
  207. package/dist/components/UITranslationInput/UIFormattedText.d.ts +46 -46
  208. package/dist/components/UITranslationInput/UIFormattedText.js +121 -121
  209. package/dist/components/UITranslationInput/UILoadButton.d.ts +52 -52
  210. package/dist/components/UITranslationInput/UILoadButton.js +109 -109
  211. package/dist/components/UITranslationInput/UILoadButton.scss +14 -14
  212. package/dist/components/UITranslationInput/UITranslationButton.d.ts +14 -14
  213. package/dist/components/UITranslationInput/UITranslationButton.js +88 -88
  214. package/dist/components/UITranslationInput/UITranslationButton.types.d.ts +67 -67
  215. package/dist/components/UITranslationInput/UITranslationButton.types.js +21 -21
  216. package/dist/components/UITranslationInput/UITranslationInput.d.ts +25 -25
  217. package/dist/components/UITranslationInput/UITranslationInput.js +169 -169
  218. package/dist/components/UITranslationInput/UITranslationInput.scss +40 -40
  219. package/dist/components/UITranslationInput/UITranslationUtils.d.ts +64 -64
  220. package/dist/components/UITranslationInput/UITranslationUtils.js +168 -168
  221. package/dist/components/UITranslationInput/defaults.d.ts +2 -2
  222. package/dist/components/UITranslationInput/defaults.js +15 -15
  223. package/dist/components/UITranslationInput/index.d.ts +2 -2
  224. package/dist/components/UITranslationInput/index.js +18 -18
  225. package/dist/components/UITreeDropdown/UITreeDropdown.d.ts +265 -265
  226. package/dist/components/UITreeDropdown/UITreeDropdown.js +661 -661
  227. package/dist/components/UITreeDropdown/UITreeDropdown.scss +64 -64
  228. package/dist/components/UITreeDropdown/index.d.ts +1 -1
  229. package/dist/components/UITreeDropdown/index.js +17 -17
  230. package/dist/components/UIVerticalDivider/UIVerticalDivider.d.ts +23 -23
  231. package/dist/components/UIVerticalDivider/UIVerticalDivider.js +41 -41
  232. package/dist/components/UIVerticalDivider/index.d.ts +1 -1
  233. package/dist/components/UIVerticalDivider/index.js +17 -17
  234. package/dist/components/UIVirtualList/UIAutoSizer.d.ts +22 -22
  235. package/dist/components/UIVirtualList/UIAutoSizer.js +33 -33
  236. package/dist/components/UIVirtualList/UICellMeasurer.d.ts +23 -23
  237. package/dist/components/UIVirtualList/UICellMeasurer.js +33 -33
  238. package/dist/components/UIVirtualList/UIVirtualList.d.ts +43 -43
  239. package/dist/components/UIVirtualList/UIVirtualList.js +70 -70
  240. package/dist/components/UIVirtualList/index.d.ts +3 -3
  241. package/dist/components/UIVirtualList/index.js +19 -19
  242. package/dist/components/index.d.ts +37 -37
  243. package/dist/components/index.js +53 -53
  244. package/dist/helper/ValidationMessage/MessageWrapper.d.ts +17 -17
  245. package/dist/helper/ValidationMessage/MessageWrapper.js +34 -34
  246. package/dist/helper/ValidationMessage/MessageWrapper.scss +44 -44
  247. package/dist/helper/ValidationMessage/index.d.ts +2 -2
  248. package/dist/helper/ValidationMessage/index.js +18 -18
  249. package/dist/helper/ValidationMessage/utils.d.ts +31 -31
  250. package/dist/helper/ValidationMessage/utils.js +121 -121
  251. package/dist/index.d.ts +2 -2
  252. package/dist/index.js +18 -18
  253. package/dist/styles/_mixins.scss +15 -15
  254. package/dist/styles/_typography.scss +72 -72
  255. package/dist/styles/_variables.scss +26 -26
  256. package/dist/styles/ui-components.scss +3 -3
  257. package/dist/utilities/DeepMerge.d.ts +10 -10
  258. package/dist/utilities/DeepMerge.js +48 -48
  259. package/dist/utilities/Focus.d.ts +4 -4
  260. package/dist/utilities/Focus.js +7 -7
  261. package/dist/utilities/Id.d.ts +2 -2
  262. package/dist/utilities/Id.js +5 -5
  263. package/dist/utilities/Keys.d.ts +2 -2
  264. package/dist/utilities/Keys.js +5 -5
  265. package/dist/utilities/index.d.ts +3 -3
  266. package/dist/utilities/index.js +19 -19
  267. package/package.json +11 -12
  268. package/storybook/183.d7ada8f4159c95c30527.manager.bundle.js +891 -0
  269. package/storybook/260.1c2260a4.iframe.bundle.js +292 -0
  270. package/storybook/275.02c0af0f1d3b6c70e72d.manager.bundle.js +10 -0
  271. package/storybook/453.6e0cb2b5c2ede7af85c5.manager.bundle.js +2 -0
  272. package/storybook/{458.a8cb7c68775e3858b342.manager.bundle.js → 458.05b97cebc6fa3809e87a.manager.bundle.js} +113 -113
  273. package/storybook/{594.4816ff3f4edb5b8b0949.manager.bundle.js → 594.4d8bf523158b8a4a1ca9.manager.bundle.js} +1 -1
  274. package/storybook/{637.173c8d06.iframe.bundle.js → 637.149b545a.iframe.bundle.js} +1 -1
  275. package/storybook/{966.bc8dd3d7eec539544b33.manager.bundle.js → 966.7154988e86ea89b1942c.manager.bundle.js} +3 -3
  276. package/storybook/{987.81102a5d201c9f5a1528.manager.bundle.js → 987.7aa55d838ce2874baae8.manager.bundle.js} +3 -3
  277. package/storybook/iframe.html +17 -17
  278. package/storybook/index.html +119 -119
  279. package/storybook/{main.73db1398c1704e93ba73.manager.bundle.js → main.bbce46728b43f51e7d37.manager.bundle.js} +1 -1
  280. package/storybook/main.fdca8543.iframe.bundle.js +99 -0
  281. package/storybook/project.json +1 -1
  282. package/storybook/{runtime~main.769376b3.iframe.bundle.js → runtime~main.a1df0937.iframe.bundle.js} +1 -1
  283. package/storybook/runtime~main.e938cbae9eda438313f6.manager.bundle.js +2 -0
  284. package/storybook/275.a8ff63b0ed4a5d620142.manager.bundle.js +0 -10
  285. package/storybook/453.af4e8cc44257a27c435f.manager.bundle.js +0 -2
  286. package/storybook/713.ec72f301.iframe.bundle.js +0 -292
  287. package/storybook/756.edf22bba3c06d7815c54.manager.bundle.js +0 -891
  288. package/storybook/main.4bf0e1ff.iframe.bundle.js +0 -99
  289. package/storybook/runtime~main.eabd5638d9f3e40b3501.manager.bundle.js +0 -2
@@ -1,517 +1,517 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.UIComboBox = void 0;
7
- const react_1 = __importDefault(require("react"));
8
- const react_2 = require("@fluentui/react");
9
- const UIHighlightMenuOption_1 = require("../UIContextualMenu/UIHighlightMenuOption");
10
- require("./UIComboBox.scss");
11
- require("./Callout.scss");
12
- const UILoader_1 = require("../UILoader");
13
- const Icons_1 = require("../Icons");
14
- const ValidationMessage_1 = require("../../helper/ValidationMessage");
15
- const UILabel_1 = require("../UILabel");
16
- const UIDropdown_1 = require("../UIDropdown");
17
- /**
18
- * UIComboBox component.
19
- *
20
- * @exports
21
- * @class {UIComboBox}
22
- * @extends {React.Component<UIComboBoxProps, UIComboBoxState>}
23
- */
24
- class UIComboBox extends react_1.default.Component {
25
- /**
26
- * Initializes component properties.
27
- *
28
- * @param {UIComboBoxProps} props
29
- */
30
- constructor(props) {
31
- super(props);
32
- // Reference to fluent ui combobox
33
- this.comboBox = react_1.default.createRef();
34
- this.selectedElement = react_1.default.createRef();
35
- this.query = '';
36
- this.ignoreOpenKeys = ['Meta', 'Control', 'Shift', 'Tab', 'Alt', 'CapsLock'];
37
- this.isListHidden = false;
38
- /**
39
- * Method called on combobox option resolvation.
40
- * We should not allow to add any custom option.
41
- *
42
- * @returns {IComboBoxOption[]} Array of combobox items.
43
- */
44
- this.onResolveOptions = () => {
45
- return this.props.options;
46
- };
47
- /**
48
- * Method called on combobox item render.
49
- * We should pass query to it and avoid rendering if it is hidden.
50
- *
51
- * @param {IComboBoxOption} props Combobox item props.
52
- * @param {Function} defaultRender Combobox item default renderer.
53
- * @returns {JSX.Element | null} Element to render.
54
- */
55
- this.onRenderItem = (props, defaultRender) => {
56
- if (defaultRender && props && !props.itemType) {
57
- // Use data for custom onRender functions
58
- props.data = this.query;
59
- if (props.title === undefined) {
60
- // Apply title by default if property not provided
61
- // In older fluent-ui versions it was applied by default, but behavior changed in version '8.66.2'
62
- props.title = props.text;
63
- }
64
- const selected = props.index !== undefined && this.getCurrentSelectedIndex() === props.index;
65
- return !props.hidden ? (react_1.default.createElement("div", { key: props.key, ref: selected ? this.selectedElement : undefined, className: `${selected ? 'ts-ComboBox--selected' : ''}` }, defaultRender(props))) : null;
66
- }
67
- return null;
68
- };
69
- /**
70
- * Method to get current selected index.
71
- *
72
- * @returns {number | undefined} Selected item index.
73
- */
74
- this.getCurrentSelectedIndex = () => {
75
- const baseCombobox = this.comboBox.current;
76
- if (!baseCombobox) {
77
- return undefined;
78
- }
79
- if (baseCombobox.state.currentPendingValueValidIndex !== -1) {
80
- return baseCombobox.state.currentPendingValueValidIndex;
81
- }
82
- return baseCombobox.props.hoisted.selectedIndices ? baseCombobox.props.hoisted.selectedIndices[0] : undefined;
83
- };
84
- /**
85
- * Return a value for the placeholder.
86
- *
87
- * @returns {string}
88
- */
89
- this.getPlaceholder = () => {
90
- if (this.props.placeholder) {
91
- return this.props.placeholder;
92
- }
93
- else {
94
- // That string should be translated
95
- return 'Search or select from dropdown';
96
- }
97
- };
98
- /**
99
- * Method called on combobox item's option/label render.
100
- * We should use different componenet which support highlighting - 'ComboboxSearchOption'.
101
- *
102
- * @param {IComboBoxOption} props Combobox item props.
103
- * @param {Function} defaultRender Combobox item default renderer.
104
- * @returns {JSX.Element | null} Element to render.
105
- */
106
- this.onRenderOption = (props, defaultRender) => {
107
- if (props) {
108
- return react_1.default.createElement(UIHighlightMenuOption_1.UIHighlightMenuOption, { text: props.text, query: this.query });
109
- }
110
- return defaultRender ? defaultRender(props) : null;
111
- };
112
- this.handleChange = (event, option) => {
113
- if (option && this.props.onHandleChange) {
114
- this.props.onHandleChange(option.key);
115
- }
116
- };
117
- this.onRenderListLoading = () => {
118
- const styles = {
119
- label: {
120
- fontSize: '11px',
121
- fontWeight: 'normal'
122
- }
123
- };
124
- return (react_1.default.createElement("div", { className: "option-loading" },
125
- react_1.default.createElement(UILoader_1.UILoader, { label: "Loading", className: "uiLoaderXSmall", labelPosition: "right", styles: styles })));
126
- };
127
- this.onInput = this.onInput.bind(this);
128
- this.reserQuery = this.reserQuery.bind(this);
129
- this.onResolveOptions = this.onResolveOptions.bind(this);
130
- this.onRenderItem = this.onRenderItem.bind(this);
131
- this.onRenderOption = this.onRenderOption.bind(this);
132
- this.onKeyDown = this.onKeyDown.bind(this);
133
- this.onClick = this.onClick.bind(this);
134
- this.toggleRefresh = this.toggleRefresh.bind(this);
135
- this.handleRefreshButton = this.handleRefreshButton.bind(this);
136
- this.onPendingValueChanged = this.onPendingValueChanged.bind(this);
137
- this.onMultiSelectChange = this.onMultiSelectChange.bind(this);
138
- this.onScrollToItem = this.onScrollToItem.bind(this);
139
- this.setFocus = this.setFocus.bind(this);
140
- (0, react_2.initializeComponentRef)(this);
141
- this.state = {
142
- toggleRefresh: false
143
- };
144
- }
145
- /**
146
- *
147
- * @param {UIComboBoxProps} nextProps
148
- * @returns {boolean}
149
- */
150
- shouldComponentUpdate(nextProps) {
151
- if (nextProps.options !== this.props.options && this.query) {
152
- // Filter options
153
- this.updateHiddenOptions(nextProps.options);
154
- }
155
- return true;
156
- }
157
- /**
158
- * Updates hidden options.
159
- *
160
- * @param {IComboBoxOption[]} opts
161
- */
162
- updateHiddenOptions(opts) {
163
- this.isListHidden = true;
164
- for (const option of opts) {
165
- option.hidden = option.text.toLowerCase().indexOf(this.query) === -1;
166
- if (this.isListHidden && !option.hidden) {
167
- this.isListHidden = false;
168
- }
169
- }
170
- }
171
- /**
172
- * Method filters options and hides unmatched options.
173
- *
174
- * @param {React.FormEvent<IComboBox>} event Combobox event object
175
- */
176
- onInput(event) {
177
- this.isListHidden = false;
178
- if (event.target) {
179
- const input = event.target;
180
- this.query = input.value.trimStart().toLowerCase();
181
- // Filter options
182
- const baseCombobox = this.comboBox.current;
183
- if (baseCombobox) {
184
- this.updateHiddenOptions(baseCombobox.props.hoisted.currentOptions);
185
- }
186
- }
187
- }
188
- /**
189
- * Method opens menu when user clicks on Combobox (input or button).
190
- */
191
- onClick() {
192
- const baseCombobox = this.comboBox.current;
193
- const isOpen = baseCombobox && baseCombobox.state.isOpen;
194
- const isDisabled = this.props.disabled;
195
- if (this.props.openMenuOnClick && baseCombobox && !isOpen && !isDisabled) {
196
- baseCombobox.focus(true);
197
- }
198
- }
199
- /**
200
- * Method handles keydown event and does following.
201
- * 1. Fix for bug(in fluentui sources) regarding keyboard navigation when last item is not visible.
202
- * 2. Opens list when user enters any key.
203
- *
204
- * @param {React.FormEvent<HTMLInputElement>} event Keydown event
205
- */
206
- onKeyDown(event) {
207
- let handled = false;
208
- const baseCombobox = this.comboBox.current;
209
- const isOpen = baseCombobox && baseCombobox.state.isOpen;
210
- if (event.which === react_2.KeyCodes.down || event.which === react_2.KeyCodes.up) {
211
- handled = this._setCyclingNavigation(event.which === react_2.KeyCodes.down);
212
- }
213
- if (handled) {
214
- // Do not handle keydown of combobox
215
- event.preventDefault();
216
- event.stopPropagation();
217
- }
218
- else if (!this.ignoreOpenKeys.includes(event.key) && baseCombobox && !isOpen) {
219
- // Open dropdown list on first key press instead of showing it right after focus
220
- baseCombobox.focus(true);
221
- }
222
- }
223
- /**
224
- * Method resets search query.
225
- */
226
- reserQuery() {
227
- this.query = '';
228
- for (const option of this.props.options) {
229
- delete option.hidden;
230
- }
231
- this.isListHidden = false;
232
- this.setState({
233
- isListHidden: this.isListHidden
234
- });
235
- }
236
- /**
237
- * Method which determines what is next visible item - it is used to fix bug in fluentui sources..
238
- *
239
- * @param {number} index Current index.
240
- * @param {boolean} forward Dirrection to look up.
241
- * @returns {ComboboxItemInfo | null} Combobox item object.
242
- */
243
- getNextVisibleItem(index, forward) {
244
- const limit = this.props.options.length;
245
- while (index >= 0 && index < limit) {
246
- if (this.props.options[index] && !this.props.options[index].hidden) {
247
- return {
248
- option: this.props.options[index],
249
- index
250
- };
251
- }
252
- index = index + (forward ? 1 : -1);
253
- }
254
- return null;
255
- }
256
- /**
257
- * Method is used as fix for bug(in fluentui sources) regarding keyboard navigation when last item is not visible.
258
- *
259
- * @param {boolean} forward Dirrection to look up.
260
- * @returns {boolean} Returs true if method changed navigation.
261
- */
262
- _setCyclingNavigation(forward) {
263
- const baseCombobox = this.comboBox.current;
264
- if (baseCombobox && baseCombobox.state.currentPendingValueValidIndex >= 0) {
265
- // Check if there exists any visible item in that direction
266
- let index = baseCombobox.state.currentPendingValueValidIndex;
267
- const limit = this.props.options.length - 1;
268
- index = index + (forward ? 1 : -1);
269
- let option = this.getNextVisibleItem(index, forward);
270
- if (option) {
271
- // Item exists - no need for custom logic as we are fixing issue in base control
272
- return false;
273
- }
274
- // Item was not found - make circular navigation
275
- option = this.getNextVisibleItem(forward ? 0 : limit, forward);
276
- if (option) {
277
- // We fixed issue in base combobox control -
278
- // when last item is not visible and we navigate it
279
- baseCombobox.setState({
280
- currentPendingValueValidIndex: option.index,
281
- currentPendingValue: option.option.text
282
- });
283
- return true;
284
- }
285
- }
286
- return false;
287
- }
288
- /**
289
- * Method for property 'useComboBoxAsMenuMinWidth' - method resolves current dropdown width and updates state with latest value.
290
- * 'minWidth' from state is used to set callout size in render.
291
- */
292
- calculateMenuMinWidth() {
293
- const comboBoxWrapper = this.comboBox.current?._comboBoxWrapper.current;
294
- if (comboBoxWrapper &&
295
- this.props.useComboBoxAsMenuMinWidth &&
296
- comboBoxWrapper.clientWidth !== this.state.minWidth) {
297
- this.setState({
298
- minWidth: comboBoxWrapper.clientWidth
299
- });
300
- }
301
- }
302
- /**
303
- * Method called only when property 'highlight' is true.
304
- * Method called after each value live change - we need recheck if there is any visible item after search is done.
305
- * 1. If there no any visible item - we hide menu callout.
306
- * 2. If there is any visible item - we show menu callout.
307
- */
308
- onPendingValueChanged() {
309
- if (this.state.isListHidden !== this.isListHidden) {
310
- this.setState({
311
- isListHidden: this.isListHidden
312
- });
313
- }
314
- }
315
- /**
316
- * Public method to close menu callout if it is open.
317
- */
318
- dismissMenu() {
319
- if (this.comboBox.current) {
320
- this.comboBox.current.dismissMenu();
321
- }
322
- }
323
- /**
324
- * Public method to set the focus on the combo box.
325
- */
326
- setFocus() {
327
- if (this.comboBox.current) {
328
- this.comboBox.current.focus();
329
- }
330
- }
331
- /**
332
- * Method called only when property 'onRefresh' has been defined.
333
- * It is called when the menu Open and Dismiss to handle the toggleRefresh state.
334
- */
335
- toggleRefresh() {
336
- this.setState({
337
- toggleRefresh: !this.state.toggleRefresh
338
- });
339
- }
340
- /**
341
- * Method called only when property 'onRefresh' has been defined.
342
- * It is called when click on the refresh buttonIcon.
343
- */
344
- handleRefreshButton() {
345
- const baseCombobox = this.comboBox.current;
346
- if (this.props.useComboBoxAsMenuMinWidth) {
347
- this.calculateMenuMinWidth();
348
- }
349
- if (this.props.onRefresh) {
350
- this.props.onRefresh();
351
- baseCombobox?.focus(true);
352
- }
353
- }
354
- /**
355
- * Handle multiselect change by avoiding 'blur' event.
356
- * Problem is that blur event uses suggested value and toggles selection for it.
357
- *
358
- * @param {React.FormEvent<IComboBox>} event on change
359
- * @param {IComboBoxOption} option changed option
360
- * @param {number} index option index
361
- * @param {string} value changed value
362
- */
363
- onMultiSelectChange(event, option, index, value) {
364
- // Ignore toggle if change triggered by blur
365
- if (this.props.onChange && event.type !== 'blur') {
366
- this.props.onChange(event, option, index, value);
367
- }
368
- }
369
- /**
370
- * Method is used to fix bug in fluent ui.
371
- * Bug is for multiselect combobox - when keyboard navigation is used, then scrollbar position is not updated to make selected option visible in viewport.
372
- */
373
- onScrollToItem() {
374
- // Multi select only
375
- const selectedElement = this.selectedElement.current;
376
- if (!this.props.multiSelect || !selectedElement) {
377
- return;
378
- }
379
- const offsetParent = selectedElement.offsetParent;
380
- if (offsetParent) {
381
- const size = offsetParent.clientHeight;
382
- const scrollSize = offsetParent.scrollHeight;
383
- if (scrollSize > size) {
384
- const elementTop = selectedElement.offsetTop;
385
- const elementBottom = elementTop + selectedElement.clientHeight;
386
- const scrollTop = offsetParent.scrollTop;
387
- const scrollBottom = scrollTop + size;
388
- if (!(elementTop >= scrollTop && elementBottom <= scrollBottom)) {
389
- // Outline node is not visible in viewport
390
- const diff = elementBottom > scrollBottom ? elementBottom - scrollBottom : elementTop - scrollTop;
391
- offsetParent.scrollTop = scrollTop + diff;
392
- }
393
- }
394
- }
395
- }
396
- /**
397
- * Method returns class names string depending on props and component state.
398
- *
399
- * @param {InputValidationMessageInfo} messageInfo Error/warning message if applied
400
- * @returns {string} Class names of root combobox element.
401
- */
402
- getClassNames(messageInfo) {
403
- const { readOnly, disabled } = this.props;
404
- const errorSuffix = messageInfo.message ? ValidationMessage_1.MESSAGE_TYPES_CLASSNAME_MAP.get(messageInfo.type) : undefined;
405
- let classNames = `ts-ComboBox${messageInfo.message ? ' ts-ComboBox--' + errorSuffix : ''}`;
406
- if (readOnly && !disabled) {
407
- classNames += ' ts-ComboBox--readonly';
408
- }
409
- if (disabled) {
410
- classNames += ' ts-ComboBox--disabled';
411
- }
412
- if ((0, UIDropdown_1.isDropdownEmpty)(this.props)) {
413
- classNames += ' ts-ComboBox--empty';
414
- }
415
- return classNames;
416
- }
417
- /**
418
- * Method returns properties for Autofill component(combobox's inner compnent for text input).
419
- * Method handles 'highlight' and 'readOnly' properties.
420
- *
421
- * @returns {IAutofillProps} Properties for Autofill component.
422
- */
423
- getAutofillProps() {
424
- const { highlight, readOnly, disabled } = this.props;
425
- const autofill = {};
426
- // Handle search highligh
427
- if (highlight) {
428
- autofill.onKeyDownCapture = this.onKeyDown;
429
- }
430
- const tabIndex = 'tabIndex' in this.props ? this.props.tabIndex : undefined;
431
- // Handle readOnly property
432
- if (readOnly && !disabled) {
433
- autofill.readOnly = readOnly;
434
- autofill.tabIndex = tabIndex;
435
- // Adjust aria attributes for readonly
436
- autofill['aria-disabled'] = undefined;
437
- autofill['aria-readonly'] = true;
438
- }
439
- else if (disabled) {
440
- autofill.disabled = undefined;
441
- autofill.readOnly = true;
442
- autofill.tabIndex = tabIndex;
443
- }
444
- return autofill;
445
- }
446
- /**
447
- * @returns {JSX.Element}
448
- */
449
- render() {
450
- const messageInfo = (0, ValidationMessage_1.getMessageInfo)(this.props);
451
- let disabled = this.props.isForceEnabled ? false : !this.props.options.length;
452
- if (this.props.readOnly) {
453
- disabled = true;
454
- }
455
- return (react_1.default.createElement("div", { ref: this.props.wrapperRef, className: this.getClassNames(messageInfo) },
456
- react_1.default.createElement(react_2.ComboBox, { componentRef: this.comboBox, disabled: disabled, iconButtonProps: {
457
- iconProps: {
458
- iconName: Icons_1.UiIcons.ArrowDown
459
- }
460
- }, calloutProps: {
461
- calloutMaxHeight: 200,
462
- className: 'ts-Callout ts-Callout-Dropdown',
463
- styles: {
464
- ...(this.props.useComboBoxAsMenuMinWidth && {
465
- calloutMain: {
466
- minWidth: this.state.minWidth,
467
- display: this.state.isListHidden ? 'none' : undefined
468
- }
469
- })
470
- }
471
- }, styles: {
472
- label: {
473
- ...UILabel_1.labelGlobalStyle,
474
- ...(this.props.disabled && {
475
- opacity: '0.4'
476
- }),
477
- ...(this.props.required && {
478
- selectors: {
479
- '::after': {
480
- content: `' *'`,
481
- color: 'var(--vscode-inputValidation-errorBorder)',
482
- paddingRight: 12
483
- }
484
- }
485
- })
486
- },
487
- errorMessage: [messageInfo.style]
488
- }, ...this.props, ...(this.props.highlight && {
489
- onInput: this.onInput,
490
- onMenuDismissed: this.reserQuery,
491
- onResolveOptions: this.onResolveOptions,
492
- onRenderItem: this.onRenderItem,
493
- onRenderOption: this.onRenderOption,
494
- placeholder: this.getPlaceholder(),
495
- onPendingValueChanged: this.onPendingValueChanged
496
- }), autofill: this.getAutofillProps(), ...(this.props.useComboBoxAsMenuMinWidth && {
497
- // Use 'onMenuOpen', because there can be dynamic size of combobox
498
- onMenuOpen: this.calculateMenuMinWidth.bind(this)
499
- }), ...(this.props.openMenuOnClick && {
500
- onClick: this.onClick.bind(this)
501
- }), ...(this.props.onRefresh && {
502
- onMenuOpen: this.handleRefreshButton,
503
- onChange: this.handleChange
504
- }), ...(this.props.isLoading && {
505
- onRenderList: this.onRenderListLoading
506
- }), ...(this.props.multiSelect && {
507
- onScrollToItem: this.onScrollToItem,
508
- ...(this.props.onChange && {
509
- onChange: this.onMultiSelectChange
510
- })
511
- }), errorMessage: messageInfo.message })));
512
- }
513
- }
514
- exports.UIComboBox = UIComboBox;
515
- // Default values for public component properties
516
- UIComboBox.defaultProps = { openMenuOnClick: true };
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.UIComboBox = void 0;
7
+ const react_1 = __importDefault(require("react"));
8
+ const react_2 = require("@fluentui/react");
9
+ const UIHighlightMenuOption_1 = require("../UIContextualMenu/UIHighlightMenuOption");
10
+ require("./UIComboBox.scss");
11
+ require("./Callout.scss");
12
+ const UILoader_1 = require("../UILoader");
13
+ const Icons_1 = require("../Icons");
14
+ const ValidationMessage_1 = require("../../helper/ValidationMessage");
15
+ const UILabel_1 = require("../UILabel");
16
+ const UIDropdown_1 = require("../UIDropdown");
17
+ /**
18
+ * UIComboBox component.
19
+ *
20
+ * @exports
21
+ * @class {UIComboBox}
22
+ * @extends {React.Component<UIComboBoxProps, UIComboBoxState>}
23
+ */
24
+ class UIComboBox extends react_1.default.Component {
25
+ /**
26
+ * Initializes component properties.
27
+ *
28
+ * @param {UIComboBoxProps} props
29
+ */
30
+ constructor(props) {
31
+ super(props);
32
+ // Reference to fluent ui combobox
33
+ this.comboBox = react_1.default.createRef();
34
+ this.selectedElement = react_1.default.createRef();
35
+ this.query = '';
36
+ this.ignoreOpenKeys = ['Meta', 'Control', 'Shift', 'Tab', 'Alt', 'CapsLock'];
37
+ this.isListHidden = false;
38
+ /**
39
+ * Method called on combobox option resolvation.
40
+ * We should not allow to add any custom option.
41
+ *
42
+ * @returns {IComboBoxOption[]} Array of combobox items.
43
+ */
44
+ this.onResolveOptions = () => {
45
+ return this.props.options;
46
+ };
47
+ /**
48
+ * Method called on combobox item render.
49
+ * We should pass query to it and avoid rendering if it is hidden.
50
+ *
51
+ * @param {IComboBoxOption} props Combobox item props.
52
+ * @param {Function} defaultRender Combobox item default renderer.
53
+ * @returns {JSX.Element | null} Element to render.
54
+ */
55
+ this.onRenderItem = (props, defaultRender) => {
56
+ if (defaultRender && props && !props.itemType) {
57
+ // Use data for custom onRender functions
58
+ props.data = this.query;
59
+ if (props.title === undefined) {
60
+ // Apply title by default if property not provided
61
+ // In older fluent-ui versions it was applied by default, but behavior changed in version '8.66.2'
62
+ props.title = props.text;
63
+ }
64
+ const selected = props.index !== undefined && this.getCurrentSelectedIndex() === props.index;
65
+ return !props.hidden ? (react_1.default.createElement("div", { key: props.key, ref: selected ? this.selectedElement : undefined, className: `${selected ? 'ts-ComboBox--selected' : ''}` }, defaultRender(props))) : null;
66
+ }
67
+ return null;
68
+ };
69
+ /**
70
+ * Method to get current selected index.
71
+ *
72
+ * @returns {number | undefined} Selected item index.
73
+ */
74
+ this.getCurrentSelectedIndex = () => {
75
+ const baseCombobox = this.comboBox.current;
76
+ if (!baseCombobox) {
77
+ return undefined;
78
+ }
79
+ if (baseCombobox.state.currentPendingValueValidIndex !== -1) {
80
+ return baseCombobox.state.currentPendingValueValidIndex;
81
+ }
82
+ return baseCombobox.props.hoisted.selectedIndices ? baseCombobox.props.hoisted.selectedIndices[0] : undefined;
83
+ };
84
+ /**
85
+ * Return a value for the placeholder.
86
+ *
87
+ * @returns {string}
88
+ */
89
+ this.getPlaceholder = () => {
90
+ if (this.props.placeholder) {
91
+ return this.props.placeholder;
92
+ }
93
+ else {
94
+ // That string should be translated
95
+ return 'Search or select from dropdown';
96
+ }
97
+ };
98
+ /**
99
+ * Method called on combobox item's option/label render.
100
+ * We should use different componenet which support highlighting - 'ComboboxSearchOption'.
101
+ *
102
+ * @param {IComboBoxOption} props Combobox item props.
103
+ * @param {Function} defaultRender Combobox item default renderer.
104
+ * @returns {JSX.Element | null} Element to render.
105
+ */
106
+ this.onRenderOption = (props, defaultRender) => {
107
+ if (props) {
108
+ return react_1.default.createElement(UIHighlightMenuOption_1.UIHighlightMenuOption, { text: props.text, query: this.query });
109
+ }
110
+ return defaultRender ? defaultRender(props) : null;
111
+ };
112
+ this.handleChange = (event, option) => {
113
+ if (option && this.props.onHandleChange) {
114
+ this.props.onHandleChange(option.key);
115
+ }
116
+ };
117
+ this.onRenderListLoading = () => {
118
+ const styles = {
119
+ label: {
120
+ fontSize: '11px',
121
+ fontWeight: 'normal'
122
+ }
123
+ };
124
+ return (react_1.default.createElement("div", { className: "option-loading" },
125
+ react_1.default.createElement(UILoader_1.UILoader, { label: "Loading", className: "uiLoaderXSmall", labelPosition: "right", styles: styles })));
126
+ };
127
+ this.onInput = this.onInput.bind(this);
128
+ this.reserQuery = this.reserQuery.bind(this);
129
+ this.onResolveOptions = this.onResolveOptions.bind(this);
130
+ this.onRenderItem = this.onRenderItem.bind(this);
131
+ this.onRenderOption = this.onRenderOption.bind(this);
132
+ this.onKeyDown = this.onKeyDown.bind(this);
133
+ this.onClick = this.onClick.bind(this);
134
+ this.toggleRefresh = this.toggleRefresh.bind(this);
135
+ this.handleRefreshButton = this.handleRefreshButton.bind(this);
136
+ this.onPendingValueChanged = this.onPendingValueChanged.bind(this);
137
+ this.onMultiSelectChange = this.onMultiSelectChange.bind(this);
138
+ this.onScrollToItem = this.onScrollToItem.bind(this);
139
+ this.setFocus = this.setFocus.bind(this);
140
+ (0, react_2.initializeComponentRef)(this);
141
+ this.state = {
142
+ toggleRefresh: false
143
+ };
144
+ }
145
+ /**
146
+ *
147
+ * @param {UIComboBoxProps} nextProps
148
+ * @returns {boolean}
149
+ */
150
+ shouldComponentUpdate(nextProps) {
151
+ if (nextProps.options !== this.props.options && this.query) {
152
+ // Filter options
153
+ this.updateHiddenOptions(nextProps.options);
154
+ }
155
+ return true;
156
+ }
157
+ /**
158
+ * Updates hidden options.
159
+ *
160
+ * @param {IComboBoxOption[]} opts
161
+ */
162
+ updateHiddenOptions(opts) {
163
+ this.isListHidden = true;
164
+ for (const option of opts) {
165
+ option.hidden = option.text.toLowerCase().indexOf(this.query) === -1;
166
+ if (this.isListHidden && !option.hidden) {
167
+ this.isListHidden = false;
168
+ }
169
+ }
170
+ }
171
+ /**
172
+ * Method filters options and hides unmatched options.
173
+ *
174
+ * @param {React.FormEvent<IComboBox>} event Combobox event object
175
+ */
176
+ onInput(event) {
177
+ this.isListHidden = false;
178
+ if (event.target) {
179
+ const input = event.target;
180
+ this.query = input.value.trimStart().toLowerCase();
181
+ // Filter options
182
+ const baseCombobox = this.comboBox.current;
183
+ if (baseCombobox) {
184
+ this.updateHiddenOptions(baseCombobox.props.hoisted.currentOptions);
185
+ }
186
+ }
187
+ }
188
+ /**
189
+ * Method opens menu when user clicks on Combobox (input or button).
190
+ */
191
+ onClick() {
192
+ const baseCombobox = this.comboBox.current;
193
+ const isOpen = baseCombobox && baseCombobox.state.isOpen;
194
+ const isDisabled = this.props.disabled;
195
+ if (this.props.openMenuOnClick && baseCombobox && !isOpen && !isDisabled) {
196
+ baseCombobox.focus(true);
197
+ }
198
+ }
199
+ /**
200
+ * Method handles keydown event and does following.
201
+ * 1. Fix for bug(in fluentui sources) regarding keyboard navigation when last item is not visible.
202
+ * 2. Opens list when user enters any key.
203
+ *
204
+ * @param {React.FormEvent<HTMLInputElement>} event Keydown event
205
+ */
206
+ onKeyDown(event) {
207
+ let handled = false;
208
+ const baseCombobox = this.comboBox.current;
209
+ const isOpen = baseCombobox && baseCombobox.state.isOpen;
210
+ if (event.which === react_2.KeyCodes.down || event.which === react_2.KeyCodes.up) {
211
+ handled = this._setCyclingNavigation(event.which === react_2.KeyCodes.down);
212
+ }
213
+ if (handled) {
214
+ // Do not handle keydown of combobox
215
+ event.preventDefault();
216
+ event.stopPropagation();
217
+ }
218
+ else if (!this.ignoreOpenKeys.includes(event.key) && baseCombobox && !isOpen) {
219
+ // Open dropdown list on first key press instead of showing it right after focus
220
+ baseCombobox.focus(true);
221
+ }
222
+ }
223
+ /**
224
+ * Method resets search query.
225
+ */
226
+ reserQuery() {
227
+ this.query = '';
228
+ for (const option of this.props.options) {
229
+ delete option.hidden;
230
+ }
231
+ this.isListHidden = false;
232
+ this.setState({
233
+ isListHidden: this.isListHidden
234
+ });
235
+ }
236
+ /**
237
+ * Method which determines what is next visible item - it is used to fix bug in fluentui sources..
238
+ *
239
+ * @param {number} index Current index.
240
+ * @param {boolean} forward Dirrection to look up.
241
+ * @returns {ComboboxItemInfo | null} Combobox item object.
242
+ */
243
+ getNextVisibleItem(index, forward) {
244
+ const limit = this.props.options.length;
245
+ while (index >= 0 && index < limit) {
246
+ if (this.props.options[index] && !this.props.options[index].hidden) {
247
+ return {
248
+ option: this.props.options[index],
249
+ index
250
+ };
251
+ }
252
+ index = index + (forward ? 1 : -1);
253
+ }
254
+ return null;
255
+ }
256
+ /**
257
+ * Method is used as fix for bug(in fluentui sources) regarding keyboard navigation when last item is not visible.
258
+ *
259
+ * @param {boolean} forward Dirrection to look up.
260
+ * @returns {boolean} Returs true if method changed navigation.
261
+ */
262
+ _setCyclingNavigation(forward) {
263
+ const baseCombobox = this.comboBox.current;
264
+ if (baseCombobox && baseCombobox.state.currentPendingValueValidIndex >= 0) {
265
+ // Check if there exists any visible item in that direction
266
+ let index = baseCombobox.state.currentPendingValueValidIndex;
267
+ const limit = this.props.options.length - 1;
268
+ index = index + (forward ? 1 : -1);
269
+ let option = this.getNextVisibleItem(index, forward);
270
+ if (option) {
271
+ // Item exists - no need for custom logic as we are fixing issue in base control
272
+ return false;
273
+ }
274
+ // Item was not found - make circular navigation
275
+ option = this.getNextVisibleItem(forward ? 0 : limit, forward);
276
+ if (option) {
277
+ // We fixed issue in base combobox control -
278
+ // when last item is not visible and we navigate it
279
+ baseCombobox.setState({
280
+ currentPendingValueValidIndex: option.index,
281
+ currentPendingValue: option.option.text
282
+ });
283
+ return true;
284
+ }
285
+ }
286
+ return false;
287
+ }
288
+ /**
289
+ * Method for property 'useComboBoxAsMenuMinWidth' - method resolves current dropdown width and updates state with latest value.
290
+ * 'minWidth' from state is used to set callout size in render.
291
+ */
292
+ calculateMenuMinWidth() {
293
+ const comboBoxWrapper = this.comboBox.current?._comboBoxWrapper.current;
294
+ if (comboBoxWrapper &&
295
+ this.props.useComboBoxAsMenuMinWidth &&
296
+ comboBoxWrapper.clientWidth !== this.state.minWidth) {
297
+ this.setState({
298
+ minWidth: comboBoxWrapper.clientWidth
299
+ });
300
+ }
301
+ }
302
+ /**
303
+ * Method called only when property 'highlight' is true.
304
+ * Method called after each value live change - we need recheck if there is any visible item after search is done.
305
+ * 1. If there no any visible item - we hide menu callout.
306
+ * 2. If there is any visible item - we show menu callout.
307
+ */
308
+ onPendingValueChanged() {
309
+ if (this.state.isListHidden !== this.isListHidden) {
310
+ this.setState({
311
+ isListHidden: this.isListHidden
312
+ });
313
+ }
314
+ }
315
+ /**
316
+ * Public method to close menu callout if it is open.
317
+ */
318
+ dismissMenu() {
319
+ if (this.comboBox.current) {
320
+ this.comboBox.current.dismissMenu();
321
+ }
322
+ }
323
+ /**
324
+ * Public method to set the focus on the combo box.
325
+ */
326
+ setFocus() {
327
+ if (this.comboBox.current) {
328
+ this.comboBox.current.focus();
329
+ }
330
+ }
331
+ /**
332
+ * Method called only when property 'onRefresh' has been defined.
333
+ * It is called when the menu Open and Dismiss to handle the toggleRefresh state.
334
+ */
335
+ toggleRefresh() {
336
+ this.setState({
337
+ toggleRefresh: !this.state.toggleRefresh
338
+ });
339
+ }
340
+ /**
341
+ * Method called only when property 'onRefresh' has been defined.
342
+ * It is called when click on the refresh buttonIcon.
343
+ */
344
+ handleRefreshButton() {
345
+ const baseCombobox = this.comboBox.current;
346
+ if (this.props.useComboBoxAsMenuMinWidth) {
347
+ this.calculateMenuMinWidth();
348
+ }
349
+ if (this.props.onRefresh) {
350
+ this.props.onRefresh();
351
+ baseCombobox?.focus(true);
352
+ }
353
+ }
354
+ /**
355
+ * Handle multiselect change by avoiding 'blur' event.
356
+ * Problem is that blur event uses suggested value and toggles selection for it.
357
+ *
358
+ * @param {React.FormEvent<IComboBox>} event on change
359
+ * @param {IComboBoxOption} option changed option
360
+ * @param {number} index option index
361
+ * @param {string} value changed value
362
+ */
363
+ onMultiSelectChange(event, option, index, value) {
364
+ // Ignore toggle if change triggered by blur
365
+ if (this.props.onChange && event.type !== 'blur') {
366
+ this.props.onChange(event, option, index, value);
367
+ }
368
+ }
369
+ /**
370
+ * Method is used to fix bug in fluent ui.
371
+ * Bug is for multiselect combobox - when keyboard navigation is used, then scrollbar position is not updated to make selected option visible in viewport.
372
+ */
373
+ onScrollToItem() {
374
+ // Multi select only
375
+ const selectedElement = this.selectedElement.current;
376
+ if (!this.props.multiSelect || !selectedElement) {
377
+ return;
378
+ }
379
+ const offsetParent = selectedElement.offsetParent;
380
+ if (offsetParent) {
381
+ const size = offsetParent.clientHeight;
382
+ const scrollSize = offsetParent.scrollHeight;
383
+ if (scrollSize > size) {
384
+ const elementTop = selectedElement.offsetTop;
385
+ const elementBottom = elementTop + selectedElement.clientHeight;
386
+ const scrollTop = offsetParent.scrollTop;
387
+ const scrollBottom = scrollTop + size;
388
+ if (!(elementTop >= scrollTop && elementBottom <= scrollBottom)) {
389
+ // Outline node is not visible in viewport
390
+ const diff = elementBottom > scrollBottom ? elementBottom - scrollBottom : elementTop - scrollTop;
391
+ offsetParent.scrollTop = scrollTop + diff;
392
+ }
393
+ }
394
+ }
395
+ }
396
+ /**
397
+ * Method returns class names string depending on props and component state.
398
+ *
399
+ * @param {InputValidationMessageInfo} messageInfo Error/warning message if applied
400
+ * @returns {string} Class names of root combobox element.
401
+ */
402
+ getClassNames(messageInfo) {
403
+ const { readOnly, disabled } = this.props;
404
+ const errorSuffix = messageInfo.message ? ValidationMessage_1.MESSAGE_TYPES_CLASSNAME_MAP.get(messageInfo.type) : undefined;
405
+ let classNames = `ts-ComboBox${messageInfo.message ? ' ts-ComboBox--' + errorSuffix : ''}`;
406
+ if (readOnly && !disabled) {
407
+ classNames += ' ts-ComboBox--readonly';
408
+ }
409
+ if (disabled) {
410
+ classNames += ' ts-ComboBox--disabled';
411
+ }
412
+ if ((0, UIDropdown_1.isDropdownEmpty)(this.props)) {
413
+ classNames += ' ts-ComboBox--empty';
414
+ }
415
+ return classNames;
416
+ }
417
+ /**
418
+ * Method returns properties for Autofill component(combobox's inner compnent for text input).
419
+ * Method handles 'highlight' and 'readOnly' properties.
420
+ *
421
+ * @returns {IAutofillProps} Properties for Autofill component.
422
+ */
423
+ getAutofillProps() {
424
+ const { highlight, readOnly, disabled } = this.props;
425
+ const autofill = {};
426
+ // Handle search highligh
427
+ if (highlight) {
428
+ autofill.onKeyDownCapture = this.onKeyDown;
429
+ }
430
+ const tabIndex = 'tabIndex' in this.props ? this.props.tabIndex : undefined;
431
+ // Handle readOnly property
432
+ if (readOnly && !disabled) {
433
+ autofill.readOnly = readOnly;
434
+ autofill.tabIndex = tabIndex;
435
+ // Adjust aria attributes for readonly
436
+ autofill['aria-disabled'] = undefined;
437
+ autofill['aria-readonly'] = true;
438
+ }
439
+ else if (disabled) {
440
+ autofill.disabled = undefined;
441
+ autofill.readOnly = true;
442
+ autofill.tabIndex = tabIndex;
443
+ }
444
+ return autofill;
445
+ }
446
+ /**
447
+ * @returns {JSX.Element}
448
+ */
449
+ render() {
450
+ const messageInfo = (0, ValidationMessage_1.getMessageInfo)(this.props);
451
+ let disabled = this.props.isForceEnabled ? false : !this.props.options.length;
452
+ if (this.props.readOnly) {
453
+ disabled = true;
454
+ }
455
+ return (react_1.default.createElement("div", { ref: this.props.wrapperRef, className: this.getClassNames(messageInfo) },
456
+ react_1.default.createElement(react_2.ComboBox, { componentRef: this.comboBox, disabled: disabled, iconButtonProps: {
457
+ iconProps: {
458
+ iconName: Icons_1.UiIcons.ArrowDown
459
+ }
460
+ }, calloutProps: {
461
+ calloutMaxHeight: 200,
462
+ className: 'ts-Callout ts-Callout-Dropdown',
463
+ styles: {
464
+ ...(this.props.useComboBoxAsMenuMinWidth && {
465
+ calloutMain: {
466
+ minWidth: this.state.minWidth,
467
+ display: this.state.isListHidden ? 'none' : undefined
468
+ }
469
+ })
470
+ }
471
+ }, styles: {
472
+ label: {
473
+ ...UILabel_1.labelGlobalStyle,
474
+ ...(this.props.disabled && {
475
+ opacity: '0.4'
476
+ }),
477
+ ...(this.props.required && {
478
+ selectors: {
479
+ '::after': {
480
+ content: `' *'`,
481
+ color: 'var(--vscode-inputValidation-errorBorder)',
482
+ paddingRight: 12
483
+ }
484
+ }
485
+ })
486
+ },
487
+ errorMessage: [messageInfo.style]
488
+ }, ...this.props, ...(this.props.highlight && {
489
+ onInput: this.onInput,
490
+ onMenuDismissed: this.reserQuery,
491
+ onResolveOptions: this.onResolveOptions,
492
+ onRenderItem: this.onRenderItem,
493
+ onRenderOption: this.onRenderOption,
494
+ placeholder: this.getPlaceholder(),
495
+ onPendingValueChanged: this.onPendingValueChanged
496
+ }), autofill: this.getAutofillProps(), ...(this.props.useComboBoxAsMenuMinWidth && {
497
+ // Use 'onMenuOpen', because there can be dynamic size of combobox
498
+ onMenuOpen: this.calculateMenuMinWidth.bind(this)
499
+ }), ...(this.props.openMenuOnClick && {
500
+ onClick: this.onClick.bind(this)
501
+ }), ...(this.props.onRefresh && {
502
+ onMenuOpen: this.handleRefreshButton,
503
+ onChange: this.handleChange
504
+ }), ...(this.props.isLoading && {
505
+ onRenderList: this.onRenderListLoading
506
+ }), ...(this.props.multiSelect && {
507
+ onScrollToItem: this.onScrollToItem,
508
+ ...(this.props.onChange && {
509
+ onChange: this.onMultiSelectChange
510
+ })
511
+ }), errorMessage: messageInfo.message })));
512
+ }
513
+ }
514
+ exports.UIComboBox = UIComboBox;
515
+ // Default values for public component properties
516
+ UIComboBox.defaultProps = { openMenuOnClick: true };
517
517
  //# sourceMappingURL=UIComboBox.js.map