mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Merge from vscode cfc1ab4c5f816765b91fb7ead3c3427a7c8581a3
This commit is contained in:
@@ -60,9 +60,9 @@ export interface IQuickInputStyles {
|
||||
export interface IQuickInputWidgetStyles {
|
||||
quickInputBackground?: Color;
|
||||
quickInputForeground?: Color;
|
||||
quickInputTitleBackground?: Color;
|
||||
contrastBorder?: Color;
|
||||
widgetShadow?: Color;
|
||||
titleColor: string | undefined;
|
||||
}
|
||||
|
||||
const $ = dom.$;
|
||||
@@ -142,6 +142,7 @@ class QuickInput extends Disposable implements IQuickInput {
|
||||
private buttonsUpdated = false;
|
||||
private readonly onDidTriggerButtonEmitter = this._register(new Emitter<IQuickInputButton>());
|
||||
private readonly onDidHideEmitter = this._register(new Emitter<void>());
|
||||
private readonly onDisposeEmitter = this._register(new Emitter<void>());
|
||||
|
||||
protected readonly visibleDisposables = this._register(new DisposableStore());
|
||||
|
||||
@@ -235,7 +236,7 @@ class QuickInput extends Disposable implements IQuickInput {
|
||||
this.update();
|
||||
}
|
||||
|
||||
onDidTriggerButton = this.onDidTriggerButtonEmitter.event;
|
||||
readonly onDidTriggerButton = this.onDidTriggerButtonEmitter.event;
|
||||
|
||||
show(): void {
|
||||
if (this.visible) {
|
||||
@@ -266,7 +267,7 @@ class QuickInput extends Disposable implements IQuickInput {
|
||||
this.onDidHideEmitter.fire();
|
||||
}
|
||||
|
||||
onDidHide = this.onDidHideEmitter.event;
|
||||
readonly onDidHide = this.onDidHideEmitter.event;
|
||||
|
||||
protected update() {
|
||||
if (!this.visible) {
|
||||
@@ -298,9 +299,8 @@ class QuickInput extends Disposable implements IQuickInput {
|
||||
this.ui.leftActionBar.clear();
|
||||
const leftButtons = this.buttons.filter(button => button === backButton);
|
||||
this.ui.leftActionBar.push(leftButtons.map((button, index) => {
|
||||
const action = new Action(`id-${index}`, '', button.iconClass || getIconClass(button.iconPath), true, () => {
|
||||
const action = new Action(`id-${index}`, '', button.iconClass || getIconClass(button.iconPath), true, async () => {
|
||||
this.onDidTriggerButtonEmitter.fire(button);
|
||||
return Promise.resolve(null);
|
||||
});
|
||||
action.tooltip = button.tooltip || '';
|
||||
return action;
|
||||
@@ -308,9 +308,8 @@ class QuickInput extends Disposable implements IQuickInput {
|
||||
this.ui.rightActionBar.clear();
|
||||
const rightButtons = this.buttons.filter(button => button !== backButton);
|
||||
this.ui.rightActionBar.push(rightButtons.map((button, index) => {
|
||||
const action = new Action(`id-${index}`, '', button.iconClass || getIconClass(button.iconPath), true, () => {
|
||||
const action = new Action(`id-${index}`, '', button.iconClass || getIconClass(button.iconPath), true, async () => {
|
||||
this.onDidTriggerButtonEmitter.fire(button);
|
||||
return Promise.resolve(null);
|
||||
});
|
||||
action.tooltip = button.tooltip || '';
|
||||
return action;
|
||||
@@ -362,17 +361,22 @@ class QuickInput extends Disposable implements IQuickInput {
|
||||
}
|
||||
}
|
||||
|
||||
readonly onDispose = this.onDisposeEmitter.event;
|
||||
|
||||
public dispose(): void {
|
||||
this.hide();
|
||||
this.onDisposeEmitter.fire();
|
||||
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
class QuickPick<T extends IQuickPickItem> extends QuickInput implements IQuickPick<T> {
|
||||
|
||||
private static readonly INPUT_BOX_ARIA_LABEL = localize('quickInputBox.ariaLabel', "Type to narrow down results.");
|
||||
private static readonly DEFAULT_ARIA_LABEL = localize('quickInputBox.ariaLabel', "Type to narrow down results.");
|
||||
|
||||
private _value = '';
|
||||
private _ariaLabel = QuickPick.DEFAULT_ARIA_LABEL;
|
||||
private _placeholder: string | undefined;
|
||||
private readonly onDidChangeValueEmitter = this._register(new Emitter<string>());
|
||||
private readonly onDidAcceptEmitter = this._register(new Emitter<void>());
|
||||
@@ -404,7 +408,6 @@ class QuickPick<T extends IQuickPickItem> extends QuickInput implements IQuickPi
|
||||
|
||||
quickNavigate: IQuickNavigateConfiguration | undefined;
|
||||
|
||||
|
||||
get value() {
|
||||
return this._value;
|
||||
}
|
||||
@@ -414,6 +417,17 @@ class QuickPick<T extends IQuickPickItem> extends QuickInput implements IQuickPi
|
||||
this.update();
|
||||
}
|
||||
|
||||
filterValue = (value: string) => value;
|
||||
|
||||
set ariaLabel(ariaLabel: string) {
|
||||
this._ariaLabel = ariaLabel || QuickPick.DEFAULT_ARIA_LABEL;
|
||||
this.update();
|
||||
}
|
||||
|
||||
get ariaLabel() {
|
||||
return this._ariaLabel;
|
||||
}
|
||||
|
||||
get placeholder() {
|
||||
return this._placeholder;
|
||||
}
|
||||
@@ -599,7 +613,7 @@ class QuickPick<T extends IQuickPickItem> extends QuickInput implements IQuickPi
|
||||
return;
|
||||
}
|
||||
this._value = value;
|
||||
this.ui.list.filter(this.ui.inputBox.value);
|
||||
this.ui.list.filter(this.filterValue(this.ui.inputBox.value));
|
||||
this.trySelectFirst();
|
||||
this.onDidChangeValueEmitter.fire(value);
|
||||
}));
|
||||
@@ -770,10 +784,17 @@ class QuickPick<T extends IQuickPickItem> extends QuickInput implements IQuickPi
|
||||
if (this.ui.inputBox.placeholder !== (this.placeholder || '')) {
|
||||
this.ui.inputBox.placeholder = (this.placeholder || '');
|
||||
}
|
||||
if (this.ui.inputBox.ariaLabel !== this.ariaLabel) {
|
||||
this.ui.inputBox.ariaLabel = this.ariaLabel;
|
||||
}
|
||||
this.ui.list.matchOnDescription = this.matchOnDescription;
|
||||
this.ui.list.matchOnDetail = this.matchOnDetail;
|
||||
this.ui.list.matchOnLabel = this.matchOnLabel;
|
||||
this.ui.list.sortByLabel = this.sortByLabel;
|
||||
if (this.itemsUpdated) {
|
||||
this.itemsUpdated = false;
|
||||
this.ui.list.setElements(this.items);
|
||||
this.ui.list.filter(this.ui.inputBox.value);
|
||||
this.ui.list.filter(this.filterValue(this.ui.inputBox.value));
|
||||
this.ui.checkAll.checked = this.ui.list.getAllVisibleChecked();
|
||||
this.ui.visibleCount.setCount(this.ui.list.getVisibleCount());
|
||||
this.ui.count.setCount(this.ui.list.getCheckedCount());
|
||||
@@ -815,12 +836,7 @@ class QuickPick<T extends IQuickPickItem> extends QuickInput implements IQuickPi
|
||||
}
|
||||
this.ui.customButton.label = this.customLabel || '';
|
||||
this.ui.customButton.element.title = this.customHover || '';
|
||||
this.ui.list.matchOnDescription = this.matchOnDescription;
|
||||
this.ui.list.matchOnDetail = this.matchOnDetail;
|
||||
this.ui.list.matchOnLabel = this.matchOnLabel;
|
||||
this.ui.list.sortByLabel = this.sortByLabel;
|
||||
this.ui.setComboboxAccessibility(true);
|
||||
this.ui.inputBox.setAttribute('aria-label', QuickPick.INPUT_BOX_ARIA_LABEL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -948,7 +964,7 @@ export class QuickInputController extends Disposable {
|
||||
|
||||
private idPrefix: string;
|
||||
private ui: QuickInputUI | undefined;
|
||||
private dimension?: dom.Dimension;
|
||||
private dimension?: dom.IDimension;
|
||||
private titleBarOffset?: number;
|
||||
private comboboxAccessibility = false;
|
||||
private enabled = true;
|
||||
@@ -1378,7 +1394,7 @@ export class QuickInputController extends Disposable {
|
||||
ui.list.sortByLabel = true;
|
||||
ui.ignoreFocusOut = false;
|
||||
this.setComboboxAccessibility(false);
|
||||
ui.inputBox.removeAttribute('aria-label');
|
||||
ui.inputBox.ariaLabel = '';
|
||||
|
||||
const backKeybindingLabel = this.options.backKeybindingLabel();
|
||||
backButton.tooltip = backKeybindingLabel ? localize('quickInput.backWithKeybinding', "Back ({0})", backKeybindingLabel) : localize('quickInput.back', "Back");
|
||||
@@ -1472,22 +1488,19 @@ export class QuickInputController extends Disposable {
|
||||
}
|
||||
}
|
||||
|
||||
accept() {
|
||||
async accept() {
|
||||
this.onDidAcceptEmitter.fire();
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
|
||||
back() {
|
||||
async back() {
|
||||
this.onDidTriggerButtonEmitter.fire(this.backButton);
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
|
||||
cancel() {
|
||||
async cancel() {
|
||||
this.hide();
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
|
||||
layout(dimension: dom.Dimension, titleBarOffset: number): void {
|
||||
layout(dimension: dom.IDimension, titleBarOffset: number): void {
|
||||
this.dimension = dimension;
|
||||
this.titleBarOffset = titleBarOffset;
|
||||
this.updateLayout();
|
||||
@@ -1515,13 +1528,13 @@ export class QuickInputController extends Disposable {
|
||||
private updateStyles() {
|
||||
if (this.ui) {
|
||||
const {
|
||||
titleColor,
|
||||
quickInputTitleBackground,
|
||||
quickInputBackground,
|
||||
quickInputForeground,
|
||||
contrastBorder,
|
||||
widgetShadow,
|
||||
} = this.styles.widget;
|
||||
this.ui.titleBar.style.backgroundColor = titleColor || '';
|
||||
this.ui.titleBar.style.backgroundColor = quickInputTitleBackground ? quickInputTitleBackground.toString() : '';
|
||||
this.ui.container.style.backgroundColor = quickInputBackground ? quickInputBackground.toString() : '';
|
||||
this.ui.container.style.color = quickInputForeground ? quickInputForeground.toString() : '';
|
||||
this.ui.container.style.border = contrastBorder ? `1px solid ${contrastBorder}` : '';
|
||||
|
||||
Reference in New Issue
Block a user