custom-electron-titlebar 3.2.6 → 3.2.10

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 (239) hide show
  1. package/.github/FUNDING.yml +1 -0
  2. package/README.md +15 -24
  3. package/_config.yml +1 -0
  4. package/{lib → build}/browser/browser.d.ts +0 -0
  5. package/{lib → build}/browser/browser.js +0 -0
  6. package/{lib → build}/browser/browser.js.map +0 -0
  7. package/{lib → build}/browser/event.d.ts +0 -0
  8. package/{lib → build}/browser/event.js +2 -1
  9. package/{lib → build}/browser/event.js.map +1 -1
  10. package/{lib → build}/browser/iframe.d.ts +0 -0
  11. package/{lib → build}/browser/iframe.js +0 -0
  12. package/{lib → build}/browser/iframe.js.map +0 -0
  13. package/{lib → build}/browser/keyboardEvent.d.ts +0 -0
  14. package/{lib → build}/browser/keyboardEvent.js +0 -0
  15. package/{lib → build}/browser/keyboardEvent.js.map +0 -0
  16. package/{lib → build}/browser/mouseEvent.d.ts +0 -0
  17. package/{lib → build}/browser/mouseEvent.js +0 -0
  18. package/{lib → build}/browser/mouseEvent.js.map +0 -0
  19. package/{lib → build}/common/arrays.d.ts +0 -0
  20. package/{lib → build}/common/arrays.js +0 -0
  21. package/{lib → build}/common/arrays.js.map +0 -0
  22. package/{lib → build}/common/async.d.ts +0 -0
  23. package/{lib → build}/common/async.js +0 -0
  24. package/{lib → build}/common/async.js.map +0 -0
  25. package/{lib → build}/common/charCode.d.ts +0 -0
  26. package/{lib → build}/common/charCode.js +0 -0
  27. package/{lib → build}/common/charCode.js.map +0 -0
  28. package/{lib → build}/common/color.d.ts +0 -0
  29. package/{lib → build}/common/color.js +0 -0
  30. package/{lib → build}/common/color.js.map +0 -0
  31. package/{lib → build}/common/dom.d.ts +0 -0
  32. package/{lib → build}/common/dom.js +16 -14
  33. package/build/common/dom.js.map +1 -0
  34. package/{lib → build}/common/event.d.ts +0 -0
  35. package/{lib → build}/common/event.js +1 -1
  36. package/build/common/event.js.map +1 -0
  37. package/{lib → build}/common/iterator.d.ts +0 -0
  38. package/{lib → build}/common/iterator.js +0 -0
  39. package/{lib → build}/common/iterator.js.map +0 -0
  40. package/{lib → build}/common/keyCodes.d.ts +0 -0
  41. package/{lib → build}/common/keyCodes.js +0 -0
  42. package/{lib → build}/common/keyCodes.js.map +0 -0
  43. package/{lib → build}/common/lifecycle.d.ts +0 -0
  44. package/{lib → build}/common/lifecycle.js +0 -0
  45. package/{lib → build}/common/lifecycle.js.map +0 -0
  46. package/{lib → build}/common/linkedList.d.ts +0 -0
  47. package/{lib → build}/common/linkedList.js +0 -0
  48. package/{lib → build}/common/linkedList.js.map +0 -0
  49. package/{lib → build}/common/platform.d.ts +0 -0
  50. package/{lib → build}/common/platform.js +0 -0
  51. package/{lib → build}/common/platform.js.map +0 -0
  52. package/{lib → build}/index.d.ts +0 -0
  53. package/{lib → build}/index.js +0 -0
  54. package/{lib → build}/index.js.map +0 -0
  55. package/{lib → build}/menu/menu.d.ts +0 -0
  56. package/{lib → build}/menu/menu.js +38 -38
  57. package/build/menu/menu.js.map +1 -0
  58. package/{lib → build}/menu/menuitem.d.ts +10 -2
  59. package/{lib → build}/menu/menuitem.js +70 -34
  60. package/build/menu/menuitem.js.map +1 -0
  61. package/{lib → build}/menubar.d.ts +0 -0
  62. package/{lib → build}/menubar.js +29 -30
  63. package/build/menubar.js.map +1 -0
  64. package/{lib → build}/themebar.d.ts +0 -0
  65. package/{lib → build}/themebar.js +2 -2
  66. package/build/themebar.js.map +1 -0
  67. package/{lib → build}/titlebar.d.ts +0 -0
  68. package/{lib → build}/titlebar.js +61 -58
  69. package/build/titlebar.js.map +1 -0
  70. package/package.json +13 -7
  71. package/lib/common/dom.js.map +0 -1
  72. package/lib/common/enableNativeMenuCommands.d.ts +0 -1
  73. package/lib/common/enableNativeMenuCommands.js +0 -32
  74. package/lib/common/enableNativeMenuCommands.js.map +0 -1
  75. package/lib/common/event.js.map +0 -1
  76. package/lib/main.d.ts +0 -1
  77. package/lib/main.js +0 -14
  78. package/lib/main.js.map +0 -1
  79. package/lib/menu/menu.js.map +0 -1
  80. package/lib/menu/menuitem.js.map +0 -1
  81. package/lib/menubar.js.map +0 -1
  82. package/lib/themebar.js.map +0 -1
  83. package/lib/titlebar.js.map +0 -1
  84. package/lib/vs/base/browser/browser.js +0 -150
  85. package/lib/vs/base/browser/canIUse.js +0 -58
  86. package/lib/vs/base/browser/codicons.js +0 -37
  87. package/lib/vs/base/browser/contextmenu.js +0 -9
  88. package/lib/vs/base/browser/dnd.js +0 -113
  89. package/lib/vs/base/browser/dom.js +0 -1417
  90. package/lib/vs/base/browser/event.js +0 -36
  91. package/lib/vs/base/browser/fastDomNode.js +0 -265
  92. package/lib/vs/base/browser/formattedTextRenderer.js +0 -248
  93. package/lib/vs/base/browser/globalMouseMoveMonitor.js +0 -137
  94. package/lib/vs/base/browser/history.js +0 -9
  95. package/lib/vs/base/browser/iframe.js +0 -126
  96. package/lib/vs/base/browser/keyboardEvent.js +0 -599
  97. package/lib/vs/base/browser/mouseEvent.js +0 -155
  98. package/lib/vs/base/browser/touch.js +0 -315
  99. package/lib/vs/base/browser/ui/actionbar/actionViewItems.js +0 -397
  100. package/lib/vs/base/browser/ui/actionbar/actionbar.js +0 -583
  101. package/lib/vs/base/browser/ui/checkbox/checkbox.js +0 -251
  102. package/lib/vs/base/browser/ui/codicons/codiconLabel.js +0 -31
  103. package/lib/vs/base/browser/ui/codicons/codiconStyles.js +0 -47
  104. package/lib/vs/base/browser/ui/contextview/contextview.js +0 -367
  105. package/lib/vs/base/browser/ui/dropdown/dropdown.js +0 -256
  106. package/lib/vs/base/browser/ui/dropdown/dropdownActionViewItem.js +0 -120
  107. package/lib/vs/base/browser/ui/keybindingLabel/keybindingLabel.js +0 -118
  108. package/lib/vs/base/browser/ui/list/list.js +0 -54
  109. package/lib/vs/base/browser/ui/list/listPaging.js +0 -322
  110. package/lib/vs/base/browser/ui/list/listView.js +0 -1388
  111. package/lib/vs/base/browser/ui/list/listWidget.js +0 -1709
  112. package/lib/vs/base/browser/ui/list/rangeMap.js +0 -223
  113. package/lib/vs/base/browser/ui/list/rowCache.js +0 -113
  114. package/lib/vs/base/browser/ui/list/splice.js +0 -23
  115. package/lib/vs/base/browser/ui/menu/menu.js +0 -1371
  116. package/lib/vs/base/browser/ui/menu/menubar.js +0 -1139
  117. package/lib/vs/base/browser/ui/scrollbar/abstractScrollbar.js +0 -278
  118. package/lib/vs/base/browser/ui/scrollbar/horizontalScrollbar.js +0 -115
  119. package/lib/vs/base/browser/ui/scrollbar/scrollableElement.js +0 -646
  120. package/lib/vs/base/browser/ui/scrollbar/scrollableElementOptions.js +0 -9
  121. package/lib/vs/base/browser/ui/scrollbar/scrollbarArrow.js +0 -106
  122. package/lib/vs/base/browser/ui/scrollbar/scrollbarState.js +0 -184
  123. package/lib/vs/base/browser/ui/scrollbar/scrollbarVisibilityController.js +0 -116
  124. package/lib/vs/base/browser/ui/scrollbar/verticalScrollbar.js +0 -114
  125. package/lib/vs/base/browser/ui/selectBox/selectBox.js +0 -85
  126. package/lib/vs/base/browser/ui/selectBox/selectBoxCustom.js +0 -985
  127. package/lib/vs/base/browser/ui/selectBox/selectBoxNative.js +0 -188
  128. package/lib/vs/base/browser/ui/toolbar/toolbar.js +0 -206
  129. package/lib/vs/base/browser/ui/widget.js +0 -69
  130. package/lib/vs/base/common/actions.js +0 -224
  131. package/lib/vs/base/common/amd.js +0 -31
  132. package/lib/vs/base/common/arrays.js +0 -641
  133. package/lib/vs/base/common/assert.js +0 -21
  134. package/lib/vs/base/common/async.js +0 -966
  135. package/lib/vs/base/common/buffer.js +0 -250
  136. package/lib/vs/base/common/cache.js +0 -40
  137. package/lib/vs/base/common/cancellation.js +0 -146
  138. package/lib/vs/base/common/charCode.js +0 -9
  139. package/lib/vs/base/common/codicon.js +0 -136
  140. package/lib/vs/base/common/codicons.js +0 -1378
  141. package/lib/vs/base/common/collections.js +0 -133
  142. package/lib/vs/base/common/color.js +0 -716
  143. package/lib/vs/base/common/comparers.js +0 -280
  144. package/lib/vs/base/common/console.js +0 -142
  145. package/lib/vs/base/common/date.js +0 -113
  146. package/lib/vs/base/common/decorators.js +0 -169
  147. package/lib/vs/base/common/errorMessage.js +0 -93
  148. package/lib/vs/base/common/errors.js +0 -213
  149. package/lib/vs/base/common/errorsWithActions.js +0 -28
  150. package/lib/vs/base/common/event.js +0 -873
  151. package/lib/vs/base/common/extpath.js +0 -401
  152. package/lib/vs/base/common/filters.js +0 -948
  153. package/lib/vs/base/common/functional.js +0 -28
  154. package/lib/vs/base/common/fuzzyScorer.js +0 -811
  155. package/lib/vs/base/common/glob.js +0 -696
  156. package/lib/vs/base/common/hash.js +0 -359
  157. package/lib/vs/base/common/history.js +0 -116
  158. package/lib/vs/base/common/htmlContent.js +0 -162
  159. package/lib/vs/base/common/idGenerator.js +0 -25
  160. package/lib/vs/base/common/iterator.js +0 -118
  161. package/lib/vs/base/common/json.js +0 -1624
  162. package/lib/vs/base/common/jsonEdit.js +0 -272
  163. package/lib/vs/base/common/jsonErrorMessages.js +0 -69
  164. package/lib/vs/base/common/jsonFormatter.js +0 -316
  165. package/lib/vs/base/common/jsonSchema.js +0 -9
  166. package/lib/vs/base/common/keyCodes.js +0 -591
  167. package/lib/vs/base/common/keybindingLabels.js +0 -231
  168. package/lib/vs/base/common/keybindingParser.js +0 -142
  169. package/lib/vs/base/common/labels.js +0 -430
  170. package/lib/vs/base/common/lazy.js +0 -71
  171. package/lib/vs/base/common/lifecycle.js +0 -308
  172. package/lib/vs/base/common/linkedList.js +0 -152
  173. package/lib/vs/base/common/linkedText.js +0 -73
  174. package/lib/vs/base/common/map.js +0 -1108
  175. package/lib/vs/base/common/marshalling.js +0 -80
  176. package/lib/vs/base/common/mime.js +0 -321
  177. package/lib/vs/base/common/navigator.js +0 -50
  178. package/lib/vs/base/common/network.js +0 -160
  179. package/lib/vs/base/common/normalization.js +0 -78
  180. package/lib/vs/base/common/numbers.js +0 -55
  181. package/lib/vs/base/common/objects.js +0 -268
  182. package/lib/vs/base/common/paging.js +0 -190
  183. package/lib/vs/base/common/parsers.js +0 -78
  184. package/lib/vs/base/common/path.js +0 -1550
  185. package/lib/vs/base/common/platform.js +0 -245
  186. package/lib/vs/base/common/process.js +0 -52
  187. package/lib/vs/base/common/processes.js +0 -32
  188. package/lib/vs/base/common/range.js +0 -79
  189. package/lib/vs/base/common/resourceTree.js +0 -185
  190. package/lib/vs/base/common/resources.js +0 -421
  191. package/lib/vs/base/common/scanCode.js +0 -1472
  192. package/lib/vs/base/common/scrollable.js +0 -397
  193. package/lib/vs/base/common/search.js +0 -55
  194. package/lib/vs/base/common/sequence.js +0 -64
  195. package/lib/vs/base/common/severity.js +0 -55
  196. package/lib/vs/base/common/skipList.js +0 -234
  197. package/lib/vs/base/common/stopwatch.js +0 -45
  198. package/lib/vs/base/common/stream.js +0 -418
  199. package/lib/vs/base/common/strings.js +0 -1283
  200. package/lib/vs/base/common/styler.js +0 -9
  201. package/lib/vs/base/common/types.js +0 -296
  202. package/lib/vs/base/common/uint.js +0 -46
  203. package/lib/vs/base/common/uri.js +0 -756
  204. package/lib/vs/base/common/uriIpc.js +0 -154
  205. package/lib/vs/base/common/uuid.js +0 -70
  206. package/lib/vs/nls.mock.js +0 -31
  207. package/lib/vs/platform/actions/browser/menuEntryActionViewItem.js +0 -342
  208. package/lib/vs/platform/actions/common/actions.js +0 -456
  209. package/lib/vs/platform/actions/common/menuService.js +0 -194
  210. package/lib/vs/platform/clipboard/browser/clipboardService.js +0 -99
  211. package/lib/vs/platform/clipboard/common/clipboardService.js +0 -14
  212. package/lib/vs/platform/contextkey/common/contextkey.js +0 -1210
  213. package/lib/vs/platform/contextkey/common/contextkeys.js +0 -23
  214. package/lib/vs/platform/contextview/browser/contextView.js +0 -15
  215. package/lib/vs/platform/contextview/browser/contextViewService.js +0 -96
  216. package/lib/vs/platform/environment/common/argv.js +0 -9
  217. package/lib/vs/platform/environment/common/environment.js +0 -15
  218. package/lib/vs/platform/instantiation/common/descriptors.js +0 -25
  219. package/lib/vs/platform/instantiation/common/extensions.js +0 -26
  220. package/lib/vs/platform/instantiation/common/graph.js +0 -93
  221. package/lib/vs/platform/instantiation/common/instantiation.js +0 -84
  222. package/lib/vs/platform/instantiation/common/instantiationService.js +0 -361
  223. package/lib/vs/platform/instantiation/common/serviceCollection.js +0 -39
  224. package/lib/vs/platform/keybinding/common/baseResolvedKeybinding.js +0 -73
  225. package/lib/vs/platform/keybinding/common/keybinding.js +0 -14
  226. package/lib/vs/platform/keybinding/common/keybindingResolver.js +0 -391
  227. package/lib/vs/platform/keybinding/common/keybindingsRegistry.js +0 -229
  228. package/lib/vs/platform/keybinding/common/resolvedKeybindingItem.js +0 -47
  229. package/lib/vs/platform/keybinding/common/usLayoutResolvedKeybinding.js +0 -160
  230. package/lib/vs/platform/layout/browser/layoutService.js +0 -14
  231. package/lib/vs/platform/menubar/common/menubar.js +0 -34
  232. package/lib/vs/platform/registry/common/platform.js +0 -38
  233. package/lib/vs/platform/theme/browser/checkbox.js +0 -32
  234. package/lib/vs/platform/theme/common/colorRegistry.js +0 -1154
  235. package/lib/vs/platform/theme/common/styler.js +0 -290
  236. package/lib/vs/platform/theme/common/theme.js +0 -21
  237. package/lib/vs/platform/theme/common/themeService.js +0 -176
  238. package/lib/vs/platform/theme/common/tokenClassificationRegistry.js +0 -540
  239. package/lib/vs/platform/theme/test/common/testThemeService.js +0 -98
