chrome-devtools-frontend 1.0.1536371 → 1.0.1537860
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/.env.template +9 -0
- package/docs/get_the_code.md +27 -0
- package/front_end/core/common/SettingRegistration.ts +10 -7
- package/front_end/core/common/Settings.ts +3 -0
- package/front_end/core/host/AidaClient.ts +64 -5
- package/front_end/core/host/DispatchHttpRequestClient.ts +62 -0
- package/front_end/core/host/GdpClient.ts +8 -57
- package/front_end/core/host/host.ts +2 -0
- package/front_end/core/protocol_client/CDPConnection.ts +10 -8
- package/front_end/core/protocol_client/InspectorBackend.ts +36 -42
- package/front_end/core/sdk/EnhancedTracesParser.ts +20 -5
- package/front_end/core/sdk/RehydratingConnection.ts +112 -4
- package/front_end/core/sdk/RehydratingObject.ts +8 -0
- package/front_end/core/sdk/TraceObject.ts +5 -1
- package/front_end/core/sdk/sdk-meta.ts +8 -2
- package/front_end/entrypoints/inspector_main/RenderingOptions.ts +4 -3
- package/front_end/generated/SupportedCSSProperties.js +1 -0
- package/front_end/models/ai_assistance/agents/PerformanceAgent.ts +23 -7
- package/front_end/models/ai_assistance/data_formatters/PerformanceTraceFormatter.snapshot.txt +110 -5
- package/front_end/models/ai_assistance/data_formatters/PerformanceTraceFormatter.ts +50 -45
- package/front_end/models/cpu_profile/ProfileTreeModel.ts +7 -7
- package/front_end/models/javascript_metadata/NativeFunctions.js +1 -1
- package/front_end/models/trace/types/File.ts +9 -0
- package/front_end/models/trace_source_maps_resolver/SourceMapsResolver.ts +1 -1
- package/front_end/panels/ai_assistance/AiAssistancePanel.ts +5 -9
- package/front_end/panels/ai_assistance/components/ChatView.ts +58 -70
- package/front_end/panels/application/BackForwardCacheTreeElement.ts +2 -6
- package/front_end/panels/application/StorageView.ts +3 -2
- package/front_end/panels/application/components/BackForwardCacheView.ts +96 -108
- package/front_end/panels/application/components/FrameDetailsView.ts +8 -11
- package/front_end/panels/application/components/OriginTrialTreeView.ts +136 -137
- package/front_end/panels/application/components/backForwardCacheView.css +8 -0
- package/front_end/panels/application/components/badge.css +9 -1
- package/front_end/panels/application/preloading/components/PreloadingGrid.ts +2 -2
- package/front_end/panels/application/preloading/components/PreloadingString.ts +27 -0
- package/front_end/panels/autofill/AutofillView.ts +1 -1
- package/front_end/panels/browser_debugger/CategorizedBreakpointsSidebarPane.ts +44 -53
- package/front_end/panels/console/ConsoleView.ts +11 -9
- package/front_end/panels/coverage/CoverageView.ts +1 -2
- package/front_end/panels/css_overview/CSSOverviewSidebarPanel.ts +1 -1
- package/front_end/panels/developer_resources/DeveloperResourcesView.ts +1 -1
- package/front_end/panels/elements/ElementStatePaneWidget.ts +1 -1
- package/front_end/panels/elements/EventListenersWidget.ts +1 -2
- package/front_end/panels/elements/PropertiesWidget.ts +1 -1
- package/front_end/panels/network/NetworkConfigView.ts +2 -1
- package/front_end/panels/network/NetworkPanel.ts +5 -4
- package/front_end/panels/network/RequestCookiesView.ts +2 -1
- package/front_end/panels/profiler/HeapSnapshotView.ts +3 -2
- package/front_end/panels/recorder/RecorderController.ts +1 -2
- package/front_end/panels/recorder/components/CreateRecordingView.ts +153 -129
- package/front_end/panels/sensors/SensorsView.ts +4 -3
- package/front_end/panels/settings/AISettingsTab.ts +162 -171
- package/front_end/panels/settings/FrameworkIgnoreListSettingsTab.ts +8 -6
- package/front_end/panels/settings/KeybindsSettingsTab.ts +3 -2
- package/front_end/panels/settings/SettingsScreen.ts +5 -8
- package/front_end/panels/settings/WorkspaceSettingsTab.ts +1 -1
- package/front_end/panels/settings/aiSettingsTab.css +151 -148
- package/front_end/panels/settings/settings-meta.ts +1 -2
- package/front_end/panels/sources/AddSourceMapURLDialog.ts +23 -26
- package/front_end/panels/sources/AiCodeCompletionPlugin.ts +2 -1
- package/front_end/panels/sources/SourcesPanel.ts +2 -1
- package/front_end/panels/sources/sources-meta.ts +8 -1
- package/front_end/panels/timeline/TimelinePanel.ts +64 -14
- package/front_end/panels/timeline/TimelineUIUtils.ts +4 -20
- package/front_end/panels/timeline/components/ExportTraceOptions.ts +33 -34
- package/front_end/panels/timeline/components/LiveMetricsView.ts +1 -0
- package/front_end/panels/timeline/components/SidebarAnnotationsTab.ts +2 -0
- package/front_end/third_party/chromium/README.chromium +2 -2
- package/front_end/third_party/puppeteer/README.chromium +2 -2
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/Browser.d.ts +9 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/Browser.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/Browser.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/BrowserContext.d.ts +2 -2
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/BrowserContext.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/BrowserContext.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/Page.d.ts +13 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/Page.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/Page.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/BrowserContext.d.ts +2 -2
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/BrowserContext.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/BrowserContext.js +5 -2
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/BrowserContext.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/Page.d.ts +2 -2
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/Page.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/Page.js +3 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/Page.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/core/Realm.d.ts +1 -12
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/core/Realm.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Accessibility.d.ts +6 -0
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Accessibility.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Accessibility.js +1 -0
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Accessibility.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Browser.d.ts +2 -2
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Browser.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Browser.js +6 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Browser.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/BrowserContext.d.ts +2 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/BrowserContext.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/BrowserContext.js +2 -2
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/BrowserContext.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Page.d.ts +2 -2
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Page.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Page.js +3 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Page.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/injected/injected.d.ts +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/revisions.d.ts +3 -3
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/revisions.js +3 -3
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/revisions.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/Mutex.d.ts +2 -2
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/disposable.d.ts +2 -2
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/disposable.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/disposable.js +3 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/disposable.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/util.d.ts +1 -0
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/util.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/util.js +1 -0
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/util.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/version.d.ts +1 -1
- package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/version.js +1 -1
- package/front_end/third_party/puppeteer/package/lib/es5-iife/puppeteer-core-browser.d.ts +28 -3
- package/front_end/third_party/puppeteer/package/lib/es5-iife/puppeteer-core-browser.js +21 -10
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/Browser.d.ts +9 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/Browser.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/Browser.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/BrowserContext.d.ts +2 -2
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/BrowserContext.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/BrowserContext.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/Input.d.ts +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/Input.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/Page.d.ts +13 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/Page.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/Page.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/BrowserContext.d.ts +2 -2
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/BrowserContext.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/BrowserContext.js +5 -2
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/BrowserContext.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/Page.d.ts +2 -2
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/Page.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/Page.js +3 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/Page.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/core/Realm.d.ts +1 -12
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/core/Realm.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Accessibility.d.ts +6 -0
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Accessibility.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Accessibility.js +1 -0
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Accessibility.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Browser.d.ts +2 -2
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Browser.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Browser.js +6 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Browser.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/BrowserContext.d.ts +2 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/BrowserContext.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/BrowserContext.js +2 -2
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/BrowserContext.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Page.d.ts +2 -2
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Page.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Page.js +3 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Page.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/revisions.d.ts +3 -3
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/revisions.js +3 -3
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/revisions.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/util/disposable.d.ts +2 -2
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/util/disposable.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/util/disposable.js +2 -2
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/util/disposable.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/util/util.d.ts +1 -0
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/util/util.d.ts.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/util/util.js +1 -0
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/util/util.js.map +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/util/version.d.ts +1 -1
- package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/util/version.js +1 -1
- package/front_end/third_party/puppeteer/package/lib/types.d.ts +28 -3
- package/front_end/third_party/puppeteer/package/package.json +2 -2
- package/front_end/third_party/puppeteer/package/src/api/Browser.ts +13 -1
- package/front_end/third_party/puppeteer/package/src/api/BrowserContext.ts +7 -2
- package/front_end/third_party/puppeteer/package/src/api/Page.ts +14 -1
- package/front_end/third_party/puppeteer/package/src/bidi/BrowserContext.ts +8 -5
- package/front_end/third_party/puppeteer/package/src/bidi/Page.ts +5 -2
- package/front_end/third_party/puppeteer/package/src/cdp/Accessibility.ts +8 -0
- package/front_end/third_party/puppeteer/package/src/cdp/Browser.ts +11 -2
- package/front_end/third_party/puppeteer/package/src/cdp/BrowserContext.ts +3 -2
- package/front_end/third_party/puppeteer/package/src/cdp/Page.ts +5 -5
- package/front_end/third_party/puppeteer/package/src/revisions.ts +3 -3
- package/front_end/third_party/puppeteer/package/src/util/disposable.ts +2 -2
- package/front_end/third_party/puppeteer/package/src/util/util.ts +1 -0
- package/front_end/third_party/puppeteer/package/src/util/version.ts +1 -1
- package/front_end/ui/components/adorners/Adorner.ts +2 -1
- package/front_end/ui/components/buttons/Button.docs.ts +195 -0
- package/front_end/ui/components/settings/SettingCheckbox.ts +49 -14
- package/front_end/ui/components/settings/settingCheckbox.css +6 -1
- package/front_end/ui/components/spinners/Spinners.docs.ts +13 -0
- package/front_end/ui/components/text_editor/AiCodeCompletionProvider.ts +280 -0
- package/front_end/ui/components/text_editor/text_editor.ts +1 -0
- package/front_end/ui/components/tooltips/Tooltip.docs.ts +76 -0
- package/front_end/ui/components/tooltips/Tooltip.ts +1 -1
- package/front_end/ui/legacy/Dialog.ts +0 -1
- package/front_end/ui/legacy/FilterBar.ts +1 -2
- package/front_end/ui/legacy/RadioButton.docs.ts +41 -0
- package/front_end/ui/legacy/SelectMenu.docs.ts +98 -0
- package/front_end/ui/legacy/Toolbar.ts +4 -6
- package/front_end/ui/legacy/UIUtils.ts +114 -1
- package/front_end/ui/legacy/Widget.ts +62 -34
- package/front_end/ui/legacy/XLink.ts +0 -3
- package/front_end/ui/legacy/components/data_grid/DataGridElement.ts +9 -0
- package/front_end/ui/legacy/components/settings_ui/SettingsUI.ts +125 -0
- package/front_end/ui/legacy/components/settings_ui/settings_ui.ts +8 -0
- package/front_end/ui/legacy/components/utils/Linkifier.ts +9 -3
- package/front_end/ui/legacy/legacy.ts +0 -2
- package/front_end/ui/visual_logging/KnownContextValues.ts +4 -1
- package/mcp/mcp.ts +5 -0
- package/package.json +1 -1
- package/front_end/models/ai_assistance/data_formatters/PerformanceTraceFormatterBounds.snapshot.txt +0 -4
- package/front_end/models/trace/lantern/testing/MetricTestUtils.ts +0 -62
- package/front_end/models/trace/lantern/testing/testing.ts +0 -5
- package/front_end/ui/components/docs/breadcrumbs_perf/initial-breadcrumb-perf.html +0 -20
- package/front_end/ui/components/docs/breadcrumbs_perf/initial-breadcrumb-perf.ts +0 -25
- package/front_end/ui/components/docs/breadcrumbs_perf/nested-breadcrumbs-perf.html +0 -20
- package/front_end/ui/components/docs/breadcrumbs_perf/nested-breadcrumbs-perf.ts +0 -36
- package/front_end/ui/components/docs/button/basic.html +0 -44
- package/front_end/ui/components/docs/button/basic.ts +0 -175
- package/front_end/ui/components/docs/radio_button/basic.html +0 -23
- package/front_end/ui/components/docs/radio_button/basic.ts +0 -50
- package/front_end/ui/components/docs/select_menu/basic.html +0 -19
- package/front_end/ui/components/docs/select_menu/basic.ts +0 -95
- package/front_end/ui/components/docs/select_menu/wide-option.html +0 -38
- package/front_end/ui/components/docs/select_menu/wide-option.ts +0 -43
- package/front_end/ui/components/docs/spinners/basic.html +0 -17
- package/front_end/ui/components/docs/spinners/basic.ts +0 -22
- package/front_end/ui/components/docs/tooltip/basic.html +0 -20
- package/front_end/ui/components/docs/tooltip/basic.ts +0 -82
- package/front_end/ui/legacy/SettingsUI.ts +0 -254
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
// Copyright 2024 The Chromium Authors
|
|
2
|
-
// Use of this source code is governed by a BSD-style license that can be
|
|
3
|
-
// found in the LICENSE file.
|
|
4
|
-
|
|
5
|
-
import * as UI from '../../../legacy/legacy.js';
|
|
6
|
-
import * as ComponentHelpers from '../../helpers/helpers.js';
|
|
7
|
-
|
|
8
|
-
await ComponentHelpers.ComponentServerSetup.setup();
|
|
9
|
-
function radioExample({name, tabbable, disabled}: {
|
|
10
|
-
name: string,
|
|
11
|
-
tabbable: boolean,
|
|
12
|
-
disabled: boolean,
|
|
13
|
-
}): HTMLElement {
|
|
14
|
-
const example = document.createElement('fieldset');
|
|
15
|
-
example.style.marginTop = '20px';
|
|
16
|
-
const legend = document.createElement('legend');
|
|
17
|
-
legend.textContent = name;
|
|
18
|
-
const list = document.createElement('div');
|
|
19
|
-
for (let i = 0; i < 3; ++i) {
|
|
20
|
-
const {label, radio} = UI.UIUtils.createRadioButton(name, `Option #${i + 1}`, name);
|
|
21
|
-
radio.tabIndex = tabbable ? 0 : -1;
|
|
22
|
-
radio.disabled = disabled;
|
|
23
|
-
radio.checked = i === 0;
|
|
24
|
-
list.append(label);
|
|
25
|
-
}
|
|
26
|
-
example.append(legend, list);
|
|
27
|
-
return example;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function init(): void {
|
|
31
|
-
const container = document.getElementById('container');
|
|
32
|
-
if (!container) {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
container.style.padding = '42px 42px';
|
|
37
|
-
container.style.margin = '42px 42px';
|
|
38
|
-
container.style.border = '1px solid rgb(0 0 0 / 20%)';
|
|
39
|
-
|
|
40
|
-
// Basic
|
|
41
|
-
container.appendChild(radioExample({name: 'basic', tabbable: true, disabled: false}));
|
|
42
|
-
|
|
43
|
-
// Not tab reachable
|
|
44
|
-
container.appendChild(radioExample({name: 'not-table-reachable', tabbable: false, disabled: false}));
|
|
45
|
-
|
|
46
|
-
// Disabled
|
|
47
|
-
container.appendChild(radioExample({name: 'disabled', tabbable: true, disabled: true}));
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
init();
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
<!--
|
|
2
|
-
Copyright 2023 The Chromium Authors
|
|
3
|
-
Use of this source code is governed by a BSD-style license that can be
|
|
4
|
-
found in the LICENSE file.
|
|
5
|
-
-->
|
|
6
|
-
<!DOCTYPE html>
|
|
7
|
-
<html>
|
|
8
|
-
|
|
9
|
-
<head>
|
|
10
|
-
<meta charset="UTF-8" />
|
|
11
|
-
<meta name="viewport" content="width=device-width" />
|
|
12
|
-
<title>Select menu example</title>
|
|
13
|
-
</head>
|
|
14
|
-
|
|
15
|
-
<body>
|
|
16
|
-
<script src="./basic.js" type="module"></script>
|
|
17
|
-
</body>
|
|
18
|
-
|
|
19
|
-
</html>
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
// Copyright 2023 The Chromium Authors
|
|
2
|
-
// Use of this source code is governed by a BSD-style license that can be
|
|
3
|
-
// found in the LICENSE file.
|
|
4
|
-
|
|
5
|
-
import * as UI from '../../../../ui/legacy/legacy.js';
|
|
6
|
-
import * as Lit from '../../../lit/lit.js';
|
|
7
|
-
import * as VisualLogging from '../../../visual_logging/visual_logging.js';
|
|
8
|
-
|
|
9
|
-
const {html} = Lit;
|
|
10
|
-
|
|
11
|
-
function createDivWithP(text: string): HTMLDivElement {
|
|
12
|
-
const div = document.createElement('div');
|
|
13
|
-
div.style.paddingLeft = '25px';
|
|
14
|
-
const p = document.createElement('p');
|
|
15
|
-
p.style.marginLeft = '-25px';
|
|
16
|
-
p.textContent = text;
|
|
17
|
-
div.appendChild(p);
|
|
18
|
-
document.body.appendChild(div);
|
|
19
|
-
return div;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
{
|
|
23
|
-
const simpleMenuHTML = createDivWithP('Simple item select with lit-html');
|
|
24
|
-
Lit.render(
|
|
25
|
-
html`<select id="menu" aria-label="Select an option"
|
|
26
|
-
@change=${onChange}>
|
|
27
|
-
<option hidden>Select an option</option>
|
|
28
|
-
<option id="option-1" jslog=${VisualLogging.item('option-1').track({
|
|
29
|
-
click: true
|
|
30
|
-
})}
|
|
31
|
-
value="Option1">Option 1</option>
|
|
32
|
-
<option jslog=${VisualLogging.item('option-2').track({
|
|
33
|
-
click: true
|
|
34
|
-
})}
|
|
35
|
-
value="Option2">Option 2</option>
|
|
36
|
-
<option disabled jslog=${VisualLogging.item('option-3').track({
|
|
37
|
-
click: true
|
|
38
|
-
})}
|
|
39
|
-
value="Option3">Option 3</option>
|
|
40
|
-
</select>`,
|
|
41
|
-
simpleMenuHTML);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
{
|
|
45
|
-
const groupMenuHTML = createDivWithP('Select with groups with lit-html');
|
|
46
|
-
Lit.render(
|
|
47
|
-
html`<select aria-label="Select an option"
|
|
48
|
-
@change=${onChange}>
|
|
49
|
-
<optgroup label="Group 1">
|
|
50
|
-
<option jslog=${VisualLogging.item('option-1').track({
|
|
51
|
-
click: true
|
|
52
|
-
})}
|
|
53
|
-
value="Option1">Option 1</option>
|
|
54
|
-
</optgroup>
|
|
55
|
-
<optgroup label="Group 2">
|
|
56
|
-
<option jslog=${VisualLogging.item('option-2').track({
|
|
57
|
-
click: true
|
|
58
|
-
})}
|
|
59
|
-
value="Option2">Option 2</option>
|
|
60
|
-
<option jslog=${VisualLogging.item('option-3').track({
|
|
61
|
-
click: true
|
|
62
|
-
})}
|
|
63
|
-
value="Option3">Option 3</option>
|
|
64
|
-
</optgroup>
|
|
65
|
-
</select>`,
|
|
66
|
-
groupMenuHTML);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
{
|
|
70
|
-
const simpleMenuImperative = createDivWithP('Simple item select with imperative API');
|
|
71
|
-
const simpleSelect = UI.UIUtils.createSelect('Select an option', [
|
|
72
|
-
'Option 1',
|
|
73
|
-
'Option 2',
|
|
74
|
-
'Option 3',
|
|
75
|
-
]);
|
|
76
|
-
simpleSelect.addEventListener('change', event => onChange(event));
|
|
77
|
-
simpleMenuImperative.appendChild(simpleSelect);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
{
|
|
81
|
-
const groupMenuImperative = createDivWithP('Select with groups with imperative API');
|
|
82
|
-
const group1 = new Map<string, string[]>([['Group 1', ['Option 1']]]);
|
|
83
|
-
const group2 = new Map<string, string[]>([['Group 2', ['Option 2', 'Option 3']]]);
|
|
84
|
-
const groupSelect = UI.UIUtils.createSelect('Select an option', [group1, group2]);
|
|
85
|
-
groupSelect.addEventListener('change', event => onChange(event));
|
|
86
|
-
groupMenuImperative.appendChild(groupSelect);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
function onChange(event: Event): void {
|
|
90
|
-
const menu = event.target;
|
|
91
|
-
if (menu instanceof HTMLSelectElement) {
|
|
92
|
-
// eslint-disable-next-line no-console
|
|
93
|
-
console.log('Option selected: ', menu.value);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
<!--
|
|
2
|
-
Copyright 2023 The Chromium Authors
|
|
3
|
-
Use of this source code is governed by a BSD-style license that can be
|
|
4
|
-
found in the LICENSE file.
|
|
5
|
-
-->
|
|
6
|
-
<!DOCTYPE html>
|
|
7
|
-
<html>
|
|
8
|
-
|
|
9
|
-
<head>
|
|
10
|
-
<meta charset="UTF-8" />
|
|
11
|
-
<meta name="viewport" content="width=device-width" />
|
|
12
|
-
<title>Select menu example</title>
|
|
13
|
-
<style>
|
|
14
|
-
#root {
|
|
15
|
-
padding: 20px;
|
|
16
|
-
width: 80%;
|
|
17
|
-
margin: 0 auto;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
#width-150 {
|
|
21
|
-
width: 150px;
|
|
22
|
-
}
|
|
23
|
-
#width-400 {
|
|
24
|
-
width: 400px;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
devtools-select-menu {
|
|
28
|
-
display: block;
|
|
29
|
-
margin: 15px;
|
|
30
|
-
}
|
|
31
|
-
</style>
|
|
32
|
-
</head>
|
|
33
|
-
|
|
34
|
-
<body>
|
|
35
|
-
<div id="root"></div>
|
|
36
|
-
<script src="./wide-option.js" type="module"></script>
|
|
37
|
-
</body>
|
|
38
|
-
</html>
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
// Copyright 2023 The Chromium Authors
|
|
2
|
-
// Use of this source code is governed by a BSD-style license that can be
|
|
3
|
-
// found in the LICENSE file.
|
|
4
|
-
|
|
5
|
-
import * as Menus from '../../../../ui/components/menus/menus.js';
|
|
6
|
-
|
|
7
|
-
const root = document.getElementById('root');
|
|
8
|
-
function makeMenu(id: string): void {
|
|
9
|
-
const items: Menus.Menu.MenuItem[] = [];
|
|
10
|
-
const menu = new Menus.SelectMenu.SelectMenu();
|
|
11
|
-
|
|
12
|
-
const options = [
|
|
13
|
-
{text: 'A short option', value: 'option-1'},
|
|
14
|
-
{text: 'A very long option that has a lot of text', value: 'option-2'},
|
|
15
|
-
{text: 'An average sized option', value: 'option-3'},
|
|
16
|
-
];
|
|
17
|
-
|
|
18
|
-
options.forEach(opt => {
|
|
19
|
-
const item = new Menus.Menu.MenuItem();
|
|
20
|
-
item.value = opt.value;
|
|
21
|
-
item.textContent = opt.text;
|
|
22
|
-
menu.appendChild(item);
|
|
23
|
-
items.push(item);
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
menu.addEventListener('selectmenuselected', (event: Menus.SelectMenu.SelectMenuItemSelectedEvent) => {
|
|
27
|
-
items.forEach(item => {
|
|
28
|
-
item.selected = item.value === event.itemValue;
|
|
29
|
-
});
|
|
30
|
-
const selectedOption = options.find(option => option.value === event.itemValue);
|
|
31
|
-
menu.buttonTitle = selectedOption?.text || '';
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
items[1].selected = true;
|
|
35
|
-
menu.buttonTitle = options[1].text;
|
|
36
|
-
menu.showArrow = true;
|
|
37
|
-
menu.id = id;
|
|
38
|
-
|
|
39
|
-
root?.appendChild(menu);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
makeMenu('width-150');
|
|
43
|
-
makeMenu('width-400');
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
<!--
|
|
2
|
-
Copyright 2025 The Chromium Authors
|
|
3
|
-
Use of this source code is governed by a BSD-style license that can be
|
|
4
|
-
found in the LICENSE file.
|
|
5
|
-
-->
|
|
6
|
-
<!DOCTYPE html>
|
|
7
|
-
<html>
|
|
8
|
-
<head>
|
|
9
|
-
<meta charset="UTF-8" />
|
|
10
|
-
<meta name="viewport" content="width=device-width" />
|
|
11
|
-
<title>Spinner example</title>
|
|
12
|
-
</head>
|
|
13
|
-
<body>
|
|
14
|
-
<div id="container"></div>
|
|
15
|
-
<script type="module" src="./basic.js"></script>
|
|
16
|
-
</body>
|
|
17
|
-
</html>
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
// Copyright 2025 The Chromium Authors
|
|
3
|
-
// Use of this source code is governed by a BSD-style license that can be
|
|
4
|
-
// found in the LICENSE file.
|
|
5
|
-
|
|
6
|
-
import '../../spinners/spinners.js';
|
|
7
|
-
|
|
8
|
-
import * as FrontendHelpers from '../../../../testing/EnvironmentHelpers.js';
|
|
9
|
-
import * as Lit from '../../../lit/lit.js';
|
|
10
|
-
import * as ComponentHelpers from '../../helpers/helpers.js';
|
|
11
|
-
|
|
12
|
-
const {html} = Lit;
|
|
13
|
-
|
|
14
|
-
await FrontendHelpers.initializeGlobalVars();
|
|
15
|
-
await ComponentHelpers.ComponentServerSetup.setup();
|
|
16
|
-
const container = document.getElementById('container');
|
|
17
|
-
|
|
18
|
-
if (!container) {
|
|
19
|
-
throw new Error('No component container found.');
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
Lit.render(html`<devtools-spinner></devtools-spinner>`, container);
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
<!--
|
|
2
|
-
Copyright 2025 The Chromium Authors
|
|
3
|
-
Use of this source code is governed by a BSD-style license that can be
|
|
4
|
-
found in the LICENSE file.
|
|
5
|
-
-->
|
|
6
|
-
<!DOCTYPE html>
|
|
7
|
-
<html>
|
|
8
|
-
<head>
|
|
9
|
-
<meta charset="UTF-8" />
|
|
10
|
-
<meta name="viewport" content="width=device-width" />
|
|
11
|
-
<title>Tooltip example</title>
|
|
12
|
-
</head>
|
|
13
|
-
<body>
|
|
14
|
-
|
|
15
|
-
<div id="container">
|
|
16
|
-
</div>
|
|
17
|
-
|
|
18
|
-
<script type="module" src="./basic.js"></script>
|
|
19
|
-
</body>
|
|
20
|
-
</html>
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
// Copyright 2025 The Chromium Authors
|
|
2
|
-
// Use of this source code is governed by a BSD-style license that can be
|
|
3
|
-
// found in the LICENSE file.
|
|
4
|
-
|
|
5
|
-
import * as FrontendHelpers from '../../../../testing/EnvironmentHelpers.js';
|
|
6
|
-
import * as Lit from '../../../lit/lit.js';
|
|
7
|
-
import * as ComponentHelpers from '../../helpers/helpers.js';
|
|
8
|
-
import {Tooltip} from '../../tooltips/Tooltip.js';
|
|
9
|
-
|
|
10
|
-
const {html} = Lit;
|
|
11
|
-
|
|
12
|
-
await FrontendHelpers.initializeGlobalVars();
|
|
13
|
-
await ComponentHelpers.ComponentServerSetup.setup();
|
|
14
|
-
const container = document.getElementById('container');
|
|
15
|
-
if (!container) {
|
|
16
|
-
throw new Error('No component container found.');
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
Lit.render(
|
|
20
|
-
html`
|
|
21
|
-
<div style="position: relative; z-index: 0;">
|
|
22
|
-
<button aria-describedby="simple-tooltip" style="position: absolute; left: 16px; top: 16px;">
|
|
23
|
-
Simple
|
|
24
|
-
</button>
|
|
25
|
-
<devtools-tooltip id="simple-tooltip">Simple content</devtools-tooltip>
|
|
26
|
-
</div>
|
|
27
|
-
<div style="position: relative; z-index: 0;">
|
|
28
|
-
<span
|
|
29
|
-
aria-details="rich-tooltip"
|
|
30
|
-
style="position: absolute; left: 16px; top: 116px; border: 1px solid black;"
|
|
31
|
-
>
|
|
32
|
-
Non-button click trigger
|
|
33
|
-
</span>
|
|
34
|
-
<devtools-tooltip id="rich-tooltip" variant="rich" trigger="click">
|
|
35
|
-
<p>Rich tooltip</p>
|
|
36
|
-
<button>Action</button>
|
|
37
|
-
</devtools-tooltip>
|
|
38
|
-
</div>
|
|
39
|
-
<div>
|
|
40
|
-
<button
|
|
41
|
-
id="removable"
|
|
42
|
-
@click=${() => document.getElementById('removable')?.remove()}
|
|
43
|
-
class="anchor"
|
|
44
|
-
aria-details="programatic"
|
|
45
|
-
style="position: absolute; left: 16px; top: 216px;"
|
|
46
|
-
>
|
|
47
|
-
Click to remove anchor
|
|
48
|
-
</button>
|
|
49
|
-
</div>
|
|
50
|
-
`,
|
|
51
|
-
container);
|
|
52
|
-
|
|
53
|
-
const anchor = container.querySelector('.anchor') as HTMLElement;
|
|
54
|
-
const programmaticTooltip = new Tooltip({id: 'programatic', variant: 'rich', anchor});
|
|
55
|
-
programmaticTooltip.append('Text content');
|
|
56
|
-
anchor.insertAdjacentElement('afterend', programmaticTooltip);
|
|
57
|
-
|
|
58
|
-
// Make the buttons draggable, so that we can experiment with the position of the tooltip.
|
|
59
|
-
container.querySelectorAll('button,span').forEach(anchor => draggable(anchor as HTMLElement));
|
|
60
|
-
function draggable(element: HTMLElement|null): void {
|
|
61
|
-
if (!element) {
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
element.addEventListener('mousedown', event => {
|
|
65
|
-
const target = event.target as HTMLElement;
|
|
66
|
-
const offsetX = event.clientX - target.getBoundingClientRect().left;
|
|
67
|
-
const offsetY = event.clientY - target.getBoundingClientRect().top;
|
|
68
|
-
|
|
69
|
-
function onMouseMove(event: MouseEvent) {
|
|
70
|
-
target.style.left = `${event.clientX - offsetX}px`;
|
|
71
|
-
target.style.top = `${event.clientY - offsetY}px`;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function onMouseUp() {
|
|
75
|
-
document.removeEventListener('mousemove', onMouseMove);
|
|
76
|
-
document.removeEventListener('mouseup', onMouseUp);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
document.addEventListener('mousemove', onMouseMove);
|
|
80
|
-
document.addEventListener('mouseup', onMouseUp);
|
|
81
|
-
});
|
|
82
|
-
}
|
|
@@ -1,254 +0,0 @@
|
|
|
1
|
-
// Copyright 2014 The Chromium Authors
|
|
2
|
-
// Use of this source code is governed by a BSD-style license that can be
|
|
3
|
-
// found in the LICENSE file.
|
|
4
|
-
|
|
5
|
-
/* eslint-disable @devtools/no-imperative-dom-api */
|
|
6
|
-
|
|
7
|
-
import * as Common from '../../core/common/common.js';
|
|
8
|
-
import * as Host from '../../core/host/host.js';
|
|
9
|
-
import * as i18n from '../../core/i18n/i18n.js';
|
|
10
|
-
import * as Platform from '../../core/platform/platform.js';
|
|
11
|
-
import * as Settings from '../components/settings/settings.js';
|
|
12
|
-
import {Directives} from '../lit/lit.js';
|
|
13
|
-
import * as VisualLogging from '../visual_logging/visual_logging.js';
|
|
14
|
-
|
|
15
|
-
import * as ARIAUtils from './ARIAUtils.js';
|
|
16
|
-
import {InspectorView} from './InspectorView.js';
|
|
17
|
-
import {Tooltip} from './Tooltip.js';
|
|
18
|
-
import {bindInput, CheckboxLabel, createOption} from './UIUtils.js';
|
|
19
|
-
|
|
20
|
-
const UIStrings = {
|
|
21
|
-
/**
|
|
22
|
-
* @description Note when a setting change will require the user to reload DevTools
|
|
23
|
-
*/
|
|
24
|
-
srequiresReload: '*Requires reload',
|
|
25
|
-
/**
|
|
26
|
-
* @description Message to display if a setting change requires a reload of DevTools
|
|
27
|
-
*/
|
|
28
|
-
oneOrMoreSettingsHaveChanged: 'One or more settings have changed which requires a reload to take effect',
|
|
29
|
-
} as const;
|
|
30
|
-
const str_ = i18n.i18n.registerUIStrings('ui/legacy/SettingsUI.ts', UIStrings);
|
|
31
|
-
const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
|
|
32
|
-
|
|
33
|
-
export function createSettingCheckbox(
|
|
34
|
-
name: Common.UIString.LocalizedString, setting: Common.Settings.Setting<boolean>, tooltip?: string): CheckboxLabel {
|
|
35
|
-
const label = CheckboxLabel.create(name, undefined, undefined, setting.name);
|
|
36
|
-
label.name = name;
|
|
37
|
-
bindCheckbox(label, setting);
|
|
38
|
-
if (tooltip) {
|
|
39
|
-
Tooltip.install(label, tooltip);
|
|
40
|
-
}
|
|
41
|
-
return label;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const createSettingSelect = function(
|
|
45
|
-
name: string, options: Common.Settings.SimpleSettingOption[], requiresReload: boolean|null,
|
|
46
|
-
setting: Common.Settings.Setting<unknown>, subtitle?: string): HTMLElement {
|
|
47
|
-
const container = document.createElement('div');
|
|
48
|
-
const settingSelectElement = container.createChild('p');
|
|
49
|
-
settingSelectElement.classList.add('settings-select');
|
|
50
|
-
const label = settingSelectElement.createChild('label');
|
|
51
|
-
const select = settingSelectElement.createChild('select');
|
|
52
|
-
label.textContent = name;
|
|
53
|
-
if (subtitle) {
|
|
54
|
-
container.classList.add('chrome-select-label');
|
|
55
|
-
label.createChild('p').textContent = subtitle;
|
|
56
|
-
}
|
|
57
|
-
select.setAttribute('jslog', `${VisualLogging.dropDown().track({change: true}).context(setting.name)}`);
|
|
58
|
-
ARIAUtils.bindLabelToControl(label, select);
|
|
59
|
-
|
|
60
|
-
for (const option of options) {
|
|
61
|
-
if (option.text && typeof option.value === 'string') {
|
|
62
|
-
select.add(createOption(option.text, option.value, Platform.StringUtilities.toKebabCase(option.value)));
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
let reloadWarning: HTMLElement|(Element | null) = (null as Element | null);
|
|
67
|
-
if (requiresReload) {
|
|
68
|
-
reloadWarning = container.createChild('p', 'reload-warning hidden');
|
|
69
|
-
reloadWarning.textContent = i18nString(UIStrings.srequiresReload);
|
|
70
|
-
ARIAUtils.markAsAlert(reloadWarning);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const {deprecation} = setting;
|
|
74
|
-
if (deprecation) {
|
|
75
|
-
const warning = new Settings.SettingDeprecationWarning.SettingDeprecationWarning();
|
|
76
|
-
warning.data = deprecation;
|
|
77
|
-
label.appendChild(warning);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
setting.addChangeListener(settingChanged);
|
|
81
|
-
settingChanged();
|
|
82
|
-
select.addEventListener('change', selectChanged, false);
|
|
83
|
-
return container;
|
|
84
|
-
|
|
85
|
-
function settingChanged(): void {
|
|
86
|
-
const newValue = setting.get();
|
|
87
|
-
for (let i = 0; i < options.length; i++) {
|
|
88
|
-
if (options[i].value === newValue) {
|
|
89
|
-
select.selectedIndex = i;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
select.disabled = setting.disabled();
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
function selectChanged(): void {
|
|
96
|
-
// Don't use event.target.value to avoid conversion of the value to string.
|
|
97
|
-
setting.set(options[select.selectedIndex].value);
|
|
98
|
-
if (reloadWarning) {
|
|
99
|
-
reloadWarning.classList.remove('hidden');
|
|
100
|
-
InspectorView.instance().displayReloadRequiredWarning(i18nString(UIStrings.oneOrMoreSettingsHaveChanged));
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
export const bindToSetting =
|
|
106
|
-
(settingOrName: string|Common.Settings.Setting<boolean|string>|Common.Settings.RegExpSetting,
|
|
107
|
-
stringValidator?: (newSettingValue: string) => boolean): ReturnType<typeof Directives.ref> => {
|
|
108
|
-
const setting = typeof settingOrName === 'string' ?
|
|
109
|
-
Common.Settings.Settings.instance().moduleSetting(settingOrName) :
|
|
110
|
-
settingOrName;
|
|
111
|
-
|
|
112
|
-
// We can't use `setValue` as the change listener directly, otherwise we won't
|
|
113
|
-
// be able to remove it again.
|
|
114
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
115
|
-
let setValue: (value: any) => void;
|
|
116
|
-
function settingChanged(): void {
|
|
117
|
-
setValue(setting.get());
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
if (setting.type() === Common.Settings.SettingType.BOOLEAN || typeof setting.defaultValue === 'boolean') {
|
|
121
|
-
return Directives.ref(e => {
|
|
122
|
-
if (e === undefined) {
|
|
123
|
-
setting.removeChangeListener(settingChanged);
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
setting.addChangeListener(settingChanged);
|
|
128
|
-
setValue =
|
|
129
|
-
bindCheckboxImpl(e as CheckboxLabel, (setting as Common.Settings.Setting<boolean>).set.bind(setting));
|
|
130
|
-
setValue(setting.get());
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
if (setting.type() === Common.Settings.SettingType.REGEX || setting instanceof Common.Settings.RegExpSetting) {
|
|
135
|
-
return Directives.ref(e => {
|
|
136
|
-
if (e === undefined) {
|
|
137
|
-
setting.removeChangeListener(settingChanged);
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
setting.addChangeListener(settingChanged);
|
|
142
|
-
setValue = bindInput(e as HTMLInputElement, setting.set.bind(setting), (value: string) => {
|
|
143
|
-
try {
|
|
144
|
-
new RegExp(value);
|
|
145
|
-
return true;
|
|
146
|
-
} catch {
|
|
147
|
-
return false;
|
|
148
|
-
}
|
|
149
|
-
}, /* numeric */ false);
|
|
150
|
-
setValue(setting.get());
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
if (typeof setting.defaultValue === 'string') {
|
|
155
|
-
return Directives.ref(e => {
|
|
156
|
-
if (e === undefined) {
|
|
157
|
-
setting.removeChangeListener(settingChanged);
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
setting.addChangeListener(settingChanged);
|
|
162
|
-
setValue = bindInput(
|
|
163
|
-
e as HTMLInputElement, setting.set.bind(setting), stringValidator ?? (() => true), /* numeric */ false);
|
|
164
|
-
setValue(setting.get());
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
throw new Error(`Cannot infer type for setting '${setting.name}'`);
|
|
169
|
-
};
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* @deprecated Prefer {@link bindToSetting} as this function leaks the checkbox via the setting listener.
|
|
173
|
-
*/
|
|
174
|
-
export const bindCheckbox = function(
|
|
175
|
-
input: CheckboxLabel, setting: Common.Settings.Setting<boolean>, metric?: UserMetricOptions): void {
|
|
176
|
-
const setValue = bindCheckboxImpl(input, setting.set.bind(setting), metric);
|
|
177
|
-
setting.addChangeListener(event => setValue(event.data));
|
|
178
|
-
setValue(setting.get());
|
|
179
|
-
};
|
|
180
|
-
|
|
181
|
-
const bindCheckboxImpl = function(
|
|
182
|
-
input: CheckboxLabel, apply: (value: boolean) => void, metric?: UserMetricOptions): (value: boolean) => void {
|
|
183
|
-
input.addEventListener('change', onInputChanged, false);
|
|
184
|
-
|
|
185
|
-
function onInputChanged(): void {
|
|
186
|
-
apply(input.checked);
|
|
187
|
-
|
|
188
|
-
if (input.checked && metric?.enable) {
|
|
189
|
-
Host.userMetrics.actionTaken(metric.enable);
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
if (!input.checked && metric?.disable) {
|
|
193
|
-
Host.userMetrics.actionTaken(metric.disable);
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
if (metric?.toggle) {
|
|
197
|
-
Host.userMetrics.actionTaken(metric.toggle);
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
return function setValue(value: boolean): void {
|
|
202
|
-
if (value !== input.checked) {
|
|
203
|
-
input.checked = value;
|
|
204
|
-
}
|
|
205
|
-
};
|
|
206
|
-
};
|
|
207
|
-
|
|
208
|
-
export const createCustomSetting = function(name: string, element: Element): Element {
|
|
209
|
-
const p = document.createElement('p');
|
|
210
|
-
p.classList.add('settings-select');
|
|
211
|
-
const label = p.createChild('label');
|
|
212
|
-
label.textContent = name;
|
|
213
|
-
ARIAUtils.bindLabelToControl(label, element);
|
|
214
|
-
p.appendChild(element);
|
|
215
|
-
return p;
|
|
216
|
-
};
|
|
217
|
-
|
|
218
|
-
export const createControlForSetting = function(
|
|
219
|
-
setting: Common.Settings.Setting<unknown>, subtitle?: string): HTMLElement|null {
|
|
220
|
-
const uiTitle = setting.title();
|
|
221
|
-
switch (setting.type()) {
|
|
222
|
-
case Common.Settings.SettingType.BOOLEAN: {
|
|
223
|
-
const component = new Settings.SettingCheckbox.SettingCheckbox();
|
|
224
|
-
component.data = {
|
|
225
|
-
setting: setting as Common.Settings.Setting<boolean>,
|
|
226
|
-
};
|
|
227
|
-
component.onchange = () => {
|
|
228
|
-
if (setting.reloadRequired()) {
|
|
229
|
-
InspectorView.instance().displayReloadRequiredWarning(i18nString(UIStrings.oneOrMoreSettingsHaveChanged));
|
|
230
|
-
}
|
|
231
|
-
};
|
|
232
|
-
return component;
|
|
233
|
-
}
|
|
234
|
-
case Common.Settings.SettingType.ENUM:
|
|
235
|
-
return createSettingSelect(uiTitle, setting.options(), setting.reloadRequired(), setting, subtitle);
|
|
236
|
-
default:
|
|
237
|
-
console.error('Invalid setting type: ' + setting.type());
|
|
238
|
-
return null;
|
|
239
|
-
}
|
|
240
|
-
};
|
|
241
|
-
|
|
242
|
-
export interface SettingUI {
|
|
243
|
-
settingElement(): Element|null;
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
/**
|
|
247
|
-
* Track toggle action as a whole or
|
|
248
|
-
* track on and off action separately.
|
|
249
|
-
*/
|
|
250
|
-
export interface UserMetricOptions {
|
|
251
|
-
toggle?: Host.UserMetrics.Action;
|
|
252
|
-
enable?: Host.UserMetrics.Action;
|
|
253
|
-
disable?: Host.UserMetrics.Action;
|
|
254
|
-
}
|