@theia/preferences 1.45.1 → 1.46.0-next.72
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/README.md +81 -81
- package/lib/browser/abstract-resource-preference-provider.d.ts +47 -47
- package/lib/browser/abstract-resource-preference-provider.js +240 -240
- package/lib/browser/abstract-resource-preference-provider.spec.d.ts +1 -1
- package/lib/browser/abstract-resource-preference-provider.spec.js +83 -83
- package/lib/browser/folder-preference-provider.d.ts +20 -20
- package/lib/browser/folder-preference-provider.js +59 -59
- package/lib/browser/folders-preferences-provider.d.ts +27 -27
- package/lib/browser/folders-preferences-provider.js +245 -245
- package/lib/browser/index.d.ts +7 -7
- package/lib/browser/index.js +34 -34
- package/lib/browser/monaco-jsonc-editor.d.ts +9 -9
- package/lib/browser/monaco-jsonc-editor.js +80 -80
- package/lib/browser/package.spec.js +25 -25
- package/lib/browser/preference-bindings.d.ts +4 -4
- package/lib/browser/preference-bindings.js +63 -63
- package/lib/browser/preference-frontend-module.d.ts +6 -6
- package/lib/browser/preference-frontend-module.js +52 -52
- package/lib/browser/preference-open-handler.d.ts +9 -9
- package/lib/browser/preference-open-handler.js +64 -64
- package/lib/browser/preference-transaction-manager.d.ts +100 -100
- package/lib/browser/preference-transaction-manager.js +293 -293
- package/lib/browser/preference-tree-model.d.ts +60 -60
- package/lib/browser/preference-tree-model.js +243 -243
- package/lib/browser/preferences-contribution.d.ts +37 -37
- package/lib/browser/preferences-contribution.js +280 -280
- package/lib/browser/preferences-json-schema-contribution.d.ts +17 -17
- package/lib/browser/preferences-json-schema-contribution.js +91 -91
- package/lib/browser/preferences-monaco-contribution.d.ts +1 -1
- package/lib/browser/preferences-monaco-contribution.js +27 -27
- package/lib/browser/section-preference-provider.d.ts +21 -21
- package/lib/browser/section-preference-provider.js +96 -96
- package/lib/browser/user-configs-preference-provider.d.ts +22 -22
- package/lib/browser/user-configs-preference-provider.js +137 -137
- package/lib/browser/user-preference-provider.d.ts +13 -13
- package/lib/browser/user-preference-provider.js +41 -41
- package/lib/browser/util/preference-scope-command-manager.d.ts +17 -17
- package/lib/browser/util/preference-scope-command-manager.js +87 -87
- package/lib/browser/util/preference-tree-generator.d.ts +31 -31
- package/lib/browser/util/preference-tree-generator.js +237 -237
- package/lib/browser/util/preference-tree-label-provider.d.ts +11 -11
- package/lib/browser/util/preference-tree-label-provider.js +77 -77
- package/lib/browser/util/preference-tree-label-provider.spec.d.ts +1 -1
- package/lib/browser/util/preference-tree-label-provider.spec.js +87 -87
- package/lib/browser/util/preference-types.d.ts +62 -62
- package/lib/browser/util/preference-types.js +128 -128
- package/lib/browser/views/components/preference-array-input.d.ts +28 -28
- package/lib/browser/views/components/preference-array-input.js +180 -180
- package/lib/browser/views/components/preference-boolean-input.d.ts +17 -17
- package/lib/browser/views/components/preference-boolean-input.js +79 -79
- package/lib/browser/views/components/preference-file-input.d.ts +29 -29
- package/lib/browser/views/components/preference-file-input.js +110 -110
- package/lib/browser/views/components/preference-json-input.d.ts +19 -19
- package/lib/browser/views/components/preference-json-input.js +93 -93
- package/lib/browser/views/components/preference-markdown-renderer.d.ts +12 -12
- package/lib/browser/views/components/preference-markdown-renderer.js +81 -81
- package/lib/browser/views/components/preference-node-renderer-creator.d.ts +48 -48
- package/lib/browser/views/components/preference-node-renderer-creator.js +132 -132
- package/lib/browser/views/components/preference-node-renderer.d.ts +112 -112
- package/lib/browser/views/components/preference-node-renderer.js +441 -441
- package/lib/browser/views/components/preference-number-input.d.ts +34 -34
- package/lib/browser/views/components/preference-number-input.js +142 -142
- package/lib/browser/views/components/preference-select-input.d.ts +28 -28
- package/lib/browser/views/components/preference-select-input.js +138 -138
- package/lib/browser/views/components/preference-string-input.d.ts +17 -17
- package/lib/browser/views/components/preference-string-input.js +89 -89
- package/lib/browser/views/preference-editor-widget.d.ts +67 -67
- package/lib/browser/views/preference-editor-widget.js +363 -363
- package/lib/browser/views/preference-scope-tabbar-widget.d.ts +54 -54
- package/lib/browser/views/preference-scope-tabbar-widget.js +343 -343
- package/lib/browser/views/preference-searchbar-widget.d.ts +53 -53
- package/lib/browser/views/preference-searchbar-widget.js +173 -173
- package/lib/browser/views/preference-tree-widget.d.ts +17 -17
- package/lib/browser/views/preference-tree-widget.js +104 -104
- package/lib/browser/views/preference-widget-bindings.d.ts +3 -3
- package/lib/browser/views/preference-widget-bindings.js +87 -87
- package/lib/browser/views/preference-widget.d.ts +36 -36
- package/lib/browser/views/preference-widget.js +126 -126
- package/lib/browser/workspace-file-preference-provider.d.ts +23 -23
- package/lib/browser/workspace-file-preference-provider.js +110 -110
- package/lib/browser/workspace-preference-provider.d.ts +28 -28
- package/lib/browser/workspace-preference-provider.js +142 -142
- package/package.json +10 -10
- package/src/browser/abstract-resource-preference-provider.spec.ts +95 -95
- package/src/browser/abstract-resource-preference-provider.ts +232 -232
- package/src/browser/folder-preference-provider.ts +58 -58
- package/src/browser/folders-preferences-provider.ts +244 -244
- package/src/browser/index.ts +23 -23
- package/src/browser/monaco-jsonc-editor.ts +67 -67
- package/src/browser/package.spec.ts +28 -28
- package/src/browser/preference-bindings.ts +65 -65
- package/src/browser/preference-frontend-module.ts +57 -57
- package/src/browser/preference-open-handler.ts +53 -53
- package/src/browser/preference-transaction-manager.ts +287 -287
- package/src/browser/preference-tree-model.ts +250 -250
- package/src/browser/preferences-contribution.ts +263 -263
- package/src/browser/preferences-json-schema-contribution.ts +86 -86
- package/src/browser/preferences-monaco-contribution.ts +27 -27
- package/src/browser/section-preference-provider.ts +83 -83
- package/src/browser/style/index.css +506 -506
- package/src/browser/style/preference-array.css +94 -94
- package/src/browser/style/preference-context-menu.css +74 -74
- package/src/browser/style/preference-file.css +31 -31
- package/src/browser/style/preference-object.css +49 -49
- package/src/browser/style/search-input.css +66 -66
- package/src/browser/user-configs-preference-provider.ts +127 -127
- package/src/browser/user-preference-provider.ts +35 -35
- package/src/browser/util/preference-scope-command-manager.ts +75 -75
- package/src/browser/util/preference-tree-generator.ts +226 -226
- package/src/browser/util/preference-tree-label-provider.spec.ts +108 -108
- package/src/browser/util/preference-tree-label-provider.ts +64 -64
- package/src/browser/util/preference-types.ts +169 -169
- package/src/browser/views/components/preference-array-input.ts +174 -174
- package/src/browser/views/components/preference-boolean-input.ts +69 -69
- package/src/browser/views/components/preference-file-input.ts +104 -104
- package/src/browser/views/components/preference-json-input.ts +78 -78
- package/src/browser/views/components/preference-markdown-renderer.ts +68 -68
- package/src/browser/views/components/preference-node-renderer-creator.ts +141 -141
- package/src/browser/views/components/preference-node-renderer.ts +477 -477
- package/src/browser/views/components/preference-number-input.ts +147 -147
- package/src/browser/views/components/preference-select-input.ts +131 -131
- package/src/browser/views/components/preference-string-input.ts +76 -76
- package/src/browser/views/preference-editor-widget.ts +349 -349
- package/src/browser/views/preference-scope-tabbar-widget.tsx +344 -344
- package/src/browser/views/preference-searchbar-widget.tsx +183 -183
- package/src/browser/views/preference-tree-widget.tsx +93 -93
- package/src/browser/views/preference-widget-bindings.ts +102 -102
- package/src/browser/views/preference-widget.tsx +117 -117
- package/src/browser/workspace-file-preference-provider.ts +100 -100
- package/src/browser/workspace-preference-provider.ts +134 -134
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { ReactWidget, StatefulWidget, Widget } from '@theia/core/lib/browser';
|
|
3
|
-
import * as React from '@theia/core/shared/react';
|
|
4
|
-
import { Emitter } from '@theia/core';
|
|
5
|
-
export interface PreferencesSearchbarState {
|
|
6
|
-
searchTerm: string;
|
|
7
|
-
}
|
|
8
|
-
export declare class PreferencesSearchbarWidget extends ReactWidget implements StatefulWidget {
|
|
9
|
-
static readonly ID = "settings.header";
|
|
10
|
-
static readonly LABEL = "Settings Header";
|
|
11
|
-
static readonly SEARCHBAR_ID = "preference-searchbar";
|
|
12
|
-
protected readonly onFilterStringChangedEmitter: Emitter<string>;
|
|
13
|
-
readonly onFilterChanged: import("@theia/core").Event<string>;
|
|
14
|
-
protected searchbarRef: React.RefObject<HTMLInputElement>;
|
|
15
|
-
protected resultsCount: number;
|
|
16
|
-
constructor(options?: Widget.IOptions);
|
|
17
|
-
protected init(): void;
|
|
18
|
-
protected handleSearch: (e: React.ChangeEvent<HTMLInputElement>) => Promise<void>;
|
|
19
|
-
protected search: (value: string) => Promise<void>;
|
|
20
|
-
focus(): void;
|
|
21
|
-
/**
|
|
22
|
-
* Clears the search input and all search results.
|
|
23
|
-
* @param e on-click mouse event.
|
|
24
|
-
*/
|
|
25
|
-
protected clearSearchResults: (e: React.MouseEvent) => Promise<void>;
|
|
26
|
-
/**
|
|
27
|
-
* Renders all search bar options.
|
|
28
|
-
*/
|
|
29
|
-
protected renderOptionContainer(): React.ReactNode;
|
|
30
|
-
/**
|
|
31
|
-
* Renders a badge displaying search results count.
|
|
32
|
-
*/
|
|
33
|
-
protected renderResultsCountOption(): React.ReactNode;
|
|
34
|
-
/**
|
|
35
|
-
* Renders a clear all button.
|
|
36
|
-
*/
|
|
37
|
-
protected renderClearAllOption(): React.ReactNode;
|
|
38
|
-
/**
|
|
39
|
-
* Determines whether the search input currently has a value.
|
|
40
|
-
* @returns true, if the search input currently has a value; false, otherwise.
|
|
41
|
-
*/
|
|
42
|
-
protected searchTermExists(): boolean;
|
|
43
|
-
protected getSearchTerm(): string;
|
|
44
|
-
updateSearchTerm(searchTerm: string): Promise<void>;
|
|
45
|
-
render(): React.ReactNode;
|
|
46
|
-
/**
|
|
47
|
-
* Updates the search result count.
|
|
48
|
-
* @param count the result count.
|
|
49
|
-
*/
|
|
50
|
-
updateResultsCount(count: number): void;
|
|
51
|
-
storeState(): PreferencesSearchbarState;
|
|
52
|
-
restoreState(oldState: PreferencesSearchbarState): void;
|
|
53
|
-
}
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ReactWidget, StatefulWidget, Widget } from '@theia/core/lib/browser';
|
|
3
|
+
import * as React from '@theia/core/shared/react';
|
|
4
|
+
import { Emitter } from '@theia/core';
|
|
5
|
+
export interface PreferencesSearchbarState {
|
|
6
|
+
searchTerm: string;
|
|
7
|
+
}
|
|
8
|
+
export declare class PreferencesSearchbarWidget extends ReactWidget implements StatefulWidget {
|
|
9
|
+
static readonly ID = "settings.header";
|
|
10
|
+
static readonly LABEL = "Settings Header";
|
|
11
|
+
static readonly SEARCHBAR_ID = "preference-searchbar";
|
|
12
|
+
protected readonly onFilterStringChangedEmitter: Emitter<string>;
|
|
13
|
+
readonly onFilterChanged: import("@theia/core").Event<string>;
|
|
14
|
+
protected searchbarRef: React.RefObject<HTMLInputElement>;
|
|
15
|
+
protected resultsCount: number;
|
|
16
|
+
constructor(options?: Widget.IOptions);
|
|
17
|
+
protected init(): void;
|
|
18
|
+
protected handleSearch: (e: React.ChangeEvent<HTMLInputElement>) => Promise<void>;
|
|
19
|
+
protected search: (value: string) => Promise<void>;
|
|
20
|
+
focus(): void;
|
|
21
|
+
/**
|
|
22
|
+
* Clears the search input and all search results.
|
|
23
|
+
* @param e on-click mouse event.
|
|
24
|
+
*/
|
|
25
|
+
protected clearSearchResults: (e: React.MouseEvent) => Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* Renders all search bar options.
|
|
28
|
+
*/
|
|
29
|
+
protected renderOptionContainer(): React.ReactNode;
|
|
30
|
+
/**
|
|
31
|
+
* Renders a badge displaying search results count.
|
|
32
|
+
*/
|
|
33
|
+
protected renderResultsCountOption(): React.ReactNode;
|
|
34
|
+
/**
|
|
35
|
+
* Renders a clear all button.
|
|
36
|
+
*/
|
|
37
|
+
protected renderClearAllOption(): React.ReactNode;
|
|
38
|
+
/**
|
|
39
|
+
* Determines whether the search input currently has a value.
|
|
40
|
+
* @returns true, if the search input currently has a value; false, otherwise.
|
|
41
|
+
*/
|
|
42
|
+
protected searchTermExists(): boolean;
|
|
43
|
+
protected getSearchTerm(): string;
|
|
44
|
+
updateSearchTerm(searchTerm: string): Promise<void>;
|
|
45
|
+
render(): React.ReactNode;
|
|
46
|
+
/**
|
|
47
|
+
* Updates the search result count.
|
|
48
|
+
* @param count the result count.
|
|
49
|
+
*/
|
|
50
|
+
updateResultsCount(count: number): void;
|
|
51
|
+
storeState(): PreferencesSearchbarState;
|
|
52
|
+
restoreState(oldState: PreferencesSearchbarState): void;
|
|
53
|
+
}
|
|
54
54
|
//# sourceMappingURL=preference-searchbar-widget.d.ts.map
|
|
@@ -1,174 +1,174 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// *****************************************************************************
|
|
3
|
-
// Copyright (C) 2020 Ericsson and others.
|
|
4
|
-
//
|
|
5
|
-
// This program and the accompanying materials are made available under the
|
|
6
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
-
//
|
|
9
|
-
// This Source Code may also be made available under the following Secondary
|
|
10
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
-
// with the GNU Classpath Exception which is available at
|
|
13
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
-
//
|
|
15
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
|
-
// *****************************************************************************
|
|
17
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
18
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
19
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
20
|
-
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;
|
|
21
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
22
|
-
};
|
|
23
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
24
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
25
|
-
};
|
|
26
|
-
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
27
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
|
28
|
-
};
|
|
29
|
-
var PreferencesSearchbarWidget_1;
|
|
30
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
-
exports.PreferencesSearchbarWidget = void 0;
|
|
32
|
-
const browser_1 = require("@theia/core/lib/browser");
|
|
33
|
-
const inversify_1 = require("@theia/core/shared/inversify");
|
|
34
|
-
const React = require("@theia/core/shared/react");
|
|
35
|
-
const debounce = require("p-debounce");
|
|
36
|
-
const core_1 = require("@theia/core");
|
|
37
|
-
const nls_1 = require("@theia/core/lib/common/nls");
|
|
38
|
-
let PreferencesSearchbarWidget = PreferencesSearchbarWidget_1 = class PreferencesSearchbarWidget extends browser_1.ReactWidget {
|
|
39
|
-
constructor(options) {
|
|
40
|
-
super(options);
|
|
41
|
-
this.onFilterStringChangedEmitter = new core_1.Emitter();
|
|
42
|
-
this.onFilterChanged = this.onFilterStringChangedEmitter.event;
|
|
43
|
-
this.searchbarRef = React.createRef();
|
|
44
|
-
this.resultsCount = 0;
|
|
45
|
-
this.handleSearch = (e) => this.search(e.target.value);
|
|
46
|
-
this.search = debounce(async (value) => {
|
|
47
|
-
this.onFilterStringChangedEmitter.fire(value);
|
|
48
|
-
this.update();
|
|
49
|
-
}, 200);
|
|
50
|
-
/**
|
|
51
|
-
* Clears the search input and all search results.
|
|
52
|
-
* @param e on-click mouse event.
|
|
53
|
-
*/
|
|
54
|
-
this.clearSearchResults = async (e) => {
|
|
55
|
-
const search = document.getElementById(PreferencesSearchbarWidget_1.SEARCHBAR_ID);
|
|
56
|
-
if (search) {
|
|
57
|
-
search.value = '';
|
|
58
|
-
await this.search(search.value);
|
|
59
|
-
this.update();
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
this.focus = this.focus.bind(this);
|
|
63
|
-
}
|
|
64
|
-
init() {
|
|
65
|
-
this.id = PreferencesSearchbarWidget_1.ID;
|
|
66
|
-
this.title.label = PreferencesSearchbarWidget_1.LABEL;
|
|
67
|
-
this.update();
|
|
68
|
-
}
|
|
69
|
-
focus() {
|
|
70
|
-
if (this.searchbarRef.current) {
|
|
71
|
-
this.searchbarRef.current.focus();
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Renders all search bar options.
|
|
76
|
-
*/
|
|
77
|
-
renderOptionContainer() {
|
|
78
|
-
const resultsCount = this.renderResultsCountOption();
|
|
79
|
-
const clearAllOption = this.renderClearAllOption();
|
|
80
|
-
return React.createElement("div", { className: "option-buttons" },
|
|
81
|
-
" ",
|
|
82
|
-
resultsCount,
|
|
83
|
-
" ",
|
|
84
|
-
clearAllOption,
|
|
85
|
-
" ");
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Renders a badge displaying search results count.
|
|
89
|
-
*/
|
|
90
|
-
renderResultsCountOption() {
|
|
91
|
-
let resultsFound;
|
|
92
|
-
if (this.resultsCount === 0) {
|
|
93
|
-
resultsFound = nls_1.nls.localizeByDefault('No Settings Found');
|
|
94
|
-
}
|
|
95
|
-
else if (this.resultsCount === 1) {
|
|
96
|
-
resultsFound = nls_1.nls.localizeByDefault('1 Setting Found');
|
|
97
|
-
}
|
|
98
|
-
else {
|
|
99
|
-
resultsFound = nls_1.nls.localizeByDefault('{0} Settings Found', this.resultsCount.toFixed(0));
|
|
100
|
-
}
|
|
101
|
-
return this.searchTermExists() ?
|
|
102
|
-
(React.createElement("span", { className: "results-found", title: resultsFound }, resultsFound))
|
|
103
|
-
: '';
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Renders a clear all button.
|
|
107
|
-
*/
|
|
108
|
-
renderClearAllOption() {
|
|
109
|
-
return React.createElement("span", { className: `${(0, browser_1.codicon)('clear-all')} option ${(this.searchTermExists() ? 'enabled' : '')}`, title: nls_1.nls.localizeByDefault('Clear Search Results'), onClick: this.clearSearchResults });
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Determines whether the search input currently has a value.
|
|
113
|
-
* @returns true, if the search input currently has a value; false, otherwise.
|
|
114
|
-
*/
|
|
115
|
-
searchTermExists() {
|
|
116
|
-
var _a;
|
|
117
|
-
return !!((_a = this.searchbarRef.current) === null || _a === void 0 ? void 0 : _a.value);
|
|
118
|
-
}
|
|
119
|
-
getSearchTerm() {
|
|
120
|
-
const search = document.getElementById(PreferencesSearchbarWidget_1.SEARCHBAR_ID);
|
|
121
|
-
return search === null || search === void 0 ? void 0 : search.value;
|
|
122
|
-
}
|
|
123
|
-
async updateSearchTerm(searchTerm) {
|
|
124
|
-
const search = document.getElementById(PreferencesSearchbarWidget_1.SEARCHBAR_ID);
|
|
125
|
-
if (!search || search.value === searchTerm) {
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
search.value = searchTerm;
|
|
129
|
-
await this.search(search.value);
|
|
130
|
-
this.update();
|
|
131
|
-
}
|
|
132
|
-
render() {
|
|
133
|
-
const optionContainer = this.renderOptionContainer();
|
|
134
|
-
return (React.createElement("div", { className: 'settings-header' },
|
|
135
|
-
React.createElement("div", { className: "settings-search-container", ref: this.focus },
|
|
136
|
-
React.createElement("input", { type: "text", id: PreferencesSearchbarWidget_1.SEARCHBAR_ID, spellCheck: false, placeholder: nls_1.nls.localizeByDefault('Search settings'), className: "settings-search-input theia-input", onChange: this.handleSearch, ref: this.searchbarRef }),
|
|
137
|
-
optionContainer)));
|
|
138
|
-
}
|
|
139
|
-
/**
|
|
140
|
-
* Updates the search result count.
|
|
141
|
-
* @param count the result count.
|
|
142
|
-
*/
|
|
143
|
-
updateResultsCount(count) {
|
|
144
|
-
this.resultsCount = count;
|
|
145
|
-
this.update();
|
|
146
|
-
}
|
|
147
|
-
storeState() {
|
|
148
|
-
return {
|
|
149
|
-
searchTerm: this.getSearchTerm()
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
restoreState(oldState) {
|
|
153
|
-
const searchInputExists = this.onDidChangeVisibility(() => {
|
|
154
|
-
this.updateSearchTerm(oldState.searchTerm || '');
|
|
155
|
-
searchInputExists.dispose();
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
};
|
|
159
|
-
PreferencesSearchbarWidget.ID = 'settings.header';
|
|
160
|
-
PreferencesSearchbarWidget.LABEL = 'Settings Header';
|
|
161
|
-
PreferencesSearchbarWidget.SEARCHBAR_ID = 'preference-searchbar';
|
|
162
|
-
__decorate([
|
|
163
|
-
(0, inversify_1.postConstruct)(),
|
|
164
|
-
__metadata("design:type", Function),
|
|
165
|
-
__metadata("design:paramtypes", []),
|
|
166
|
-
__metadata("design:returntype", void 0)
|
|
167
|
-
], PreferencesSearchbarWidget.prototype, "init", null);
|
|
168
|
-
PreferencesSearchbarWidget = PreferencesSearchbarWidget_1 = __decorate([
|
|
169
|
-
(0, inversify_1.injectable)(),
|
|
170
|
-
__param(0, (0, inversify_1.unmanaged)()),
|
|
171
|
-
__metadata("design:paramtypes", [Object])
|
|
172
|
-
], PreferencesSearchbarWidget);
|
|
173
|
-
exports.PreferencesSearchbarWidget = PreferencesSearchbarWidget;
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2020 Ericsson and others.
|
|
4
|
+
//
|
|
5
|
+
// This program and the accompanying materials are made available under the
|
|
6
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
+
//
|
|
9
|
+
// This Source Code may also be made available under the following Secondary
|
|
10
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
+
// with the GNU Classpath Exception which is available at
|
|
13
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
+
//
|
|
15
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
|
+
// *****************************************************************************
|
|
17
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
18
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
19
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
20
|
+
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;
|
|
21
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
22
|
+
};
|
|
23
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
24
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
25
|
+
};
|
|
26
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
27
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
28
|
+
};
|
|
29
|
+
var PreferencesSearchbarWidget_1;
|
|
30
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
+
exports.PreferencesSearchbarWidget = void 0;
|
|
32
|
+
const browser_1 = require("@theia/core/lib/browser");
|
|
33
|
+
const inversify_1 = require("@theia/core/shared/inversify");
|
|
34
|
+
const React = require("@theia/core/shared/react");
|
|
35
|
+
const debounce = require("p-debounce");
|
|
36
|
+
const core_1 = require("@theia/core");
|
|
37
|
+
const nls_1 = require("@theia/core/lib/common/nls");
|
|
38
|
+
let PreferencesSearchbarWidget = PreferencesSearchbarWidget_1 = class PreferencesSearchbarWidget extends browser_1.ReactWidget {
|
|
39
|
+
constructor(options) {
|
|
40
|
+
super(options);
|
|
41
|
+
this.onFilterStringChangedEmitter = new core_1.Emitter();
|
|
42
|
+
this.onFilterChanged = this.onFilterStringChangedEmitter.event;
|
|
43
|
+
this.searchbarRef = React.createRef();
|
|
44
|
+
this.resultsCount = 0;
|
|
45
|
+
this.handleSearch = (e) => this.search(e.target.value);
|
|
46
|
+
this.search = debounce(async (value) => {
|
|
47
|
+
this.onFilterStringChangedEmitter.fire(value);
|
|
48
|
+
this.update();
|
|
49
|
+
}, 200);
|
|
50
|
+
/**
|
|
51
|
+
* Clears the search input and all search results.
|
|
52
|
+
* @param e on-click mouse event.
|
|
53
|
+
*/
|
|
54
|
+
this.clearSearchResults = async (e) => {
|
|
55
|
+
const search = document.getElementById(PreferencesSearchbarWidget_1.SEARCHBAR_ID);
|
|
56
|
+
if (search) {
|
|
57
|
+
search.value = '';
|
|
58
|
+
await this.search(search.value);
|
|
59
|
+
this.update();
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
this.focus = this.focus.bind(this);
|
|
63
|
+
}
|
|
64
|
+
init() {
|
|
65
|
+
this.id = PreferencesSearchbarWidget_1.ID;
|
|
66
|
+
this.title.label = PreferencesSearchbarWidget_1.LABEL;
|
|
67
|
+
this.update();
|
|
68
|
+
}
|
|
69
|
+
focus() {
|
|
70
|
+
if (this.searchbarRef.current) {
|
|
71
|
+
this.searchbarRef.current.focus();
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Renders all search bar options.
|
|
76
|
+
*/
|
|
77
|
+
renderOptionContainer() {
|
|
78
|
+
const resultsCount = this.renderResultsCountOption();
|
|
79
|
+
const clearAllOption = this.renderClearAllOption();
|
|
80
|
+
return React.createElement("div", { className: "option-buttons" },
|
|
81
|
+
" ",
|
|
82
|
+
resultsCount,
|
|
83
|
+
" ",
|
|
84
|
+
clearAllOption,
|
|
85
|
+
" ");
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Renders a badge displaying search results count.
|
|
89
|
+
*/
|
|
90
|
+
renderResultsCountOption() {
|
|
91
|
+
let resultsFound;
|
|
92
|
+
if (this.resultsCount === 0) {
|
|
93
|
+
resultsFound = nls_1.nls.localizeByDefault('No Settings Found');
|
|
94
|
+
}
|
|
95
|
+
else if (this.resultsCount === 1) {
|
|
96
|
+
resultsFound = nls_1.nls.localizeByDefault('1 Setting Found');
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
resultsFound = nls_1.nls.localizeByDefault('{0} Settings Found', this.resultsCount.toFixed(0));
|
|
100
|
+
}
|
|
101
|
+
return this.searchTermExists() ?
|
|
102
|
+
(React.createElement("span", { className: "results-found", title: resultsFound }, resultsFound))
|
|
103
|
+
: '';
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Renders a clear all button.
|
|
107
|
+
*/
|
|
108
|
+
renderClearAllOption() {
|
|
109
|
+
return React.createElement("span", { className: `${(0, browser_1.codicon)('clear-all')} option ${(this.searchTermExists() ? 'enabled' : '')}`, title: nls_1.nls.localizeByDefault('Clear Search Results'), onClick: this.clearSearchResults });
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Determines whether the search input currently has a value.
|
|
113
|
+
* @returns true, if the search input currently has a value; false, otherwise.
|
|
114
|
+
*/
|
|
115
|
+
searchTermExists() {
|
|
116
|
+
var _a;
|
|
117
|
+
return !!((_a = this.searchbarRef.current) === null || _a === void 0 ? void 0 : _a.value);
|
|
118
|
+
}
|
|
119
|
+
getSearchTerm() {
|
|
120
|
+
const search = document.getElementById(PreferencesSearchbarWidget_1.SEARCHBAR_ID);
|
|
121
|
+
return search === null || search === void 0 ? void 0 : search.value;
|
|
122
|
+
}
|
|
123
|
+
async updateSearchTerm(searchTerm) {
|
|
124
|
+
const search = document.getElementById(PreferencesSearchbarWidget_1.SEARCHBAR_ID);
|
|
125
|
+
if (!search || search.value === searchTerm) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
search.value = searchTerm;
|
|
129
|
+
await this.search(search.value);
|
|
130
|
+
this.update();
|
|
131
|
+
}
|
|
132
|
+
render() {
|
|
133
|
+
const optionContainer = this.renderOptionContainer();
|
|
134
|
+
return (React.createElement("div", { className: 'settings-header' },
|
|
135
|
+
React.createElement("div", { className: "settings-search-container", ref: this.focus },
|
|
136
|
+
React.createElement("input", { type: "text", id: PreferencesSearchbarWidget_1.SEARCHBAR_ID, spellCheck: false, placeholder: nls_1.nls.localizeByDefault('Search settings'), className: "settings-search-input theia-input", onChange: this.handleSearch, ref: this.searchbarRef }),
|
|
137
|
+
optionContainer)));
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Updates the search result count.
|
|
141
|
+
* @param count the result count.
|
|
142
|
+
*/
|
|
143
|
+
updateResultsCount(count) {
|
|
144
|
+
this.resultsCount = count;
|
|
145
|
+
this.update();
|
|
146
|
+
}
|
|
147
|
+
storeState() {
|
|
148
|
+
return {
|
|
149
|
+
searchTerm: this.getSearchTerm()
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
restoreState(oldState) {
|
|
153
|
+
const searchInputExists = this.onDidChangeVisibility(() => {
|
|
154
|
+
this.updateSearchTerm(oldState.searchTerm || '');
|
|
155
|
+
searchInputExists.dispose();
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
PreferencesSearchbarWidget.ID = 'settings.header';
|
|
160
|
+
PreferencesSearchbarWidget.LABEL = 'Settings Header';
|
|
161
|
+
PreferencesSearchbarWidget.SEARCHBAR_ID = 'preference-searchbar';
|
|
162
|
+
__decorate([
|
|
163
|
+
(0, inversify_1.postConstruct)(),
|
|
164
|
+
__metadata("design:type", Function),
|
|
165
|
+
__metadata("design:paramtypes", []),
|
|
166
|
+
__metadata("design:returntype", void 0)
|
|
167
|
+
], PreferencesSearchbarWidget.prototype, "init", null);
|
|
168
|
+
PreferencesSearchbarWidget = PreferencesSearchbarWidget_1 = __decorate([
|
|
169
|
+
(0, inversify_1.injectable)(),
|
|
170
|
+
__param(0, (0, inversify_1.unmanaged)()),
|
|
171
|
+
__metadata("design:paramtypes", [Object])
|
|
172
|
+
], PreferencesSearchbarWidget);
|
|
173
|
+
exports.PreferencesSearchbarWidget = PreferencesSearchbarWidget;
|
|
174
174
|
//# sourceMappingURL=preference-searchbar-widget.js.map
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { TreeNode, TreeProps, TreeWidget } from '@theia/core/lib/browser';
|
|
3
|
-
import React = require('@theia/core/shared/react');
|
|
4
|
-
import { PreferenceTreeModel, PreferenceTreeNodeRow, PreferenceTreeNodeProps } from '../preference-tree-model';
|
|
5
|
-
export declare class PreferencesTreeWidget extends TreeWidget {
|
|
6
|
-
static ID: string;
|
|
7
|
-
protected shouldFireSelectionEvents: boolean;
|
|
8
|
-
protected firstVisibleLeafNodeID: string;
|
|
9
|
-
readonly model: PreferenceTreeModel;
|
|
10
|
-
protected readonly treeProps: TreeProps;
|
|
11
|
-
init(): void;
|
|
12
|
-
doUpdateRows(): void;
|
|
13
|
-
protected doRenderNodeRow({ depth, visibleChildren, node, isExpansible }: PreferenceTreeNodeRow): React.ReactNode;
|
|
14
|
-
protected renderNode(node: TreeNode, props: PreferenceTreeNodeProps): React.ReactNode;
|
|
15
|
-
protected renderExpansionToggle(node: TreeNode, props: PreferenceTreeNodeProps): React.ReactNode;
|
|
16
|
-
protected toNodeName(node: TreeNode): string;
|
|
17
|
-
}
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { TreeNode, TreeProps, TreeWidget } from '@theia/core/lib/browser';
|
|
3
|
+
import React = require('@theia/core/shared/react');
|
|
4
|
+
import { PreferenceTreeModel, PreferenceTreeNodeRow, PreferenceTreeNodeProps } from '../preference-tree-model';
|
|
5
|
+
export declare class PreferencesTreeWidget extends TreeWidget {
|
|
6
|
+
static ID: string;
|
|
7
|
+
protected shouldFireSelectionEvents: boolean;
|
|
8
|
+
protected firstVisibleLeafNodeID: string;
|
|
9
|
+
readonly model: PreferenceTreeModel;
|
|
10
|
+
protected readonly treeProps: TreeProps;
|
|
11
|
+
init(): void;
|
|
12
|
+
doUpdateRows(): void;
|
|
13
|
+
protected doRenderNodeRow({ depth, visibleChildren, node, isExpansible }: PreferenceTreeNodeRow): React.ReactNode;
|
|
14
|
+
protected renderNode(node: TreeNode, props: PreferenceTreeNodeProps): React.ReactNode;
|
|
15
|
+
protected renderExpansionToggle(node: TreeNode, props: PreferenceTreeNodeProps): React.ReactNode;
|
|
16
|
+
protected toNodeName(node: TreeNode): string;
|
|
17
|
+
}
|
|
18
18
|
//# sourceMappingURL=preference-tree-widget.d.ts.map
|