@@ -1,985 +0,0 @@
1
- "use strict";
2
- /*---------------------------------------------------------------------------------------------
3
- * Copyright (c) Microsoft Corporation. All rights reserved.
4
- * Licensed under the MIT License. See License.txt in the project root for license information.
5
- *--------------------------------------------------------------------------------------------*/
6
-
7
- Object.defineProperty(exports, "__esModule", {
8
- value: true
9
- });
10
- exports.SelectBoxList = void 0;
11
-
12
- require("../../../../css!./selectBoxCustom");
13
-
14
- const lifecycle_1 = require("../../../common/lifecycle");
15
-
16
- const event_1 = require("../../../common/event");
17
-
18
- const keyCodes_1 = require("../../../common/keyCodes");
19
-
20
- const keyboardEvent_1 = require("../../keyboardEvent");
21
-
22
- const dom = require("../../dom");
23
-
24
- const arrays = require("../../../common/arrays");
25
-
26
- const listWidget_1 = require("../list/listWidget");
27
-
28
- const event_2 = require("../../event");
29
-
30
- const platform_1 = require("../../../common/platform");
31
-
32
- const nls_1 = require("../../../../nls");
33
-
34
- const $ = dom.$;
35
- const SELECT_OPTION_ENTRY_TEMPLATE_ID = 'selectOption.entry.template';
36
-
37
- class SelectListRenderer {
38
- get templateId() {
39
- return SELECT_OPTION_ENTRY_TEMPLATE_ID;
40
- }
41
-
42
- renderTemplate(container) {
43
- const data = Object.create(null);
44
- data.disposables = [];
45
- data.root = container;
46
- data.text = dom.append(container, $('.option-text'));
47
- data.decoratorRight = dom.append(container, $('.option-decorator-right'));
48
- return data;
49
- }
50
-
51
- renderElement(element, index, templateData) {
52
- const data = templateData;
53
- const text = element.text;
54
- const decoratorRight = element.decoratorRight;
55
- const isDisabled = element.isDisabled;
56
- data.text.textContent = text;
57
- data.decoratorRight.innerText = !!decoratorRight ? decoratorRight : ''; // pseudo-select disabled option
58
-
59
- if (isDisabled) {
60
- data.root.classList.add('option-disabled');
61
- } else {
62
- // Make sure we do class removal from prior template rendering
63
- data.root.classList.remove('option-disabled');
64
- }
65
- }
66
-
67
- disposeTemplate(templateData) {
68
- templateData.disposables = lifecycle_1.dispose(templateData.disposables);
69
- }
70
-
71
- }
72
-
73
- class SelectBoxList extends lifecycle_1.Disposable {
74
- constructor(options, selected, contextViewProvider, styles, selectBoxOptions) {
75
- super();
76
- this.options = [];
77
- this._currentSelection = 0;
78
- this._hasDetails = false;
79
- this._skipLayout = false;
80
- this._sticky = false; // for dev purposes only
81
-
82
- this._isVisible = false;
83
- this.selectBoxOptions = selectBoxOptions || Object.create(null);
84
-
85
- if (typeof this.selectBoxOptions.minBottomMargin !== 'number') {
86
- this.selectBoxOptions.minBottomMargin = SelectBoxList.DEFAULT_DROPDOWN_MINIMUM_BOTTOM_MARGIN;
87
- } else if (this.selectBoxOptions.minBottomMargin < 0) {
88
- this.selectBoxOptions.minBottomMargin = 0;
89
- }
90
-
91
- this.selectElement = document.createElement('select'); // Use custom CSS vars for padding calculation
92
-
93
- this.selectElement.className = 'monaco-select-box monaco-select-box-dropdown-padding';
94
-
95
- if (typeof this.selectBoxOptions.ariaLabel === 'string') {
96
- this.selectElement.setAttribute('aria-label', this.selectBoxOptions.ariaLabel);
97
- }
98
-
99
- this._onDidSelect = new event_1.Emitter();
100
-
101
- this._register(this._onDidSelect);
102
-
103
- this.styles = styles;
104
- this.registerListeners();
105
- this.constructSelectDropDown(contextViewProvider);
106
- this.selected = selected || 0;
107
-
108
- if (options) {
109
- this.setOptions(options, selected);
110
- }
111
- } // IDelegate - List renderer
112
-
113
-
114
- getHeight() {
115
- return 18;
116
- }
117
-
118
- getTemplateId() {
119
- return SELECT_OPTION_ENTRY_TEMPLATE_ID;
120
- }
121
-
122
- constructSelectDropDown(contextViewProvider) {
123
- // SetUp ContextView container to hold select Dropdown
124
- this.contextViewProvider = contextViewProvider;
125
- this.selectDropDownContainer = dom.$('.monaco-select-box-dropdown-container'); // Use custom CSS vars for padding calculation (shared with parent select)
126
-
127
- this.selectDropDownContainer.classList.add('monaco-select-box-dropdown-padding'); // Setup container for select option details
128
-
129
- this.selectionDetailsPane = dom.append(this.selectDropDownContainer, $('.select-box-details-pane')); // Create span flex box item/div we can measure and control
130
-
131
- let widthControlOuterDiv = dom.append(this.selectDropDownContainer, $('.select-box-dropdown-container-width-control'));
132
- let widthControlInnerDiv = dom.append(widthControlOuterDiv, $('.width-control-div'));
133
- this.widthControlElement = document.createElement('span');
134
- this.widthControlElement.className = 'option-text-width-control';
135
- dom.append(widthControlInnerDiv, this.widthControlElement); // Always default to below position
136
-
137
- this._dropDownPosition = 0
138
- /* BELOW */
139
- ; // Inline stylesheet for themes
140
-
141
- this.styleElement = dom.createStyleSheet(this.selectDropDownContainer);
142
- }
143
-
144
- registerListeners() {
145
- // Parent native select keyboard listeners
146
- this._register(dom.addStandardDisposableListener(this.selectElement, 'change', e => {
147
- this.selected = e.target.selectedIndex;
148
-
149
- this._onDidSelect.fire({
150
- index: e.target.selectedIndex,
151
- selected: e.target.value
152
- });
153
-
154
- if (!!this.options[this.selected] && !!this.options[this.selected].text) {
155
- this.selectElement.title = this.options[this.selected].text;
156
- }
157
- })); // Have to implement both keyboard and mouse controllers to handle disabled options
158
- // Intercept mouse events to override normal select actions on parents
159
-
160
-
161
- this._register(dom.addDisposableListener(this.selectElement, dom.EventType.CLICK, e => {
162
- dom.EventHelper.stop(e);
163
-
164
- if (this._isVisible) {
165
- this.hideSelectDropDown(true);
166
- } else {
167
- this.showSelectDropDown();
168
- }
169
- }));
170
-
171
- this._register(dom.addDisposableListener(this.selectElement, dom.EventType.MOUSE_DOWN, e => {
172
- dom.EventHelper.stop(e);
173
- })); // Intercept keyboard handling
174
-
175
-
176
- this._register(dom.addDisposableListener(this.selectElement, dom.EventType.KEY_DOWN, e => {
177
- const event = new keyboardEvent_1.StandardKeyboardEvent(e);
178
- let showDropDown = false; // Create and drop down select list on keyboard select
179
-
180
- if (platform_1.isMacintosh) {
181
- if (event.keyCode === 18
182
- /* DownArrow */
183
- || event.keyCode === 16
184
- /* UpArrow */
185
- || event.keyCode === 10
186
- /* Space */
187
- || event.keyCode === 3
188
- /* Enter */
189
- ) {
190
- showDropDown = true;
191
- }
192
- } else {
193
- if (event.keyCode === 18
194
- /* DownArrow */
195
- && event.altKey || event.keyCode === 16
196
- /* UpArrow */
197
- && event.altKey || event.keyCode === 10
198
- /* Space */
199
- || event.keyCode === 3
200
- /* Enter */
201
- ) {
202
- showDropDown = true;
203
- }
204
- }
205
-
206
- if (showDropDown) {
207
- this.showSelectDropDown();
208
- dom.EventHelper.stop(e, true);
209
- }
210
- }));
211
- }
212
-
213
- get onDidSelect() {
214
- return this._onDidSelect.event;
215
- }
216
-
217
- setOptions(options, selected) {
218
- if (!arrays.equals(this.options, options)) {
219
- this.options = options;
220
- this.selectElement.options.length = 0;
221
- this._hasDetails = false;
222
- this.options.forEach((option, index) => {
223
- this.selectElement.add(this.createOption(option.text, index, option.isDisabled));
224
-
225
- if (typeof option.description === 'string') {
226
- this._hasDetails = true;
227
- }
228
- });
229
- }
230
-
231
- if (selected !== undefined) {
232
- this.select(selected); // Set current = selected since this is not necessarily a user exit
233
-
234
- this._currentSelection = this.selected;
235
- }
236
- }
237
-
238
- setOptionsList() {
239
- // Mirror options in drop-down
240
- // Populate select list for non-native select mode
241
- if (this.selectList) {
242
- this.selectList.splice(0, this.selectList.length, this.options);
243
- }
244
- }
245
-
246
- select(index) {
247
- if (index >= 0 && index < this.options.length) {
248
- this.selected = index;
249
- } else if (index > this.options.length - 1) {
250
- // Adjust index to end of list
251
- // This could make client out of sync with the select
252
- this.select(this.options.length - 1);
253
- } else if (this.selected < 0) {
254
- this.selected = 0;
255
- }
256
-
257
- this.selectElement.selectedIndex = this.selected;
258
-
259
- if (!!this.options[this.selected] && !!this.options[this.selected].text) {
260
- this.selectElement.title = this.options[this.selected].text;
261
- }
262
- }
263
-
264
- setAriaLabel(label) {
265
- this.selectBoxOptions.ariaLabel = label;
266
- this.selectElement.setAttribute('aria-label', this.selectBoxOptions.ariaLabel);
267
- }
268
-
269
- focus() {
270
- if (this.selectElement) {
271
- this.selectElement.focus();
272
- }
273
- }
274
-
275
- blur() {
276
- if (this.selectElement) {
277
- this.selectElement.blur();
278
- }
279
- }
280
-
281
- render(container) {
282
- this.container = container;
283
- container.classList.add('select-container');
284
- container.appendChild(this.selectElement);
285
- this.applyStyles();
286
- }
287
-
288
- style(styles) {
289
- const content = [];
290
- this.styles = styles; // Style non-native select mode
291
-
292
- if (this.styles.listFocusBackground) {
293
- content.push(`.monaco-select-box-dropdown-container > .select-box-dropdown-list-container .monaco-list .monaco-list-row.focused { background-color: ${this.styles.listFocusBackground} !important; }`);
294
- }
295
-
296
- if (this.styles.listFocusForeground) {
297
- content.push(`.monaco-select-box-dropdown-container > .select-box-dropdown-list-container .monaco-list .monaco-list-row.focused:not(:hover) { color: ${this.styles.listFocusForeground} !important; }`);
298
- }
299
-
300
- if (this.styles.decoratorRightForeground) {
301
- content.push(`.monaco-select-box-dropdown-container > .select-box-dropdown-list-container .monaco-list .monaco-list-row .option-decorator-right { color: ${this.styles.decoratorRightForeground} !important; }`);
302
- }
303
-
304
- if (this.styles.selectBackground && this.styles.selectBorder && !this.styles.selectBorder.equals(this.styles.selectBackground)) {
305
- content.push(`.monaco-select-box-dropdown-container { border: 1px solid ${this.styles.selectBorder} } `);
306
- content.push(`.monaco-select-box-dropdown-container > .select-box-details-pane.border-top { border-top: 1px solid ${this.styles.selectBorder} } `);
307
- content.push(`.monaco-select-box-dropdown-container > .select-box-details-pane.border-bottom { border-bottom: 1px solid ${this.styles.selectBorder} } `);
308
- } else if (this.styles.selectListBorder) {
309
- content.push(`.monaco-select-box-dropdown-container > .select-box-details-pane.border-top { border-top: 1px solid ${this.styles.selectListBorder} } `);
310
- content.push(`.monaco-select-box-dropdown-container > .select-box-details-pane.border-bottom { border-bottom: 1px solid ${this.styles.selectListBorder} } `);
311
- } // Hover foreground - ignore for disabled options
312
-
313
-
314
- if (this.styles.listHoverForeground) {
315
- content.push(`.monaco-select-box-dropdown-container > .select-box-dropdown-list-container .monaco-list .monaco-list-row:hover { color: ${this.styles.listHoverForeground} !important; }`);
316
- content.push(`.monaco-select-box-dropdown-container > .select-box-dropdown-list-container .monaco-list .monaco-list-row.option-disabled:hover { background-color: ${this.styles.listActiveSelectionForeground} !important; }`);
317
- } // Hover background - ignore for disabled options
318
-
319
-
320
- if (this.styles.listHoverBackground) {
321
- content.push(`.monaco-select-box-dropdown-container > .select-box-dropdown-list-container .monaco-list .monaco-list-row:not(.option-disabled):not(.focused):hover { background-color: ${this.styles.listHoverBackground} !important; }`);
322
- content.push(`.monaco-select-box-dropdown-container > .select-box-dropdown-list-container .monaco-list .monaco-list-row.option-disabled:hover { background-color: ${this.styles.selectBackground} !important; }`);
323
- } // Match quick input outline styles - ignore for disabled options
324
-
325
-
326
- if (this.styles.listFocusOutline) {
327
- content.push(`.monaco-select-box-dropdown-container > .select-box-dropdown-list-container .monaco-list .monaco-list-row.focused { outline: 1.6px dotted ${this.styles.listFocusOutline} !important; outline-offset: -1.6px !important; }`);
328
- }
329
-
330
- if (this.styles.listHoverOutline) {
331
- content.push(`.monaco-select-box-dropdown-container > .select-box-dropdown-list-container .monaco-list .monaco-list-row:hover:not(.focused) { outline: 1.6px dashed ${this.styles.listHoverOutline} !important; outline-offset: -1.6px !important; }`);
332
- content.push(`.monaco-select-box-dropdown-container > .select-box-dropdown-list-container .monaco-list .monaco-list-row.option-disabled:hover { outline: none !important; }`);
333
- }
334
-
335
- this.styleElement.textContent = content.join('\n');
336
- this.applyStyles();
337
- }
338
-
339
- applyStyles() {
340
- // Style parent select
341
- if (this.selectElement) {
342
- const background = this.styles.selectBackground ? this.styles.selectBackground.toString() : '';
343
- const foreground = this.styles.selectForeground ? this.styles.selectForeground.toString() : '';
344
- const border = this.styles.selectBorder ? this.styles.selectBorder.toString() : '';
345
- this.selectElement.style.backgroundColor = background;
346
- this.selectElement.style.color = foreground;
347
- this.selectElement.style.borderColor = border;
348
- } // Style drop down select list (non-native mode only)
349
-
350
-
351
- if (this.selectList) {
352
- this.styleList();
353
- }
354
- }
355
-
356
- styleList() {
357
- if (this.selectList) {
358
- const background = this.styles.selectBackground ? this.styles.selectBackground.toString() : '';
359
- this.selectList.style({});
360
- const listBackground = this.styles.selectListBackground ? this.styles.selectListBackground.toString() : background;
361
- this.selectDropDownListContainer.style.backgroundColor = listBackground;
362
- this.selectionDetailsPane.style.backgroundColor = listBackground;
363
- const optionsBorder = this.styles.focusBorder ? this.styles.focusBorder.toString() : '';
364
- this.selectDropDownContainer.style.outlineColor = optionsBorder;
365
- this.selectDropDownContainer.style.outlineOffset = '-1px';
366
- }
367
- }
368
-
369
- createOption(value, index, disabled) {
370
- let option = document.createElement('option');
371
- option.value = value;
372
- option.text = value;
373
- option.disabled = !!disabled;
374
- return option;
375
- } // ContextView dropdown methods
376
-
377
-
378
- showSelectDropDown() {
379
- this.selectionDetailsPane.innerText = '';
380
-
381
- if (!this.contextViewProvider || this._isVisible) {
382
- return;
383
- } // Lazily create and populate list only at open, moved from constructor
384
-
385
-
386
- this.createSelectList(this.selectDropDownContainer);
387
- this.setOptionsList(); // This allows us to flip the position based on measurement
388
- // Set drop-down position above/below from required height and margins
389
- // If pre-layout cannot fit at least one option do not show drop-down
390
-
391
- this.contextViewProvider.showContextView({
392
- getAnchor: () => this.selectElement,
393
- render: container => this.renderSelectDropDown(container, true),
394
- layout: () => {
395
- this.layoutSelectDropDown();
396
- },
397
- onHide: () => {
398
- this.selectDropDownContainer.classList.remove('visible');
399
- this.selectElement.classList.remove('synthetic-focus');
400
- },
401
- anchorPosition: this._dropDownPosition
402
- }, this.selectBoxOptions.optionsAsChildren ? this.container : undefined); // Hide so we can relay out
403
-
404
- this._isVisible = true;
405
- this.hideSelectDropDown(false);
406
- this.contextViewProvider.showContextView({
407
- getAnchor: () => this.selectElement,
408
- render: container => this.renderSelectDropDown(container),
409
- layout: () => this.layoutSelectDropDown(),
410
- onHide: () => {
411
- this.selectDropDownContainer.classList.remove('visible');
412
- this.selectElement.classList.remove('synthetic-focus');
413
- },
414
- anchorPosition: this._dropDownPosition
415
- }, this.selectBoxOptions.optionsAsChildren ? this.container : undefined); // Track initial selection the case user escape, blur
416
-
417
- this._currentSelection = this.selected;
418
- this._isVisible = true;
419
- this.selectElement.setAttribute('aria-expanded', 'true');
420
- }
421
-
422
- hideSelectDropDown(focusSelect) {
423
- if (!this.contextViewProvider || !this._isVisible) {
424
- return;
425
- }
426
-
427
- this._isVisible = false;
428
- this.selectElement.setAttribute('aria-expanded', 'false');
429
-
430
- if (focusSelect) {
431
- this.selectElement.focus();
432
- }
433
-
434
- this.contextViewProvider.hideContextView();
435
- }
436
-
437
- renderSelectDropDown(container, preLayoutPosition) {
438
- container.appendChild(this.selectDropDownContainer); // Pre-Layout allows us to change position
439
-
440
- this.layoutSelectDropDown(preLayoutPosition);
441
- return {
442
- dispose: () => {
443
- // contextView will dispose itself if moving from one View to another
444
- try {
445
- container.removeChild(this.selectDropDownContainer); // remove to take out the CSS rules we add
446
- } catch (error) {// Ignore, removed already by change of focus
447
- }
448
- }
449
- };
450
- } // Iterate over detailed descriptions, find max height
451
-
452
-
453
- measureMaxDetailsHeight() {
454
- let maxDetailsPaneHeight = 0;
455
- this.options.forEach((_option, index) => {
456
- this.updateDetail(index);
457
-
458
- if (this.selectionDetailsPane.offsetHeight > maxDetailsPaneHeight) {
459
- maxDetailsPaneHeight = this.selectionDetailsPane.offsetHeight;
460
- }
461
- });
462
- return maxDetailsPaneHeight;
463
- }
464
-
465
- layoutSelectDropDown(preLayoutPosition) {
466
- // Avoid recursion from layout called in onListFocus
467
- if (this._skipLayout) {
468
- return false;
469
- } // Layout ContextView drop down select list and container
470
- // Have to manage our vertical overflow, sizing, position below or above
471
- // Position has to be determined and set prior to contextView instantiation
472
-
473
-
474
- if (this.selectList) {
475
- // Make visible to enable measurements
476
- this.selectDropDownContainer.classList.add('visible');
477
- const selectPosition = dom.getDomNodePagePosition(this.selectElement);
478
- const styles = getComputedStyle(this.selectElement);
479
- const verticalPadding = parseFloat(styles.getPropertyValue('--dropdown-padding-top')) + parseFloat(styles.getPropertyValue('--dropdown-padding-bottom'));
480
- const maxSelectDropDownHeightBelow = window.innerHeight - selectPosition.top - selectPosition.height - (this.selectBoxOptions.minBottomMargin || 0);
481
- const maxSelectDropDownHeightAbove = selectPosition.top - SelectBoxList.DEFAULT_DROPDOWN_MINIMUM_TOP_MARGIN; // Determine optimal width - min(longest option), opt(parent select, excluding margins), max(ContextView controlled)
482
-
483
- const selectWidth = this.selectElement.offsetWidth;
484
- const selectMinWidth = this.setWidthControlElement(this.widthControlElement);
485
- const selectOptimalWidth = Math.max(selectMinWidth, Math.round(selectWidth)).toString() + 'px';
486
- this.selectDropDownContainer.style.width = selectOptimalWidth; // Get initial list height and determine space above and below
487
-
488
- this.selectList.getHTMLElement().style.height = '';
489
- this.selectList.layout();
490
- let listHeight = this.selectList.contentHeight;
491
- const maxDetailsPaneHeight = this._hasDetails ? this.measureMaxDetailsHeight() : 0;
492
- const minRequiredDropDownHeight = listHeight + verticalPadding + maxDetailsPaneHeight;
493
- const maxVisibleOptionsBelow = Math.floor((maxSelectDropDownHeightBelow - verticalPadding - maxDetailsPaneHeight) / this.getHeight());
494
- const maxVisibleOptionsAbove = Math.floor((maxSelectDropDownHeightAbove - verticalPadding - maxDetailsPaneHeight) / this.getHeight()); // If we are only doing pre-layout check/adjust position only
495
- // Calculate vertical space available, flip up if insufficient
496
- // Use reflected padding on parent select, ContextView style
497
- // properties not available before DOM attachment
498
-
499
- if (preLayoutPosition) {
500
- // Check if select moved out of viewport , do not open
501
- // If at least one option cannot be shown, don't open the drop-down or hide/remove if open
502
- if (selectPosition.top + selectPosition.height > window.innerHeight - 22 || selectPosition.top < SelectBoxList.DEFAULT_DROPDOWN_MINIMUM_TOP_MARGIN || maxVisibleOptionsBelow < 1 && maxVisibleOptionsAbove < 1) {
503
- // Indicate we cannot open
504
- return false;
505
- } // Determine if we have to flip up
506
- // Always show complete list items - never more than Max available vertical height
507
-
508
-
509
- if (maxVisibleOptionsBelow < SelectBoxList.DEFAULT_MINIMUM_VISIBLE_OPTIONS && maxVisibleOptionsAbove > maxVisibleOptionsBelow && this.options.length > maxVisibleOptionsBelow) {
510
- this._dropDownPosition = 1
511
- /* ABOVE */
512
- ;
513
- this.selectDropDownContainer.removeChild(this.selectDropDownListContainer);
514
- this.selectDropDownContainer.removeChild(this.selectionDetailsPane);
515
- this.selectDropDownContainer.appendChild(this.selectionDetailsPane);
516
- this.selectDropDownContainer.appendChild(this.selectDropDownListContainer);
517
- this.selectionDetailsPane.classList.remove('border-top');
518
- this.selectionDetailsPane.classList.add('border-bottom');
519
- } else {
520
- this._dropDownPosition = 0
521
- /* BELOW */
522
- ;
523
- this.selectDropDownContainer.removeChild(this.selectDropDownListContainer);
524
- this.selectDropDownContainer.removeChild(this.selectionDetailsPane);
525
- this.selectDropDownContainer.appendChild(this.selectDropDownListContainer);
526
- this.selectDropDownContainer.appendChild(this.selectionDetailsPane);
527
- this.selectionDetailsPane.classList.remove('border-bottom');
528
- this.selectionDetailsPane.classList.add('border-top');
529
- } // Do full layout on showSelectDropDown only
530
-
531
-
532
- return true;
533
- } // Check if select out of viewport or cutting into status bar
534
-
535
-
536
- if (selectPosition.top + selectPosition.height > window.innerHeight - 22 || selectPosition.top < SelectBoxList.DEFAULT_DROPDOWN_MINIMUM_TOP_MARGIN || this._dropDownPosition === 0
537
- /* BELOW */
538
- && maxVisibleOptionsBelow < 1 || this._dropDownPosition === 1
539
- /* ABOVE */
540
- && maxVisibleOptionsAbove < 1) {
541
- // Cannot properly layout, close and hide
542
- this.hideSelectDropDown(true);
543
- return false;
544
- } // SetUp list dimensions and layout - account for container padding
545
- // Use position to check above or below available space
546
-
547
-
548
- if (this._dropDownPosition === 0
549
- /* BELOW */
550
- ) {
551
- if (this._isVisible && maxVisibleOptionsBelow + maxVisibleOptionsAbove < 1) {
552
- // If drop-down is visible, must be doing a DOM re-layout, hide since we don't fit
553
- // Hide drop-down, hide contextview, focus on parent select
554
- this.hideSelectDropDown(true);
555
- return false;
556
- } // Adjust list height to max from select bottom to margin (default/minBottomMargin)
557
-
558
-
559
- if (minRequiredDropDownHeight > maxSelectDropDownHeightBelow) {
560
- listHeight = maxVisibleOptionsBelow * this.getHeight();
561
- }
562
- } else {
563
- if (minRequiredDropDownHeight > maxSelectDropDownHeightAbove) {
564
- listHeight = maxVisibleOptionsAbove * this.getHeight();
565
- }
566
- } // Set adjusted list height and relayout
567
-
568
-
569
- this.selectList.layout(listHeight);
570
- this.selectList.domFocus(); // Finally set focus on selected item
571
-
572
- if (this.selectList.length > 0) {
573
- this.selectList.setFocus([this.selected || 0]);
574
- this.selectList.reveal(this.selectList.getFocus()[0] || 0);
575
- }
576
-
577
- if (this._hasDetails) {
578
- // Leave the selectDropDownContainer to size itself according to children (list + details) - #57447
579
- this.selectList.getHTMLElement().style.height = listHeight + verticalPadding + 'px';
580
- this.selectDropDownContainer.style.height = '';
581
- } else {
582
- this.selectDropDownContainer.style.height = listHeight + verticalPadding + 'px';
583
- }
584
-
585
- this.updateDetail(this.selected);
586
- this.selectDropDownContainer.style.width = selectOptimalWidth; // Maintain focus outline on parent select as well as list container - tabindex for focus
587
-
588
- this.selectDropDownListContainer.setAttribute('tabindex', '0');
589
- this.selectElement.classList.add('synthetic-focus');
590
- this.selectDropDownContainer.classList.add('synthetic-focus');
591
- return true;
592
- } else {
593
- return false;
594
- }
595
- }
596
-
597
- setWidthControlElement(container) {
598
- let elementWidth = 0;
599
-
600
- if (container) {
601
- let longest = 0;
602
- let longestLength = 0;
603
- this.options.forEach((option, index) => {
604
- const len = option.text.length + (!!option.decoratorRight ? option.decoratorRight.length : 0);
605
-
606
- if (len > longestLength) {
607
- longest = index;
608
- longestLength = len;
609
- }
610
- });
611
- container.textContent = this.options[longest].text + (!!this.options[longest].decoratorRight ? this.options[longest].decoratorRight + ' ' : '');
612
- elementWidth = dom.getTotalWidth(container);
613
- }
614
-
615
- return elementWidth;
616
- }
617
-
618
- createSelectList(parent) {
619
- // If we have already constructive list on open, skip
620
- if (this.selectList) {
621
- return;
622
- } // SetUp container for list
623
-
624
-
625
- this.selectDropDownListContainer = dom.append(parent, $('.select-box-dropdown-list-container'));
626
- this.listRenderer = new SelectListRenderer();
627
- this.selectList = new listWidget_1.List('SelectBoxCustom', this.selectDropDownListContainer, this, [this.listRenderer], {
628
- useShadows: false,
629
- verticalScrollMode: 3
630
- /* Visible */
631
- ,
632
- keyboardSupport: false,
633
- mouseSupport: false,
634
- accessibilityProvider: {
635
- getAriaLabel: element => {
636
- let label = element.text;
637
-
638
- if (element.decoratorRight) {
639
- label += `. ${element.decoratorRight}`;
640
- }
641
-
642
- if (element.description) {
643
- label += `. ${element.description}`;
644
- }
645
-
646
- return label;
647
- },
648
- getWidgetAriaLabel: () => nls_1.localize({
649
- key: 'selectBox',
650
- comment: ['Behave like native select dropdown element.']
651
- }, "Select Box"),
652
- getRole: () => 'option',
653
- getWidgetRole: () => 'listbox'
654
- }
655
- });
656
-
657
- if (this.selectBoxOptions.ariaLabel) {
658
- this.selectList.ariaLabel = this.selectBoxOptions.ariaLabel;
659
- } // SetUp list keyboard controller - control navigation, disabled items, focus
660
-
661
-
662
- const onSelectDropDownKeyDown = event_1.Event.chain(event_2.domEvent(this.selectDropDownListContainer, 'keydown')).filter(() => this.selectList.length > 0).map(e => new keyboardEvent_1.StandardKeyboardEvent(e));
663
-
664
- this._register(onSelectDropDownKeyDown.filter(e => e.keyCode === 3
665
- /* Enter */
666
- ).on(e => this.onEnter(e), this));
667
-
668
- this._register(onSelectDropDownKeyDown.filter(e => e.keyCode === 9
669
- /* Escape */
670
- ).on(e => this.onEscape(e), this));
671
-
672
- this._register(onSelectDropDownKeyDown.filter(e => e.keyCode === 16
673
- /* UpArrow */
674
- ).on(this.onUpArrow, this));
675
-
676
- this._register(onSelectDropDownKeyDown.filter(e => e.keyCode === 18
677
- /* DownArrow */
678
- ).on(this.onDownArrow, this));
679
-
680
- this._register(onSelectDropDownKeyDown.filter(e => e.keyCode === 12
681
- /* PageDown */
682
- ).on(this.onPageDown, this));
683
-
684
- this._register(onSelectDropDownKeyDown.filter(e => e.keyCode === 11
685
- /* PageUp */
686
- ).on(this.onPageUp, this));
687
-
688
- this._register(onSelectDropDownKeyDown.filter(e => e.keyCode === 14
689
- /* Home */
690
- ).on(this.onHome, this));
691
-
692
- this._register(onSelectDropDownKeyDown.filter(e => e.keyCode === 13
693
- /* End */
694
- ).on(this.onEnd, this));
695
-
696
- this._register(onSelectDropDownKeyDown.filter(e => e.keyCode >= 21
697
- /* KEY_0 */
698
- && e.keyCode <= 56
699
- /* KEY_Z */
700
- || e.keyCode >= 80
701
- /* US_SEMICOLON */
702
- && e.keyCode <= 108
703
- /* NUMPAD_DIVIDE */
704
- ).on(this.onCharacter, this)); // SetUp list mouse controller - control navigation, disabled items, focus
705
-
706
-
707
- this._register(event_1.Event.chain(event_2.domEvent(this.selectList.getHTMLElement(), 'mouseup')).filter(() => this.selectList.length > 0).on(e => this.onMouseUp(e), this));
708
-
709
- this._register(this.selectList.onMouseOver(e => typeof e.index !== 'undefined' && this.selectList.setFocus([e.index])));
710
-
711
- this._register(this.selectList.onDidChangeFocus(e => this.onListFocus(e)));
712
-
713
- this._register(dom.addDisposableListener(this.selectDropDownContainer, dom.EventType.FOCUS_OUT, e => {
714
- if (!this._isVisible || dom.isAncestor(e.relatedTarget, this.selectDropDownContainer)) {
715
- return;
716
- }
717
-
718
- this.onListBlur();
719
- }));
720
-
721
- this.selectList.getHTMLElement().setAttribute('aria-label', this.selectBoxOptions.ariaLabel || '');
722
- this.selectList.getHTMLElement().setAttribute('aria-expanded', 'true');
723
- this.styleList();
724
- } // List methods
725
- // List mouse controller - active exit, select option, fire onDidSelect if change, return focus to parent select
726
-
727
-
728
- onMouseUp(e) {
729
- dom.EventHelper.stop(e);
730
- const target = e.target;
731
-
732
- if (!target) {
733
- return;
734
- } // Check our mouse event is on an option (not scrollbar)
735
-
736
-
737
- if (!!target.classList.contains('slider')) {
738
- return;
739
- }
740
-
741
- const listRowElement = target.closest('.monaco-list-row');
742
-
743
- if (!listRowElement) {
744
- return;
745
- }
746
-
747
- const index = Number(listRowElement.getAttribute('data-index'));
748
- const disabled = listRowElement.classList.contains('option-disabled'); // Ignore mouse selection of disabled options
749
-
750
- if (index >= 0 && index < this.options.length && !disabled) {
751
- this.selected = index;
752
- this.select(this.selected);
753
- this.selectList.setFocus([this.selected]);
754
- this.selectList.reveal(this.selectList.getFocus()[0]); // Only fire if selection change
755
-
756
- if (this.selected !== this._currentSelection) {
757
- // Set current = selected
758
- this._currentSelection = this.selected;
759
-
760
- this._onDidSelect.fire({
761
- index: this.selectElement.selectedIndex,
762
- selected: this.options[this.selected].text
763
- });
764
-
765
- if (!!this.options[this.selected] && !!this.options[this.selected].text) {
766
- this.selectElement.title = this.options[this.selected].text;
767
- }
768
- }
769
-
770
- this.hideSelectDropDown(true);
771
- }
772
- } // List Exit - passive - implicit no selection change, hide drop-down
773
-
774
-
775
- onListBlur() {
776
- if (this._sticky) {
777
- return;
778
- }
779
-
780
- if (this.selected !== this._currentSelection) {
781
- // Reset selected to current if no change
782
- this.select(this._currentSelection);
783
- }
784
-
785
- this.hideSelectDropDown(false);
786
- } // List Focus Change - passive - update details pane with newly focused element's data
787
-
788
-
789
- onListFocus(e) {
790
- // Skip during initial layout
791
- if (!this._isVisible || !this._hasDetails) {
792
- return;
793
- }
794
-
795
- this.updateDetail(e.indexes[0]);
796
- }
797
-
798
- updateDetail(selectedIndex) {
799
- this.selectionDetailsPane.innerText = '';
800
- const description = this.options[selectedIndex].description;
801
- const descriptionIsMarkdown = this.options[selectedIndex].descriptionIsMarkdown;
802
-
803
- if (description) {
804
- if (descriptionIsMarkdown) {} else {
805
- this.selectionDetailsPane.innerText = description;
806
- }
807
-
808
- this.selectionDetailsPane.style.display = 'block';
809
- } else {
810
- this.selectionDetailsPane.style.display = 'none';
811
- } // Avoid recursion
812
-
813
-
814
- this._skipLayout = true;
815
- this.contextViewProvider.layout();
816
- this._skipLayout = false;
817
- } // List keyboard controller
818
- // List exit - active - hide ContextView dropdown, reset selection, return focus to parent select
819
-
820
-
821
- onEscape(e) {
822
- dom.EventHelper.stop(e); // Reset selection to value when opened
823
-
824
- this.select(this._currentSelection);
825
- this.hideSelectDropDown(true);
826
- } // List exit - active - hide ContextView dropdown, return focus to parent select, fire onDidSelect if change
827
-
828
-
829
- onEnter(e) {
830
- dom.EventHelper.stop(e); // Only fire if selection change
831
-
832
- if (this.selected !== this._currentSelection) {
833
- this._currentSelection = this.selected;
834
-
835
- this._onDidSelect.fire({
836
- index: this.selectElement.selectedIndex,
837
- selected: this.options[this.selected].text
838
- });
839
-
840
- if (!!this.options[this.selected] && !!this.options[this.selected].text) {
841
- this.selectElement.title = this.options[this.selected].text;
842
- }
843
- }
844
-
845
- this.hideSelectDropDown(true);
846
- } // List navigation - have to handle a disabled option (jump over)
847
-
848
-
849
- onDownArrow() {
850
- if (this.selected < this.options.length - 1) {
851
- // Skip disabled options
852
- const nextOptionDisabled = this.options[this.selected + 1].isDisabled;
853
-
854
- if (nextOptionDisabled && this.options.length > this.selected + 2) {
855
- this.selected += 2;
856
- } else if (nextOptionDisabled) {
857
- return;
858
- } else {
859
- this.selected++;
860
- } // Set focus/selection - only fire event when closing drop-down or on blur
861
-
862
-
863
- this.select(this.selected);
864
- this.selectList.setFocus([this.selected]);
865
- this.selectList.reveal(this.selectList.getFocus()[0]);
866
- }
867
- }
868
-
869
- onUpArrow() {
870
- if (this.selected > 0) {
871
- // Skip disabled options
872
- const previousOptionDisabled = this.options[this.selected - 1].isDisabled;
873
-
874
- if (previousOptionDisabled && this.selected > 1) {
875
- this.selected -= 2;
876
- } else {
877
- this.selected--;
878
- } // Set focus/selection - only fire event when closing drop-down or on blur
879
-
880
-
881
- this.select(this.selected);
882
- this.selectList.setFocus([this.selected]);
883
- this.selectList.reveal(this.selectList.getFocus()[0]);
884
- }
885
- }
886
-
887
- onPageUp(e) {
888
- dom.EventHelper.stop(e);
889
- this.selectList.focusPreviousPage(); // Allow scrolling to settle
890
-
891
- setTimeout(() => {
892
- this.selected = this.selectList.getFocus()[0]; // Shift selection down if we land on a disabled option
893
-
894
- if (this.options[this.selected].isDisabled && this.selected < this.options.length - 1) {
895
- this.selected++;
896
- this.selectList.setFocus([this.selected]);
897
- }
898
-
899
- this.selectList.reveal(this.selected);
900
- this.select(this.selected);
901
- }, 1);
902
- }
903
-
904
- onPageDown(e) {
905
- dom.EventHelper.stop(e);
906
- this.selectList.focusNextPage(); // Allow scrolling to settle
907
-
908
- setTimeout(() => {
909
- this.selected = this.selectList.getFocus()[0]; // Shift selection up if we land on a disabled option
910
-
911
- if (this.options[this.selected].isDisabled && this.selected > 0) {
912
- this.selected--;
913
- this.selectList.setFocus([this.selected]);
914
- }
915
-
916
- this.selectList.reveal(this.selected);
917
- this.select(this.selected);
918
- }, 1);
919
- }
920
-
921
- onHome(e) {
922
- dom.EventHelper.stop(e);
923
-
924
- if (this.options.length < 2) {
925
- return;
926
- }
927
-
928
- this.selected = 0;
929
-
930
- if (this.options[this.selected].isDisabled && this.selected > 1) {
931
- this.selected++;
932
- }
933
-
934
- this.selectList.setFocus([this.selected]);
935
- this.selectList.reveal(this.selected);
936
- this.select(this.selected);
937
- }
938
-
939
- onEnd(e) {
940
- dom.EventHelper.stop(e);
941
-
942
- if (this.options.length < 2) {
943
- return;
944
- }
945
-
946
- this.selected = this.options.length - 1;
947
-
948
- if (this.options[this.selected].isDisabled && this.selected > 1) {
949
- this.selected--;
950
- }
951
-
952
- this.selectList.setFocus([this.selected]);
953
- this.selectList.reveal(this.selected);
954
- this.select(this.selected);
955
- } // Mimic option first character navigation of native select
956
-
957
-
958
- onCharacter(e) {
959
- const ch = keyCodes_1.KeyCodeUtils.toString(e.keyCode);
960
- let optionIndex = -1;
961
-
962
- for (let i = 0; i < this.options.length - 1; i++) {
963
- optionIndex = (i + this.selected + 1) % this.options.length;
964
-
965
- if (this.options[optionIndex].text.charAt(0).toUpperCase() === ch && !this.options[optionIndex].isDisabled) {
966
- this.select(optionIndex);
967
- this.selectList.setFocus([optionIndex]);
968
- this.selectList.reveal(this.selectList.getFocus()[0]);
969
- dom.EventHelper.stop(e);
970
- break;
971
- }
972
- }
973
- }
974
-
975
- dispose() {
976
- this.hideSelectDropDown(false);
977
- super.dispose();
978
- }
979
-
980
- }
981
-
982
- exports.SelectBoxList = SelectBoxList;
983
- SelectBoxList.DEFAULT_DROPDOWN_MINIMUM_BOTTOM_MARGIN = 32;
984
- SelectBoxList.DEFAULT_DROPDOWN_MINIMUM_TOP_MARGIN = 2;
985
- SelectBoxList.DEFAULT_MINIMUM_VISIBLE_OPTIONS = 3;