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.
- package/.github/FUNDING.yml +1 -0
- package/README.md +15 -24
- package/_config.yml +1 -0
- package/{lib → build}/browser/browser.d.ts +0 -0
- package/{lib → build}/browser/browser.js +0 -0
- package/{lib → build}/browser/browser.js.map +0 -0
- package/{lib → build}/browser/event.d.ts +0 -0
- package/{lib → build}/browser/event.js +2 -1
- package/{lib → build}/browser/event.js.map +1 -1
- package/{lib → build}/browser/iframe.d.ts +0 -0
- package/{lib → build}/browser/iframe.js +0 -0
- package/{lib → build}/browser/iframe.js.map +0 -0
- package/{lib → build}/browser/keyboardEvent.d.ts +0 -0
- package/{lib → build}/browser/keyboardEvent.js +0 -0
- package/{lib → build}/browser/keyboardEvent.js.map +0 -0
- package/{lib → build}/browser/mouseEvent.d.ts +0 -0
- package/{lib → build}/browser/mouseEvent.js +0 -0
- package/{lib → build}/browser/mouseEvent.js.map +0 -0
- package/{lib → build}/common/arrays.d.ts +0 -0
- package/{lib → build}/common/arrays.js +0 -0
- package/{lib → build}/common/arrays.js.map +0 -0
- package/{lib → build}/common/async.d.ts +0 -0
- package/{lib → build}/common/async.js +0 -0
- package/{lib → build}/common/async.js.map +0 -0
- package/{lib → build}/common/charCode.d.ts +0 -0
- package/{lib → build}/common/charCode.js +0 -0
- package/{lib → build}/common/charCode.js.map +0 -0
- package/{lib → build}/common/color.d.ts +0 -0
- package/{lib → build}/common/color.js +0 -0
- package/{lib → build}/common/color.js.map +0 -0
- package/{lib → build}/common/dom.d.ts +0 -0
- package/{lib → build}/common/dom.js +16 -14
- package/build/common/dom.js.map +1 -0
- package/{lib → build}/common/event.d.ts +0 -0
- package/{lib → build}/common/event.js +1 -1
- package/build/common/event.js.map +1 -0
- package/{lib → build}/common/iterator.d.ts +0 -0
- package/{lib → build}/common/iterator.js +0 -0
- package/{lib → build}/common/iterator.js.map +0 -0
- package/{lib → build}/common/keyCodes.d.ts +0 -0
- package/{lib → build}/common/keyCodes.js +0 -0
- package/{lib → build}/common/keyCodes.js.map +0 -0
- package/{lib → build}/common/lifecycle.d.ts +0 -0
- package/{lib → build}/common/lifecycle.js +0 -0
- package/{lib → build}/common/lifecycle.js.map +0 -0
- package/{lib → build}/common/linkedList.d.ts +0 -0
- package/{lib → build}/common/linkedList.js +0 -0
- package/{lib → build}/common/linkedList.js.map +0 -0
- package/{lib → build}/common/platform.d.ts +0 -0
- package/{lib → build}/common/platform.js +0 -0
- package/{lib → build}/common/platform.js.map +0 -0
- package/{lib → build}/index.d.ts +0 -0
- package/{lib → build}/index.js +0 -0
- package/{lib → build}/index.js.map +0 -0
- package/{lib → build}/menu/menu.d.ts +0 -0
- package/{lib → build}/menu/menu.js +38 -38
- package/build/menu/menu.js.map +1 -0
- package/{lib → build}/menu/menuitem.d.ts +10 -2
- package/{lib → build}/menu/menuitem.js +70 -34
- package/build/menu/menuitem.js.map +1 -0
- package/{lib → build}/menubar.d.ts +0 -0
- package/{lib → build}/menubar.js +29 -30
- package/build/menubar.js.map +1 -0
- package/{lib → build}/themebar.d.ts +0 -0
- package/{lib → build}/themebar.js +2 -2
- package/build/themebar.js.map +1 -0
- package/{lib → build}/titlebar.d.ts +0 -0
- package/{lib → build}/titlebar.js +61 -58
- package/build/titlebar.js.map +1 -0
- package/package.json +13 -7
- package/lib/common/dom.js.map +0 -1
- package/lib/common/enableNativeMenuCommands.d.ts +0 -1
- package/lib/common/enableNativeMenuCommands.js +0 -32
- package/lib/common/enableNativeMenuCommands.js.map +0 -1
- package/lib/common/event.js.map +0 -1
- package/lib/main.d.ts +0 -1
- package/lib/main.js +0 -14
- package/lib/main.js.map +0 -1
- package/lib/menu/menu.js.map +0 -1
- package/lib/menu/menuitem.js.map +0 -1
- package/lib/menubar.js.map +0 -1
- package/lib/themebar.js.map +0 -1
- package/lib/titlebar.js.map +0 -1
- package/lib/vs/base/browser/browser.js +0 -150
- package/lib/vs/base/browser/canIUse.js +0 -58
- package/lib/vs/base/browser/codicons.js +0 -37
- package/lib/vs/base/browser/contextmenu.js +0 -9
- package/lib/vs/base/browser/dnd.js +0 -113
- package/lib/vs/base/browser/dom.js +0 -1417
- package/lib/vs/base/browser/event.js +0 -36
- package/lib/vs/base/browser/fastDomNode.js +0 -265
- package/lib/vs/base/browser/formattedTextRenderer.js +0 -248
- package/lib/vs/base/browser/globalMouseMoveMonitor.js +0 -137
- package/lib/vs/base/browser/history.js +0 -9
- package/lib/vs/base/browser/iframe.js +0 -126
- package/lib/vs/base/browser/keyboardEvent.js +0 -599
- package/lib/vs/base/browser/mouseEvent.js +0 -155
- package/lib/vs/base/browser/touch.js +0 -315
- package/lib/vs/base/browser/ui/actionbar/actionViewItems.js +0 -397
- package/lib/vs/base/browser/ui/actionbar/actionbar.js +0 -583
- package/lib/vs/base/browser/ui/checkbox/checkbox.js +0 -251
- package/lib/vs/base/browser/ui/codicons/codiconLabel.js +0 -31
- package/lib/vs/base/browser/ui/codicons/codiconStyles.js +0 -47
- package/lib/vs/base/browser/ui/contextview/contextview.js +0 -367
- package/lib/vs/base/browser/ui/dropdown/dropdown.js +0 -256
- package/lib/vs/base/browser/ui/dropdown/dropdownActionViewItem.js +0 -120
- package/lib/vs/base/browser/ui/keybindingLabel/keybindingLabel.js +0 -118
- package/lib/vs/base/browser/ui/list/list.js +0 -54
- package/lib/vs/base/browser/ui/list/listPaging.js +0 -322
- package/lib/vs/base/browser/ui/list/listView.js +0 -1388
- package/lib/vs/base/browser/ui/list/listWidget.js +0 -1709
- package/lib/vs/base/browser/ui/list/rangeMap.js +0 -223
- package/lib/vs/base/browser/ui/list/rowCache.js +0 -113
- package/lib/vs/base/browser/ui/list/splice.js +0 -23
- package/lib/vs/base/browser/ui/menu/menu.js +0 -1371
- package/lib/vs/base/browser/ui/menu/menubar.js +0 -1139
- package/lib/vs/base/browser/ui/scrollbar/abstractScrollbar.js +0 -278
- package/lib/vs/base/browser/ui/scrollbar/horizontalScrollbar.js +0 -115
- package/lib/vs/base/browser/ui/scrollbar/scrollableElement.js +0 -646
- package/lib/vs/base/browser/ui/scrollbar/scrollableElementOptions.js +0 -9
- package/lib/vs/base/browser/ui/scrollbar/scrollbarArrow.js +0 -106
- package/lib/vs/base/browser/ui/scrollbar/scrollbarState.js +0 -184
- package/lib/vs/base/browser/ui/scrollbar/scrollbarVisibilityController.js +0 -116
- package/lib/vs/base/browser/ui/scrollbar/verticalScrollbar.js +0 -114
- package/lib/vs/base/browser/ui/selectBox/selectBox.js +0 -85
- package/lib/vs/base/browser/ui/selectBox/selectBoxCustom.js +0 -985
- package/lib/vs/base/browser/ui/selectBox/selectBoxNative.js +0 -188
- package/lib/vs/base/browser/ui/toolbar/toolbar.js +0 -206
- package/lib/vs/base/browser/ui/widget.js +0 -69
- package/lib/vs/base/common/actions.js +0 -224
- package/lib/vs/base/common/amd.js +0 -31
- package/lib/vs/base/common/arrays.js +0 -641
- package/lib/vs/base/common/assert.js +0 -21
- package/lib/vs/base/common/async.js +0 -966
- package/lib/vs/base/common/buffer.js +0 -250
- package/lib/vs/base/common/cache.js +0 -40
- package/lib/vs/base/common/cancellation.js +0 -146
- package/lib/vs/base/common/charCode.js +0 -9
- package/lib/vs/base/common/codicon.js +0 -136
- package/lib/vs/base/common/codicons.js +0 -1378
- package/lib/vs/base/common/collections.js +0 -133
- package/lib/vs/base/common/color.js +0 -716
- package/lib/vs/base/common/comparers.js +0 -280
- package/lib/vs/base/common/console.js +0 -142
- package/lib/vs/base/common/date.js +0 -113
- package/lib/vs/base/common/decorators.js +0 -169
- package/lib/vs/base/common/errorMessage.js +0 -93
- package/lib/vs/base/common/errors.js +0 -213
- package/lib/vs/base/common/errorsWithActions.js +0 -28
- package/lib/vs/base/common/event.js +0 -873
- package/lib/vs/base/common/extpath.js +0 -401
- package/lib/vs/base/common/filters.js +0 -948
- package/lib/vs/base/common/functional.js +0 -28
- package/lib/vs/base/common/fuzzyScorer.js +0 -811
- package/lib/vs/base/common/glob.js +0 -696
- package/lib/vs/base/common/hash.js +0 -359
- package/lib/vs/base/common/history.js +0 -116
- package/lib/vs/base/common/htmlContent.js +0 -162
- package/lib/vs/base/common/idGenerator.js +0 -25
- package/lib/vs/base/common/iterator.js +0 -118
- package/lib/vs/base/common/json.js +0 -1624
- package/lib/vs/base/common/jsonEdit.js +0 -272
- package/lib/vs/base/common/jsonErrorMessages.js +0 -69
- package/lib/vs/base/common/jsonFormatter.js +0 -316
- package/lib/vs/base/common/jsonSchema.js +0 -9
- package/lib/vs/base/common/keyCodes.js +0 -591
- package/lib/vs/base/common/keybindingLabels.js +0 -231
- package/lib/vs/base/common/keybindingParser.js +0 -142
- package/lib/vs/base/common/labels.js +0 -430
- package/lib/vs/base/common/lazy.js +0 -71
- package/lib/vs/base/common/lifecycle.js +0 -308
- package/lib/vs/base/common/linkedList.js +0 -152
- package/lib/vs/base/common/linkedText.js +0 -73
- package/lib/vs/base/common/map.js +0 -1108
- package/lib/vs/base/common/marshalling.js +0 -80
- package/lib/vs/base/common/mime.js +0 -321
- package/lib/vs/base/common/navigator.js +0 -50
- package/lib/vs/base/common/network.js +0 -160
- package/lib/vs/base/common/normalization.js +0 -78
- package/lib/vs/base/common/numbers.js +0 -55
- package/lib/vs/base/common/objects.js +0 -268
- package/lib/vs/base/common/paging.js +0 -190
- package/lib/vs/base/common/parsers.js +0 -78
- package/lib/vs/base/common/path.js +0 -1550
- package/lib/vs/base/common/platform.js +0 -245
- package/lib/vs/base/common/process.js +0 -52
- package/lib/vs/base/common/processes.js +0 -32
- package/lib/vs/base/common/range.js +0 -79
- package/lib/vs/base/common/resourceTree.js +0 -185
- package/lib/vs/base/common/resources.js +0 -421
- package/lib/vs/base/common/scanCode.js +0 -1472
- package/lib/vs/base/common/scrollable.js +0 -397
- package/lib/vs/base/common/search.js +0 -55
- package/lib/vs/base/common/sequence.js +0 -64
- package/lib/vs/base/common/severity.js +0 -55
- package/lib/vs/base/common/skipList.js +0 -234
- package/lib/vs/base/common/stopwatch.js +0 -45
- package/lib/vs/base/common/stream.js +0 -418
- package/lib/vs/base/common/strings.js +0 -1283
- package/lib/vs/base/common/styler.js +0 -9
- package/lib/vs/base/common/types.js +0 -296
- package/lib/vs/base/common/uint.js +0 -46
- package/lib/vs/base/common/uri.js +0 -756
- package/lib/vs/base/common/uriIpc.js +0 -154
- package/lib/vs/base/common/uuid.js +0 -70
- package/lib/vs/nls.mock.js +0 -31
- package/lib/vs/platform/actions/browser/menuEntryActionViewItem.js +0 -342
- package/lib/vs/platform/actions/common/actions.js +0 -456
- package/lib/vs/platform/actions/common/menuService.js +0 -194
- package/lib/vs/platform/clipboard/browser/clipboardService.js +0 -99
- package/lib/vs/platform/clipboard/common/clipboardService.js +0 -14
- package/lib/vs/platform/contextkey/common/contextkey.js +0 -1210
- package/lib/vs/platform/contextkey/common/contextkeys.js +0 -23
- package/lib/vs/platform/contextview/browser/contextView.js +0 -15
- package/lib/vs/platform/contextview/browser/contextViewService.js +0 -96
- package/lib/vs/platform/environment/common/argv.js +0 -9
- package/lib/vs/platform/environment/common/environment.js +0 -15
- package/lib/vs/platform/instantiation/common/descriptors.js +0 -25
- package/lib/vs/platform/instantiation/common/extensions.js +0 -26
- package/lib/vs/platform/instantiation/common/graph.js +0 -93
- package/lib/vs/platform/instantiation/common/instantiation.js +0 -84
- package/lib/vs/platform/instantiation/common/instantiationService.js +0 -361
- package/lib/vs/platform/instantiation/common/serviceCollection.js +0 -39
- package/lib/vs/platform/keybinding/common/baseResolvedKeybinding.js +0 -73
- package/lib/vs/platform/keybinding/common/keybinding.js +0 -14
- package/lib/vs/platform/keybinding/common/keybindingResolver.js +0 -391
- package/lib/vs/platform/keybinding/common/keybindingsRegistry.js +0 -229
- package/lib/vs/platform/keybinding/common/resolvedKeybindingItem.js +0 -47
- package/lib/vs/platform/keybinding/common/usLayoutResolvedKeybinding.js +0 -160
- package/lib/vs/platform/layout/browser/layoutService.js +0 -14
- package/lib/vs/platform/menubar/common/menubar.js +0 -34
- package/lib/vs/platform/registry/common/platform.js +0 -38
- package/lib/vs/platform/theme/browser/checkbox.js +0 -32
- package/lib/vs/platform/theme/common/colorRegistry.js +0 -1154
- package/lib/vs/platform/theme/common/styler.js +0 -290
- package/lib/vs/platform/theme/common/theme.js +0 -21
- package/lib/vs/platform/theme/common/themeService.js +0 -176
- package/lib/vs/platform/theme/common/tokenClassificationRegistry.js +0 -540
- package/lib/vs/platform/theme/test/common/testThemeService.js +0 -98
|
@@ -1,1709 +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
|
-
var __decorate = this && this.__decorate || function (decorators, target, key, desc) {
|
|
8
|
-
var c = arguments.length,
|
|
9
|
-
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
10
|
-
d;
|
|
11
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
12
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
Object.defineProperty(exports, "__esModule", {
|
|
16
|
-
value: true
|
|
17
|
-
});
|
|
18
|
-
exports.List = exports.DefaultStyleController = exports.MouseController = exports.isSelectionRangeChangeEvent = exports.isSelectionSingleChangeEvent = exports.DefaultKeyboardNavigationDelegate = exports.isMonacoEditor = exports.isInputElement = void 0;
|
|
19
|
-
|
|
20
|
-
require("../../../../css!./list");
|
|
21
|
-
|
|
22
|
-
const lifecycle_1 = require("../../../common/lifecycle");
|
|
23
|
-
|
|
24
|
-
const types_1 = require("../../../common/types");
|
|
25
|
-
|
|
26
|
-
const arrays_1 = require("../../../common/arrays");
|
|
27
|
-
|
|
28
|
-
const decorators_1 = require("../../../common/decorators");
|
|
29
|
-
|
|
30
|
-
const platform = require("../../../common/platform");
|
|
31
|
-
|
|
32
|
-
const touch_1 = require("../../touch");
|
|
33
|
-
|
|
34
|
-
const keyboardEvent_1 = require("../../keyboardEvent");
|
|
35
|
-
|
|
36
|
-
const event_1 = require("../../../common/event");
|
|
37
|
-
|
|
38
|
-
const event_2 = require("../../event");
|
|
39
|
-
|
|
40
|
-
const list_1 = require("./list");
|
|
41
|
-
|
|
42
|
-
const listView_1 = require("./listView");
|
|
43
|
-
|
|
44
|
-
const color_1 = require("../../../common/color");
|
|
45
|
-
|
|
46
|
-
const objects_1 = require("../../../common/objects");
|
|
47
|
-
|
|
48
|
-
const splice_1 = require("./splice");
|
|
49
|
-
|
|
50
|
-
const numbers_1 = require("../../../common/numbers");
|
|
51
|
-
|
|
52
|
-
const filters_1 = require("../../../common/filters");
|
|
53
|
-
|
|
54
|
-
const dom_1 = require("../../dom");
|
|
55
|
-
|
|
56
|
-
class TraitRenderer {
|
|
57
|
-
constructor(trait) {
|
|
58
|
-
this.trait = trait;
|
|
59
|
-
this.renderedElements = [];
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
get templateId() {
|
|
63
|
-
return `template:${this.trait.trait}`;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
renderTemplate(container) {
|
|
67
|
-
return container;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
renderElement(element, index, templateData) {
|
|
71
|
-
const renderedElementIndex = this.renderedElements.findIndex(el => el.templateData === templateData);
|
|
72
|
-
|
|
73
|
-
if (renderedElementIndex >= 0) {
|
|
74
|
-
const rendered = this.renderedElements[renderedElementIndex];
|
|
75
|
-
this.trait.unrender(templateData);
|
|
76
|
-
rendered.index = index;
|
|
77
|
-
} else {
|
|
78
|
-
const rendered = {
|
|
79
|
-
index,
|
|
80
|
-
templateData
|
|
81
|
-
};
|
|
82
|
-
this.renderedElements.push(rendered);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
this.trait.renderIndex(index, templateData);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
splice(start, deleteCount, insertCount) {
|
|
89
|
-
const rendered = [];
|
|
90
|
-
|
|
91
|
-
for (const renderedElement of this.renderedElements) {
|
|
92
|
-
if (renderedElement.index < start) {
|
|
93
|
-
rendered.push(renderedElement);
|
|
94
|
-
} else if (renderedElement.index >= start + deleteCount) {
|
|
95
|
-
rendered.push({
|
|
96
|
-
index: renderedElement.index + insertCount - deleteCount,
|
|
97
|
-
templateData: renderedElement.templateData
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
this.renderedElements = rendered;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
renderIndexes(indexes) {
|
|
106
|
-
for (const {
|
|
107
|
-
index,
|
|
108
|
-
templateData
|
|
109
|
-
} of this.renderedElements) {
|
|
110
|
-
if (indexes.indexOf(index) > -1) {
|
|
111
|
-
this.trait.renderIndex(index, templateData);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
disposeTemplate(templateData) {
|
|
117
|
-
const index = this.renderedElements.findIndex(el => el.templateData === templateData);
|
|
118
|
-
|
|
119
|
-
if (index < 0) {
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
this.renderedElements.splice(index, 1);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
class Trait {
|
|
129
|
-
constructor(_trait) {
|
|
130
|
-
this._trait = _trait;
|
|
131
|
-
this.indexes = [];
|
|
132
|
-
this.sortedIndexes = [];
|
|
133
|
-
this._onChange = new event_1.Emitter();
|
|
134
|
-
this.onChange = this._onChange.event;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
get trait() {
|
|
138
|
-
return this._trait;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
get renderer() {
|
|
142
|
-
return new TraitRenderer(this);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
splice(start, deleteCount, elements) {
|
|
146
|
-
const diff = elements.length - deleteCount;
|
|
147
|
-
const end = start + deleteCount;
|
|
148
|
-
const indexes = [...this.sortedIndexes.filter(i => i < start), ...elements.map((hasTrait, i) => hasTrait ? i + start : -1).filter(i => i !== -1), ...this.sortedIndexes.filter(i => i >= end).map(i => i + diff)];
|
|
149
|
-
this.renderer.splice(start, deleteCount, elements.length);
|
|
150
|
-
|
|
151
|
-
this._set(indexes, indexes);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
renderIndex(index, container) {
|
|
155
|
-
container.classList.toggle(this._trait, this.contains(index));
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
unrender(container) {
|
|
159
|
-
container.classList.remove(this._trait);
|
|
160
|
-
}
|
|
161
|
-
/**
|
|
162
|
-
* Sets the indexes which should have this trait.
|
|
163
|
-
*
|
|
164
|
-
* @param indexes Indexes which should have this trait.
|
|
165
|
-
* @return The old indexes which had this trait.
|
|
166
|
-
*/
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
set(indexes, browserEvent) {
|
|
170
|
-
return this._set(indexes, [...indexes].sort(numericSort), browserEvent);
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
_set(indexes, sortedIndexes, browserEvent) {
|
|
174
|
-
const result = this.indexes;
|
|
175
|
-
const sortedResult = this.sortedIndexes;
|
|
176
|
-
this.indexes = indexes;
|
|
177
|
-
this.sortedIndexes = sortedIndexes;
|
|
178
|
-
const toRender = disjunction(sortedResult, indexes);
|
|
179
|
-
this.renderer.renderIndexes(toRender);
|
|
180
|
-
|
|
181
|
-
this._onChange.fire({
|
|
182
|
-
indexes,
|
|
183
|
-
browserEvent
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
return result;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
get() {
|
|
190
|
-
return this.indexes;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
contains(index) {
|
|
194
|
-
return arrays_1.binarySearch(this.sortedIndexes, index, numericSort) >= 0;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
dispose() {
|
|
198
|
-
lifecycle_1.dispose(this._onChange);
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
__decorate([decorators_1.memoize], Trait.prototype, "renderer", null);
|
|
204
|
-
|
|
205
|
-
class SelectionTrait extends Trait {
|
|
206
|
-
constructor(setAriaSelected) {
|
|
207
|
-
super('selected');
|
|
208
|
-
this.setAriaSelected = setAriaSelected;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
renderIndex(index, container) {
|
|
212
|
-
super.renderIndex(index, container);
|
|
213
|
-
|
|
214
|
-
if (this.setAriaSelected) {
|
|
215
|
-
if (this.contains(index)) {
|
|
216
|
-
container.setAttribute('aria-selected', 'true');
|
|
217
|
-
} else {
|
|
218
|
-
container.setAttribute('aria-selected', 'false');
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
}
|
|
224
|
-
/**
|
|
225
|
-
* The TraitSpliceable is used as a util class to be able
|
|
226
|
-
* to preserve traits across splice calls, given an identity
|
|
227
|
-
* provider.
|
|
228
|
-
*/
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
class TraitSpliceable {
|
|
232
|
-
constructor(trait, view, identityProvider) {
|
|
233
|
-
this.trait = trait;
|
|
234
|
-
this.view = view;
|
|
235
|
-
this.identityProvider = identityProvider;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
splice(start, deleteCount, elements) {
|
|
239
|
-
if (!this.identityProvider) {
|
|
240
|
-
return this.trait.splice(start, deleteCount, elements.map(() => false));
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
const pastElementsWithTrait = this.trait.get().map(i => this.identityProvider.getId(this.view.element(i)).toString());
|
|
244
|
-
const elementsWithTrait = elements.map(e => pastElementsWithTrait.indexOf(this.identityProvider.getId(e).toString()) > -1);
|
|
245
|
-
this.trait.splice(start, deleteCount, elementsWithTrait);
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
function isInputElement(e) {
|
|
251
|
-
return e.tagName === 'INPUT' || e.tagName === 'TEXTAREA';
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
exports.isInputElement = isInputElement;
|
|
255
|
-
|
|
256
|
-
function isMonacoEditor(e) {
|
|
257
|
-
if (e.classList.contains('monaco-editor')) {
|
|
258
|
-
return true;
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
if (e.classList.contains('monaco-list')) {
|
|
262
|
-
return false;
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
if (!e.parentElement) {
|
|
266
|
-
return false;
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
return isMonacoEditor(e.parentElement);
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
exports.isMonacoEditor = isMonacoEditor;
|
|
273
|
-
|
|
274
|
-
class KeyboardController {
|
|
275
|
-
constructor(list, view, options) {
|
|
276
|
-
this.list = list;
|
|
277
|
-
this.view = view;
|
|
278
|
-
this.disposables = new lifecycle_1.DisposableStore();
|
|
279
|
-
const multipleSelectionSupport = options.multipleSelectionSupport !== false;
|
|
280
|
-
const onKeyDown = event_1.Event.chain(event_2.domEvent(view.domNode, 'keydown')).filter(e => !isInputElement(e.target)).map(e => new keyboardEvent_1.StandardKeyboardEvent(e));
|
|
281
|
-
onKeyDown.filter(e => e.keyCode === 3
|
|
282
|
-
/* Enter */
|
|
283
|
-
).on(this.onEnter, this, this.disposables);
|
|
284
|
-
onKeyDown.filter(e => e.keyCode === 16
|
|
285
|
-
/* UpArrow */
|
|
286
|
-
).on(this.onUpArrow, this, this.disposables);
|
|
287
|
-
onKeyDown.filter(e => e.keyCode === 18
|
|
288
|
-
/* DownArrow */
|
|
289
|
-
).on(this.onDownArrow, this, this.disposables);
|
|
290
|
-
onKeyDown.filter(e => e.keyCode === 11
|
|
291
|
-
/* PageUp */
|
|
292
|
-
).on(this.onPageUpArrow, this, this.disposables);
|
|
293
|
-
onKeyDown.filter(e => e.keyCode === 12
|
|
294
|
-
/* PageDown */
|
|
295
|
-
).on(this.onPageDownArrow, this, this.disposables);
|
|
296
|
-
onKeyDown.filter(e => e.keyCode === 9
|
|
297
|
-
/* Escape */
|
|
298
|
-
).on(this.onEscape, this, this.disposables);
|
|
299
|
-
|
|
300
|
-
if (multipleSelectionSupport) {
|
|
301
|
-
onKeyDown.filter(e => (platform.isMacintosh ? e.metaKey : e.ctrlKey) && e.keyCode === 31
|
|
302
|
-
/* KEY_A */
|
|
303
|
-
).on(this.onCtrlA, this, this.disposables);
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
onEnter(e) {
|
|
308
|
-
e.preventDefault();
|
|
309
|
-
e.stopPropagation();
|
|
310
|
-
this.list.setSelection(this.list.getFocus(), e.browserEvent);
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
onUpArrow(e) {
|
|
314
|
-
e.preventDefault();
|
|
315
|
-
e.stopPropagation();
|
|
316
|
-
this.list.focusPrevious(1, false, e.browserEvent);
|
|
317
|
-
this.list.reveal(this.list.getFocus()[0]);
|
|
318
|
-
this.view.domNode.focus();
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
onDownArrow(e) {
|
|
322
|
-
e.preventDefault();
|
|
323
|
-
e.stopPropagation();
|
|
324
|
-
this.list.focusNext(1, false, e.browserEvent);
|
|
325
|
-
this.list.reveal(this.list.getFocus()[0]);
|
|
326
|
-
this.view.domNode.focus();
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
onPageUpArrow(e) {
|
|
330
|
-
e.preventDefault();
|
|
331
|
-
e.stopPropagation();
|
|
332
|
-
this.list.focusPreviousPage(e.browserEvent);
|
|
333
|
-
this.list.reveal(this.list.getFocus()[0]);
|
|
334
|
-
this.view.domNode.focus();
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
onPageDownArrow(e) {
|
|
338
|
-
e.preventDefault();
|
|
339
|
-
e.stopPropagation();
|
|
340
|
-
this.list.focusNextPage(e.browserEvent);
|
|
341
|
-
this.list.reveal(this.list.getFocus()[0]);
|
|
342
|
-
this.view.domNode.focus();
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
onCtrlA(e) {
|
|
346
|
-
e.preventDefault();
|
|
347
|
-
e.stopPropagation();
|
|
348
|
-
this.list.setSelection(arrays_1.range(this.list.length), e.browserEvent);
|
|
349
|
-
this.view.domNode.focus();
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
onEscape(e) {
|
|
353
|
-
e.preventDefault();
|
|
354
|
-
e.stopPropagation();
|
|
355
|
-
this.list.setSelection([], e.browserEvent);
|
|
356
|
-
this.view.domNode.focus();
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
dispose() {
|
|
360
|
-
this.disposables.dispose();
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
var TypeLabelControllerState;
|
|
366
|
-
|
|
367
|
-
(function (TypeLabelControllerState) {
|
|
368
|
-
TypeLabelControllerState[TypeLabelControllerState["Idle"] = 0] = "Idle";
|
|
369
|
-
TypeLabelControllerState[TypeLabelControllerState["Typing"] = 1] = "Typing";
|
|
370
|
-
})(TypeLabelControllerState || (TypeLabelControllerState = {}));
|
|
371
|
-
|
|
372
|
-
exports.DefaultKeyboardNavigationDelegate = new class {
|
|
373
|
-
mightProducePrintableCharacter(event) {
|
|
374
|
-
if (event.ctrlKey || event.metaKey || event.altKey) {
|
|
375
|
-
return false;
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
return event.keyCode >= 31
|
|
379
|
-
/* KEY_A */
|
|
380
|
-
&& event.keyCode <= 56
|
|
381
|
-
/* KEY_Z */
|
|
382
|
-
|| event.keyCode >= 21
|
|
383
|
-
/* KEY_0 */
|
|
384
|
-
&& event.keyCode <= 30
|
|
385
|
-
/* KEY_9 */
|
|
386
|
-
|| event.keyCode >= 93
|
|
387
|
-
/* NUMPAD_0 */
|
|
388
|
-
&& event.keyCode <= 102
|
|
389
|
-
/* NUMPAD_9 */
|
|
390
|
-
|| event.keyCode >= 80
|
|
391
|
-
/* US_SEMICOLON */
|
|
392
|
-
&& event.keyCode <= 90
|
|
393
|
-
/* US_QUOTE */
|
|
394
|
-
;
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
}();
|
|
398
|
-
|
|
399
|
-
class TypeLabelController {
|
|
400
|
-
constructor(list, view, keyboardNavigationLabelProvider, delegate) {
|
|
401
|
-
this.list = list;
|
|
402
|
-
this.view = view;
|
|
403
|
-
this.keyboardNavigationLabelProvider = keyboardNavigationLabelProvider;
|
|
404
|
-
this.delegate = delegate;
|
|
405
|
-
this.enabled = false;
|
|
406
|
-
this.state = TypeLabelControllerState.Idle;
|
|
407
|
-
this.automaticKeyboardNavigation = true;
|
|
408
|
-
this.triggered = false;
|
|
409
|
-
this.previouslyFocused = -1;
|
|
410
|
-
this.enabledDisposables = new lifecycle_1.DisposableStore();
|
|
411
|
-
this.disposables = new lifecycle_1.DisposableStore();
|
|
412
|
-
this.updateOptions(list.options);
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
updateOptions(options) {
|
|
416
|
-
const enableKeyboardNavigation = typeof options.enableKeyboardNavigation === 'undefined' ? true : !!options.enableKeyboardNavigation;
|
|
417
|
-
|
|
418
|
-
if (enableKeyboardNavigation) {
|
|
419
|
-
this.enable();
|
|
420
|
-
} else {
|
|
421
|
-
this.disable();
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
if (typeof options.automaticKeyboardNavigation !== 'undefined') {
|
|
425
|
-
this.automaticKeyboardNavigation = options.automaticKeyboardNavigation;
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
toggle() {
|
|
430
|
-
this.triggered = !this.triggered;
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
enable() {
|
|
434
|
-
if (this.enabled) {
|
|
435
|
-
return;
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
const onChar = event_1.Event.chain(event_2.domEvent(this.view.domNode, 'keydown')).filter(e => !isInputElement(e.target)).filter(() => this.automaticKeyboardNavigation || this.triggered).map(event => new keyboardEvent_1.StandardKeyboardEvent(event)).filter(e => this.delegate.mightProducePrintableCharacter(e)).forEach(e => {
|
|
439
|
-
e.stopPropagation();
|
|
440
|
-
e.preventDefault();
|
|
441
|
-
}).map(event => event.browserEvent.key).event;
|
|
442
|
-
const onClear = event_1.Event.debounce(onChar, () => null, 800);
|
|
443
|
-
const onInput = event_1.Event.reduce(event_1.Event.any(onChar, onClear), (r, i) => i === null ? null : (r || '') + i);
|
|
444
|
-
onInput(this.onInput, this, this.enabledDisposables);
|
|
445
|
-
onClear(this.onClear, this, this.enabledDisposables);
|
|
446
|
-
this.enabled = true;
|
|
447
|
-
this.triggered = false;
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
disable() {
|
|
451
|
-
if (!this.enabled) {
|
|
452
|
-
return;
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
this.enabledDisposables.clear();
|
|
456
|
-
this.enabled = false;
|
|
457
|
-
this.triggered = false;
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
onClear() {
|
|
461
|
-
var _a;
|
|
462
|
-
|
|
463
|
-
const focus = this.list.getFocus();
|
|
464
|
-
|
|
465
|
-
if (focus.length > 0 && focus[0] === this.previouslyFocused) {
|
|
466
|
-
// List: re-anounce element on typing end since typed keys will interupt aria label of focused element
|
|
467
|
-
// Do not announce if there was a focus change at the end to prevent duplication https://github.com/microsoft/vscode/issues/95961
|
|
468
|
-
const ariaLabel = (_a = this.list.options.accessibilityProvider) === null || _a === void 0 ? void 0 : _a.getAriaLabel(this.list.element(focus[0]));
|
|
469
|
-
|
|
470
|
-
if (ariaLabel) {
|
|
471
|
-
alert(ariaLabel);
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
this.previouslyFocused = -1;
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
onInput(word) {
|
|
479
|
-
if (!word) {
|
|
480
|
-
this.state = TypeLabelControllerState.Idle;
|
|
481
|
-
this.triggered = false;
|
|
482
|
-
return;
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
const focus = this.list.getFocus();
|
|
486
|
-
const start = focus.length > 0 ? focus[0] : 0;
|
|
487
|
-
const delta = this.state === TypeLabelControllerState.Idle ? 1 : 0;
|
|
488
|
-
this.state = TypeLabelControllerState.Typing;
|
|
489
|
-
|
|
490
|
-
for (let i = 0; i < this.list.length; i++) {
|
|
491
|
-
const index = (start + i + delta) % this.list.length;
|
|
492
|
-
const label = this.keyboardNavigationLabelProvider.getKeyboardNavigationLabel(this.view.element(index));
|
|
493
|
-
const labelStr = label && label.toString();
|
|
494
|
-
|
|
495
|
-
if (typeof labelStr === 'undefined' || filters_1.matchesPrefix(word, labelStr)) {
|
|
496
|
-
this.previouslyFocused = start;
|
|
497
|
-
this.list.setFocus([index]);
|
|
498
|
-
this.list.reveal(index);
|
|
499
|
-
return;
|
|
500
|
-
}
|
|
501
|
-
}
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
dispose() {
|
|
505
|
-
this.disable();
|
|
506
|
-
this.enabledDisposables.dispose();
|
|
507
|
-
this.disposables.dispose();
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
class DOMFocusController {
|
|
513
|
-
constructor(list, view) {
|
|
514
|
-
this.list = list;
|
|
515
|
-
this.view = view;
|
|
516
|
-
this.disposables = new lifecycle_1.DisposableStore();
|
|
517
|
-
const onKeyDown = event_1.Event.chain(event_2.domEvent(view.domNode, 'keydown')).filter(e => !isInputElement(e.target)).map(e => new keyboardEvent_1.StandardKeyboardEvent(e));
|
|
518
|
-
onKeyDown.filter(e => e.keyCode === 2
|
|
519
|
-
/* Tab */
|
|
520
|
-
&& !e.ctrlKey && !e.metaKey && !e.shiftKey && !e.altKey).on(this.onTab, this, this.disposables);
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
onTab(e) {
|
|
524
|
-
if (e.target !== this.view.domNode) {
|
|
525
|
-
return;
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
const focus = this.list.getFocus();
|
|
529
|
-
|
|
530
|
-
if (focus.length === 0) {
|
|
531
|
-
return;
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
const focusedDomElement = this.view.domElement(focus[0]);
|
|
535
|
-
|
|
536
|
-
if (!focusedDomElement) {
|
|
537
|
-
return;
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
const tabIndexElement = focusedDomElement.querySelector('[tabIndex]');
|
|
541
|
-
|
|
542
|
-
if (!tabIndexElement || !(tabIndexElement instanceof HTMLElement) || tabIndexElement.tabIndex === -1) {
|
|
543
|
-
return;
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
const style = window.getComputedStyle(tabIndexElement);
|
|
547
|
-
|
|
548
|
-
if (style.visibility === 'hidden' || style.display === 'none') {
|
|
549
|
-
return;
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
e.preventDefault();
|
|
553
|
-
e.stopPropagation();
|
|
554
|
-
tabIndexElement.focus();
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
dispose() {
|
|
558
|
-
this.disposables.dispose();
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
function isSelectionSingleChangeEvent(event) {
|
|
564
|
-
return platform.isMacintosh ? event.browserEvent.metaKey : event.browserEvent.ctrlKey;
|
|
565
|
-
}
|
|
566
|
-
|
|
567
|
-
exports.isSelectionSingleChangeEvent = isSelectionSingleChangeEvent;
|
|
568
|
-
|
|
569
|
-
function isSelectionRangeChangeEvent(event) {
|
|
570
|
-
return event.browserEvent.shiftKey;
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
exports.isSelectionRangeChangeEvent = isSelectionRangeChangeEvent;
|
|
574
|
-
|
|
575
|
-
function isMouseRightClick(event) {
|
|
576
|
-
return event instanceof MouseEvent && event.button === 2;
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
const DefaultMultipleSelectionController = {
|
|
580
|
-
isSelectionSingleChangeEvent,
|
|
581
|
-
isSelectionRangeChangeEvent
|
|
582
|
-
};
|
|
583
|
-
|
|
584
|
-
class MouseController {
|
|
585
|
-
constructor(list) {
|
|
586
|
-
this.list = list;
|
|
587
|
-
this.disposables = new lifecycle_1.DisposableStore();
|
|
588
|
-
this._onPointer = new event_1.Emitter();
|
|
589
|
-
this.onPointer = this._onPointer.event;
|
|
590
|
-
this.multipleSelectionSupport = !(list.options.multipleSelectionSupport === false);
|
|
591
|
-
|
|
592
|
-
if (this.multipleSelectionSupport) {
|
|
593
|
-
this.multipleSelectionController = list.options.multipleSelectionController || DefaultMultipleSelectionController;
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
this.mouseSupport = typeof list.options.mouseSupport === 'undefined' || !!list.options.mouseSupport;
|
|
597
|
-
|
|
598
|
-
if (this.mouseSupport) {
|
|
599
|
-
list.onMouseDown(this.onMouseDown, this, this.disposables);
|
|
600
|
-
list.onContextMenu(this.onContextMenu, this, this.disposables);
|
|
601
|
-
list.onMouseDblClick(this.onDoubleClick, this, this.disposables);
|
|
602
|
-
list.onTouchStart(this.onMouseDown, this, this.disposables);
|
|
603
|
-
this.disposables.add(touch_1.Gesture.addTarget(list.getHTMLElement()));
|
|
604
|
-
}
|
|
605
|
-
|
|
606
|
-
event_1.Event.any(list.onMouseClick, list.onMouseMiddleClick, list.onTap)(this.onViewPointer, this, this.disposables);
|
|
607
|
-
}
|
|
608
|
-
|
|
609
|
-
isSelectionSingleChangeEvent(event) {
|
|
610
|
-
if (this.multipleSelectionController) {
|
|
611
|
-
return this.multipleSelectionController.isSelectionSingleChangeEvent(event);
|
|
612
|
-
}
|
|
613
|
-
|
|
614
|
-
return platform.isMacintosh ? event.browserEvent.metaKey : event.browserEvent.ctrlKey;
|
|
615
|
-
}
|
|
616
|
-
|
|
617
|
-
isSelectionRangeChangeEvent(event) {
|
|
618
|
-
if (this.multipleSelectionController) {
|
|
619
|
-
return this.multipleSelectionController.isSelectionRangeChangeEvent(event);
|
|
620
|
-
}
|
|
621
|
-
|
|
622
|
-
return event.browserEvent.shiftKey;
|
|
623
|
-
}
|
|
624
|
-
|
|
625
|
-
isSelectionChangeEvent(event) {
|
|
626
|
-
return this.isSelectionSingleChangeEvent(event) || this.isSelectionRangeChangeEvent(event);
|
|
627
|
-
}
|
|
628
|
-
|
|
629
|
-
onMouseDown(e) {
|
|
630
|
-
if (isMonacoEditor(e.browserEvent.target)) {
|
|
631
|
-
return;
|
|
632
|
-
}
|
|
633
|
-
|
|
634
|
-
if (document.activeElement !== e.browserEvent.target) {
|
|
635
|
-
this.list.domFocus();
|
|
636
|
-
}
|
|
637
|
-
}
|
|
638
|
-
|
|
639
|
-
onContextMenu(e) {
|
|
640
|
-
if (isMonacoEditor(e.browserEvent.target)) {
|
|
641
|
-
return;
|
|
642
|
-
}
|
|
643
|
-
|
|
644
|
-
const focus = typeof e.index === 'undefined' ? [] : [e.index];
|
|
645
|
-
this.list.setFocus(focus, e.browserEvent);
|
|
646
|
-
}
|
|
647
|
-
|
|
648
|
-
onViewPointer(e) {
|
|
649
|
-
if (!this.mouseSupport) {
|
|
650
|
-
return;
|
|
651
|
-
}
|
|
652
|
-
|
|
653
|
-
if (isInputElement(e.browserEvent.target) || isMonacoEditor(e.browserEvent.target)) {
|
|
654
|
-
return;
|
|
655
|
-
}
|
|
656
|
-
|
|
657
|
-
let reference = this.list.getFocus()[0];
|
|
658
|
-
const selection = this.list.getSelection();
|
|
659
|
-
reference = reference === undefined ? selection[0] : reference;
|
|
660
|
-
const focus = e.index;
|
|
661
|
-
|
|
662
|
-
if (typeof focus === 'undefined') {
|
|
663
|
-
this.list.setFocus([], e.browserEvent);
|
|
664
|
-
this.list.setSelection([], e.browserEvent);
|
|
665
|
-
return;
|
|
666
|
-
}
|
|
667
|
-
|
|
668
|
-
if (this.multipleSelectionSupport && this.isSelectionRangeChangeEvent(e)) {
|
|
669
|
-
return this.changeSelection(e, reference);
|
|
670
|
-
}
|
|
671
|
-
|
|
672
|
-
if (this.multipleSelectionSupport && this.isSelectionChangeEvent(e)) {
|
|
673
|
-
return this.changeSelection(e, reference);
|
|
674
|
-
}
|
|
675
|
-
|
|
676
|
-
this.list.setFocus([focus], e.browserEvent);
|
|
677
|
-
|
|
678
|
-
if (!isMouseRightClick(e.browserEvent)) {
|
|
679
|
-
this.list.setSelection([focus], e.browserEvent);
|
|
680
|
-
}
|
|
681
|
-
|
|
682
|
-
this._onPointer.fire(e);
|
|
683
|
-
}
|
|
684
|
-
|
|
685
|
-
onDoubleClick(e) {
|
|
686
|
-
if (isInputElement(e.browserEvent.target) || isMonacoEditor(e.browserEvent.target)) {
|
|
687
|
-
return;
|
|
688
|
-
}
|
|
689
|
-
|
|
690
|
-
if (this.multipleSelectionSupport && this.isSelectionChangeEvent(e)) {
|
|
691
|
-
return;
|
|
692
|
-
}
|
|
693
|
-
|
|
694
|
-
const focus = this.list.getFocus();
|
|
695
|
-
this.list.setSelection(focus, e.browserEvent);
|
|
696
|
-
}
|
|
697
|
-
|
|
698
|
-
changeSelection(e, reference) {
|
|
699
|
-
const focus = e.index;
|
|
700
|
-
|
|
701
|
-
if (this.isSelectionRangeChangeEvent(e) && reference !== undefined) {
|
|
702
|
-
const min = Math.min(reference, focus);
|
|
703
|
-
const max = Math.max(reference, focus);
|
|
704
|
-
const rangeSelection = arrays_1.range(min, max + 1);
|
|
705
|
-
const selection = this.list.getSelection();
|
|
706
|
-
const contiguousRange = getContiguousRangeContaining(disjunction(selection, [reference]), reference);
|
|
707
|
-
|
|
708
|
-
if (contiguousRange.length === 0) {
|
|
709
|
-
return;
|
|
710
|
-
}
|
|
711
|
-
|
|
712
|
-
const newSelection = disjunction(rangeSelection, relativeComplement(selection, contiguousRange));
|
|
713
|
-
this.list.setSelection(newSelection, e.browserEvent);
|
|
714
|
-
} else if (this.isSelectionSingleChangeEvent(e)) {
|
|
715
|
-
const selection = this.list.getSelection();
|
|
716
|
-
const newSelection = selection.filter(i => i !== focus);
|
|
717
|
-
this.list.setFocus([focus]);
|
|
718
|
-
|
|
719
|
-
if (selection.length === newSelection.length) {
|
|
720
|
-
this.list.setSelection([...newSelection, focus], e.browserEvent);
|
|
721
|
-
} else {
|
|
722
|
-
this.list.setSelection(newSelection, e.browserEvent);
|
|
723
|
-
}
|
|
724
|
-
}
|
|
725
|
-
}
|
|
726
|
-
|
|
727
|
-
dispose() {
|
|
728
|
-
this.disposables.dispose();
|
|
729
|
-
}
|
|
730
|
-
|
|
731
|
-
}
|
|
732
|
-
|
|
733
|
-
exports.MouseController = MouseController;
|
|
734
|
-
|
|
735
|
-
class DefaultStyleController {
|
|
736
|
-
constructor(styleElement, selectorSuffix) {
|
|
737
|
-
this.styleElement = styleElement;
|
|
738
|
-
this.selectorSuffix = selectorSuffix;
|
|
739
|
-
}
|
|
740
|
-
|
|
741
|
-
style(styles) {
|
|
742
|
-
const suffix = this.selectorSuffix && `.${this.selectorSuffix}`;
|
|
743
|
-
const content = [];
|
|
744
|
-
|
|
745
|
-
if (styles.listBackground) {
|
|
746
|
-
if (styles.listBackground.isOpaque()) {
|
|
747
|
-
content.push(`.monaco-list${suffix} .monaco-list-rows { background: ${styles.listBackground}; }`);
|
|
748
|
-
} else if (!platform.isMacintosh) {
|
|
749
|
-
// subpixel AA doesn't exist in macOS
|
|
750
|
-
console.warn(`List with id '${this.selectorSuffix}' was styled with a non-opaque background color. This will break sub-pixel antialiasing.`);
|
|
751
|
-
}
|
|
752
|
-
}
|
|
753
|
-
|
|
754
|
-
if (styles.listFocusBackground) {
|
|
755
|
-
content.push(`.monaco-list${suffix}:focus .monaco-list-row.focused { background-color: ${styles.listFocusBackground}; }`);
|
|
756
|
-
content.push(`.monaco-list${suffix}:focus .monaco-list-row.focused:hover { background-color: ${styles.listFocusBackground}; }`); // overwrite :hover style in this case!
|
|
757
|
-
}
|
|
758
|
-
|
|
759
|
-
if (styles.listFocusForeground) {
|
|
760
|
-
content.push(`.monaco-list${suffix}:focus .monaco-list-row.focused { color: ${styles.listFocusForeground}; }`);
|
|
761
|
-
}
|
|
762
|
-
|
|
763
|
-
if (styles.listActiveSelectionBackground) {
|
|
764
|
-
content.push(`.monaco-list${suffix}:focus .monaco-list-row.selected { background-color: ${styles.listActiveSelectionBackground}; }`);
|
|
765
|
-
content.push(`.monaco-list${suffix}:focus .monaco-list-row.selected:hover { background-color: ${styles.listActiveSelectionBackground}; }`); // overwrite :hover style in this case!
|
|
766
|
-
}
|
|
767
|
-
|
|
768
|
-
if (styles.listActiveSelectionForeground) {
|
|
769
|
-
content.push(`.monaco-list${suffix}:focus .monaco-list-row.selected { color: ${styles.listActiveSelectionForeground}; }`);
|
|
770
|
-
}
|
|
771
|
-
|
|
772
|
-
if (styles.listFocusAndSelectionBackground) {
|
|
773
|
-
content.push(`
|
|
774
|
-
.monaco-drag-image,
|
|
775
|
-
.monaco-list${suffix}:focus .monaco-list-row.selected.focused { background-color: ${styles.listFocusAndSelectionBackground}; }
|
|
776
|
-
`);
|
|
777
|
-
}
|
|
778
|
-
|
|
779
|
-
if (styles.listFocusAndSelectionForeground) {
|
|
780
|
-
content.push(`
|
|
781
|
-
.monaco-drag-image,
|
|
782
|
-
.monaco-list${suffix}:focus .monaco-list-row.selected.focused { color: ${styles.listFocusAndSelectionForeground}; }
|
|
783
|
-
`);
|
|
784
|
-
}
|
|
785
|
-
|
|
786
|
-
if (styles.listInactiveFocusBackground) {
|
|
787
|
-
content.push(`.monaco-list${suffix} .monaco-list-row.focused { background-color: ${styles.listInactiveFocusBackground}; }`);
|
|
788
|
-
content.push(`.monaco-list${suffix} .monaco-list-row.focused:hover { background-color: ${styles.listInactiveFocusBackground}; }`); // overwrite :hover style in this case!
|
|
789
|
-
}
|
|
790
|
-
|
|
791
|
-
if (styles.listInactiveSelectionBackground) {
|
|
792
|
-
content.push(`.monaco-list${suffix} .monaco-list-row.selected { background-color: ${styles.listInactiveSelectionBackground}; }`);
|
|
793
|
-
content.push(`.monaco-list${suffix} .monaco-list-row.selected:hover { background-color: ${styles.listInactiveSelectionBackground}; }`); // overwrite :hover style in this case!
|
|
794
|
-
}
|
|
795
|
-
|
|
796
|
-
if (styles.listInactiveSelectionForeground) {
|
|
797
|
-
content.push(`.monaco-list${suffix} .monaco-list-row.selected { color: ${styles.listInactiveSelectionForeground}; }`);
|
|
798
|
-
}
|
|
799
|
-
|
|
800
|
-
if (styles.listHoverBackground) {
|
|
801
|
-
content.push(`.monaco-list${suffix}:not(.drop-target) .monaco-list-row:hover:not(.selected):not(.focused) { background-color: ${styles.listHoverBackground}; }`);
|
|
802
|
-
}
|
|
803
|
-
|
|
804
|
-
if (styles.listHoverForeground) {
|
|
805
|
-
content.push(`.monaco-list${suffix} .monaco-list-row:hover:not(.selected):not(.focused) { color: ${styles.listHoverForeground}; }`);
|
|
806
|
-
}
|
|
807
|
-
|
|
808
|
-
if (styles.listSelectionOutline) {
|
|
809
|
-
content.push(`.monaco-list${suffix} .monaco-list-row.selected { outline: 1px dotted ${styles.listSelectionOutline}; outline-offset: -1px; }`);
|
|
810
|
-
}
|
|
811
|
-
|
|
812
|
-
if (styles.listFocusOutline) {
|
|
813
|
-
content.push(`
|
|
814
|
-
.monaco-drag-image,
|
|
815
|
-
.monaco-list${suffix}:focus .monaco-list-row.focused { outline: 1px solid ${styles.listFocusOutline}; outline-offset: -1px; }
|
|
816
|
-
`);
|
|
817
|
-
}
|
|
818
|
-
|
|
819
|
-
if (styles.listInactiveFocusOutline) {
|
|
820
|
-
content.push(`.monaco-list${suffix} .monaco-list-row.focused { outline: 1px dotted ${styles.listInactiveFocusOutline}; outline-offset: -1px; }`);
|
|
821
|
-
}
|
|
822
|
-
|
|
823
|
-
if (styles.listHoverOutline) {
|
|
824
|
-
content.push(`.monaco-list${suffix} .monaco-list-row:hover { outline: 1px dashed ${styles.listHoverOutline}; outline-offset: -1px; }`);
|
|
825
|
-
}
|
|
826
|
-
|
|
827
|
-
if (styles.listDropBackground) {
|
|
828
|
-
content.push(`
|
|
829
|
-
.monaco-list${suffix}.drop-target,
|
|
830
|
-
.monaco-list${suffix} .monaco-list-rows.drop-target,
|
|
831
|
-
.monaco-list${suffix} .monaco-list-row.drop-target { background-color: ${styles.listDropBackground} !important; color: inherit !important; }
|
|
832
|
-
`);
|
|
833
|
-
}
|
|
834
|
-
|
|
835
|
-
if (styles.listFilterWidgetBackground) {
|
|
836
|
-
content.push(`.monaco-list-type-filter { background-color: ${styles.listFilterWidgetBackground} }`);
|
|
837
|
-
}
|
|
838
|
-
|
|
839
|
-
if (styles.listFilterWidgetOutline) {
|
|
840
|
-
content.push(`.monaco-list-type-filter { border: 1px solid ${styles.listFilterWidgetOutline}; }`);
|
|
841
|
-
}
|
|
842
|
-
|
|
843
|
-
if (styles.listFilterWidgetNoMatchesOutline) {
|
|
844
|
-
content.push(`.monaco-list-type-filter.no-matches { border: 1px solid ${styles.listFilterWidgetNoMatchesOutline}; }`);
|
|
845
|
-
}
|
|
846
|
-
|
|
847
|
-
if (styles.listMatchesShadow) {
|
|
848
|
-
content.push(`.monaco-list-type-filter { box-shadow: 1px 1px 1px ${styles.listMatchesShadow}; }`);
|
|
849
|
-
}
|
|
850
|
-
|
|
851
|
-
this.styleElement.textContent = content.join('\n');
|
|
852
|
-
}
|
|
853
|
-
|
|
854
|
-
}
|
|
855
|
-
|
|
856
|
-
exports.DefaultStyleController = DefaultStyleController;
|
|
857
|
-
const defaultStyles = {
|
|
858
|
-
listFocusBackground: color_1.Color.fromHex('#7FB0D0'),
|
|
859
|
-
listActiveSelectionBackground: color_1.Color.fromHex('#0E639C'),
|
|
860
|
-
listActiveSelectionForeground: color_1.Color.fromHex('#FFFFFF'),
|
|
861
|
-
listFocusAndSelectionBackground: color_1.Color.fromHex('#094771'),
|
|
862
|
-
listFocusAndSelectionForeground: color_1.Color.fromHex('#FFFFFF'),
|
|
863
|
-
listInactiveSelectionBackground: color_1.Color.fromHex('#3F3F46'),
|
|
864
|
-
listHoverBackground: color_1.Color.fromHex('#2A2D2E'),
|
|
865
|
-
listDropBackground: color_1.Color.fromHex('#383B3D'),
|
|
866
|
-
treeIndentGuidesStroke: color_1.Color.fromHex('#a9a9a9')
|
|
867
|
-
};
|
|
868
|
-
const DefaultOptions = {
|
|
869
|
-
keyboardSupport: true,
|
|
870
|
-
mouseSupport: true,
|
|
871
|
-
multipleSelectionSupport: true,
|
|
872
|
-
dnd: {
|
|
873
|
-
getDragURI() {
|
|
874
|
-
return null;
|
|
875
|
-
},
|
|
876
|
-
|
|
877
|
-
onDragStart() {},
|
|
878
|
-
|
|
879
|
-
onDragOver() {
|
|
880
|
-
return false;
|
|
881
|
-
},
|
|
882
|
-
|
|
883
|
-
drop() {}
|
|
884
|
-
|
|
885
|
-
}
|
|
886
|
-
}; // TODO@Joao: move these utils into a SortedArray class
|
|
887
|
-
|
|
888
|
-
function getContiguousRangeContaining(range, value) {
|
|
889
|
-
const index = range.indexOf(value);
|
|
890
|
-
|
|
891
|
-
if (index === -1) {
|
|
892
|
-
return [];
|
|
893
|
-
}
|
|
894
|
-
|
|
895
|
-
const result = [];
|
|
896
|
-
let i = index - 1;
|
|
897
|
-
|
|
898
|
-
while (i >= 0 && range[i] === value - (index - i)) {
|
|
899
|
-
result.push(range[i--]);
|
|
900
|
-
}
|
|
901
|
-
|
|
902
|
-
result.reverse();
|
|
903
|
-
i = index;
|
|
904
|
-
|
|
905
|
-
while (i < range.length && range[i] === value + (i - index)) {
|
|
906
|
-
result.push(range[i++]);
|
|
907
|
-
}
|
|
908
|
-
|
|
909
|
-
return result;
|
|
910
|
-
}
|
|
911
|
-
/**
|
|
912
|
-
* Given two sorted collections of numbers, returns the intersection
|
|
913
|
-
* between them (OR).
|
|
914
|
-
*/
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
function disjunction(one, other) {
|
|
918
|
-
const result = [];
|
|
919
|
-
let i = 0,
|
|
920
|
-
j = 0;
|
|
921
|
-
|
|
922
|
-
while (i < one.length || j < other.length) {
|
|
923
|
-
if (i >= one.length) {
|
|
924
|
-
result.push(other[j++]);
|
|
925
|
-
} else if (j >= other.length) {
|
|
926
|
-
result.push(one[i++]);
|
|
927
|
-
} else if (one[i] === other[j]) {
|
|
928
|
-
result.push(one[i]);
|
|
929
|
-
i++;
|
|
930
|
-
j++;
|
|
931
|
-
continue;
|
|
932
|
-
} else if (one[i] < other[j]) {
|
|
933
|
-
result.push(one[i++]);
|
|
934
|
-
} else {
|
|
935
|
-
result.push(other[j++]);
|
|
936
|
-
}
|
|
937
|
-
}
|
|
938
|
-
|
|
939
|
-
return result;
|
|
940
|
-
}
|
|
941
|
-
/**
|
|
942
|
-
* Given two sorted collections of numbers, returns the relative
|
|
943
|
-
* complement between them (XOR).
|
|
944
|
-
*/
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
function relativeComplement(one, other) {
|
|
948
|
-
const result = [];
|
|
949
|
-
let i = 0,
|
|
950
|
-
j = 0;
|
|
951
|
-
|
|
952
|
-
while (i < one.length || j < other.length) {
|
|
953
|
-
if (i >= one.length) {
|
|
954
|
-
result.push(other[j++]);
|
|
955
|
-
} else if (j >= other.length) {
|
|
956
|
-
result.push(one[i++]);
|
|
957
|
-
} else if (one[i] === other[j]) {
|
|
958
|
-
i++;
|
|
959
|
-
j++;
|
|
960
|
-
continue;
|
|
961
|
-
} else if (one[i] < other[j]) {
|
|
962
|
-
result.push(one[i++]);
|
|
963
|
-
} else {
|
|
964
|
-
j++;
|
|
965
|
-
}
|
|
966
|
-
}
|
|
967
|
-
|
|
968
|
-
return result;
|
|
969
|
-
}
|
|
970
|
-
|
|
971
|
-
const numericSort = (a, b) => a - b;
|
|
972
|
-
|
|
973
|
-
class PipelineRenderer {
|
|
974
|
-
constructor(_templateId, renderers) {
|
|
975
|
-
this._templateId = _templateId;
|
|
976
|
-
this.renderers = renderers;
|
|
977
|
-
}
|
|
978
|
-
|
|
979
|
-
get templateId() {
|
|
980
|
-
return this._templateId;
|
|
981
|
-
}
|
|
982
|
-
|
|
983
|
-
renderTemplate(container) {
|
|
984
|
-
return this.renderers.map(r => r.renderTemplate(container));
|
|
985
|
-
}
|
|
986
|
-
|
|
987
|
-
renderElement(element, index, templateData, height) {
|
|
988
|
-
let i = 0;
|
|
989
|
-
|
|
990
|
-
for (const renderer of this.renderers) {
|
|
991
|
-
renderer.renderElement(element, index, templateData[i++], height);
|
|
992
|
-
}
|
|
993
|
-
}
|
|
994
|
-
|
|
995
|
-
disposeElement(element, index, templateData, height) {
|
|
996
|
-
let i = 0;
|
|
997
|
-
|
|
998
|
-
for (const renderer of this.renderers) {
|
|
999
|
-
if (renderer.disposeElement) {
|
|
1000
|
-
renderer.disposeElement(element, index, templateData[i], height);
|
|
1001
|
-
}
|
|
1002
|
-
|
|
1003
|
-
i += 1;
|
|
1004
|
-
}
|
|
1005
|
-
}
|
|
1006
|
-
|
|
1007
|
-
disposeTemplate(templateData) {
|
|
1008
|
-
let i = 0;
|
|
1009
|
-
|
|
1010
|
-
for (const renderer of this.renderers) {
|
|
1011
|
-
renderer.disposeTemplate(templateData[i++]);
|
|
1012
|
-
}
|
|
1013
|
-
}
|
|
1014
|
-
|
|
1015
|
-
}
|
|
1016
|
-
|
|
1017
|
-
class AccessibiltyRenderer {
|
|
1018
|
-
constructor(accessibilityProvider) {
|
|
1019
|
-
this.accessibilityProvider = accessibilityProvider;
|
|
1020
|
-
this.templateId = 'a18n';
|
|
1021
|
-
}
|
|
1022
|
-
|
|
1023
|
-
renderTemplate(container) {
|
|
1024
|
-
return container;
|
|
1025
|
-
}
|
|
1026
|
-
|
|
1027
|
-
renderElement(element, index, container) {
|
|
1028
|
-
const ariaLabel = this.accessibilityProvider.getAriaLabel(element);
|
|
1029
|
-
|
|
1030
|
-
if (ariaLabel) {
|
|
1031
|
-
container.setAttribute('aria-label', ariaLabel);
|
|
1032
|
-
} else {
|
|
1033
|
-
container.removeAttribute('aria-label');
|
|
1034
|
-
}
|
|
1035
|
-
|
|
1036
|
-
const ariaLevel = this.accessibilityProvider.getAriaLevel && this.accessibilityProvider.getAriaLevel(element);
|
|
1037
|
-
|
|
1038
|
-
if (typeof ariaLevel === 'number') {
|
|
1039
|
-
container.setAttribute('aria-level', `${ariaLevel}`);
|
|
1040
|
-
} else {
|
|
1041
|
-
container.removeAttribute('aria-level');
|
|
1042
|
-
}
|
|
1043
|
-
}
|
|
1044
|
-
|
|
1045
|
-
disposeTemplate(templateData) {// noop
|
|
1046
|
-
}
|
|
1047
|
-
|
|
1048
|
-
}
|
|
1049
|
-
|
|
1050
|
-
class ListViewDragAndDrop {
|
|
1051
|
-
constructor(list, dnd) {
|
|
1052
|
-
this.list = list;
|
|
1053
|
-
this.dnd = dnd;
|
|
1054
|
-
}
|
|
1055
|
-
|
|
1056
|
-
getDragElements(element) {
|
|
1057
|
-
const selection = this.list.getSelectedElements();
|
|
1058
|
-
const elements = selection.indexOf(element) > -1 ? selection : [element];
|
|
1059
|
-
return elements;
|
|
1060
|
-
}
|
|
1061
|
-
|
|
1062
|
-
getDragURI(element) {
|
|
1063
|
-
return this.dnd.getDragURI(element);
|
|
1064
|
-
}
|
|
1065
|
-
|
|
1066
|
-
getDragLabel(elements, originalEvent) {
|
|
1067
|
-
if (this.dnd.getDragLabel) {
|
|
1068
|
-
return this.dnd.getDragLabel(elements, originalEvent);
|
|
1069
|
-
}
|
|
1070
|
-
|
|
1071
|
-
return undefined;
|
|
1072
|
-
}
|
|
1073
|
-
|
|
1074
|
-
onDragStart(data, originalEvent) {
|
|
1075
|
-
if (this.dnd.onDragStart) {
|
|
1076
|
-
this.dnd.onDragStart(data, originalEvent);
|
|
1077
|
-
}
|
|
1078
|
-
}
|
|
1079
|
-
|
|
1080
|
-
onDragOver(data, targetElement, targetIndex, originalEvent) {
|
|
1081
|
-
return this.dnd.onDragOver(data, targetElement, targetIndex, originalEvent);
|
|
1082
|
-
}
|
|
1083
|
-
|
|
1084
|
-
onDragEnd(originalEvent) {
|
|
1085
|
-
if (this.dnd.onDragEnd) {
|
|
1086
|
-
this.dnd.onDragEnd(originalEvent);
|
|
1087
|
-
}
|
|
1088
|
-
}
|
|
1089
|
-
|
|
1090
|
-
drop(data, targetElement, targetIndex, originalEvent) {
|
|
1091
|
-
this.dnd.drop(data, targetElement, targetIndex, originalEvent);
|
|
1092
|
-
}
|
|
1093
|
-
|
|
1094
|
-
}
|
|
1095
|
-
|
|
1096
|
-
class List {
|
|
1097
|
-
constructor(user, container, virtualDelegate, renderers, _options = DefaultOptions) {
|
|
1098
|
-
var _a;
|
|
1099
|
-
|
|
1100
|
-
this.user = user;
|
|
1101
|
-
this._options = _options;
|
|
1102
|
-
this.eventBufferer = new event_1.EventBufferer();
|
|
1103
|
-
this._ariaLabel = '';
|
|
1104
|
-
this.disposables = new lifecycle_1.DisposableStore();
|
|
1105
|
-
this.didJustPressContextMenuKey = false;
|
|
1106
|
-
this._onDidDispose = new event_1.Emitter();
|
|
1107
|
-
this.onDidDispose = this._onDidDispose.event;
|
|
1108
|
-
const role = this._options.accessibilityProvider && this._options.accessibilityProvider.getWidgetRole ? (_a = this._options.accessibilityProvider) === null || _a === void 0 ? void 0 : _a.getWidgetRole() : 'list';
|
|
1109
|
-
this.selection = new SelectionTrait(role !== 'listbox');
|
|
1110
|
-
this.focus = new Trait('focused');
|
|
1111
|
-
objects_1.mixin(_options, defaultStyles, false);
|
|
1112
|
-
const baseRenderers = [this.focus.renderer, this.selection.renderer];
|
|
1113
|
-
this.accessibilityProvider = _options.accessibilityProvider;
|
|
1114
|
-
|
|
1115
|
-
if (this.accessibilityProvider) {
|
|
1116
|
-
baseRenderers.push(new AccessibiltyRenderer(this.accessibilityProvider));
|
|
1117
|
-
|
|
1118
|
-
if (this.accessibilityProvider.onDidChangeActiveDescendant) {
|
|
1119
|
-
this.accessibilityProvider.onDidChangeActiveDescendant(this.onDidChangeActiveDescendant, this, this.disposables);
|
|
1120
|
-
}
|
|
1121
|
-
}
|
|
1122
|
-
|
|
1123
|
-
renderers = renderers.map(r => new PipelineRenderer(r.templateId, [...baseRenderers, r]));
|
|
1124
|
-
const viewOptions = { ..._options,
|
|
1125
|
-
dnd: _options.dnd && new ListViewDragAndDrop(this, _options.dnd)
|
|
1126
|
-
};
|
|
1127
|
-
this.view = new listView_1.ListView(container, virtualDelegate, renderers, viewOptions);
|
|
1128
|
-
this.view.domNode.setAttribute('role', role);
|
|
1129
|
-
|
|
1130
|
-
if (_options.styleController) {
|
|
1131
|
-
this.styleController = _options.styleController(this.view.domId);
|
|
1132
|
-
} else {
|
|
1133
|
-
const styleElement = dom_1.createStyleSheet(this.view.domNode);
|
|
1134
|
-
this.styleController = new DefaultStyleController(styleElement, this.view.domId);
|
|
1135
|
-
}
|
|
1136
|
-
|
|
1137
|
-
this.spliceable = new splice_1.CombinedSpliceable([new TraitSpliceable(this.focus, this.view, _options.identityProvider), new TraitSpliceable(this.selection, this.view, _options.identityProvider), this.view]);
|
|
1138
|
-
this.disposables.add(this.focus);
|
|
1139
|
-
this.disposables.add(this.selection);
|
|
1140
|
-
this.disposables.add(this.view);
|
|
1141
|
-
this.disposables.add(this._onDidDispose);
|
|
1142
|
-
this.onDidFocus = event_1.Event.map(event_2.domEvent(this.view.domNode, 'focus', true), () => null);
|
|
1143
|
-
this.onDidBlur = event_1.Event.map(event_2.domEvent(this.view.domNode, 'blur', true), () => null);
|
|
1144
|
-
this.disposables.add(new DOMFocusController(this, this.view));
|
|
1145
|
-
|
|
1146
|
-
if (typeof _options.keyboardSupport !== 'boolean' || _options.keyboardSupport) {
|
|
1147
|
-
const controller = new KeyboardController(this, this.view, _options);
|
|
1148
|
-
this.disposables.add(controller);
|
|
1149
|
-
}
|
|
1150
|
-
|
|
1151
|
-
if (_options.keyboardNavigationLabelProvider) {
|
|
1152
|
-
const delegate = _options.keyboardNavigationDelegate || exports.DefaultKeyboardNavigationDelegate;
|
|
1153
|
-
this.typeLabelController = new TypeLabelController(this, this.view, _options.keyboardNavigationLabelProvider, delegate);
|
|
1154
|
-
this.disposables.add(this.typeLabelController);
|
|
1155
|
-
}
|
|
1156
|
-
|
|
1157
|
-
this.mouseController = this.createMouseController(_options);
|
|
1158
|
-
this.disposables.add(this.mouseController);
|
|
1159
|
-
this.onDidChangeFocus(this._onFocusChange, this, this.disposables);
|
|
1160
|
-
this.onDidChangeSelection(this._onSelectionChange, this, this.disposables);
|
|
1161
|
-
|
|
1162
|
-
if (this.accessibilityProvider) {
|
|
1163
|
-
this.ariaLabel = this.accessibilityProvider.getWidgetAriaLabel();
|
|
1164
|
-
}
|
|
1165
|
-
|
|
1166
|
-
if (_options.multipleSelectionSupport) {
|
|
1167
|
-
this.view.domNode.setAttribute('aria-multiselectable', 'true');
|
|
1168
|
-
}
|
|
1169
|
-
}
|
|
1170
|
-
|
|
1171
|
-
get onDidChangeFocus() {
|
|
1172
|
-
return event_1.Event.map(this.eventBufferer.wrapEvent(this.focus.onChange), e => this.toListEvent(e));
|
|
1173
|
-
}
|
|
1174
|
-
|
|
1175
|
-
get onDidChangeSelection() {
|
|
1176
|
-
return event_1.Event.map(this.eventBufferer.wrapEvent(this.selection.onChange), e => this.toListEvent(e));
|
|
1177
|
-
}
|
|
1178
|
-
|
|
1179
|
-
get domId() {
|
|
1180
|
-
return this.view.domId;
|
|
1181
|
-
}
|
|
1182
|
-
|
|
1183
|
-
get onDidScroll() {
|
|
1184
|
-
return this.view.onDidScroll;
|
|
1185
|
-
}
|
|
1186
|
-
|
|
1187
|
-
get onMouseClick() {
|
|
1188
|
-
return this.view.onMouseClick;
|
|
1189
|
-
}
|
|
1190
|
-
|
|
1191
|
-
get onMouseDblClick() {
|
|
1192
|
-
return this.view.onMouseDblClick;
|
|
1193
|
-
}
|
|
1194
|
-
|
|
1195
|
-
get onMouseMiddleClick() {
|
|
1196
|
-
return this.view.onMouseMiddleClick;
|
|
1197
|
-
}
|
|
1198
|
-
|
|
1199
|
-
get onPointer() {
|
|
1200
|
-
return this.mouseController.onPointer;
|
|
1201
|
-
}
|
|
1202
|
-
|
|
1203
|
-
get onMouseUp() {
|
|
1204
|
-
return this.view.onMouseUp;
|
|
1205
|
-
}
|
|
1206
|
-
|
|
1207
|
-
get onMouseDown() {
|
|
1208
|
-
return this.view.onMouseDown;
|
|
1209
|
-
}
|
|
1210
|
-
|
|
1211
|
-
get onMouseOver() {
|
|
1212
|
-
return this.view.onMouseOver;
|
|
1213
|
-
}
|
|
1214
|
-
|
|
1215
|
-
get onMouseMove() {
|
|
1216
|
-
return this.view.onMouseMove;
|
|
1217
|
-
}
|
|
1218
|
-
|
|
1219
|
-
get onMouseOut() {
|
|
1220
|
-
return this.view.onMouseOut;
|
|
1221
|
-
}
|
|
1222
|
-
|
|
1223
|
-
get onTouchStart() {
|
|
1224
|
-
return this.view.onTouchStart;
|
|
1225
|
-
}
|
|
1226
|
-
|
|
1227
|
-
get onTap() {
|
|
1228
|
-
return this.view.onTap;
|
|
1229
|
-
}
|
|
1230
|
-
|
|
1231
|
-
get onContextMenu() {
|
|
1232
|
-
const fromKeydown = event_1.Event.chain(event_2.domEvent(this.view.domNode, 'keydown')).map(e => new keyboardEvent_1.StandardKeyboardEvent(e)).filter(e => this.didJustPressContextMenuKey = e.keyCode === 58
|
|
1233
|
-
/* ContextMenu */
|
|
1234
|
-
|| e.shiftKey && e.keyCode === 68
|
|
1235
|
-
/* F10 */
|
|
1236
|
-
).filter(e => {
|
|
1237
|
-
e.preventDefault();
|
|
1238
|
-
e.stopPropagation();
|
|
1239
|
-
return false;
|
|
1240
|
-
}).event;
|
|
1241
|
-
const fromKeyup = event_1.Event.chain(event_2.domEvent(this.view.domNode, 'keyup')).filter(() => {
|
|
1242
|
-
const didJustPressContextMenuKey = this.didJustPressContextMenuKey;
|
|
1243
|
-
this.didJustPressContextMenuKey = false;
|
|
1244
|
-
return didJustPressContextMenuKey;
|
|
1245
|
-
}).filter(() => this.getFocus().length > 0 && !!this.view.domElement(this.getFocus()[0])).map(browserEvent => {
|
|
1246
|
-
const index = this.getFocus()[0];
|
|
1247
|
-
const element = this.view.element(index);
|
|
1248
|
-
const anchor = this.view.domElement(index);
|
|
1249
|
-
return {
|
|
1250
|
-
index,
|
|
1251
|
-
element,
|
|
1252
|
-
anchor,
|
|
1253
|
-
browserEvent
|
|
1254
|
-
};
|
|
1255
|
-
}).event;
|
|
1256
|
-
const fromMouse = event_1.Event.chain(this.view.onContextMenu).filter(() => !this.didJustPressContextMenuKey).map(({
|
|
1257
|
-
element,
|
|
1258
|
-
index,
|
|
1259
|
-
browserEvent
|
|
1260
|
-
}) => ({
|
|
1261
|
-
element,
|
|
1262
|
-
index,
|
|
1263
|
-
anchor: {
|
|
1264
|
-
x: browserEvent.clientX + 1,
|
|
1265
|
-
y: browserEvent.clientY
|
|
1266
|
-
},
|
|
1267
|
-
browserEvent
|
|
1268
|
-
})).event;
|
|
1269
|
-
return event_1.Event.any(fromKeydown, fromKeyup, fromMouse);
|
|
1270
|
-
}
|
|
1271
|
-
|
|
1272
|
-
get onKeyDown() {
|
|
1273
|
-
return event_2.domEvent(this.view.domNode, 'keydown');
|
|
1274
|
-
}
|
|
1275
|
-
|
|
1276
|
-
get onKeyUp() {
|
|
1277
|
-
return event_2.domEvent(this.view.domNode, 'keyup');
|
|
1278
|
-
}
|
|
1279
|
-
|
|
1280
|
-
get onKeyPress() {
|
|
1281
|
-
return event_2.domEvent(this.view.domNode, 'keypress');
|
|
1282
|
-
}
|
|
1283
|
-
|
|
1284
|
-
createMouseController(options) {
|
|
1285
|
-
return new MouseController(this);
|
|
1286
|
-
}
|
|
1287
|
-
|
|
1288
|
-
updateOptions(optionsUpdate = {}) {
|
|
1289
|
-
this._options = { ...this._options,
|
|
1290
|
-
...optionsUpdate
|
|
1291
|
-
};
|
|
1292
|
-
|
|
1293
|
-
if (this.typeLabelController) {
|
|
1294
|
-
this.typeLabelController.updateOptions(this._options);
|
|
1295
|
-
}
|
|
1296
|
-
|
|
1297
|
-
this.view.updateOptions(optionsUpdate);
|
|
1298
|
-
}
|
|
1299
|
-
|
|
1300
|
-
get options() {
|
|
1301
|
-
return this._options;
|
|
1302
|
-
}
|
|
1303
|
-
|
|
1304
|
-
splice(start, deleteCount, elements = []) {
|
|
1305
|
-
if (start < 0 || start > this.view.length) {
|
|
1306
|
-
throw new list_1.ListError(this.user, `Invalid start index: ${start}`);
|
|
1307
|
-
}
|
|
1308
|
-
|
|
1309
|
-
if (deleteCount < 0) {
|
|
1310
|
-
throw new list_1.ListError(this.user, `Invalid delete count: ${deleteCount}`);
|
|
1311
|
-
}
|
|
1312
|
-
|
|
1313
|
-
if (deleteCount === 0 && elements.length === 0) {
|
|
1314
|
-
return;
|
|
1315
|
-
}
|
|
1316
|
-
|
|
1317
|
-
this.eventBufferer.bufferEvents(() => this.spliceable.splice(start, deleteCount, elements));
|
|
1318
|
-
}
|
|
1319
|
-
|
|
1320
|
-
updateWidth(index) {
|
|
1321
|
-
this.view.updateWidth(index);
|
|
1322
|
-
}
|
|
1323
|
-
|
|
1324
|
-
updateElementHeight(index, size) {
|
|
1325
|
-
this.view.updateElementHeight(index, size, null);
|
|
1326
|
-
}
|
|
1327
|
-
|
|
1328
|
-
rerender() {
|
|
1329
|
-
this.view.rerender();
|
|
1330
|
-
}
|
|
1331
|
-
|
|
1332
|
-
element(index) {
|
|
1333
|
-
return this.view.element(index);
|
|
1334
|
-
}
|
|
1335
|
-
|
|
1336
|
-
indexOf(element) {
|
|
1337
|
-
return this.view.indexOf(element);
|
|
1338
|
-
}
|
|
1339
|
-
|
|
1340
|
-
get length() {
|
|
1341
|
-
return this.view.length;
|
|
1342
|
-
}
|
|
1343
|
-
|
|
1344
|
-
get contentHeight() {
|
|
1345
|
-
return this.view.contentHeight;
|
|
1346
|
-
}
|
|
1347
|
-
|
|
1348
|
-
get onDidChangeContentHeight() {
|
|
1349
|
-
return this.view.onDidChangeContentHeight;
|
|
1350
|
-
}
|
|
1351
|
-
|
|
1352
|
-
get scrollTop() {
|
|
1353
|
-
return this.view.getScrollTop();
|
|
1354
|
-
}
|
|
1355
|
-
|
|
1356
|
-
set scrollTop(scrollTop) {
|
|
1357
|
-
this.view.setScrollTop(scrollTop);
|
|
1358
|
-
}
|
|
1359
|
-
|
|
1360
|
-
get scrollLeft() {
|
|
1361
|
-
return this.view.getScrollLeft();
|
|
1362
|
-
}
|
|
1363
|
-
|
|
1364
|
-
set scrollLeft(scrollLeft) {
|
|
1365
|
-
this.view.setScrollLeft(scrollLeft);
|
|
1366
|
-
}
|
|
1367
|
-
|
|
1368
|
-
get scrollHeight() {
|
|
1369
|
-
return this.view.scrollHeight;
|
|
1370
|
-
}
|
|
1371
|
-
|
|
1372
|
-
get renderHeight() {
|
|
1373
|
-
return this.view.renderHeight;
|
|
1374
|
-
}
|
|
1375
|
-
|
|
1376
|
-
get firstVisibleIndex() {
|
|
1377
|
-
return this.view.firstVisibleIndex;
|
|
1378
|
-
}
|
|
1379
|
-
|
|
1380
|
-
get lastVisibleIndex() {
|
|
1381
|
-
return this.view.lastVisibleIndex;
|
|
1382
|
-
}
|
|
1383
|
-
|
|
1384
|
-
get ariaLabel() {
|
|
1385
|
-
return this._ariaLabel;
|
|
1386
|
-
}
|
|
1387
|
-
|
|
1388
|
-
set ariaLabel(value) {
|
|
1389
|
-
this._ariaLabel = value;
|
|
1390
|
-
this.view.domNode.setAttribute('aria-label', value);
|
|
1391
|
-
}
|
|
1392
|
-
|
|
1393
|
-
domFocus() {
|
|
1394
|
-
this.view.domNode.focus();
|
|
1395
|
-
}
|
|
1396
|
-
|
|
1397
|
-
layout(height, width) {
|
|
1398
|
-
this.view.layout(height, width);
|
|
1399
|
-
}
|
|
1400
|
-
|
|
1401
|
-
toggleKeyboardNavigation() {
|
|
1402
|
-
if (this.typeLabelController) {
|
|
1403
|
-
this.typeLabelController.toggle();
|
|
1404
|
-
}
|
|
1405
|
-
}
|
|
1406
|
-
|
|
1407
|
-
setSelection(indexes, browserEvent) {
|
|
1408
|
-
for (const index of indexes) {
|
|
1409
|
-
if (index < 0 || index >= this.length) {
|
|
1410
|
-
throw new list_1.ListError(this.user, `Invalid index ${index}`);
|
|
1411
|
-
}
|
|
1412
|
-
}
|
|
1413
|
-
|
|
1414
|
-
this.selection.set(indexes, browserEvent);
|
|
1415
|
-
}
|
|
1416
|
-
|
|
1417
|
-
getSelection() {
|
|
1418
|
-
return this.selection.get();
|
|
1419
|
-
}
|
|
1420
|
-
|
|
1421
|
-
getSelectedElements() {
|
|
1422
|
-
return this.getSelection().map(i => this.view.element(i));
|
|
1423
|
-
}
|
|
1424
|
-
|
|
1425
|
-
setFocus(indexes, browserEvent) {
|
|
1426
|
-
for (const index of indexes) {
|
|
1427
|
-
if (index < 0 || index >= this.length) {
|
|
1428
|
-
throw new list_1.ListError(this.user, `Invalid index ${index}`);
|
|
1429
|
-
}
|
|
1430
|
-
}
|
|
1431
|
-
|
|
1432
|
-
this.focus.set(indexes, browserEvent);
|
|
1433
|
-
}
|
|
1434
|
-
|
|
1435
|
-
focusNext(n = 1, loop = false, browserEvent, filter) {
|
|
1436
|
-
if (this.length === 0) {
|
|
1437
|
-
return;
|
|
1438
|
-
}
|
|
1439
|
-
|
|
1440
|
-
const focus = this.focus.get();
|
|
1441
|
-
const index = this.findNextIndex(focus.length > 0 ? focus[0] + n : 0, loop, filter);
|
|
1442
|
-
|
|
1443
|
-
if (index > -1) {
|
|
1444
|
-
this.setFocus([index], browserEvent);
|
|
1445
|
-
}
|
|
1446
|
-
}
|
|
1447
|
-
|
|
1448
|
-
focusPrevious(n = 1, loop = false, browserEvent, filter) {
|
|
1449
|
-
if (this.length === 0) {
|
|
1450
|
-
return;
|
|
1451
|
-
}
|
|
1452
|
-
|
|
1453
|
-
const focus = this.focus.get();
|
|
1454
|
-
const index = this.findPreviousIndex(focus.length > 0 ? focus[0] - n : 0, loop, filter);
|
|
1455
|
-
|
|
1456
|
-
if (index > -1) {
|
|
1457
|
-
this.setFocus([index], browserEvent);
|
|
1458
|
-
}
|
|
1459
|
-
}
|
|
1460
|
-
|
|
1461
|
-
focusNextPage(browserEvent, filter) {
|
|
1462
|
-
let lastPageIndex = this.view.indexAt(this.view.getScrollTop() + this.view.renderHeight);
|
|
1463
|
-
lastPageIndex = lastPageIndex === 0 ? 0 : lastPageIndex - 1;
|
|
1464
|
-
const lastPageElement = this.view.element(lastPageIndex);
|
|
1465
|
-
const currentlyFocusedElement = this.getFocusedElements()[0];
|
|
1466
|
-
|
|
1467
|
-
if (currentlyFocusedElement !== lastPageElement) {
|
|
1468
|
-
const lastGoodPageIndex = this.findPreviousIndex(lastPageIndex, false, filter);
|
|
1469
|
-
|
|
1470
|
-
if (lastGoodPageIndex > -1 && currentlyFocusedElement !== this.view.element(lastGoodPageIndex)) {
|
|
1471
|
-
this.setFocus([lastGoodPageIndex], browserEvent);
|
|
1472
|
-
} else {
|
|
1473
|
-
this.setFocus([lastPageIndex], browserEvent);
|
|
1474
|
-
}
|
|
1475
|
-
} else {
|
|
1476
|
-
const previousScrollTop = this.view.getScrollTop();
|
|
1477
|
-
this.view.setScrollTop(previousScrollTop + this.view.renderHeight - this.view.elementHeight(lastPageIndex));
|
|
1478
|
-
|
|
1479
|
-
if (this.view.getScrollTop() !== previousScrollTop) {
|
|
1480
|
-
// Let the scroll event listener run
|
|
1481
|
-
setTimeout(() => this.focusNextPage(browserEvent, filter), 0);
|
|
1482
|
-
}
|
|
1483
|
-
}
|
|
1484
|
-
}
|
|
1485
|
-
|
|
1486
|
-
focusPreviousPage(browserEvent, filter) {
|
|
1487
|
-
let firstPageIndex;
|
|
1488
|
-
const scrollTop = this.view.getScrollTop();
|
|
1489
|
-
|
|
1490
|
-
if (scrollTop === 0) {
|
|
1491
|
-
firstPageIndex = this.view.indexAt(scrollTop);
|
|
1492
|
-
} else {
|
|
1493
|
-
firstPageIndex = this.view.indexAfter(scrollTop - 1);
|
|
1494
|
-
}
|
|
1495
|
-
|
|
1496
|
-
const firstPageElement = this.view.element(firstPageIndex);
|
|
1497
|
-
const currentlyFocusedElement = this.getFocusedElements()[0];
|
|
1498
|
-
|
|
1499
|
-
if (currentlyFocusedElement !== firstPageElement) {
|
|
1500
|
-
const firstGoodPageIndex = this.findNextIndex(firstPageIndex, false, filter);
|
|
1501
|
-
|
|
1502
|
-
if (firstGoodPageIndex > -1 && currentlyFocusedElement !== this.view.element(firstGoodPageIndex)) {
|
|
1503
|
-
this.setFocus([firstGoodPageIndex], browserEvent);
|
|
1504
|
-
} else {
|
|
1505
|
-
this.setFocus([firstPageIndex], browserEvent);
|
|
1506
|
-
}
|
|
1507
|
-
} else {
|
|
1508
|
-
const previousScrollTop = scrollTop;
|
|
1509
|
-
this.view.setScrollTop(scrollTop - this.view.renderHeight);
|
|
1510
|
-
|
|
1511
|
-
if (this.view.getScrollTop() !== previousScrollTop) {
|
|
1512
|
-
// Let the scroll event listener run
|
|
1513
|
-
setTimeout(() => this.focusPreviousPage(browserEvent, filter), 0);
|
|
1514
|
-
}
|
|
1515
|
-
}
|
|
1516
|
-
}
|
|
1517
|
-
|
|
1518
|
-
focusLast(browserEvent, filter) {
|
|
1519
|
-
if (this.length === 0) {
|
|
1520
|
-
return;
|
|
1521
|
-
}
|
|
1522
|
-
|
|
1523
|
-
const index = this.findPreviousIndex(this.length - 1, false, filter);
|
|
1524
|
-
|
|
1525
|
-
if (index > -1) {
|
|
1526
|
-
this.setFocus([index], browserEvent);
|
|
1527
|
-
}
|
|
1528
|
-
}
|
|
1529
|
-
|
|
1530
|
-
focusFirst(browserEvent, filter) {
|
|
1531
|
-
this.focusNth(0, browserEvent, filter);
|
|
1532
|
-
}
|
|
1533
|
-
|
|
1534
|
-
focusNth(n, browserEvent, filter) {
|
|
1535
|
-
if (this.length === 0) {
|
|
1536
|
-
return;
|
|
1537
|
-
}
|
|
1538
|
-
|
|
1539
|
-
const index = this.findNextIndex(n, false, filter);
|
|
1540
|
-
|
|
1541
|
-
if (index > -1) {
|
|
1542
|
-
this.setFocus([index], browserEvent);
|
|
1543
|
-
}
|
|
1544
|
-
}
|
|
1545
|
-
|
|
1546
|
-
findNextIndex(index, loop = false, filter) {
|
|
1547
|
-
for (let i = 0; i < this.length; i++) {
|
|
1548
|
-
if (index >= this.length && !loop) {
|
|
1549
|
-
return -1;
|
|
1550
|
-
}
|
|
1551
|
-
|
|
1552
|
-
index = index % this.length;
|
|
1553
|
-
|
|
1554
|
-
if (!filter || filter(this.element(index))) {
|
|
1555
|
-
return index;
|
|
1556
|
-
}
|
|
1557
|
-
|
|
1558
|
-
index++;
|
|
1559
|
-
}
|
|
1560
|
-
|
|
1561
|
-
return -1;
|
|
1562
|
-
}
|
|
1563
|
-
|
|
1564
|
-
findPreviousIndex(index, loop = false, filter) {
|
|
1565
|
-
for (let i = 0; i < this.length; i++) {
|
|
1566
|
-
if (index < 0 && !loop) {
|
|
1567
|
-
return -1;
|
|
1568
|
-
}
|
|
1569
|
-
|
|
1570
|
-
index = (this.length + index % this.length) % this.length;
|
|
1571
|
-
|
|
1572
|
-
if (!filter || filter(this.element(index))) {
|
|
1573
|
-
return index;
|
|
1574
|
-
}
|
|
1575
|
-
|
|
1576
|
-
index--;
|
|
1577
|
-
}
|
|
1578
|
-
|
|
1579
|
-
return -1;
|
|
1580
|
-
}
|
|
1581
|
-
|
|
1582
|
-
getFocus() {
|
|
1583
|
-
return this.focus.get();
|
|
1584
|
-
}
|
|
1585
|
-
|
|
1586
|
-
getFocusedElements() {
|
|
1587
|
-
return this.getFocus().map(i => this.view.element(i));
|
|
1588
|
-
}
|
|
1589
|
-
|
|
1590
|
-
reveal(index, relativeTop) {
|
|
1591
|
-
if (index < 0 || index >= this.length) {
|
|
1592
|
-
throw new list_1.ListError(this.user, `Invalid index ${index}`);
|
|
1593
|
-
}
|
|
1594
|
-
|
|
1595
|
-
const scrollTop = this.view.getScrollTop();
|
|
1596
|
-
const elementTop = this.view.elementTop(index);
|
|
1597
|
-
const elementHeight = this.view.elementHeight(index);
|
|
1598
|
-
|
|
1599
|
-
if (types_1.isNumber(relativeTop)) {
|
|
1600
|
-
// y = mx + b
|
|
1601
|
-
const m = elementHeight - this.view.renderHeight;
|
|
1602
|
-
this.view.setScrollTop(m * numbers_1.clamp(relativeTop, 0, 1) + elementTop);
|
|
1603
|
-
} else {
|
|
1604
|
-
const viewItemBottom = elementTop + elementHeight;
|
|
1605
|
-
const wrapperBottom = scrollTop + this.view.renderHeight;
|
|
1606
|
-
|
|
1607
|
-
if (elementTop < scrollTop && viewItemBottom >= wrapperBottom) {// The element is already overflowing the viewport, no-op
|
|
1608
|
-
} else if (elementTop < scrollTop) {
|
|
1609
|
-
this.view.setScrollTop(elementTop);
|
|
1610
|
-
} else if (viewItemBottom >= wrapperBottom) {
|
|
1611
|
-
this.view.setScrollTop(viewItemBottom - this.view.renderHeight);
|
|
1612
|
-
}
|
|
1613
|
-
}
|
|
1614
|
-
}
|
|
1615
|
-
/**
|
|
1616
|
-
* Returns the relative position of an element rendered in the list.
|
|
1617
|
-
* Returns `null` if the element isn't *entirely* in the visible viewport.
|
|
1618
|
-
*/
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
getRelativeTop(index) {
|
|
1622
|
-
if (index < 0 || index >= this.length) {
|
|
1623
|
-
throw new list_1.ListError(this.user, `Invalid index ${index}`);
|
|
1624
|
-
}
|
|
1625
|
-
|
|
1626
|
-
const scrollTop = this.view.getScrollTop();
|
|
1627
|
-
const elementTop = this.view.elementTop(index);
|
|
1628
|
-
const elementHeight = this.view.elementHeight(index);
|
|
1629
|
-
|
|
1630
|
-
if (elementTop < scrollTop || elementTop + elementHeight > scrollTop + this.view.renderHeight) {
|
|
1631
|
-
return null;
|
|
1632
|
-
} // y = mx + b
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
const m = elementHeight - this.view.renderHeight;
|
|
1636
|
-
return Math.abs((scrollTop - elementTop) / m);
|
|
1637
|
-
}
|
|
1638
|
-
|
|
1639
|
-
isDOMFocused() {
|
|
1640
|
-
return this.view.domNode === document.activeElement;
|
|
1641
|
-
}
|
|
1642
|
-
|
|
1643
|
-
getHTMLElement() {
|
|
1644
|
-
return this.view.domNode;
|
|
1645
|
-
}
|
|
1646
|
-
|
|
1647
|
-
style(styles) {
|
|
1648
|
-
this.styleController.style(styles);
|
|
1649
|
-
}
|
|
1650
|
-
|
|
1651
|
-
toListEvent({
|
|
1652
|
-
indexes,
|
|
1653
|
-
browserEvent
|
|
1654
|
-
}) {
|
|
1655
|
-
return {
|
|
1656
|
-
indexes,
|
|
1657
|
-
elements: indexes.map(i => this.view.element(i)),
|
|
1658
|
-
browserEvent
|
|
1659
|
-
};
|
|
1660
|
-
}
|
|
1661
|
-
|
|
1662
|
-
_onFocusChange() {
|
|
1663
|
-
const focus = this.focus.get();
|
|
1664
|
-
this.view.domNode.classList.toggle('element-focused', focus.length > 0);
|
|
1665
|
-
this.onDidChangeActiveDescendant();
|
|
1666
|
-
}
|
|
1667
|
-
|
|
1668
|
-
onDidChangeActiveDescendant() {
|
|
1669
|
-
var _a;
|
|
1670
|
-
|
|
1671
|
-
const focus = this.focus.get();
|
|
1672
|
-
|
|
1673
|
-
if (focus.length > 0) {
|
|
1674
|
-
let id;
|
|
1675
|
-
|
|
1676
|
-
if ((_a = this.accessibilityProvider) === null || _a === void 0 ? void 0 : _a.getActiveDescendantId) {
|
|
1677
|
-
id = this.accessibilityProvider.getActiveDescendantId(this.view.element(focus[0]));
|
|
1678
|
-
}
|
|
1679
|
-
|
|
1680
|
-
this.view.domNode.setAttribute('aria-activedescendant', id || this.view.getElementDomId(focus[0]));
|
|
1681
|
-
} else {
|
|
1682
|
-
this.view.domNode.removeAttribute('aria-activedescendant');
|
|
1683
|
-
}
|
|
1684
|
-
}
|
|
1685
|
-
|
|
1686
|
-
_onSelectionChange() {
|
|
1687
|
-
const selection = this.selection.get();
|
|
1688
|
-
this.view.domNode.classList.toggle('selection-none', selection.length === 0);
|
|
1689
|
-
this.view.domNode.classList.toggle('selection-single', selection.length === 1);
|
|
1690
|
-
this.view.domNode.classList.toggle('selection-multiple', selection.length > 1);
|
|
1691
|
-
}
|
|
1692
|
-
|
|
1693
|
-
dispose() {
|
|
1694
|
-
this._onDidDispose.fire();
|
|
1695
|
-
|
|
1696
|
-
this.disposables.dispose();
|
|
1697
|
-
|
|
1698
|
-
this._onDidDispose.dispose();
|
|
1699
|
-
}
|
|
1700
|
-
|
|
1701
|
-
}
|
|
1702
|
-
|
|
1703
|
-
__decorate([decorators_1.memoize], List.prototype, "onDidChangeFocus", null);
|
|
1704
|
-
|
|
1705
|
-
__decorate([decorators_1.memoize], List.prototype, "onDidChangeSelection", null);
|
|
1706
|
-
|
|
1707
|
-
__decorate([decorators_1.memoize], List.prototype, "onContextMenu", null);
|
|
1708
|
-
|
|
1709
|
-
exports.List = List;
|