monaco-editor-core 0.55.0-dev-20251019 → 0.55.0-dev-20251021
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/esm/nls.messages.cs.js +1 -1
- package/esm/nls.messages.de.js +1 -1
- package/esm/nls.messages.es.js +1 -1
- package/esm/nls.messages.fr.js +1 -1
- package/esm/nls.messages.it.js +1 -1
- package/esm/nls.messages.ja.js +1 -1
- package/esm/nls.messages.ko.js +1 -1
- package/esm/nls.messages.pl.js +1 -1
- package/esm/nls.messages.pt-br.js +1 -1
- package/esm/nls.messages.ru.js +1 -1
- package/esm/nls.messages.tr.js +1 -1
- package/esm/nls.messages.zh-cn.js +1 -1
- package/esm/nls.messages.zh-tw.js +1 -1
- package/esm/vs/base/browser/ui/findinput/findInput.js +4 -5
- package/esm/vs/base/browser/ui/findinput/findInput.js.map +1 -1
- package/esm/vs/base/browser/ui/findinput/findInputToggles.js +3 -4
- package/esm/vs/base/browser/ui/findinput/findInputToggles.js.map +1 -1
- package/esm/vs/base/browser/ui/findinput/replaceInput.js +2 -2
- package/esm/vs/base/browser/ui/findinput/replaceInput.js.map +1 -1
- package/esm/vs/base/browser/ui/hover/hover.js.map +1 -1
- package/esm/vs/base/browser/ui/toggle/toggle.js +9 -6
- package/esm/vs/base/browser/ui/toggle/toggle.js.map +1 -1
- package/esm/vs/base/browser/ui/tree/abstractTree.js +7 -6
- package/esm/vs/base/browser/ui/tree/abstractTree.js.map +1 -1
- package/esm/vs/base/common/actions.js +5 -0
- package/esm/vs/base/common/actions.js.map +1 -1
- package/esm/vs/base/common/async.js +5 -5
- package/esm/vs/base/common/async.js.map +1 -1
- package/esm/vs/editor/browser/controller/editContext/native/nativeEditContext.js +20 -12
- package/esm/vs/editor/browser/controller/editContext/native/nativeEditContext.js.map +1 -1
- package/esm/vs/editor/browser/services/hoverService/hoverWidget.js +15 -0
- package/esm/vs/editor/browser/services/hoverService/hoverWidget.js.map +1 -1
- package/esm/vs/editor/browser/widget/diffEditor/diffEditorWidget.js +6 -0
- package/esm/vs/editor/browser/widget/diffEditor/diffEditorWidget.js.map +1 -1
- package/esm/vs/editor/browser/widget/multiDiffEditor/diffEditorItemTemplate.js +1 -0
- package/esm/vs/editor/browser/widget/multiDiffEditor/diffEditorItemTemplate.js.map +1 -1
- package/esm/vs/editor/contrib/find/browser/findOptionsWidget.js +4 -5
- package/esm/vs/editor/contrib/find/browser/findOptionsWidget.js.map +1 -1
- package/esm/vs/editor/contrib/find/browser/findWidget.js +12 -12
- package/esm/vs/editor/contrib/find/browser/findWidget.js.map +1 -1
- package/esm/vs/editor/contrib/hover/browser/glyphHoverWidget.js +22 -2
- package/esm/vs/editor/contrib/hover/browser/glyphHoverWidget.js.map +1 -1
- package/esm/vs/editor/contrib/inlineCompletions/browser/model/inlineCompletionsSource.js +0 -1
- package/esm/vs/editor/contrib/inlineCompletions/browser/model/inlineCompletionsSource.js.map +1 -1
- package/esm/vs/editor/contrib/inlineCompletions/browser/telemetry.js.map +1 -1
- package/esm/vs/editor/contrib/rename/browser/renameWidget.js +1 -4
- package/esm/vs/editor/contrib/rename/browser/renameWidget.js.map +1 -1
- package/package.json +2 -2
- package/version.txt +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["file:///mnt/vss/_work/1/s/dependencies/vscode/out-editor-src/vs/base/browser/ui/hover/hover.ts","vs/base/browser/ui/hover/hover.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAoYhG,MAAM,UAAU,mCAAmC,CAAC,GAAY;IAC/D,MAAM,SAAS,GAAG,GAAyC,CAAC;IAC5D,OAAO,OAAO,SAAS,KAAK,QAAQ,IAAI,UAAU,IAAI,SAAS,IAAI,8BAA8B,IAAI,SAAS,CAAC;AAChH,CAAC;AA8BD,2BAA2B","file":"hover.js","sourceRoot":"file:///mnt/vss/_work/1/s/dependencies/vscode/out-editor-src","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\nimport { IHoverDelegate } from './hoverDelegate.js';\nimport { HoverPosition } from './hoverWidget.js';\nimport { CancellationToken } from '../../../common/cancellation.js';\nimport { IMarkdownString } from '../../../common/htmlContent.js';\nimport { IDisposable } from '../../../common/lifecycle.js';\n\n/**\n * Enables the convenient display of rich markdown-based hovers in the workbench.\n */\nexport interface IHoverDelegate2 {\n\t/**\n\t * Shows a hover after a delay, or immediately if the {@link groupId} matches the currently\n\t * shown hover.\n\t *\n\t * Use this method when you want to:\n\t *\n\t * - Control showing the hover yourself.\n\t * - Show the hover after the standard delay.\n\t *\n\t * @param options The options of the hover.\n\t * @param groupId The group ID of the hover. If the group ID is the same as the currently shown\n\t * hover, the hover will be shown immediately, skipping the delay.\n\t */\n\tshowDelayedHover(\n\t\toptions: IHoverOptions,\n\t\tlifecycleOptions: Pick<IHoverLifecycleOptions, 'groupId'>,\n\t): IHoverWidget | undefined;\n\n\t/**\n\t * A simple wrapper around showDelayedHover that includes listening to events on the\n\t * {@link target} element that shows the hover.\n\t *\n\t * Use this method when you want to:\n\t *\n\t * - Let the hover service handle showing the hover.\n\t * - Show the hover after the standard delay.\n\t * - Want the hover positioned beside the {@link target} element.\n\t *\n\t * @param target The target element to listener for mouseover events on.\n\t * @param hoverOptions The options of the hover.\n\t * @param lifecycleOptions The options of the hover's lifecycle.\n\t */\n\tsetupDelayedHover(\n\t\ttarget: HTMLElement,\n\t\thoverOptions: (() => IDelayedHoverOptions) | IDelayedHoverOptions,\n\t\tlifecycleOptions?: IHoverLifecycleOptions,\n\t): IDisposable;\n\n\t/**\n\t * A simple wrapper around showDelayedHover that includes listening to events on the\n\t * {@link target} element that shows the hover. This differs from {@link setupDelayedHover} in\n\t * that the hover will be shown at the mouse position instead of the\n\t * {@link target target} element's position, ignoring any\n\t * {@link IHoverOptions.position position options} that are passed in.\n\t *\n\t * Use this method when you want to:\n\t *\n\t * - Let the hover service handle showing the hover.\n\t * - Show the hover after the standard delay.\n\t * - Want the hover positioned beside the mouse.\n\t *\n\t * @param target The target element to listener for mouseover events on.\n\t * @param hoverOptions The options of the hover.\n\t * @param lifecycleOptions The options of the hover's lifecycle.\n\t */\n\tsetupDelayedHoverAtMouse(\n\t\ttarget: HTMLElement,\n\t\thoverOptions: (() => IDelayedHoverAtMouseOptions) | IDelayedHoverAtMouseOptions,\n\t\tlifecycleOptions?: IHoverLifecycleOptions,\n\t): IDisposable;\n\n\t/**\n\t * Shows a hover immediately, provided a hover with the same {@link options} object is not\n\t * already visible.\n\t *\n\t * Use this method when you want to:\n\t *\n\t * - Control showing the hover yourself.\n\t * - Show the hover immediately.\n\t *\n\t * @param options A set of options defining the characteristics of the hover.\n\t * @param focus Whether to focus the hover (useful for keyboard accessibility).\n\t *\n\t * @example A simple usage with a single element target.\n\t *\n\t * ```typescript\n\t * showInstantHover({\n\t * text: new MarkdownString('Hello world'),\n\t * target: someElement\n\t * });\n\t * ```\n\t */\n\tshowInstantHover(\n\t\toptions: IHoverOptions,\n\t\tfocus?: boolean\n\t): IHoverWidget | undefined;\n\n\t/**\n\t * Hides the hover if it was visible. This call will be ignored if the hover is currently\n\t * \"locked\" via the alt/option key unless `force` is set.\n\t */\n\thideHover(force?: boolean): void;\n\n\t/**\n\t * This should only be used until we have the ability to show multiple context views\n\t * simultaneously. #188822\n\t */\n\tshowAndFocusLastHover(): void;\n\n\t/**\n\t * Sets up a managed hover for the given element. A managed hover will set up listeners for\n\t * mouse events, show the hover after a delay and provide hooks to easily update the content.\n\t *\n\t * This should be used over {@link showInstantHover} when fine-grained control is not needed. The\n\t * managed hover also does not scale well, consider using {@link showInstantHover} when showing hovers\n\t * for many elements.\n\t *\n\t * @param hoverDelegate The hover delegate containing hooks and configuration for the hover.\n\t * @param targetElement The target element to show the hover for.\n\t * @param content The content of the hover or a factory that creates it at the time it's shown.\n\t * @param options Additional options for the managed hover.\n\t *\n\t * @deprecated Use {@link setupDelayedHover} or {@link setupDelayedHoverAtMouse} instead where\n\t * possible.\n\t */\n\tsetupManagedHover(hoverDelegate: IHoverDelegate, targetElement: HTMLElement, content: IManagedHoverContentOrFactory, options?: IManagedHoverOptions): IManagedHover;\n\n\t/**\n\t * Shows the hover for the given element if one has been setup.\n\t *\n\t * @param targetElement The target element of the hover, as set up in {@link setupManagedHover}.\n\t *\n\t * @deprecated Use {@link setupDelayedHover} or {@link setupDelayedHoverAtMouse} instead where\n\t * possible.\n\t */\n\tshowManagedHover(targetElement: HTMLElement): void;\n}\n\nexport interface IHoverWidget extends IDisposable {\n\t/**\n\t * Whether the hover widget has been disposed.\n\t */\n\treadonly isDisposed: boolean;\n}\n\nexport interface IHoverOptions {\n\t/**\n\t * The content to display in the primary section of the hover. The type of text determines the\n\t * default `hideOnHover` behavior.\n\t */\n\tcontent: IMarkdownString | string | HTMLElement;\n\n\t/**\n\t * The target for the hover. This determines the position of the hover and it will only be\n\t * hidden when the mouse leaves both the hover and the target. A HTMLElement can be used for\n\t * simple cases and a IHoverTarget for more complex cases where multiple elements and/or a\n\t * dispose method is required.\n\t */\n\ttarget: IHoverTarget | HTMLElement;\n\n\t/*\n\t * The container to pass to {@link IContextViewProvider.showContextView} which renders the hover\n\t * in. This is particularly useful for more natural tab focusing behavior, where the hover is\n\t * created as the next tab index after the element being hovered and/or to workaround the\n\t * element's container hiding on `focusout`.\n\t */\n\tcontainer?: HTMLElement;\n\n\t/**\n\t * An ID to associate with the hover to be used as an equality check. Normally when calling\n\t * {@link IHoverService.showHover} the options object itself is used to determine if the hover\n\t * is the same one that is already showing, when this is set, the ID will be used instead.\n\t *\n\t * When `undefined`, this will default to a serialized version of {@link content}. In this case\n\t * it will remain `undefined` if {@link content} is a `HTMLElement`.\n\t */\n\tid?: string;\n\n\t/**\n\t * A set of actions for the hover's \"status bar\".\n\t */\n\tactions?: IHoverAction[];\n\n\t/**\n\t * An optional array of classes to add to the hover element.\n\t */\n\tadditionalClasses?: string[];\n\n\t/**\n\t * An optional link handler for markdown links, if this is not provided the IOpenerService will\n\t * be used to open the links using its default options.\n\t */\n\tlinkHandler?(url: string): void;\n\n\t/**\n\t * Whether to trap focus in the following ways:\n\t * - When the hover closes, focus goes to the element that had focus before the hover opened\n\t * - If there are elements in the hover to focus, focus stays inside of the hover when tabbing\n\t * Note that this is overridden to true when in screen reader optimized mode.\n\t */\n\ttrapFocus?: boolean;\n\n\t/**\n\t * Options that defines where the hover is positioned.\n\t */\n\tposition?: IHoverPositionOptions;\n\n\t/**\n\t * Options that defines how long the hover is shown and when it hides.\n\t */\n\tpersistence?: IHoverPersistenceOptions;\n\n\t/**\n\t * Options that define how the hover looks.\n\t */\n\tappearance?: IHoverAppearanceOptions;\n}\n\n// `target` is ignored for delayed hover methods as it's included in the method and added\n// automatically when the hover options get resolved.\nexport type IDelayedHoverOptions = Omit<IHoverOptions, 'target'>;\n\n// `position` is ignored for delayed at mouse hover methods as it's overwritten by the mouse event.\n// `showPointer` is always false when using mouse positioning\nexport type IDelayedHoverAtMouseOptions = Omit<IDelayedHoverOptions, 'position' | 'appearance'> & { appearance?: Omit<IHoverAppearanceOptions, 'showPointer'> };\n\nexport interface IHoverLifecycleOptions {\n\t/**\n\t * The group ID of the hover. If the group ID is the same as the currently shown hover, the\n\t * hover will be shown immediately, skipping the delay.\n\t *\n\t * @example Use a UUID to set a unique `groupId` for related hovers\n\t *\n\t * ```typescript\n\t * const groupId = generateUuid();\n\t * showDelayedHover({ content: 'Button 1', target: someElement1 }, { groupId });\n\t * showDelayedHover({ content: 'Button 2', target: someElement2 }, { groupId });\n\t * ```\n\t *\n\t * @example Use a feature-specific string to set a unqiue `groupId` for related hovers\n\t *\n\t * ```typescript\n\t * showDelayedHover({ content: 'Button 1', target: someElement1 }, { groupId: 'my-feature-items' });\n\t * showDelayedHover({ content: 'Button 2', target: someElement2 }, { groupId: 'my-feature-items' });\n\t * ```\n\t */\n\tgroupId?: string;\n\n\t/**\n\t * Whether to set up space and enter keyboard events for the hover, when these are pressed when\n\t * the hover's target is focused it will show and focus the hover.\n\t *\n\t * Typically this should _not_ be used when the space or enter events are already handled by\n\t * something else.\n\t */\n\tsetupKeyboardEvents?: boolean;\n}\n\nexport interface IHoverPositionOptions {\n\t/**\n\t * Position of the hover. The default is to show above the target. This option will be ignored\n\t * if there is not enough room to layout the hover in the specified position, unless the\n\t * forcePosition option is set.\n\t */\n\thoverPosition?: HoverPosition | MouseEvent;\n\n\t/**\n\t * Force the hover position, reducing the size of the hover instead of adjusting the hover\n\t * position.\n\t */\n\tforcePosition?: boolean;\n}\n\nexport interface IHoverPersistenceOptions {\n\t/**\n\t * Whether to hide the hover when the mouse leaves the `target` and enters the actual hover.\n\t * This is false by default when text is an `IMarkdownString` and true when `text` is a\n\t * `string`. Note that this will be ignored if any `actions` are provided as hovering is\n\t * required to make them accessible.\n\t *\n\t * In general hiding on hover is desired for:\n\t * - Regular text where selection is not important\n\t * - Markdown that contains no links where selection is not important\n\t */\n\thideOnHover?: boolean;\n\n\t/**\n\t * Whether to hide the hover when a key is pressed.\n\t */\n\thideOnKeyDown?: boolean;\n\n\t/**\n\t * Whether to make the hover sticky, this means it will not be hidden when the mouse leaves the\n\t * hover.\n\t */\n\tsticky?: boolean;\n}\n\nexport interface IHoverAppearanceOptions {\n\t/**\n\t * Whether to show the hover pointer, a little arrow that connects the target and the hover.\n\t */\n\tshowPointer?: boolean;\n\n\t/**\n\t * Whether to show a compact hover, reducing the font size and padding of the hover.\n\t */\n\tcompact?: boolean;\n\n\t/**\n\t * When {@link hideOnHover} is explicitly true or undefined and its auto value is detected to\n\t * hide, show a hint at the bottom of the hover explaining how to mouse over the widget. This\n\t * should be used in the cases where despite the hover having no interactive content, it's\n\t * likely the user may want to interact with it somehow.\n\t */\n\tshowHoverHint?: boolean;\n\n\t/**\n\t * Whether to skip the fade in animation, this should be used when hovering from one hover to\n\t * another in the same group so it looks like the hover is moving from one element to the other.\n\t */\n\tskipFadeInAnimation?: boolean;\n\n\t/**\n\t * The max height of the hover relative to the window height.\n\t * Accepted values: (0,1]\n\t * Default: 0.5\n\t */\n\tmaxHeightRatio?: number;\n}\n\nexport interface IHoverAction {\n\t/**\n\t * The label to use in the hover's status bar.\n\t */\n\tlabel: string;\n\n\t/**\n\t * The command ID of the action, this is used to resolve the keybinding to display after the\n\t * action label.\n\t */\n\tcommandId: string;\n\n\t/**\n\t * An optional class of an icon that will be displayed before the label.\n\t */\n\ticonClass?: string;\n\n\t/**\n\t * The callback to run the action.\n\t * @param target The action element that was activated.\n\t */\n\trun(target: HTMLElement): void;\n}\n\n/**\n * A target for a hover.\n */\nexport interface IHoverTarget extends Partial<IDisposable> {\n\t/**\n\t * A set of target elements used to position the hover. If multiple elements are used the hover\n\t * will try to not overlap any target element. An example use case for this is show a hover for\n\t * wrapped text.\n\t */\n\treadonly targetElements: readonly HTMLElement[];\n\n\t/**\n\t * An optional absolute x coordinate to position the hover with, for example to position the\n\t * hover using `MouseEvent.pageX`.\n\t */\n\treadonly x?: number;\n\n\t/**\n\t * An optional absolute y coordinate to position the hover with, for example to position the\n\t * hover using `MouseEvent.pageY`.\n\t */\n\treadonly y?: number;\n}\n\n// #region Managed hover\n\nexport interface IManagedHoverTooltipMarkdownString {\n\tmarkdown: IMarkdownString | string | undefined | ((token: CancellationToken) => Promise<IMarkdownString | string | undefined>);\n\tmarkdownNotSupportedFallback: string | undefined;\n}\n\nexport function isManagedHoverTooltipMarkdownString(obj: unknown): obj is IManagedHoverTooltipMarkdownString {\n\tconst candidate = obj as IManagedHoverTooltipMarkdownString;\n\treturn typeof candidate === 'object' && 'markdown' in candidate && 'markdownNotSupportedFallback' in candidate;\n}\n\nexport interface IManagedHoverTooltipHTMLElement {\n\telement: (token: CancellationToken) => HTMLElement | Promise<HTMLElement>;\n}\n\nexport type IManagedHoverContent = string | IManagedHoverTooltipMarkdownString | IManagedHoverTooltipHTMLElement | HTMLElement | undefined;\nexport type IManagedHoverContentOrFactory = IManagedHoverContent | (() => IManagedHoverContent);\n\nexport interface IManagedHoverOptions extends Pick<IHoverOptions, 'actions' | 'linkHandler' | 'trapFocus'> {\n\tappearance?: Pick<IHoverAppearanceOptions, 'showHoverHint'>;\n}\n\nexport interface IManagedHover extends IDisposable {\n\t/**\n\t * Allows to programmatically open the hover.\n\t */\n\tshow(focus?: boolean): void;\n\n\t/**\n\t * Allows to programmatically hide the hover.\n\t */\n\thide(): void;\n\n\t/**\n\t * Updates the contents of the hover.\n\t */\n\tupdate(tooltip: IManagedHoverContent, options?: IManagedHoverOptions): void;\n}\n\n// #endregion Managed hover\n","/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\nimport { IHoverDelegate } from './hoverDelegate.js';\nimport { HoverPosition } from './hoverWidget.js';\nimport { CancellationToken } from '../../../common/cancellation.js';\nimport { IMarkdownString } from '../../../common/htmlContent.js';\nimport { IDisposable } from '../../../common/lifecycle.js';\n\n/**\n * Enables the convenient display of rich markdown-based hovers in the workbench.\n */\nexport interface IHoverDelegate2 {\n\t/**\n\t * Shows a hover after a delay, or immediately if the {@link groupId} matches the currently\n\t * shown hover.\n\t *\n\t * Use this method when you want to:\n\t *\n\t * - Control showing the hover yourself.\n\t * - Show the hover after the standard delay.\n\t *\n\t * @param options The options of the hover.\n\t * @param groupId The group ID of the hover. If the group ID is the same as the currently shown\n\t * hover, the hover will be shown immediately, skipping the delay.\n\t */\n\tshowDelayedHover(\n\t\toptions: IHoverOptions,\n\t\tlifecycleOptions: Pick<IHoverLifecycleOptions, 'groupId'>,\n\t): IHoverWidget | undefined;\n\n\t/**\n\t * A simple wrapper around showDelayedHover that includes listening to events on the\n\t * {@link target} element that shows the hover.\n\t *\n\t * Use this method when you want to:\n\t *\n\t * - Let the hover service handle showing the hover.\n\t * - Show the hover after the standard delay.\n\t * - Want the hover positioned beside the {@link target} element.\n\t *\n\t * @param target The target element to listener for mouseover events on.\n\t * @param hoverOptions The options of the hover.\n\t * @param lifecycleOptions The options of the hover's lifecycle.\n\t */\n\tsetupDelayedHover(\n\t\ttarget: HTMLElement,\n\t\thoverOptions: (() => IDelayedHoverOptions) | IDelayedHoverOptions,\n\t\tlifecycleOptions?: IHoverLifecycleOptions,\n\t): IDisposable;\n\n\t/**\n\t * A simple wrapper around showDelayedHover that includes listening to events on the\n\t * {@link target} element that shows the hover. This differs from {@link setupDelayedHover} in\n\t * that the hover will be shown at the mouse position instead of the\n\t * {@link target target} element's position, ignoring any\n\t * {@link IHoverOptions.position position options} that are passed in.\n\t *\n\t * Use this method when you want to:\n\t *\n\t * - Let the hover service handle showing the hover.\n\t * - Show the hover after the standard delay.\n\t * - Want the hover positioned beside the mouse.\n\t *\n\t * @param target The target element to listener for mouseover events on.\n\t * @param hoverOptions The options of the hover.\n\t * @param lifecycleOptions The options of the hover's lifecycle.\n\t */\n\tsetupDelayedHoverAtMouse(\n\t\ttarget: HTMLElement,\n\t\thoverOptions: (() => IDelayedHoverAtMouseOptions) | IDelayedHoverAtMouseOptions,\n\t\tlifecycleOptions?: IHoverLifecycleOptions,\n\t): IDisposable;\n\n\t/**\n\t * Shows a hover immediately, provided a hover with the same {@link options} object is not\n\t * already visible.\n\t *\n\t * Use this method when you want to:\n\t *\n\t * - Control showing the hover yourself.\n\t * - Show the hover immediately.\n\t *\n\t * @param options A set of options defining the characteristics of the hover.\n\t * @param focus Whether to focus the hover (useful for keyboard accessibility).\n\t *\n\t * @example A simple usage with a single element target.\n\t *\n\t * ```typescript\n\t * showInstantHover({\n\t * text: new MarkdownString('Hello world'),\n\t * target: someElement\n\t * });\n\t * ```\n\t */\n\tshowInstantHover(\n\t\toptions: IHoverOptions,\n\t\tfocus?: boolean\n\t): IHoverWidget | undefined;\n\n\t/**\n\t * Hides the hover if it was visible. This call will be ignored if the hover is currently\n\t * \"locked\" via the alt/option key unless `force` is set.\n\t */\n\thideHover(force?: boolean): void;\n\n\t/**\n\t * This should only be used until we have the ability to show multiple context views\n\t * simultaneously. #188822\n\t */\n\tshowAndFocusLastHover(): void;\n\n\t/**\n\t * Sets up a managed hover for the given element. A managed hover will set up listeners for\n\t * mouse events, show the hover after a delay and provide hooks to easily update the content.\n\t *\n\t * This should be used over {@link showInstantHover} when fine-grained control is not needed. The\n\t * managed hover also does not scale well, consider using {@link showInstantHover} when showing hovers\n\t * for many elements.\n\t *\n\t * @param hoverDelegate The hover delegate containing hooks and configuration for the hover.\n\t * @param targetElement The target element to show the hover for.\n\t * @param content The content of the hover or a factory that creates it at the time it's shown.\n\t * @param options Additional options for the managed hover.\n\t *\n\t * @deprecated Use {@link setupDelayedHover} or {@link setupDelayedHoverAtMouse} instead where\n\t * possible.\n\t */\n\tsetupManagedHover(hoverDelegate: IHoverDelegate, targetElement: HTMLElement, content: IManagedHoverContentOrFactory, options?: IManagedHoverOptions): IManagedHover;\n\n\t/**\n\t * Shows the hover for the given element if one has been setup.\n\t *\n\t * @param targetElement The target element of the hover, as set up in {@link setupManagedHover}.\n\t *\n\t * @deprecated Use {@link setupDelayedHover} or {@link setupDelayedHoverAtMouse} instead where\n\t * possible.\n\t */\n\tshowManagedHover(targetElement: HTMLElement): void;\n}\n\nexport interface IHoverWidget extends IDisposable {\n\t/**\n\t * Whether the hover widget has been disposed.\n\t */\n\treadonly isDisposed: boolean;\n}\n\nexport interface IHoverOptions {\n\t/**\n\t * The content to display in the primary section of the hover. The type of text determines the\n\t * default `hideOnHover` behavior.\n\t */\n\tcontent: IMarkdownString | string | HTMLElement;\n\n\t/**\n\t * The target for the hover. This determines the position of the hover and it will only be\n\t * hidden when the mouse leaves both the hover and the target. A HTMLElement can be used for\n\t * simple cases and a IHoverTarget for more complex cases where multiple elements and/or a\n\t * dispose method is required.\n\t */\n\ttarget: IHoverTarget | HTMLElement;\n\n\t/*\n\t * The container to pass to {@link IContextViewProvider.showContextView} which renders the hover\n\t * in. This is particularly useful for more natural tab focusing behavior, where the hover is\n\t * created as the next tab index after the element being hovered and/or to workaround the\n\t * element's container hiding on `focusout`.\n\t */\n\tcontainer?: HTMLElement;\n\n\t/**\n\t * An ID to associate with the hover to be used as an equality check. Normally when calling\n\t * {@link IHoverService.showHover} the options object itself is used to determine if the hover\n\t * is the same one that is already showing, when this is set, the ID will be used instead.\n\t *\n\t * When `undefined`, this will default to a serialized version of {@link content}. In this case\n\t * it will remain `undefined` if {@link content} is a `HTMLElement`.\n\t */\n\tid?: string;\n\n\t/**\n\t * A set of actions for the hover's \"status bar\".\n\t */\n\tactions?: IHoverAction[];\n\n\t/**\n\t * An optional array of classes to add to the hover element.\n\t */\n\tadditionalClasses?: string[];\n\n\t/**\n\t * An optional link handler for markdown links, if this is not provided the IOpenerService will\n\t * be used to open the links using its default options.\n\t */\n\tlinkHandler?(url: string): void;\n\n\t/**\n\t * Whether to trap focus in the following ways:\n\t * - When the hover closes, focus goes to the element that had focus before the hover opened\n\t * - If there are elements in the hover to focus, focus stays inside of the hover when tabbing\n\t * Note that this is overridden to true when in screen reader optimized mode.\n\t */\n\ttrapFocus?: boolean;\n\n\t/**\n\t * Options that defines where the hover is positioned.\n\t */\n\tposition?: IHoverPositionOptions;\n\n\t/**\n\t * Options that defines how long the hover is shown and when it hides.\n\t */\n\tpersistence?: IHoverPersistenceOptions;\n\n\t/**\n\t * Options that define how the hover looks.\n\t */\n\tappearance?: IHoverAppearanceOptions;\n}\n\n// `target` is ignored for delayed hover methods as it's included in the method and added\n// automatically when the hover options get resolved.\nexport type IDelayedHoverOptions = Omit<IHoverOptions, 'target'>;\n\n// `position` is ignored for delayed at mouse hover methods as it's overwritten by the mouse event.\n// `showPointer` is always false when using mouse positioning\nexport type IDelayedHoverAtMouseOptions = Omit<IDelayedHoverOptions, 'position' | 'appearance'> & { appearance?: Omit<IHoverAppearanceOptions, 'showPointer'> };\n\nexport interface IHoverLifecycleOptions {\n\t/**\n\t * The group ID of the hover. If the group ID is the same as the currently shown hover, the\n\t * hover will be shown immediately, skipping the delay.\n\t *\n\t * @example Use a UUID to set a unique `groupId` for related hovers\n\t *\n\t * ```typescript\n\t * const groupId = generateUuid();\n\t * showDelayedHover({ content: 'Button 1', target: someElement1 }, { groupId });\n\t * showDelayedHover({ content: 'Button 2', target: someElement2 }, { groupId });\n\t * ```\n\t *\n\t * @example Use a feature-specific string to set a unqiue `groupId` for related hovers\n\t *\n\t * ```typescript\n\t * showDelayedHover({ content: 'Button 1', target: someElement1 }, { groupId: 'my-feature-items' });\n\t * showDelayedHover({ content: 'Button 2', target: someElement2 }, { groupId: 'my-feature-items' });\n\t * ```\n\t */\n\tgroupId?: string;\n\n\t/**\n\t * Whether to set up space and enter keyboard events for the hover, when these are pressed when\n\t * the hover's target is focused it will show and focus the hover.\n\t *\n\t * Typically this should _not_ be used when the space or enter events are already handled by\n\t * something else.\n\t */\n\tsetupKeyboardEvents?: boolean;\n}\n\nexport interface IHoverPositionOptions {\n\t/**\n\t * Position of the hover. The default is to show above the target. This option will be ignored\n\t * if there is not enough room to layout the hover in the specified position, unless the\n\t * forcePosition option is set.\n\t */\n\thoverPosition?: HoverPosition | MouseEvent;\n\n\t/**\n\t * Force the hover position, reducing the size of the hover instead of adjusting the hover\n\t * position.\n\t */\n\tforcePosition?: boolean;\n}\n\nexport interface IHoverPersistenceOptions {\n\t/**\n\t * Whether to hide the hover when the mouse leaves the `target` and enters the actual hover.\n\t * This is false by default when text is an `IMarkdownString` and true when `text` is a\n\t * `string`. Note that this will be ignored if any `actions` are provided as hovering is\n\t * required to make them accessible.\n\t *\n\t * In general hiding on hover is desired for:\n\t * - Regular text where selection is not important\n\t * - Markdown that contains no links where selection is not important\n\t */\n\thideOnHover?: boolean;\n\n\t/**\n\t * Whether to hide the hover when a key is pressed.\n\t */\n\thideOnKeyDown?: boolean;\n\n\t/**\n\t * Whether to make the hover sticky, this means it will not be hidden when the mouse leaves the\n\t * hover.\n\t */\n\tsticky?: boolean;\n}\n\nexport interface IHoverAppearanceOptions {\n\t/**\n\t * Whether to show the hover pointer, a little arrow that connects the target and the hover.\n\t */\n\tshowPointer?: boolean;\n\n\t/**\n\t * Whether to show a compact hover, reducing the font size and padding of the hover.\n\t */\n\tcompact?: boolean;\n\n\t/**\n\t * When {@link hideOnHover} is explicitly true or undefined and its auto value is detected to\n\t * hide, show a hint at the bottom of the hover explaining how to mouse over the widget. This\n\t * should be used in the cases where despite the hover having no interactive content, it's\n\t * likely the user may want to interact with it somehow.\n\t */\n\tshowHoverHint?: boolean;\n\n\t/**\n\t * Whether to skip the fade in animation, this should be used when hovering from one hover to\n\t * another in the same group so it looks like the hover is moving from one element to the other.\n\t */\n\tskipFadeInAnimation?: boolean;\n\n\t/**\n\t * The max height of the hover relative to the window height.\n\t * Accepted values: (0,1]\n\t * Default: 0.5\n\t */\n\tmaxHeightRatio?: number;\n}\n\nexport interface IHoverAction {\n\t/**\n\t * The label to use in the hover's status bar.\n\t */\n\tlabel: string;\n\n\t/**\n\t * The command ID of the action, this is used to resolve the keybinding to display after the\n\t * action label.\n\t */\n\tcommandId: string;\n\n\t/**\n\t * An optional class of an icon that will be displayed before the label.\n\t */\n\ticonClass?: string;\n\n\t/**\n\t * The callback to run the action.\n\t * @param target The action element that was activated.\n\t */\n\trun(target: HTMLElement): void;\n}\n\n/**\n * A target for a hover.\n */\nexport interface IHoverTarget extends Partial<IDisposable> {\n\t/**\n\t * A set of target elements used to position the hover. If multiple elements are used the hover\n\t * will try to not overlap any target element. An example use case for this is show a hover for\n\t * wrapped text.\n\t */\n\treadonly targetElements: readonly HTMLElement[];\n\n\t/**\n\t * An optional absolute x coordinate to position the hover with, for example to position the\n\t * hover using `MouseEvent.pageX`.\n\t */\n\treadonly x?: number;\n\n\t/**\n\t * An optional absolute y coordinate to position the hover with, for example to position the\n\t * hover using `MouseEvent.pageY`.\n\t */\n\treadonly y?: number;\n}\n\n// #region Managed hover\n\nexport interface IManagedHoverTooltipMarkdownString {\n\tmarkdown: IMarkdownString | string | undefined | ((token: CancellationToken) => Promise<IMarkdownString | string | undefined>);\n\tmarkdownNotSupportedFallback: string | undefined;\n}\n\nexport function isManagedHoverTooltipMarkdownString(obj: unknown): obj is IManagedHoverTooltipMarkdownString {\n\tconst candidate = obj as IManagedHoverTooltipMarkdownString;\n\treturn typeof candidate === 'object' && 'markdown' in candidate && 'markdownNotSupportedFallback' in candidate;\n}\n\nexport interface IManagedHoverTooltipHTMLElement {\n\telement: (token: CancellationToken) => HTMLElement | Promise<HTMLElement>;\n}\n\nexport type IManagedHoverContent = string | IManagedHoverTooltipMarkdownString | IManagedHoverTooltipHTMLElement | HTMLElement | undefined;\nexport type IManagedHoverContentOrFactory = IManagedHoverContent | (() => IManagedHoverContent);\n\nexport interface IManagedHoverOptions extends Pick<IHoverOptions, 'actions' | 'linkHandler' | 'trapFocus'> {\n\tappearance?: Pick<IHoverAppearanceOptions, 'showHoverHint'>;\n}\n\nexport interface IManagedHover extends IDisposable {\n\t/**\n\t * Allows to programmatically open the hover.\n\t */\n\tshow(focus?: boolean): void;\n\n\t/**\n\t * Allows to programmatically hide the hover.\n\t */\n\thide(): void;\n\n\t/**\n\t * Updates the contents of the hover.\n\t */\n\tupdate(tooltip: IManagedHoverContent, options?: IManagedHoverOptions): void;\n}\n\n// #endregion Managed hover\n"]}
|
|
1
|
+
{"version":3,"sources":["file:///mnt/vss/_work/1/s/dependencies/vscode/out-editor-src/vs/base/browser/ui/hover/hover.ts","vs/base/browser/ui/hover/hover.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAoZhG,MAAM,UAAU,mCAAmC,CAAC,GAAY;IAC/D,MAAM,SAAS,GAAG,GAAyC,CAAC;IAC5D,OAAO,OAAO,SAAS,KAAK,QAAQ,IAAI,UAAU,IAAI,SAAS,IAAI,8BAA8B,IAAI,SAAS,CAAC;AAChH,CAAC;AA8BD,2BAA2B","file":"hover.js","sourceRoot":"file:///mnt/vss/_work/1/s/dependencies/vscode/out-editor-src","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\nimport { IHoverDelegate } from './hoverDelegate.js';\nimport { HoverPosition } from './hoverWidget.js';\nimport { CancellationToken } from '../../../common/cancellation.js';\nimport { IMarkdownString } from '../../../common/htmlContent.js';\nimport { IDisposable } from '../../../common/lifecycle.js';\n\n/**\n * Enables the convenient display of rich markdown-based hovers in the workbench.\n */\nexport interface IHoverDelegate2 {\n\t/**\n\t * Shows a hover after a delay, or immediately if the {@link groupId} matches the currently\n\t * shown hover.\n\t *\n\t * Use this method when you want to:\n\t *\n\t * - Control showing the hover yourself.\n\t * - Show the hover after the standard delay.\n\t *\n\t * @param options The options of the hover.\n\t * @param groupId The group ID of the hover. If the group ID is the same as the currently shown\n\t * hover, the hover will be shown immediately, skipping the delay.\n\t */\n\tshowDelayedHover(\n\t\toptions: IHoverOptions,\n\t\tlifecycleOptions: Pick<IHoverLifecycleOptions, 'groupId'>,\n\t): IHoverWidget | undefined;\n\n\t/**\n\t * A simple wrapper around showDelayedHover that includes listening to events on the\n\t * {@link target} element that shows the hover.\n\t *\n\t * Use this method when you want to:\n\t *\n\t * - Let the hover service handle showing the hover.\n\t * - Show the hover after the standard delay.\n\t * - Want the hover positioned beside the {@link target} element.\n\t *\n\t * @param target The target element to listener for mouseover events on.\n\t * @param hoverOptions The options of the hover.\n\t * @param lifecycleOptions The options of the hover's lifecycle.\n\t */\n\tsetupDelayedHover(\n\t\ttarget: HTMLElement,\n\t\thoverOptions: (() => IDelayedHoverOptions) | IDelayedHoverOptions,\n\t\tlifecycleOptions?: IHoverLifecycleOptions,\n\t): IDisposable;\n\n\t/**\n\t * A simple wrapper around showDelayedHover that includes listening to events on the\n\t * {@link target} element that shows the hover. This differs from {@link setupDelayedHover} in\n\t * that the hover will be shown at the mouse position instead of the\n\t * {@link target target} element's position, ignoring any\n\t * {@link IHoverOptions.position position options} that are passed in.\n\t *\n\t * Use this method when you want to:\n\t *\n\t * - Let the hover service handle showing the hover.\n\t * - Show the hover after the standard delay.\n\t * - Want the hover positioned beside the mouse.\n\t *\n\t * @param target The target element to listener for mouseover events on.\n\t * @param hoverOptions The options of the hover.\n\t * @param lifecycleOptions The options of the hover's lifecycle.\n\t */\n\tsetupDelayedHoverAtMouse(\n\t\ttarget: HTMLElement,\n\t\thoverOptions: (() => IDelayedHoverAtMouseOptions) | IDelayedHoverAtMouseOptions,\n\t\tlifecycleOptions?: IHoverLifecycleOptions,\n\t): IDisposable;\n\n\t/**\n\t * Shows a hover immediately, provided a hover with the same {@link options} object is not\n\t * already visible.\n\t *\n\t * Use this method when you want to:\n\t *\n\t * - Control showing the hover yourself.\n\t * - Show the hover immediately.\n\t *\n\t * @param options A set of options defining the characteristics of the hover.\n\t * @param focus Whether to focus the hover (useful for keyboard accessibility).\n\t *\n\t * @example A simple usage with a single element target.\n\t *\n\t * ```typescript\n\t * showInstantHover({\n\t * text: new MarkdownString('Hello world'),\n\t * target: someElement\n\t * });\n\t * ```\n\t */\n\tshowInstantHover(\n\t\toptions: IHoverOptions,\n\t\tfocus?: boolean\n\t): IHoverWidget | undefined;\n\n\t/**\n\t * Hides the hover if it was visible. This call will be ignored if the hover is currently\n\t * \"locked\" via the alt/option key unless `force` is set.\n\t */\n\thideHover(force?: boolean): void;\n\n\t/**\n\t * This should only be used until we have the ability to show multiple context views\n\t * simultaneously. #188822\n\t */\n\tshowAndFocusLastHover(): void;\n\n\t/**\n\t * Sets up a managed hover for the given element. A managed hover will set up listeners for\n\t * mouse events, show the hover after a delay and provide hooks to easily update the content.\n\t *\n\t * This should be used over {@link showInstantHover} when fine-grained control is not needed. The\n\t * managed hover also does not scale well, consider using {@link showInstantHover} when showing hovers\n\t * for many elements.\n\t *\n\t * @param hoverDelegate The hover delegate containing hooks and configuration for the hover.\n\t * @param targetElement The target element to show the hover for.\n\t * @param content The content of the hover or a factory that creates it at the time it's shown.\n\t * @param options Additional options for the managed hover.\n\t *\n\t * @deprecated Use {@link setupDelayedHover} or {@link setupDelayedHoverAtMouse} instead where\n\t * possible.\n\t */\n\tsetupManagedHover(hoverDelegate: IHoverDelegate, targetElement: HTMLElement, content: IManagedHoverContentOrFactory, options?: IManagedHoverOptions): IManagedHover;\n\n\t/**\n\t * Shows the hover for the given element if one has been setup.\n\t *\n\t * @param targetElement The target element of the hover, as set up in {@link setupManagedHover}.\n\t *\n\t * @deprecated Use {@link setupDelayedHover} or {@link setupDelayedHoverAtMouse} instead where\n\t * possible.\n\t */\n\tshowManagedHover(targetElement: HTMLElement): void;\n}\n\nexport interface IHoverWidget extends IDisposable {\n\t/**\n\t * Whether the hover widget has been disposed.\n\t */\n\treadonly isDisposed: boolean;\n}\n\nexport const enum HoverStyle {\n\t/**\n\t * The hover is anchored below the element with a pointer above it pointing at the target.\n\t */\n\tPointer = 1,\n\t/**\n\t * The hover is anchored to the bottom right of the cursor's location.\n\t */\n\tMouse = 2,\n}\n\nexport interface IHoverOptions {\n\t/**\n\t * The content to display in the primary section of the hover. The type of text determines the\n\t * default `hideOnHover` behavior.\n\t */\n\tcontent: IMarkdownString | string | HTMLElement;\n\n\t/**\n\t * The target for the hover. This determines the position of the hover and it will only be\n\t * hidden when the mouse leaves both the hover and the target. A HTMLElement can be used for\n\t * simple cases and a IHoverTarget for more complex cases where multiple elements and/or a\n\t * dispose method is required.\n\t */\n\ttarget: IHoverTarget | HTMLElement;\n\n\t/*\n\t * The container to pass to {@link IContextViewProvider.showContextView} which renders the hover\n\t * in. This is particularly useful for more natural tab focusing behavior, where the hover is\n\t * created as the next tab index after the element being hovered and/or to workaround the\n\t * element's container hiding on `focusout`.\n\t */\n\tcontainer?: HTMLElement;\n\n\t/**\n\t * An ID to associate with the hover to be used as an equality check. Normally when calling\n\t * {@link IHoverService.showHover} the options object itself is used to determine if the hover\n\t * is the same one that is already showing, when this is set, the ID will be used instead.\n\t *\n\t * When `undefined`, this will default to a serialized version of {@link content}. In this case\n\t * it will remain `undefined` if {@link content} is a `HTMLElement`.\n\t */\n\tid?: string;\n\n\t/**\n\t * A set of actions for the hover's \"status bar\".\n\t */\n\tactions?: IHoverAction[];\n\n\t/**\n\t * An optional array of classes to add to the hover element.\n\t */\n\tadditionalClasses?: string[];\n\n\t/**\n\t * An optional link handler for markdown links, if this is not provided the IOpenerService will\n\t * be used to open the links using its default options.\n\t */\n\tlinkHandler?(url: string): void;\n\n\t/**\n\t * Whether to trap focus in the following ways:\n\t * - When the hover closes, focus goes to the element that had focus before the hover opened\n\t * - If there are elements in the hover to focus, focus stays inside of the hover when tabbing\n\t * Note that this is overridden to true when in screen reader optimized mode.\n\t */\n\ttrapFocus?: boolean;\n\n\t/**\n\t * The style of the hover, this sets default values of {@link position} and {@link appearance}:\n\t */\n\tstyle?: HoverStyle;\n\n\t/**\n\t * Options that defines where the hover is positioned.\n\t */\n\tposition?: IHoverPositionOptions;\n\n\t/**\n\t * Options that defines how long the hover is shown and when it hides.\n\t */\n\tpersistence?: IHoverPersistenceOptions;\n\n\t/**\n\t * Options that define how the hover looks.\n\t */\n\tappearance?: IHoverAppearanceOptions;\n}\n\n// `target` is ignored for delayed hover methods as it's included in the method and added\n// automatically when the hover options get resolved.\nexport type IDelayedHoverOptions = Omit<IHoverOptions, 'target'>;\n\n// `position` is ignored for delayed at mouse hover methods as it's overwritten by the mouse event.\n// `showPointer` is always false when using mouse positioning\nexport type IDelayedHoverAtMouseOptions = Omit<IDelayedHoverOptions, 'position' | 'appearance'> & { appearance?: Omit<IHoverAppearanceOptions, 'showPointer'> };\n\nexport interface IHoverLifecycleOptions {\n\t/**\n\t * The group ID of the hover. If the group ID is the same as the currently shown hover, the\n\t * hover will be shown immediately, skipping the delay.\n\t *\n\t * @example Use a UUID to set a unique `groupId` for related hovers\n\t *\n\t * ```typescript\n\t * const groupId = generateUuid();\n\t * showDelayedHover({ content: 'Button 1', target: someElement1 }, { groupId });\n\t * showDelayedHover({ content: 'Button 2', target: someElement2 }, { groupId });\n\t * ```\n\t *\n\t * @example Use a feature-specific string to set a unqiue `groupId` for related hovers\n\t *\n\t * ```typescript\n\t * showDelayedHover({ content: 'Button 1', target: someElement1 }, { groupId: 'my-feature-items' });\n\t * showDelayedHover({ content: 'Button 2', target: someElement2 }, { groupId: 'my-feature-items' });\n\t * ```\n\t */\n\tgroupId?: string;\n\n\t/**\n\t * Whether to set up space and enter keyboard events for the hover, when these are pressed when\n\t * the hover's target is focused it will show and focus the hover.\n\t *\n\t * Typically this should _not_ be used when the space or enter events are already handled by\n\t * something else.\n\t */\n\tsetupKeyboardEvents?: boolean;\n}\n\nexport interface IHoverPositionOptions {\n\t/**\n\t * Position of the hover. The default is to show above the target. This option will be ignored\n\t * if there is not enough room to layout the hover in the specified position, unless the\n\t * forcePosition option is set.\n\t */\n\thoverPosition?: HoverPosition | MouseEvent;\n\n\t/**\n\t * Force the hover position, reducing the size of the hover instead of adjusting the hover\n\t * position.\n\t */\n\tforcePosition?: boolean;\n}\n\nexport interface IHoverPersistenceOptions {\n\t/**\n\t * Whether to hide the hover when the mouse leaves the `target` and enters the actual hover.\n\t * This is false by default when text is an `IMarkdownString` and true when `text` is a\n\t * `string`. Note that this will be ignored if any `actions` are provided as hovering is\n\t * required to make them accessible.\n\t *\n\t * In general hiding on hover is desired for:\n\t * - Regular text where selection is not important\n\t * - Markdown that contains no links where selection is not important\n\t */\n\thideOnHover?: boolean;\n\n\t/**\n\t * Whether to hide the hover when a key is pressed.\n\t */\n\thideOnKeyDown?: boolean;\n\n\t/**\n\t * Whether to make the hover sticky, this means it will not be hidden when the mouse leaves the\n\t * hover.\n\t */\n\tsticky?: boolean;\n}\n\nexport interface IHoverAppearanceOptions {\n\t/**\n\t * Whether to show the hover pointer, a little arrow that connects the target and the hover.\n\t */\n\tshowPointer?: boolean;\n\n\t/**\n\t * Whether to show a compact hover, reducing the font size and padding of the hover.\n\t */\n\tcompact?: boolean;\n\n\t/**\n\t * When {@link hideOnHover} is explicitly true or undefined and its auto value is detected to\n\t * hide, show a hint at the bottom of the hover explaining how to mouse over the widget. This\n\t * should be used in the cases where despite the hover having no interactive content, it's\n\t * likely the user may want to interact with it somehow.\n\t */\n\tshowHoverHint?: boolean;\n\n\t/**\n\t * Whether to skip the fade in animation, this should be used when hovering from one hover to\n\t * another in the same group so it looks like the hover is moving from one element to the other.\n\t */\n\tskipFadeInAnimation?: boolean;\n\n\t/**\n\t * The max height of the hover relative to the window height.\n\t * Accepted values: (0,1]\n\t * Default: 0.5\n\t */\n\tmaxHeightRatio?: number;\n}\n\nexport interface IHoverAction {\n\t/**\n\t * The label to use in the hover's status bar.\n\t */\n\tlabel: string;\n\n\t/**\n\t * The command ID of the action, this is used to resolve the keybinding to display after the\n\t * action label.\n\t */\n\tcommandId: string;\n\n\t/**\n\t * An optional class of an icon that will be displayed before the label.\n\t */\n\ticonClass?: string;\n\n\t/**\n\t * The callback to run the action.\n\t * @param target The action element that was activated.\n\t */\n\trun(target: HTMLElement): void;\n}\n\n/**\n * A target for a hover.\n */\nexport interface IHoverTarget extends Partial<IDisposable> {\n\t/**\n\t * A set of target elements used to position the hover. If multiple elements are used the hover\n\t * will try to not overlap any target element. An example use case for this is show a hover for\n\t * wrapped text.\n\t */\n\treadonly targetElements: readonly HTMLElement[];\n\n\t/**\n\t * An optional absolute x coordinate to position the hover with, for example to position the\n\t * hover using `MouseEvent.pageX`.\n\t */\n\treadonly x?: number;\n\n\t/**\n\t * An optional absolute y coordinate to position the hover with, for example to position the\n\t * hover using `MouseEvent.pageY`.\n\t */\n\treadonly y?: number;\n}\n\n// #region Managed hover\n\nexport interface IManagedHoverTooltipMarkdownString {\n\tmarkdown: IMarkdownString | string | undefined | ((token: CancellationToken) => Promise<IMarkdownString | string | undefined>);\n\tmarkdownNotSupportedFallback: string | undefined;\n}\n\nexport function isManagedHoverTooltipMarkdownString(obj: unknown): obj is IManagedHoverTooltipMarkdownString {\n\tconst candidate = obj as IManagedHoverTooltipMarkdownString;\n\treturn typeof candidate === 'object' && 'markdown' in candidate && 'markdownNotSupportedFallback' in candidate;\n}\n\nexport interface IManagedHoverTooltipHTMLElement {\n\telement: (token: CancellationToken) => HTMLElement | Promise<HTMLElement>;\n}\n\nexport type IManagedHoverContent = string | IManagedHoverTooltipMarkdownString | IManagedHoverTooltipHTMLElement | HTMLElement | undefined;\nexport type IManagedHoverContentOrFactory = IManagedHoverContent | (() => IManagedHoverContent);\n\nexport interface IManagedHoverOptions extends Pick<IHoverOptions, 'actions' | 'linkHandler' | 'trapFocus'> {\n\tappearance?: Pick<IHoverAppearanceOptions, 'showHoverHint'>;\n}\n\nexport interface IManagedHover extends IDisposable {\n\t/**\n\t * Allows to programmatically open the hover.\n\t */\n\tshow(focus?: boolean): void;\n\n\t/**\n\t * Allows to programmatically hide the hover.\n\t */\n\thide(): void;\n\n\t/**\n\t * Updates the contents of the hover.\n\t */\n\tupdate(tooltip: IManagedHoverContent, options?: IManagedHoverOptions): void;\n}\n\n// #endregion Managed hover\n","/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\nimport { IHoverDelegate } from './hoverDelegate.js';\nimport { HoverPosition } from './hoverWidget.js';\nimport { CancellationToken } from '../../../common/cancellation.js';\nimport { IMarkdownString } from '../../../common/htmlContent.js';\nimport { IDisposable } from '../../../common/lifecycle.js';\n\n/**\n * Enables the convenient display of rich markdown-based hovers in the workbench.\n */\nexport interface IHoverDelegate2 {\n\t/**\n\t * Shows a hover after a delay, or immediately if the {@link groupId} matches the currently\n\t * shown hover.\n\t *\n\t * Use this method when you want to:\n\t *\n\t * - Control showing the hover yourself.\n\t * - Show the hover after the standard delay.\n\t *\n\t * @param options The options of the hover.\n\t * @param groupId The group ID of the hover. If the group ID is the same as the currently shown\n\t * hover, the hover will be shown immediately, skipping the delay.\n\t */\n\tshowDelayedHover(\n\t\toptions: IHoverOptions,\n\t\tlifecycleOptions: Pick<IHoverLifecycleOptions, 'groupId'>,\n\t): IHoverWidget | undefined;\n\n\t/**\n\t * A simple wrapper around showDelayedHover that includes listening to events on the\n\t * {@link target} element that shows the hover.\n\t *\n\t * Use this method when you want to:\n\t *\n\t * - Let the hover service handle showing the hover.\n\t * - Show the hover after the standard delay.\n\t * - Want the hover positioned beside the {@link target} element.\n\t *\n\t * @param target The target element to listener for mouseover events on.\n\t * @param hoverOptions The options of the hover.\n\t * @param lifecycleOptions The options of the hover's lifecycle.\n\t */\n\tsetupDelayedHover(\n\t\ttarget: HTMLElement,\n\t\thoverOptions: (() => IDelayedHoverOptions) | IDelayedHoverOptions,\n\t\tlifecycleOptions?: IHoverLifecycleOptions,\n\t): IDisposable;\n\n\t/**\n\t * A simple wrapper around showDelayedHover that includes listening to events on the\n\t * {@link target} element that shows the hover. This differs from {@link setupDelayedHover} in\n\t * that the hover will be shown at the mouse position instead of the\n\t * {@link target target} element's position, ignoring any\n\t * {@link IHoverOptions.position position options} that are passed in.\n\t *\n\t * Use this method when you want to:\n\t *\n\t * - Let the hover service handle showing the hover.\n\t * - Show the hover after the standard delay.\n\t * - Want the hover positioned beside the mouse.\n\t *\n\t * @param target The target element to listener for mouseover events on.\n\t * @param hoverOptions The options of the hover.\n\t * @param lifecycleOptions The options of the hover's lifecycle.\n\t */\n\tsetupDelayedHoverAtMouse(\n\t\ttarget: HTMLElement,\n\t\thoverOptions: (() => IDelayedHoverAtMouseOptions) | IDelayedHoverAtMouseOptions,\n\t\tlifecycleOptions?: IHoverLifecycleOptions,\n\t): IDisposable;\n\n\t/**\n\t * Shows a hover immediately, provided a hover with the same {@link options} object is not\n\t * already visible.\n\t *\n\t * Use this method when you want to:\n\t *\n\t * - Control showing the hover yourself.\n\t * - Show the hover immediately.\n\t *\n\t * @param options A set of options defining the characteristics of the hover.\n\t * @param focus Whether to focus the hover (useful for keyboard accessibility).\n\t *\n\t * @example A simple usage with a single element target.\n\t *\n\t * ```typescript\n\t * showInstantHover({\n\t * text: new MarkdownString('Hello world'),\n\t * target: someElement\n\t * });\n\t * ```\n\t */\n\tshowInstantHover(\n\t\toptions: IHoverOptions,\n\t\tfocus?: boolean\n\t): IHoverWidget | undefined;\n\n\t/**\n\t * Hides the hover if it was visible. This call will be ignored if the hover is currently\n\t * \"locked\" via the alt/option key unless `force` is set.\n\t */\n\thideHover(force?: boolean): void;\n\n\t/**\n\t * This should only be used until we have the ability to show multiple context views\n\t * simultaneously. #188822\n\t */\n\tshowAndFocusLastHover(): void;\n\n\t/**\n\t * Sets up a managed hover for the given element. A managed hover will set up listeners for\n\t * mouse events, show the hover after a delay and provide hooks to easily update the content.\n\t *\n\t * This should be used over {@link showInstantHover} when fine-grained control is not needed. The\n\t * managed hover also does not scale well, consider using {@link showInstantHover} when showing hovers\n\t * for many elements.\n\t *\n\t * @param hoverDelegate The hover delegate containing hooks and configuration for the hover.\n\t * @param targetElement The target element to show the hover for.\n\t * @param content The content of the hover or a factory that creates it at the time it's shown.\n\t * @param options Additional options for the managed hover.\n\t *\n\t * @deprecated Use {@link setupDelayedHover} or {@link setupDelayedHoverAtMouse} instead where\n\t * possible.\n\t */\n\tsetupManagedHover(hoverDelegate: IHoverDelegate, targetElement: HTMLElement, content: IManagedHoverContentOrFactory, options?: IManagedHoverOptions): IManagedHover;\n\n\t/**\n\t * Shows the hover for the given element if one has been setup.\n\t *\n\t * @param targetElement The target element of the hover, as set up in {@link setupManagedHover}.\n\t *\n\t * @deprecated Use {@link setupDelayedHover} or {@link setupDelayedHoverAtMouse} instead where\n\t * possible.\n\t */\n\tshowManagedHover(targetElement: HTMLElement): void;\n}\n\nexport interface IHoverWidget extends IDisposable {\n\t/**\n\t * Whether the hover widget has been disposed.\n\t */\n\treadonly isDisposed: boolean;\n}\n\nexport const enum HoverStyle {\n\t/**\n\t * The hover is anchored below the element with a pointer above it pointing at the target.\n\t */\n\tPointer = 1,\n\t/**\n\t * The hover is anchored to the bottom right of the cursor's location.\n\t */\n\tMouse = 2,\n}\n\nexport interface IHoverOptions {\n\t/**\n\t * The content to display in the primary section of the hover. The type of text determines the\n\t * default `hideOnHover` behavior.\n\t */\n\tcontent: IMarkdownString | string | HTMLElement;\n\n\t/**\n\t * The target for the hover. This determines the position of the hover and it will only be\n\t * hidden when the mouse leaves both the hover and the target. A HTMLElement can be used for\n\t * simple cases and a IHoverTarget for more complex cases where multiple elements and/or a\n\t * dispose method is required.\n\t */\n\ttarget: IHoverTarget | HTMLElement;\n\n\t/*\n\t * The container to pass to {@link IContextViewProvider.showContextView} which renders the hover\n\t * in. This is particularly useful for more natural tab focusing behavior, where the hover is\n\t * created as the next tab index after the element being hovered and/or to workaround the\n\t * element's container hiding on `focusout`.\n\t */\n\tcontainer?: HTMLElement;\n\n\t/**\n\t * An ID to associate with the hover to be used as an equality check. Normally when calling\n\t * {@link IHoverService.showHover} the options object itself is used to determine if the hover\n\t * is the same one that is already showing, when this is set, the ID will be used instead.\n\t *\n\t * When `undefined`, this will default to a serialized version of {@link content}. In this case\n\t * it will remain `undefined` if {@link content} is a `HTMLElement`.\n\t */\n\tid?: string;\n\n\t/**\n\t * A set of actions for the hover's \"status bar\".\n\t */\n\tactions?: IHoverAction[];\n\n\t/**\n\t * An optional array of classes to add to the hover element.\n\t */\n\tadditionalClasses?: string[];\n\n\t/**\n\t * An optional link handler for markdown links, if this is not provided the IOpenerService will\n\t * be used to open the links using its default options.\n\t */\n\tlinkHandler?(url: string): void;\n\n\t/**\n\t * Whether to trap focus in the following ways:\n\t * - When the hover closes, focus goes to the element that had focus before the hover opened\n\t * - If there are elements in the hover to focus, focus stays inside of the hover when tabbing\n\t * Note that this is overridden to true when in screen reader optimized mode.\n\t */\n\ttrapFocus?: boolean;\n\n\t/**\n\t * The style of the hover, this sets default values of {@link position} and {@link appearance}:\n\t */\n\tstyle?: HoverStyle;\n\n\t/**\n\t * Options that defines where the hover is positioned.\n\t */\n\tposition?: IHoverPositionOptions;\n\n\t/**\n\t * Options that defines how long the hover is shown and when it hides.\n\t */\n\tpersistence?: IHoverPersistenceOptions;\n\n\t/**\n\t * Options that define how the hover looks.\n\t */\n\tappearance?: IHoverAppearanceOptions;\n}\n\n// `target` is ignored for delayed hover methods as it's included in the method and added\n// automatically when the hover options get resolved.\nexport type IDelayedHoverOptions = Omit<IHoverOptions, 'target'>;\n\n// `position` is ignored for delayed at mouse hover methods as it's overwritten by the mouse event.\n// `showPointer` is always false when using mouse positioning\nexport type IDelayedHoverAtMouseOptions = Omit<IDelayedHoverOptions, 'position' | 'appearance'> & { appearance?: Omit<IHoverAppearanceOptions, 'showPointer'> };\n\nexport interface IHoverLifecycleOptions {\n\t/**\n\t * The group ID of the hover. If the group ID is the same as the currently shown hover, the\n\t * hover will be shown immediately, skipping the delay.\n\t *\n\t * @example Use a UUID to set a unique `groupId` for related hovers\n\t *\n\t * ```typescript\n\t * const groupId = generateUuid();\n\t * showDelayedHover({ content: 'Button 1', target: someElement1 }, { groupId });\n\t * showDelayedHover({ content: 'Button 2', target: someElement2 }, { groupId });\n\t * ```\n\t *\n\t * @example Use a feature-specific string to set a unqiue `groupId` for related hovers\n\t *\n\t * ```typescript\n\t * showDelayedHover({ content: 'Button 1', target: someElement1 }, { groupId: 'my-feature-items' });\n\t * showDelayedHover({ content: 'Button 2', target: someElement2 }, { groupId: 'my-feature-items' });\n\t * ```\n\t */\n\tgroupId?: string;\n\n\t/**\n\t * Whether to set up space and enter keyboard events for the hover, when these are pressed when\n\t * the hover's target is focused it will show and focus the hover.\n\t *\n\t * Typically this should _not_ be used when the space or enter events are already handled by\n\t * something else.\n\t */\n\tsetupKeyboardEvents?: boolean;\n}\n\nexport interface IHoverPositionOptions {\n\t/**\n\t * Position of the hover. The default is to show above the target. This option will be ignored\n\t * if there is not enough room to layout the hover in the specified position, unless the\n\t * forcePosition option is set.\n\t */\n\thoverPosition?: HoverPosition | MouseEvent;\n\n\t/**\n\t * Force the hover position, reducing the size of the hover instead of adjusting the hover\n\t * position.\n\t */\n\tforcePosition?: boolean;\n}\n\nexport interface IHoverPersistenceOptions {\n\t/**\n\t * Whether to hide the hover when the mouse leaves the `target` and enters the actual hover.\n\t * This is false by default when text is an `IMarkdownString` and true when `text` is a\n\t * `string`. Note that this will be ignored if any `actions` are provided as hovering is\n\t * required to make them accessible.\n\t *\n\t * In general hiding on hover is desired for:\n\t * - Regular text where selection is not important\n\t * - Markdown that contains no links where selection is not important\n\t */\n\thideOnHover?: boolean;\n\n\t/**\n\t * Whether to hide the hover when a key is pressed.\n\t */\n\thideOnKeyDown?: boolean;\n\n\t/**\n\t * Whether to make the hover sticky, this means it will not be hidden when the mouse leaves the\n\t * hover.\n\t */\n\tsticky?: boolean;\n}\n\nexport interface IHoverAppearanceOptions {\n\t/**\n\t * Whether to show the hover pointer, a little arrow that connects the target and the hover.\n\t */\n\tshowPointer?: boolean;\n\n\t/**\n\t * Whether to show a compact hover, reducing the font size and padding of the hover.\n\t */\n\tcompact?: boolean;\n\n\t/**\n\t * When {@link hideOnHover} is explicitly true or undefined and its auto value is detected to\n\t * hide, show a hint at the bottom of the hover explaining how to mouse over the widget. This\n\t * should be used in the cases where despite the hover having no interactive content, it's\n\t * likely the user may want to interact with it somehow.\n\t */\n\tshowHoverHint?: boolean;\n\n\t/**\n\t * Whether to skip the fade in animation, this should be used when hovering from one hover to\n\t * another in the same group so it looks like the hover is moving from one element to the other.\n\t */\n\tskipFadeInAnimation?: boolean;\n\n\t/**\n\t * The max height of the hover relative to the window height.\n\t * Accepted values: (0,1]\n\t * Default: 0.5\n\t */\n\tmaxHeightRatio?: number;\n}\n\nexport interface IHoverAction {\n\t/**\n\t * The label to use in the hover's status bar.\n\t */\n\tlabel: string;\n\n\t/**\n\t * The command ID of the action, this is used to resolve the keybinding to display after the\n\t * action label.\n\t */\n\tcommandId: string;\n\n\t/**\n\t * An optional class of an icon that will be displayed before the label.\n\t */\n\ticonClass?: string;\n\n\t/**\n\t * The callback to run the action.\n\t * @param target The action element that was activated.\n\t */\n\trun(target: HTMLElement): void;\n}\n\n/**\n * A target for a hover.\n */\nexport interface IHoverTarget extends Partial<IDisposable> {\n\t/**\n\t * A set of target elements used to position the hover. If multiple elements are used the hover\n\t * will try to not overlap any target element. An example use case for this is show a hover for\n\t * wrapped text.\n\t */\n\treadonly targetElements: readonly HTMLElement[];\n\n\t/**\n\t * An optional absolute x coordinate to position the hover with, for example to position the\n\t * hover using `MouseEvent.pageX`.\n\t */\n\treadonly x?: number;\n\n\t/**\n\t * An optional absolute y coordinate to position the hover with, for example to position the\n\t * hover using `MouseEvent.pageY`.\n\t */\n\treadonly y?: number;\n}\n\n// #region Managed hover\n\nexport interface IManagedHoverTooltipMarkdownString {\n\tmarkdown: IMarkdownString | string | undefined | ((token: CancellationToken) => Promise<IMarkdownString | string | undefined>);\n\tmarkdownNotSupportedFallback: string | undefined;\n}\n\nexport function isManagedHoverTooltipMarkdownString(obj: unknown): obj is IManagedHoverTooltipMarkdownString {\n\tconst candidate = obj as IManagedHoverTooltipMarkdownString;\n\treturn typeof candidate === 'object' && 'markdown' in candidate && 'markdownNotSupportedFallback' in candidate;\n}\n\nexport interface IManagedHoverTooltipHTMLElement {\n\telement: (token: CancellationToken) => HTMLElement | Promise<HTMLElement>;\n}\n\nexport type IManagedHoverContent = string | IManagedHoverTooltipMarkdownString | IManagedHoverTooltipHTMLElement | HTMLElement | undefined;\nexport type IManagedHoverContentOrFactory = IManagedHoverContent | (() => IManagedHoverContent);\n\nexport interface IManagedHoverOptions extends Pick<IHoverOptions, 'actions' | 'linkHandler' | 'trapFocus'> {\n\tappearance?: Pick<IHoverAppearanceOptions, 'showHoverHint'>;\n}\n\nexport interface IManagedHover extends IDisposable {\n\t/**\n\t * Allows to programmatically open the hover.\n\t */\n\tshow(focus?: boolean): void;\n\n\t/**\n\t * Allows to programmatically hide the hover.\n\t */\n\thide(): void;\n\n\t/**\n\t * Updates the contents of the hover.\n\t */\n\tupdate(tooltip: IManagedHoverContent, options?: IManagedHoverOptions): void;\n}\n\n// #endregion Managed hover\n"]}
|
|
@@ -2,7 +2,6 @@ import { Codicon } from '../../../common/codicons.js';
|
|
|
2
2
|
import { Emitter } from '../../../common/event.js';
|
|
3
3
|
import { ThemeIcon } from '../../../common/themables.js';
|
|
4
4
|
import { getBaseLayerHoverDelegate } from '../hover/hoverDelegate2.js';
|
|
5
|
-
import { getDefaultHoverDelegate } from '../hover/hoverDelegateFactory.js';
|
|
6
5
|
import { Widget } from '../widget.js';
|
|
7
6
|
import './toggle.css';
|
|
8
7
|
export const unthemedToggleStyles = {
|
|
@@ -18,6 +17,7 @@ export class Toggle extends Widget {
|
|
|
18
17
|
this._onChange = this._register(new Emitter());
|
|
19
18
|
this._onKeyDown = this._register(new Emitter());
|
|
20
19
|
this._opts = opts;
|
|
20
|
+
this._title = this._opts.title;
|
|
21
21
|
this._checked = this._opts.isChecked;
|
|
22
22
|
const classes = ['monaco-custom-toggle'];
|
|
23
23
|
if (this._opts.icon) {
|
|
@@ -31,14 +31,17 @@ export class Toggle extends Widget {
|
|
|
31
31
|
classes.push('checked');
|
|
32
32
|
}
|
|
33
33
|
this.domNode = document.createElement('div');
|
|
34
|
-
this.
|
|
34
|
+
this._register(getBaseLayerHoverDelegate().setupDelayedHover(this.domNode, () => ({
|
|
35
|
+
content: this._title,
|
|
36
|
+
style: 1 /* HoverStyle.Pointer */,
|
|
37
|
+
}), this._opts.hoverLifecycleOptions));
|
|
35
38
|
this.domNode.classList.add(...classes);
|
|
36
39
|
if (!this._opts.notFocusable) {
|
|
37
40
|
this.domNode.tabIndex = 0;
|
|
38
41
|
}
|
|
39
42
|
this.domNode.setAttribute('role', 'checkbox');
|
|
40
43
|
this.domNode.setAttribute('aria-checked', String(this._checked));
|
|
41
|
-
this.
|
|
44
|
+
this.setTitle(this._opts.title);
|
|
42
45
|
this.applyStyles();
|
|
43
46
|
this.onclick(this.domNode, (ev) => {
|
|
44
47
|
if (this.enabled) {
|
|
@@ -105,7 +108,7 @@ export class Toggle extends Widget {
|
|
|
105
108
|
this.domNode.classList.add('disabled');
|
|
106
109
|
}
|
|
107
110
|
setTitle(newTitle) {
|
|
108
|
-
this.
|
|
111
|
+
this._title = newTitle;
|
|
109
112
|
this.domNode.setAttribute('aria-label', newTitle);
|
|
110
113
|
}
|
|
111
114
|
set visible(visible) {
|
|
@@ -153,7 +156,7 @@ class BaseCheckbox extends Widget {
|
|
|
153
156
|
}
|
|
154
157
|
export class Checkbox extends BaseCheckbox {
|
|
155
158
|
constructor(title, isChecked, styles) {
|
|
156
|
-
const toggle = new Toggle({ title, isChecked, icon: Codicon.check, actionClassName: BaseCheckbox.CLASS_NAME,
|
|
159
|
+
const toggle = new Toggle({ title, isChecked, icon: Codicon.check, actionClassName: BaseCheckbox.CLASS_NAME, hoverLifecycleOptions: styles.hoverLifecycleOptions, ...unthemedToggleStyles });
|
|
157
160
|
super(toggle, toggle.domNode, styles);
|
|
158
161
|
this._register(toggle);
|
|
159
162
|
this._register(this.checkbox.onChange(keyboard => {
|
|
@@ -197,7 +200,7 @@ export class TriStateCheckbox extends BaseCheckbox {
|
|
|
197
200
|
isChecked: _state === true,
|
|
198
201
|
icon,
|
|
199
202
|
actionClassName: Checkbox.CLASS_NAME,
|
|
200
|
-
|
|
203
|
+
hoverLifecycleOptions: styles.hoverLifecycleOptions,
|
|
201
204
|
...unthemedToggleStyles
|
|
202
205
|
});
|
|
203
206
|
super(checkbox, checkbox.domNode, styles);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["file:///mnt/vss/_work/1/s/dependencies/vscode/out-editor-src/vs/base/browser/ui/toggle/toggle.ts","vs/base/browser/ui/toggle/toggle.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AACtD,OAAO,EAAE,OAAO,EAAS,MAAM,0BAA0B,CAAC;AAE1D,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAIzD,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAC3E,OAAO,EAAE,MAAM,EAAE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ACrB,KAAK,IAAI;gBACR,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;gBACrC,MAAM;YACP,KAAK,SAAS;gBACb,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;gBACpC,MAAM;YACP,KAAK,KAAK;gBACT,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;gBACjC,MAAM;QACR,CAAC;QACD,KAAK,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAC5B,CAAC;CACD","file":"toggle.js","sourceRoot":"file:///mnt/vss/_work/1/s/dependencies/vscode/out-editor-src","sourcesContent":["\nimport { Codicon } from '../../../common/codicons.js';\nimport { Emitter, Event } from '../../../common/event.js';\nimport { KeyCode } from '../../../common/keyCodes.js';\nimport { ThemeIcon } from '../../../common/themables.js';\nimport { IKeyboardEvent } from '../../keyboardEvent.js';\nimport { IManagedHover } from '../hover/hover.js';\nimport { IHoverDelegate } from '../hover/hoverDelegate.js';\nimport { getBaseLayerHoverDelegate } from '../hover/hoverDelegate2.js';\nimport { getDefaultHoverDelegate } from '../hover/hoverDelegateFactory.js';\nimport { Widget } from '../widget.js';\nimport './toggle.css';\n\nexport interface IToggleOpts extends IToggleStyles {\n\treadonly actionClassName?: string;\n\treadonly icon?: ThemeIcon;\n\treadonly title: string;\n\treadonly isChecked: boolean;\n\treadonly notFocusable?: boolean;\n\treadonly hoverDelegate?: IHoverDelegate;\n}\n\nexport interface IToggleStyles {\n\treadonly inputActiveOptionBorder: string | undefined;\n\treadonly inputActiveOptionForeground: string | undefined;\n\treadonly inputActiveOptionBackground: string | undefined;\n}\n\nexport interface ICheckboxStyles {\n\treadonly checkboxBackground: string | undefined;\n\treadonly checkboxBorder: string | undefined;\n\treadonly checkboxForeground: string | undefined;\n\treadonly checkboxDisabledBackground: string | undefined;\n\treadonly checkboxDisabledForeground: string | undefined;\n\treadonly size?: number;\n\treadonly hoverDelegate?: IHoverDelegate;\n}\n\nexport const unthemedToggleStyles = {\n\tinputActiveOptionBorder: '#007ACC00',\n\tinputActiveOptionForeground: '#FFFFFF',\n\tinputActiveOptionBackground: '#0E639C50'\n};\n\nexport class Toggle extends Widget {\n\n\tprivate readonly _onChange = this._register(new Emitter<boolean>());\n\tget onChange(): Event<boolean /* via keyboard */> { return this._onChange.event; }\n\n\tprivate readonly _onKeyDown = this._register(new Emitter<IKeyboardEvent>());\n\tget onKeyDown(): Event<IKeyboardEvent> { return this._onKeyDown.event; }\n\n\tprivate readonly _opts: IToggleOpts;\n\tprivate _icon: ThemeIcon | undefined;\n\treadonly domNode: HTMLElement;\n\n\tprivate _checked: boolean;\n\tprivate _hover: IManagedHover;\n\n\tconstructor(opts: IToggleOpts) {\n\t\tsuper();\n\n\t\tthis._opts = opts;\n\t\tthis._checked = this._opts.isChecked;\n\n\t\tconst classes = ['monaco-custom-toggle'];\n\t\tif (this._opts.icon) {\n\t\t\tthis._icon = this._opts.icon;\n\t\t\tclasses.push(...ThemeIcon.asClassNameArray(this._icon));\n\t\t}\n\t\tif (this._opts.actionClassName) {\n\t\t\tclasses.push(...this._opts.actionClassName.split(' '));\n\t\t}\n\t\tif (this._checked) {\n\t\t\tclasses.push('checked');\n\t\t}\n\n\t\tthis.domNode = document.createElement('div');\n\t\tthis._hover = this._register(getBaseLayerHoverDelegate().setupManagedHover(opts.hoverDelegate ?? getDefaultHoverDelegate('mouse'), this.domNode, this._opts.title));\n\t\tthis.domNode.classList.add(...classes);\n\t\tif (!this._opts.notFocusable) {\n\t\t\tthis.domNode.tabIndex = 0;\n\t\t}\n\t\tthis.domNode.setAttribute('role', 'checkbox');\n\t\tthis.domNode.setAttribute('aria-checked', String(this._checked));\n\t\tthis.domNode.setAttribute('aria-label', this._opts.title);\n\n\t\tthis.applyStyles();\n\n\t\tthis.onclick(this.domNode, (ev) => {\n\t\t\tif (this.enabled) {\n\t\t\t\tthis.checked = !this._checked;\n\t\t\t\tthis._onChange.fire(false);\n\t\t\t\tev.preventDefault();\n\t\t\t}\n\t\t});\n\n\t\tthis._register(this.ignoreGesture(this.domNode));\n\n\t\tthis.onkeydown(this.domNode, (keyboardEvent) => {\n\t\t\tif (!this.enabled) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (keyboardEvent.keyCode === KeyCode.Space || keyboardEvent.keyCode === KeyCode.Enter) {\n\t\t\t\tthis.checked = !this._checked;\n\t\t\t\tthis._onChange.fire(true);\n\t\t\t\tkeyboardEvent.preventDefault();\n\t\t\t\tkeyboardEvent.stopPropagation();\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthis._onKeyDown.fire(keyboardEvent);\n\t\t});\n\t}\n\n\tget enabled(): boolean {\n\t\treturn this.domNode.getAttribute('aria-disabled') !== 'true';\n\t}\n\n\tfocus(): void {\n\t\tthis.domNode.focus();\n\t}\n\n\tget checked(): boolean {\n\t\treturn this._checked;\n\t}\n\n\tset checked(newIsChecked: boolean) {\n\t\tthis._checked = newIsChecked;\n\n\t\tthis.domNode.setAttribute('aria-checked', String(this._checked));\n\t\tthis.domNode.classList.toggle('checked', this._checked);\n\n\t\tthis.applyStyles();\n\t}\n\n\tsetIcon(icon: ThemeIcon | undefined): void {\n\t\tif (this._icon) {\n\t\t\tthis.domNode.classList.remove(...ThemeIcon.asClassNameArray(this._icon));\n\t\t}\n\t\tthis._icon = icon;\n\t\tif (this._icon) {\n\t\t\tthis.domNode.classList.add(...ThemeIcon.asClassNameArray(this._icon));\n\t\t}\n\t}\n\n\twidth(): number {\n\t\treturn 2 /*margin left*/ + 2 /*border*/ + 2 /*padding*/ + 16 /* icon width */;\n\t}\n\n\tprotected applyStyles(): void {\n\t\tif (this.domNode) {\n\t\t\tthis.domNode.style.borderColor = (this._checked && this._opts.inputActiveOptionBorder) || '';\n\t\t\tthis.domNode.style.color = (this._checked && this._opts.inputActiveOptionForeground) || 'inherit';\n\t\t\tthis.domNode.style.backgroundColor = (this._checked && this._opts.inputActiveOptionBackground) || '';\n\t\t}\n\t}\n\n\tenable(): void {\n\t\tthis.domNode.setAttribute('aria-disabled', String(false));\n\t\tthis.domNode.classList.remove('disabled');\n\t}\n\n\tdisable(): void {\n\t\tthis.domNode.setAttribute('aria-disabled', String(true));\n\t\tthis.domNode.classList.add('disabled');\n\t}\n\n\tsetTitle(newTitle: string): void {\n\t\tthis._hover.update(newTitle);\n\t\tthis.domNode.setAttribute('aria-label', newTitle);\n\t}\n\n\tset visible(visible: boolean) {\n\t\tthis.domNode.style.display = visible ? '' : 'none';\n\t}\n\n\tget visible() {\n\t\treturn this.domNode.style.display !== 'none';\n\t}\n}\n\n\nabstract class BaseCheckbox extends Widget {\n\tstatic readonly CLASS_NAME = 'monaco-checkbox';\n\n\tprotected readonly _onChange = this._register(new Emitter<boolean>());\n\treadonly onChange: Event<boolean /* via keyboard */> = this._onChange.event;\n\n\tconstructor(\n\t\tprotected readonly checkbox: Toggle,\n\t\treadonly domNode: HTMLElement,\n\t\tprotected readonly styles: ICheckboxStyles\n\t) {\n\t\tsuper();\n\n\t\tthis.applyStyles();\n\t}\n\n\tget enabled(): boolean {\n\t\treturn this.checkbox.enabled;\n\t}\n\n\tenable(): void {\n\t\tthis.checkbox.enable();\n\t\tthis.applyStyles(true);\n\t}\n\n\tdisable(): void {\n\t\tthis.checkbox.disable();\n\t\tthis.applyStyles(false);\n\t}\n\n\tsetTitle(newTitle: string): void {\n\t\tthis.checkbox.setTitle(newTitle);\n\t}\n\n\tprotected applyStyles(enabled = this.enabled): void {\n\t\tthis.domNode.style.color = (enabled ? this.styles.checkboxForeground : this.styles.checkboxDisabledForeground) || '';\n\t\tthis.domNode.style.backgroundColor = (enabled ? this.styles.checkboxBackground : this.styles.checkboxDisabledBackground) || '';\n\t\tthis.domNode.style.borderColor = (enabled ? this.styles.checkboxBorder : this.styles.checkboxDisabledBackground) || '';\n\n\t\tconst size = this.styles.size || 18;\n\t\tthis.domNode.style.width =\n\t\t\tthis.domNode.style.height =\n\t\t\tthis.domNode.style.fontSize = `${size}px`;\n\t\tthis.domNode.style.fontSize = `${size - 2}px`;\n\t}\n}\n\nexport class Checkbox extends BaseCheckbox {\n\tconstructor(title: string, isChecked: boolean, styles: ICheckboxStyles) {\n\t\tconst toggle = new Toggle({ title, isChecked, icon: Codicon.check, actionClassName: BaseCheckbox.CLASS_NAME, hoverDelegate: styles.hoverDelegate, ...unthemedToggleStyles });\n\t\tsuper(toggle, toggle.domNode, styles);\n\n\t\tthis._register(toggle);\n\t\tthis._register(this.checkbox.onChange(keyboard => {\n\t\t\tthis.applyStyles();\n\t\t\tthis._onChange.fire(keyboard);\n\t\t}));\n\t}\n\n\tget checked(): boolean {\n\t\treturn this.checkbox.checked;\n\t}\n\n\tset checked(newIsChecked: boolean) {\n\t\tthis.checkbox.checked = newIsChecked;\n\t\tthis.applyStyles();\n\t}\n\n\tprotected override applyStyles(enabled?: boolean): void {\n\t\tif (this.checkbox.checked) {\n\t\t\tthis.checkbox.setIcon(Codicon.check);\n\t\t} else {\n\t\t\tthis.checkbox.setIcon(undefined);\n\t\t}\n\t\tsuper.applyStyles(enabled);\n\t}\n}\n\nexport class TriStateCheckbox extends BaseCheckbox {\n\tconstructor(\n\t\ttitle: string,\n\t\tprivate _state: boolean | 'partial',\n\t\tstyles: ICheckboxStyles\n\t) {\n\t\tlet icon: ThemeIcon | undefined;\n\t\tswitch (_state) {\n\t\t\tcase true:\n\t\t\t\ticon = Codicon.check;\n\t\t\t\tbreak;\n\t\t\tcase 'partial':\n\t\t\t\ticon = Codicon.dash;\n\t\t\t\tbreak;\n\t\t\tcase false:\n\t\t\t\ticon = undefined;\n\t\t\t\tbreak;\n\t\t}\n\t\tconst checkbox = new Toggle({\n\t\t\ttitle,\n\t\t\tisChecked: _state === true,\n\t\t\ticon,\n\t\t\tactionClassName: Checkbox.CLASS_NAME,\n\t\t\thoverDelegate: styles.hoverDelegate,\n\t\t\t...unthemedToggleStyles\n\t\t});\n\t\tsuper(\n\t\t\tcheckbox,\n\t\t\tcheckbox.domNode,\n\t\t\tstyles\n\t\t);\n\n\t\tthis._register(checkbox);\n\t\tthis._register(this.checkbox.onChange(keyboard => {\n\t\t\tthis._state = this.checkbox.checked;\n\t\t\tthis.applyStyles();\n\t\t\tthis._onChange.fire(keyboard);\n\t\t}));\n\t}\n\n\tget checked(): boolean | 'partial' {\n\t\treturn this._state;\n\t}\n\n\tset checked(newState: boolean | 'partial') {\n\t\tif (this._state !== newState) {\n\t\t\tthis._state = newState;\n\t\t\tthis.checkbox.checked = newState === true;\n\t\t\tthis.applyStyles();\n\t\t}\n\t}\n\n\tprotected override applyStyles(enabled?: boolean): void {\n\t\tswitch (this._state) {\n\t\t\tcase true:\n\t\t\t\tthis.checkbox.setIcon(Codicon.check);\n\t\t\t\tbreak;\n\t\t\tcase 'partial':\n\t\t\t\tthis.checkbox.setIcon(Codicon.dash);\n\t\t\t\tbreak;\n\t\t\tcase false:\n\t\t\t\tthis.checkbox.setIcon(undefined);\n\t\t\t\tbreak;\n\t\t}\n\t\tsuper.applyStyles(enabled);\n\t}\n}\n","\nimport { Codicon } from '../../../common/codicons.js';\nimport { Emitter, Event } from '../../../common/event.js';\nimport { KeyCode } from '../../../common/keyCodes.js';\nimport { ThemeIcon } from '../../../common/themables.js';\nimport { IKeyboardEvent } from '../../keyboardEvent.js';\nimport { IManagedHover } from '../hover/hover.js';\nimport { IHoverDelegate } from '../hover/hoverDelegate.js';\nimport { getBaseLayerHoverDelegate } from '../hover/hoverDelegate2.js';\nimport { getDefaultHoverDelegate } from '../hover/hoverDelegateFactory.js';\nimport { Widget } from '../widget.js';\nimport './toggle.css';\n\nexport interface IToggleOpts extends IToggleStyles {\n\treadonly actionClassName?: string;\n\treadonly icon?: ThemeIcon;\n\treadonly title: string;\n\treadonly isChecked: boolean;\n\treadonly notFocusable?: boolean;\n\treadonly hoverDelegate?: IHoverDelegate;\n}\n\nexport interface IToggleStyles {\n\treadonly inputActiveOptionBorder: string | undefined;\n\treadonly inputActiveOptionForeground: string | undefined;\n\treadonly inputActiveOptionBackground: string | undefined;\n}\n\nexport interface ICheckboxStyles {\n\treadonly checkboxBackground: string | undefined;\n\treadonly checkboxBorder: string | undefined;\n\treadonly checkboxForeground: string | undefined;\n\treadonly checkboxDisabledBackground: string | undefined;\n\treadonly checkboxDisabledForeground: string | undefined;\n\treadonly size?: number;\n\treadonly hoverDelegate?: IHoverDelegate;\n}\n\nexport const unthemedToggleStyles = {\n\tinputActiveOptionBorder: '#007ACC00',\n\tinputActiveOptionForeground: '#FFFFFF',\n\tinputActiveOptionBackground: '#0E639C50'\n};\n\nexport class Toggle extends Widget {\n\n\tprivate readonly _onChange = this._register(new Emitter<boolean>());\n\tget onChange(): Event<boolean /* via keyboard */> { return this._onChange.event; }\n\n\tprivate readonly _onKeyDown = this._register(new Emitter<IKeyboardEvent>());\n\tget onKeyDown(): Event<IKeyboardEvent> { return this._onKeyDown.event; }\n\n\tprivate readonly _opts: IToggleOpts;\n\tprivate _icon: ThemeIcon | undefined;\n\treadonly domNode: HTMLElement;\n\n\tprivate _checked: boolean;\n\tprivate _hover: IManagedHover;\n\n\tconstructor(opts: IToggleOpts) {\n\t\tsuper();\n\n\t\tthis._opts = opts;\n\t\tthis._checked = this._opts.isChecked;\n\n\t\tconst classes = ['monaco-custom-toggle'];\n\t\tif (this._opts.icon) {\n\t\t\tthis._icon = this._opts.icon;\n\t\t\tclasses.push(...ThemeIcon.asClassNameArray(this._icon));\n\t\t}\n\t\tif (this._opts.actionClassName) {\n\t\t\tclasses.push(...this._opts.actionClassName.split(' '));\n\t\t}\n\t\tif (this._checked) {\n\t\t\tclasses.push('checked');\n\t\t}\n\n\t\tthis.domNode = document.createElement('div');\n\t\tthis._hover = this._register(getBaseLayerHoverDelegate().setupManagedHover(opts.hoverDelegate ?? getDefaultHoverDelegate('mouse'), this.domNode, this._opts.title));\n\t\tthis.domNode.classList.add(...classes);\n\t\tif (!this._opts.notFocusable) {\n\t\t\tthis.domNode.tabIndex = 0;\n\t\t}\n\t\tthis.domNode.setAttribute('role', 'checkbox');\n\t\tthis.domNode.setAttribute('aria-checked', String(this._checked));\n\t\tthis.domNode.setAttribute('aria-label', this._opts.title);\n\n\t\tthis.applyStyles();\n\n\t\tthis.onclick(this.domNode, (ev) => {\n\t\t\tif (this.enabled) {\n\t\t\t\tthis.checked = !this._checked;\n\t\t\t\tthis._onChange.fire(false);\n\t\t\t\tev.preventDefault();\n\t\t\t}\n\t\t});\n\n\t\tthis._register(this.ignoreGesture(this.domNode));\n\n\t\tthis.onkeydown(this.domNode, (keyboardEvent) => {\n\t\t\tif (!this.enabled) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (keyboardEvent.keyCode === KeyCode.Space || keyboardEvent.keyCode === KeyCode.Enter) {\n\t\t\t\tthis.checked = !this._checked;\n\t\t\t\tthis._onChange.fire(true);\n\t\t\t\tkeyboardEvent.preventDefault();\n\t\t\t\tkeyboardEvent.stopPropagation();\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthis._onKeyDown.fire(keyboardEvent);\n\t\t});\n\t}\n\n\tget enabled(): boolean {\n\t\treturn this.domNode.getAttribute('aria-disabled') !== 'true';\n\t}\n\n\tfocus(): void {\n\t\tthis.domNode.focus();\n\t}\n\n\tget checked(): boolean {\n\t\treturn this._checked;\n\t}\n\n\tset checked(newIsChecked: boolean) {\n\t\tthis._checked = newIsChecked;\n\n\t\tthis.domNode.setAttribute('aria-checked', String(this._checked));\n\t\tthis.domNode.classList.toggle('checked', this._checked);\n\n\t\tthis.applyStyles();\n\t}\n\n\tsetIcon(icon: ThemeIcon | undefined): void {\n\t\tif (this._icon) {\n\t\t\tthis.domNode.classList.remove(...ThemeIcon.asClassNameArray(this._icon));\n\t\t}\n\t\tthis._icon = icon;\n\t\tif (this._icon) {\n\t\t\tthis.domNode.classList.add(...ThemeIcon.asClassNameArray(this._icon));\n\t\t}\n\t}\n\n\twidth(): number {\n\t\treturn 2 /*margin left*/ + 2 /*border*/ + 2 /*padding*/ + 16 /* icon width */;\n\t}\n\n\tprotected applyStyles(): void {\n\t\tif (this.domNode) {\n\t\t\tthis.domNode.style.borderColor = (this._checked && this._opts.inputActiveOptionBorder) || '';\n\t\t\tthis.domNode.style.color = (this._checked && this._opts.inputActiveOptionForeground) || 'inherit';\n\t\t\tthis.domNode.style.backgroundColor = (this._checked && this._opts.inputActiveOptionBackground) || '';\n\t\t}\n\t}\n\n\tenable(): void {\n\t\tthis.domNode.setAttribute('aria-disabled', String(false));\n\t\tthis.domNode.classList.remove('disabled');\n\t}\n\n\tdisable(): void {\n\t\tthis.domNode.setAttribute('aria-disabled', String(true));\n\t\tthis.domNode.classList.add('disabled');\n\t}\n\n\tsetTitle(newTitle: string): void {\n\t\tthis._hover.update(newTitle);\n\t\tthis.domNode.setAttribute('aria-label', newTitle);\n\t}\n\n\tset visible(visible: boolean) {\n\t\tthis.domNode.style.display = visible ? '' : 'none';\n\t}\n\n\tget visible() {\n\t\treturn this.domNode.style.display !== 'none';\n\t}\n}\n\n\nabstract class BaseCheckbox extends Widget {\n\tstatic readonly CLASS_NAME = 'monaco-checkbox';\n\n\tprotected readonly _onChange = this._register(new Emitter<boolean>());\n\treadonly onChange: Event<boolean /* via keyboard */> = this._onChange.event;\n\n\tconstructor(\n\t\tprotected readonly checkbox: Toggle,\n\t\treadonly domNode: HTMLElement,\n\t\tprotected readonly styles: ICheckboxStyles\n\t) {\n\t\tsuper();\n\n\t\tthis.applyStyles();\n\t}\n\n\tget enabled(): boolean {\n\t\treturn this.checkbox.enabled;\n\t}\n\n\tenable(): void {\n\t\tthis.checkbox.enable();\n\t\tthis.applyStyles(true);\n\t}\n\n\tdisable(): void {\n\t\tthis.checkbox.disable();\n\t\tthis.applyStyles(false);\n\t}\n\n\tsetTitle(newTitle: string): void {\n\t\tthis.checkbox.setTitle(newTitle);\n\t}\n\n\tprotected applyStyles(enabled = this.enabled): void {\n\t\tthis.domNode.style.color = (enabled ? this.styles.checkboxForeground : this.styles.checkboxDisabledForeground) || '';\n\t\tthis.domNode.style.backgroundColor = (enabled ? this.styles.checkboxBackground : this.styles.checkboxDisabledBackground) || '';\n\t\tthis.domNode.style.borderColor = (enabled ? this.styles.checkboxBorder : this.styles.checkboxDisabledBackground) || '';\n\n\t\tconst size = this.styles.size || 18;\n\t\tthis.domNode.style.width =\n\t\t\tthis.domNode.style.height =\n\t\t\tthis.domNode.style.fontSize = `${size}px`;\n\t\tthis.domNode.style.fontSize = `${size - 2}px`;\n\t}\n}\n\nexport class Checkbox extends BaseCheckbox {\n\tconstructor(title: string, isChecked: boolean, styles: ICheckboxStyles) {\n\t\tconst toggle = new Toggle({ title, isChecked, icon: Codicon.check, actionClassName: BaseCheckbox.CLASS_NAME, hoverDelegate: styles.hoverDelegate, ...unthemedToggleStyles });\n\t\tsuper(toggle, toggle.domNode, styles);\n\n\t\tthis._register(toggle);\n\t\tthis._register(this.checkbox.onChange(keyboard => {\n\t\t\tthis.applyStyles();\n\t\t\tthis._onChange.fire(keyboard);\n\t\t}));\n\t}\n\n\tget checked(): boolean {\n\t\treturn this.checkbox.checked;\n\t}\n\n\tset checked(newIsChecked: boolean) {\n\t\tthis.checkbox.checked = newIsChecked;\n\t\tthis.applyStyles();\n\t}\n\n\tprotected override applyStyles(enabled?: boolean): void {\n\t\tif (this.checkbox.checked) {\n\t\t\tthis.checkbox.setIcon(Codicon.check);\n\t\t} else {\n\t\t\tthis.checkbox.setIcon(undefined);\n\t\t}\n\t\tsuper.applyStyles(enabled);\n\t}\n}\n\nexport class TriStateCheckbox extends BaseCheckbox {\n\tconstructor(\n\t\ttitle: string,\n\t\tprivate _state: boolean | 'partial',\n\t\tstyles: ICheckboxStyles\n\t) {\n\t\tlet icon: ThemeIcon | undefined;\n\t\tswitch (_state) {\n\t\t\tcase true:\n\t\t\t\ticon = Codicon.check;\n\t\t\t\tbreak;\n\t\t\tcase 'partial':\n\t\t\t\ticon = Codicon.dash;\n\t\t\t\tbreak;\n\t\t\tcase false:\n\t\t\t\ticon = undefined;\n\t\t\t\tbreak;\n\t\t}\n\t\tconst checkbox = new Toggle({\n\t\t\ttitle,\n\t\t\tisChecked: _state === true,\n\t\t\ticon,\n\t\t\tactionClassName: Checkbox.CLASS_NAME,\n\t\t\thoverDelegate: styles.hoverDelegate,\n\t\t\t...unthemedToggleStyles\n\t\t});\n\t\tsuper(\n\t\t\tcheckbox,\n\t\t\tcheckbox.domNode,\n\t\t\tstyles\n\t\t);\n\n\t\tthis._register(checkbox);\n\t\tthis._register(this.checkbox.onChange(keyboard => {\n\t\t\tthis._state = this.checkbox.checked;\n\t\t\tthis.applyStyles();\n\t\t\tthis._onChange.fire(keyboard);\n\t\t}));\n\t}\n\n\tget checked(): boolean | 'partial' {\n\t\treturn this._state;\n\t}\n\n\tset checked(newState: boolean | 'partial') {\n\t\tif (this._state !== newState) {\n\t\t\tthis._state = newState;\n\t\t\tthis.checkbox.checked = newState === true;\n\t\t\tthis.applyStyles();\n\t\t}\n\t}\n\n\tprotected override applyStyles(enabled?: boolean): void {\n\t\tswitch (this._state) {\n\t\t\tcase true:\n\t\t\t\tthis.checkbox.setIcon(Codicon.check);\n\t\t\t\tbreak;\n\t\t\tcase 'partial':\n\t\t\t\tthis.checkbox.setIcon(Codicon.dash);\n\t\t\t\tbreak;\n\t\t\tcase false:\n\t\t\t\tthis.checkbox.setIcon(undefined);\n\t\t\t\tbreak;\n\t\t}\n\t\tsuper.applyStyles(enabled);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["file:///mnt/vss/_work/1/s/dependencies/vscode/out-editor-src/vs/base/browser/ui/toggle/toggle.ts","vs/base/browser/ui/toggle/toggle.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AACtD,OAAO,EAAE,OAAO,EAAS,MAAM,0BAA0B,CAAC;AAE1D,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAGzD,OAAO,EAAE,yBAAyB,EAAE,MAAM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AAC;QACpB,CAAC;IACF,CAAC;IAEkB,WAAW,CAAC,OAAiB;QAC/C,QAAQ,IAAI,CAAC,MAAM,EAAE,CAAC;YACrB,KAAK,IAAI;gBACR,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;gBACrC,MAAM;YACP,KAAK,SAAS;gBACb,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;gBACpC,MAAM;YACP,KAAK,KAAK;gBACT,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;gBACjC,MAAM;QACR,CAAC;QACD,KAAK,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAC5B,CAAC;CACD","file":"toggle.js","sourceRoot":"file:///mnt/vss/_work/1/s/dependencies/vscode/out-editor-src","sourcesContent":["\nimport { Codicon } from '../../../common/codicons.js';\nimport { Emitter, Event } from '../../../common/event.js';\nimport { KeyCode } from '../../../common/keyCodes.js';\nimport { ThemeIcon } from '../../../common/themables.js';\nimport { IKeyboardEvent } from '../../keyboardEvent.js';\nimport { HoverStyle, IHoverLifecycleOptions } from '../hover/hover.js';\nimport { getBaseLayerHoverDelegate } from '../hover/hoverDelegate2.js';\nimport { Widget } from '../widget.js';\nimport './toggle.css';\n\nexport interface IToggleOpts extends IToggleStyles {\n\treadonly actionClassName?: string;\n\treadonly icon?: ThemeIcon;\n\treadonly title: string;\n\treadonly isChecked: boolean;\n\treadonly notFocusable?: boolean;\n\treadonly hoverLifecycleOptions?: IHoverLifecycleOptions;\n}\n\nexport interface IToggleStyles {\n\treadonly inputActiveOptionBorder: string | undefined;\n\treadonly inputActiveOptionForeground: string | undefined;\n\treadonly inputActiveOptionBackground: string | undefined;\n}\n\nexport interface ICheckboxStyles {\n\treadonly checkboxBackground: string | undefined;\n\treadonly checkboxBorder: string | undefined;\n\treadonly checkboxForeground: string | undefined;\n\treadonly checkboxDisabledBackground: string | undefined;\n\treadonly checkboxDisabledForeground: string | undefined;\n\treadonly size?: number;\n\treadonly hoverLifecycleOptions?: IHoverLifecycleOptions;\n}\n\nexport const unthemedToggleStyles = {\n\tinputActiveOptionBorder: '#007ACC00',\n\tinputActiveOptionForeground: '#FFFFFF',\n\tinputActiveOptionBackground: '#0E639C50'\n};\n\nexport class Toggle extends Widget {\n\n\tprivate readonly _onChange = this._register(new Emitter<boolean>());\n\tget onChange(): Event<boolean /* via keyboard */> { return this._onChange.event; }\n\n\tprivate readonly _onKeyDown = this._register(new Emitter<IKeyboardEvent>());\n\tget onKeyDown(): Event<IKeyboardEvent> { return this._onKeyDown.event; }\n\n\tprivate readonly _opts: IToggleOpts;\n\tprivate _title: string;\n\tprivate _icon: ThemeIcon | undefined;\n\treadonly domNode: HTMLElement;\n\n\tprivate _checked: boolean;\n\n\tconstructor(opts: IToggleOpts) {\n\t\tsuper();\n\n\t\tthis._opts = opts;\n\t\tthis._title = this._opts.title;\n\t\tthis._checked = this._opts.isChecked;\n\n\t\tconst classes = ['monaco-custom-toggle'];\n\t\tif (this._opts.icon) {\n\t\t\tthis._icon = this._opts.icon;\n\t\t\tclasses.push(...ThemeIcon.asClassNameArray(this._icon));\n\t\t}\n\t\tif (this._opts.actionClassName) {\n\t\t\tclasses.push(...this._opts.actionClassName.split(' '));\n\t\t}\n\t\tif (this._checked) {\n\t\t\tclasses.push('checked');\n\t\t}\n\n\t\tthis.domNode = document.createElement('div');\n\t\tthis._register(getBaseLayerHoverDelegate().setupDelayedHover(this.domNode, () => ({\n\t\t\tcontent: this._title,\n\t\t\tstyle: HoverStyle.Pointer,\n\t\t}), this._opts.hoverLifecycleOptions));\n\t\tthis.domNode.classList.add(...classes);\n\t\tif (!this._opts.notFocusable) {\n\t\t\tthis.domNode.tabIndex = 0;\n\t\t}\n\t\tthis.domNode.setAttribute('role', 'checkbox');\n\t\tthis.domNode.setAttribute('aria-checked', String(this._checked));\n\n\t\tthis.setTitle(this._opts.title);\n\t\tthis.applyStyles();\n\n\t\tthis.onclick(this.domNode, (ev) => {\n\t\t\tif (this.enabled) {\n\t\t\t\tthis.checked = !this._checked;\n\t\t\t\tthis._onChange.fire(false);\n\t\t\t\tev.preventDefault();\n\t\t\t}\n\t\t});\n\n\t\tthis._register(this.ignoreGesture(this.domNode));\n\n\t\tthis.onkeydown(this.domNode, (keyboardEvent) => {\n\t\t\tif (!this.enabled) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (keyboardEvent.keyCode === KeyCode.Space || keyboardEvent.keyCode === KeyCode.Enter) {\n\t\t\t\tthis.checked = !this._checked;\n\t\t\t\tthis._onChange.fire(true);\n\t\t\t\tkeyboardEvent.preventDefault();\n\t\t\t\tkeyboardEvent.stopPropagation();\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthis._onKeyDown.fire(keyboardEvent);\n\t\t});\n\t}\n\n\tget enabled(): boolean {\n\t\treturn this.domNode.getAttribute('aria-disabled') !== 'true';\n\t}\n\n\tfocus(): void {\n\t\tthis.domNode.focus();\n\t}\n\n\tget checked(): boolean {\n\t\treturn this._checked;\n\t}\n\n\tset checked(newIsChecked: boolean) {\n\t\tthis._checked = newIsChecked;\n\n\t\tthis.domNode.setAttribute('aria-checked', String(this._checked));\n\t\tthis.domNode.classList.toggle('checked', this._checked);\n\n\t\tthis.applyStyles();\n\t}\n\n\tsetIcon(icon: ThemeIcon | undefined): void {\n\t\tif (this._icon) {\n\t\t\tthis.domNode.classList.remove(...ThemeIcon.asClassNameArray(this._icon));\n\t\t}\n\t\tthis._icon = icon;\n\t\tif (this._icon) {\n\t\t\tthis.domNode.classList.add(...ThemeIcon.asClassNameArray(this._icon));\n\t\t}\n\t}\n\n\twidth(): number {\n\t\treturn 2 /*margin left*/ + 2 /*border*/ + 2 /*padding*/ + 16 /* icon width */;\n\t}\n\n\tprotected applyStyles(): void {\n\t\tif (this.domNode) {\n\t\t\tthis.domNode.style.borderColor = (this._checked && this._opts.inputActiveOptionBorder) || '';\n\t\t\tthis.domNode.style.color = (this._checked && this._opts.inputActiveOptionForeground) || 'inherit';\n\t\t\tthis.domNode.style.backgroundColor = (this._checked && this._opts.inputActiveOptionBackground) || '';\n\t\t}\n\t}\n\n\tenable(): void {\n\t\tthis.domNode.setAttribute('aria-disabled', String(false));\n\t\tthis.domNode.classList.remove('disabled');\n\t}\n\n\tdisable(): void {\n\t\tthis.domNode.setAttribute('aria-disabled', String(true));\n\t\tthis.domNode.classList.add('disabled');\n\t}\n\n\tsetTitle(newTitle: string): void {\n\t\tthis._title = newTitle;\n\t\tthis.domNode.setAttribute('aria-label', newTitle);\n\t}\n\n\tset visible(visible: boolean) {\n\t\tthis.domNode.style.display = visible ? '' : 'none';\n\t}\n\n\tget visible() {\n\t\treturn this.domNode.style.display !== 'none';\n\t}\n}\n\n\nabstract class BaseCheckbox extends Widget {\n\tstatic readonly CLASS_NAME = 'monaco-checkbox';\n\n\tprotected readonly _onChange = this._register(new Emitter<boolean>());\n\treadonly onChange: Event<boolean /* via keyboard */> = this._onChange.event;\n\n\tconstructor(\n\t\tprotected readonly checkbox: Toggle,\n\t\treadonly domNode: HTMLElement,\n\t\tprotected readonly styles: ICheckboxStyles\n\t) {\n\t\tsuper();\n\n\t\tthis.applyStyles();\n\t}\n\n\tget enabled(): boolean {\n\t\treturn this.checkbox.enabled;\n\t}\n\n\tenable(): void {\n\t\tthis.checkbox.enable();\n\t\tthis.applyStyles(true);\n\t}\n\n\tdisable(): void {\n\t\tthis.checkbox.disable();\n\t\tthis.applyStyles(false);\n\t}\n\n\tsetTitle(newTitle: string): void {\n\t\tthis.checkbox.setTitle(newTitle);\n\t}\n\n\tprotected applyStyles(enabled = this.enabled): void {\n\t\tthis.domNode.style.color = (enabled ? this.styles.checkboxForeground : this.styles.checkboxDisabledForeground) || '';\n\t\tthis.domNode.style.backgroundColor = (enabled ? this.styles.checkboxBackground : this.styles.checkboxDisabledBackground) || '';\n\t\tthis.domNode.style.borderColor = (enabled ? this.styles.checkboxBorder : this.styles.checkboxDisabledBackground) || '';\n\n\t\tconst size = this.styles.size || 18;\n\t\tthis.domNode.style.width =\n\t\t\tthis.domNode.style.height =\n\t\t\tthis.domNode.style.fontSize = `${size}px`;\n\t\tthis.domNode.style.fontSize = `${size - 2}px`;\n\t}\n}\n\nexport class Checkbox extends BaseCheckbox {\n\tconstructor(title: string, isChecked: boolean, styles: ICheckboxStyles) {\n\t\tconst toggle = new Toggle({ title, isChecked, icon: Codicon.check, actionClassName: BaseCheckbox.CLASS_NAME, hoverLifecycleOptions: styles.hoverLifecycleOptions, ...unthemedToggleStyles });\n\t\tsuper(toggle, toggle.domNode, styles);\n\n\t\tthis._register(toggle);\n\t\tthis._register(this.checkbox.onChange(keyboard => {\n\t\t\tthis.applyStyles();\n\t\t\tthis._onChange.fire(keyboard);\n\t\t}));\n\t}\n\n\tget checked(): boolean {\n\t\treturn this.checkbox.checked;\n\t}\n\n\tset checked(newIsChecked: boolean) {\n\t\tthis.checkbox.checked = newIsChecked;\n\t\tthis.applyStyles();\n\t}\n\n\tprotected override applyStyles(enabled?: boolean): void {\n\t\tif (this.checkbox.checked) {\n\t\t\tthis.checkbox.setIcon(Codicon.check);\n\t\t} else {\n\t\t\tthis.checkbox.setIcon(undefined);\n\t\t}\n\t\tsuper.applyStyles(enabled);\n\t}\n}\n\nexport class TriStateCheckbox extends BaseCheckbox {\n\tconstructor(\n\t\ttitle: string,\n\t\tprivate _state: boolean | 'partial',\n\t\tstyles: ICheckboxStyles\n\t) {\n\t\tlet icon: ThemeIcon | undefined;\n\t\tswitch (_state) {\n\t\t\tcase true:\n\t\t\t\ticon = Codicon.check;\n\t\t\t\tbreak;\n\t\t\tcase 'partial':\n\t\t\t\ticon = Codicon.dash;\n\t\t\t\tbreak;\n\t\t\tcase false:\n\t\t\t\ticon = undefined;\n\t\t\t\tbreak;\n\t\t}\n\t\tconst checkbox = new Toggle({\n\t\t\ttitle,\n\t\t\tisChecked: _state === true,\n\t\t\ticon,\n\t\t\tactionClassName: Checkbox.CLASS_NAME,\n\t\t\thoverLifecycleOptions: styles.hoverLifecycleOptions,\n\t\t\t...unthemedToggleStyles\n\t\t});\n\t\tsuper(\n\t\t\tcheckbox,\n\t\t\tcheckbox.domNode,\n\t\t\tstyles\n\t\t);\n\n\t\tthis._register(checkbox);\n\t\tthis._register(this.checkbox.onChange(keyboard => {\n\t\t\tthis._state = this.checkbox.checked;\n\t\t\tthis.applyStyles();\n\t\t\tthis._onChange.fire(keyboard);\n\t\t}));\n\t}\n\n\tget checked(): boolean | 'partial' {\n\t\treturn this._state;\n\t}\n\n\tset checked(newState: boolean | 'partial') {\n\t\tif (this._state !== newState) {\n\t\t\tthis._state = newState;\n\t\t\tthis.checkbox.checked = newState === true;\n\t\t\tthis.applyStyles();\n\t\t}\n\t}\n\n\tprotected override applyStyles(enabled?: boolean): void {\n\t\tswitch (this._state) {\n\t\t\tcase true:\n\t\t\t\tthis.checkbox.setIcon(Codicon.check);\n\t\t\t\tbreak;\n\t\t\tcase 'partial':\n\t\t\t\tthis.checkbox.setIcon(Codicon.dash);\n\t\t\t\tbreak;\n\t\t\tcase false:\n\t\t\t\tthis.checkbox.setIcon(undefined);\n\t\t\t\tbreak;\n\t\t}\n\t\tsuper.applyStyles(enabled);\n\t}\n}\n","\nimport { Codicon } from '../../../common/codicons.js';\nimport { Emitter, Event } from '../../../common/event.js';\nimport { KeyCode } from '../../../common/keyCodes.js';\nimport { ThemeIcon } from '../../../common/themables.js';\nimport { IKeyboardEvent } from '../../keyboardEvent.js';\nimport { HoverStyle, IHoverLifecycleOptions } from '../hover/hover.js';\nimport { getBaseLayerHoverDelegate } from '../hover/hoverDelegate2.js';\nimport { Widget } from '../widget.js';\nimport './toggle.css';\n\nexport interface IToggleOpts extends IToggleStyles {\n\treadonly actionClassName?: string;\n\treadonly icon?: ThemeIcon;\n\treadonly title: string;\n\treadonly isChecked: boolean;\n\treadonly notFocusable?: boolean;\n\treadonly hoverLifecycleOptions?: IHoverLifecycleOptions;\n}\n\nexport interface IToggleStyles {\n\treadonly inputActiveOptionBorder: string | undefined;\n\treadonly inputActiveOptionForeground: string | undefined;\n\treadonly inputActiveOptionBackground: string | undefined;\n}\n\nexport interface ICheckboxStyles {\n\treadonly checkboxBackground: string | undefined;\n\treadonly checkboxBorder: string | undefined;\n\treadonly checkboxForeground: string | undefined;\n\treadonly checkboxDisabledBackground: string | undefined;\n\treadonly checkboxDisabledForeground: string | undefined;\n\treadonly size?: number;\n\treadonly hoverLifecycleOptions?: IHoverLifecycleOptions;\n}\n\nexport const unthemedToggleStyles = {\n\tinputActiveOptionBorder: '#007ACC00',\n\tinputActiveOptionForeground: '#FFFFFF',\n\tinputActiveOptionBackground: '#0E639C50'\n};\n\nexport class Toggle extends Widget {\n\n\tprivate readonly _onChange = this._register(new Emitter<boolean>());\n\tget onChange(): Event<boolean /* via keyboard */> { return this._onChange.event; }\n\n\tprivate readonly _onKeyDown = this._register(new Emitter<IKeyboardEvent>());\n\tget onKeyDown(): Event<IKeyboardEvent> { return this._onKeyDown.event; }\n\n\tprivate readonly _opts: IToggleOpts;\n\tprivate _title: string;\n\tprivate _icon: ThemeIcon | undefined;\n\treadonly domNode: HTMLElement;\n\n\tprivate _checked: boolean;\n\n\tconstructor(opts: IToggleOpts) {\n\t\tsuper();\n\n\t\tthis._opts = opts;\n\t\tthis._title = this._opts.title;\n\t\tthis._checked = this._opts.isChecked;\n\n\t\tconst classes = ['monaco-custom-toggle'];\n\t\tif (this._opts.icon) {\n\t\t\tthis._icon = this._opts.icon;\n\t\t\tclasses.push(...ThemeIcon.asClassNameArray(this._icon));\n\t\t}\n\t\tif (this._opts.actionClassName) {\n\t\t\tclasses.push(...this._opts.actionClassName.split(' '));\n\t\t}\n\t\tif (this._checked) {\n\t\t\tclasses.push('checked');\n\t\t}\n\n\t\tthis.domNode = document.createElement('div');\n\t\tthis._register(getBaseLayerHoverDelegate().setupDelayedHover(this.domNode, () => ({\n\t\t\tcontent: this._title,\n\t\t\tstyle: HoverStyle.Pointer,\n\t\t}), this._opts.hoverLifecycleOptions));\n\t\tthis.domNode.classList.add(...classes);\n\t\tif (!this._opts.notFocusable) {\n\t\t\tthis.domNode.tabIndex = 0;\n\t\t}\n\t\tthis.domNode.setAttribute('role', 'checkbox');\n\t\tthis.domNode.setAttribute('aria-checked', String(this._checked));\n\n\t\tthis.setTitle(this._opts.title);\n\t\tthis.applyStyles();\n\n\t\tthis.onclick(this.domNode, (ev) => {\n\t\t\tif (this.enabled) {\n\t\t\t\tthis.checked = !this._checked;\n\t\t\t\tthis._onChange.fire(false);\n\t\t\t\tev.preventDefault();\n\t\t\t}\n\t\t});\n\n\t\tthis._register(this.ignoreGesture(this.domNode));\n\n\t\tthis.onkeydown(this.domNode, (keyboardEvent) => {\n\t\t\tif (!this.enabled) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (keyboardEvent.keyCode === KeyCode.Space || keyboardEvent.keyCode === KeyCode.Enter) {\n\t\t\t\tthis.checked = !this._checked;\n\t\t\t\tthis._onChange.fire(true);\n\t\t\t\tkeyboardEvent.preventDefault();\n\t\t\t\tkeyboardEvent.stopPropagation();\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthis._onKeyDown.fire(keyboardEvent);\n\t\t});\n\t}\n\n\tget enabled(): boolean {\n\t\treturn this.domNode.getAttribute('aria-disabled') !== 'true';\n\t}\n\n\tfocus(): void {\n\t\tthis.domNode.focus();\n\t}\n\n\tget checked(): boolean {\n\t\treturn this._checked;\n\t}\n\n\tset checked(newIsChecked: boolean) {\n\t\tthis._checked = newIsChecked;\n\n\t\tthis.domNode.setAttribute('aria-checked', String(this._checked));\n\t\tthis.domNode.classList.toggle('checked', this._checked);\n\n\t\tthis.applyStyles();\n\t}\n\n\tsetIcon(icon: ThemeIcon | undefined): void {\n\t\tif (this._icon) {\n\t\t\tthis.domNode.classList.remove(...ThemeIcon.asClassNameArray(this._icon));\n\t\t}\n\t\tthis._icon = icon;\n\t\tif (this._icon) {\n\t\t\tthis.domNode.classList.add(...ThemeIcon.asClassNameArray(this._icon));\n\t\t}\n\t}\n\n\twidth(): number {\n\t\treturn 2 /*margin left*/ + 2 /*border*/ + 2 /*padding*/ + 16 /* icon width */;\n\t}\n\n\tprotected applyStyles(): void {\n\t\tif (this.domNode) {\n\t\t\tthis.domNode.style.borderColor = (this._checked && this._opts.inputActiveOptionBorder) || '';\n\t\t\tthis.domNode.style.color = (this._checked && this._opts.inputActiveOptionForeground) || 'inherit';\n\t\t\tthis.domNode.style.backgroundColor = (this._checked && this._opts.inputActiveOptionBackground) || '';\n\t\t}\n\t}\n\n\tenable(): void {\n\t\tthis.domNode.setAttribute('aria-disabled', String(false));\n\t\tthis.domNode.classList.remove('disabled');\n\t}\n\n\tdisable(): void {\n\t\tthis.domNode.setAttribute('aria-disabled', String(true));\n\t\tthis.domNode.classList.add('disabled');\n\t}\n\n\tsetTitle(newTitle: string): void {\n\t\tthis._title = newTitle;\n\t\tthis.domNode.setAttribute('aria-label', newTitle);\n\t}\n\n\tset visible(visible: boolean) {\n\t\tthis.domNode.style.display = visible ? '' : 'none';\n\t}\n\n\tget visible() {\n\t\treturn this.domNode.style.display !== 'none';\n\t}\n}\n\n\nabstract class BaseCheckbox extends Widget {\n\tstatic readonly CLASS_NAME = 'monaco-checkbox';\n\n\tprotected readonly _onChange = this._register(new Emitter<boolean>());\n\treadonly onChange: Event<boolean /* via keyboard */> = this._onChange.event;\n\n\tconstructor(\n\t\tprotected readonly checkbox: Toggle,\n\t\treadonly domNode: HTMLElement,\n\t\tprotected readonly styles: ICheckboxStyles\n\t) {\n\t\tsuper();\n\n\t\tthis.applyStyles();\n\t}\n\n\tget enabled(): boolean {\n\t\treturn this.checkbox.enabled;\n\t}\n\n\tenable(): void {\n\t\tthis.checkbox.enable();\n\t\tthis.applyStyles(true);\n\t}\n\n\tdisable(): void {\n\t\tthis.checkbox.disable();\n\t\tthis.applyStyles(false);\n\t}\n\n\tsetTitle(newTitle: string): void {\n\t\tthis.checkbox.setTitle(newTitle);\n\t}\n\n\tprotected applyStyles(enabled = this.enabled): void {\n\t\tthis.domNode.style.color = (enabled ? this.styles.checkboxForeground : this.styles.checkboxDisabledForeground) || '';\n\t\tthis.domNode.style.backgroundColor = (enabled ? this.styles.checkboxBackground : this.styles.checkboxDisabledBackground) || '';\n\t\tthis.domNode.style.borderColor = (enabled ? this.styles.checkboxBorder : this.styles.checkboxDisabledBackground) || '';\n\n\t\tconst size = this.styles.size || 18;\n\t\tthis.domNode.style.width =\n\t\t\tthis.domNode.style.height =\n\t\t\tthis.domNode.style.fontSize = `${size}px`;\n\t\tthis.domNode.style.fontSize = `${size - 2}px`;\n\t}\n}\n\nexport class Checkbox extends BaseCheckbox {\n\tconstructor(title: string, isChecked: boolean, styles: ICheckboxStyles) {\n\t\tconst toggle = new Toggle({ title, isChecked, icon: Codicon.check, actionClassName: BaseCheckbox.CLASS_NAME, hoverLifecycleOptions: styles.hoverLifecycleOptions, ...unthemedToggleStyles });\n\t\tsuper(toggle, toggle.domNode, styles);\n\n\t\tthis._register(toggle);\n\t\tthis._register(this.checkbox.onChange(keyboard => {\n\t\t\tthis.applyStyles();\n\t\t\tthis._onChange.fire(keyboard);\n\t\t}));\n\t}\n\n\tget checked(): boolean {\n\t\treturn this.checkbox.checked;\n\t}\n\n\tset checked(newIsChecked: boolean) {\n\t\tthis.checkbox.checked = newIsChecked;\n\t\tthis.applyStyles();\n\t}\n\n\tprotected override applyStyles(enabled?: boolean): void {\n\t\tif (this.checkbox.checked) {\n\t\t\tthis.checkbox.setIcon(Codicon.check);\n\t\t} else {\n\t\t\tthis.checkbox.setIcon(undefined);\n\t\t}\n\t\tsuper.applyStyles(enabled);\n\t}\n}\n\nexport class TriStateCheckbox extends BaseCheckbox {\n\tconstructor(\n\t\ttitle: string,\n\t\tprivate _state: boolean | 'partial',\n\t\tstyles: ICheckboxStyles\n\t) {\n\t\tlet icon: ThemeIcon | undefined;\n\t\tswitch (_state) {\n\t\t\tcase true:\n\t\t\t\ticon = Codicon.check;\n\t\t\t\tbreak;\n\t\t\tcase 'partial':\n\t\t\t\ticon = Codicon.dash;\n\t\t\t\tbreak;\n\t\t\tcase false:\n\t\t\t\ticon = undefined;\n\t\t\t\tbreak;\n\t\t}\n\t\tconst checkbox = new Toggle({\n\t\t\ttitle,\n\t\t\tisChecked: _state === true,\n\t\t\ticon,\n\t\t\tactionClassName: Checkbox.CLASS_NAME,\n\t\t\thoverLifecycleOptions: styles.hoverLifecycleOptions,\n\t\t\t...unthemedToggleStyles\n\t\t});\n\t\tsuper(\n\t\t\tcheckbox,\n\t\t\tcheckbox.domNode,\n\t\t\tstyles\n\t\t);\n\n\t\tthis._register(checkbox);\n\t\tthis._register(this.checkbox.onChange(keyboard => {\n\t\t\tthis._state = this.checkbox.checked;\n\t\t\tthis.applyStyles();\n\t\t\tthis._onChange.fire(keyboard);\n\t\t}));\n\t}\n\n\tget checked(): boolean | 'partial' {\n\t\treturn this._state;\n\t}\n\n\tset checked(newState: boolean | 'partial') {\n\t\tif (this._state !== newState) {\n\t\t\tthis._state = newState;\n\t\t\tthis.checkbox.checked = newState === true;\n\t\t\tthis.applyStyles();\n\t\t}\n\t}\n\n\tprotected override applyStyles(enabled?: boolean): void {\n\t\tswitch (this._state) {\n\t\t\tcase true:\n\t\t\t\tthis.checkbox.setIcon(Codicon.check);\n\t\t\t\tbreak;\n\t\t\tcase 'partial':\n\t\t\t\tthis.checkbox.setIcon(Codicon.dash);\n\t\t\t\tbreak;\n\t\t\tcase false:\n\t\t\t\tthis.checkbox.setIcon(undefined);\n\t\t\t\tbreak;\n\t\t}\n\t\tsuper.applyStyles(enabled);\n\t}\n}\n"]}
|
|
@@ -27,7 +27,6 @@ import { Disposable, DisposableStore, dispose, toDisposable } from '../../../com
|
|
|
27
27
|
import { clamp } from '../../../common/numbers.js';
|
|
28
28
|
import './media/tree.css';
|
|
29
29
|
import { localize } from '../../../../nls.js';
|
|
30
|
-
import { createInstantHoverDelegate } from '../hover/hoverDelegateFactory.js';
|
|
31
30
|
import { autorun, constObservable } from '../../../common/observable.js';
|
|
32
31
|
import { alert } from '../aria/aria.js';
|
|
33
32
|
class TreeElementsDragAndDropData extends ElementsDragAndDropData {
|
|
@@ -493,7 +492,7 @@ export class FindFilter {
|
|
|
493
492
|
}
|
|
494
493
|
}
|
|
495
494
|
class TreeFindToggle extends Toggle {
|
|
496
|
-
constructor(contribution, opts,
|
|
495
|
+
constructor(contribution, opts, hoverLifecycleOptions) {
|
|
497
496
|
super({
|
|
498
497
|
icon: contribution.icon,
|
|
499
498
|
title: contribution.title,
|
|
@@ -501,7 +500,7 @@ class TreeFindToggle extends Toggle {
|
|
|
501
500
|
inputActiveOptionBorder: opts.inputActiveOptionBorder,
|
|
502
501
|
inputActiveOptionForeground: opts.inputActiveOptionForeground,
|
|
503
502
|
inputActiveOptionBackground: opts.inputActiveOptionBackground,
|
|
504
|
-
|
|
503
|
+
hoverLifecycleOptions,
|
|
505
504
|
});
|
|
506
505
|
this.id = contribution.id;
|
|
507
506
|
}
|
|
@@ -566,8 +565,9 @@ class FindWidget extends Disposable {
|
|
|
566
565
|
if (styles.listFilterWidgetShadow) {
|
|
567
566
|
this.elements.root.style.boxShadow = `0 0 8px 2px ${styles.listFilterWidgetShadow}`;
|
|
568
567
|
}
|
|
569
|
-
const toggleHoverDelegate = this._register(createInstantHoverDelegate());
|
|
570
|
-
|
|
568
|
+
// const toggleHoverDelegate = this._register(createInstantHoverDelegate());
|
|
569
|
+
const hoverLifecycleOptions = { groupId: 'abstract-tree' };
|
|
570
|
+
this.toggles = toggleContributions.map(contribution => this._register(new TreeFindToggle(contribution, styles.toggleStyles, hoverLifecycleOptions)));
|
|
571
571
|
this.onDidToggleChange = Event.any(...this.toggles.map(toggle => Event.map(toggle.onChange, () => ({ id: toggle.id, isChecked: toggle.checked }))));
|
|
572
572
|
const history = options?.history || [];
|
|
573
573
|
this.findInput = this._register(new FindInput(this.elements.findInput, contextViewProvider, {
|
|
@@ -577,7 +577,8 @@ class FindWidget extends Disposable {
|
|
|
577
577
|
showCommonFindToggles: false,
|
|
578
578
|
inputBoxStyles: styles.inputBoxStyles,
|
|
579
579
|
toggleStyles: styles.toggleStyles,
|
|
580
|
-
history: new Set(history)
|
|
580
|
+
history: new Set(history),
|
|
581
|
+
hoverLifecycleOptions,
|
|
581
582
|
}));
|
|
582
583
|
this.actionbar = this._register(new ActionBar(this.elements.actionbar));
|
|
583
584
|
const emitter = this._register(new DomEmitter(this.findInput.inputBox.inputElement, 'keydown'));
|