import { CdkScrollable, ExtendedScrollToOptions } from '@angular/cdk/scrolling'; import { AfterViewInit, EventEmitter, InjectionToken, Provider, TemplateRef } from '@angular/core'; import { KbqButtonStyles } from '@koobiq/components/button'; import { KbqCodeBlockLocaleConfiguration, KbqComponentColors } from '@koobiq/components/core'; import { KbqCodeBlockFile, KbqTabLinkTemplateContext } from './types'; import * as i0 from "@angular/core"; /** Localization configuration provider. */ export declare const KBQ_CODE_BLOCK_LOCALE_CONFIGURATION: InjectionToken; /** Utility provider for `KBQ_CODE_BLOCK_LOCALE_CONFIGURATION`. */ export declare const kbqCodeBlockLocaleConfigurationProvider: (configuration: KbqCodeBlockLocaleConfiguration) => Provider; /** Fallback file name for code block if file name is not specified. */ export declare const KBQ_CODE_BLOCK_FALLBACK_FILE_NAME: InjectionToken; /** Utility provider for `KBQ_CODE_BLOCK_FALLBACK_FILE_NAME`. */ export declare const kbqCodeBlockFallbackFileNameProvider: (fileName: string) => Provider; /** Marks a template as a custom tab link. */ export declare class KbqCodeBlockTabLinkContent { static ɵfac: i0.ɵɵFactoryDeclaration; static ɵdir: i0.ɵɵDirectiveDeclaration; } /** * Component which highlights blocks of code. */ export declare class KbqCodeBlock implements AfterViewInit { private readonly copyButtonTooltip?; /** * Reference to the scrollable code content. * * @deprecated Use `scrollTo` method instead, will be removed from public API (mark as private) in the next major release. * * @docs-private */ readonly scrollableCodeContent: CdkScrollable; private readonly highlight; private readonly preElementRef; /** @docs-private */ protected readonly contentExceedsMaxHeight: import("@angular/core").WritableSignal; /** @docs-private */ protected readonly tabLinkTemplate: TemplateRef; /** Whether to display line numbers. */ lineNumbers: boolean; /** Whether the code block should be filled. */ filled: boolean; /** Added soft wrap toggle button. */ canToggleSoftWrap: boolean; /** Whether sequences of whitespace should be preserved. */ softWrap: boolean; /** * Output to support two-way binding on `[(softWrap)]` property. */ readonly softWrapChange: EventEmitter; /** * Allows to view all the code, otherwise it will be hidden. * Works only with `maxHeight` property. */ viewAll: boolean; /** * Output to support two-way binding on `[(viewAll)]` property. */ readonly viewAllChange: EventEmitter; /** * Maximum height of the code block content, other parts will be hidden. * Can be toggled by `viewAll` property. */ maxHeight: number; /** * @docs-private */ protected get calculatedMaxHeight(): number | null; /** * @deprecated Will be removed in next major release, use `canDownload` instead. * * @docs-private */ set canLoad(value: boolean); /** Added download code button. */ canDownload: boolean; /** Added copy code button. */ canCopy: boolean; /** * @deprecated Will be removed in next major release, use `files` instead. */ set codeFiles(files: KbqCodeBlockFile[]); /** * @TODO Mark as `required`, after removing `codeFiles` * * Files to display. */ get files(): KbqCodeBlockFile[]; set files(files: KbqCodeBlockFile[]); private _files; /** Defines which file (index) is active. */ activeFileIndex: number; /** * Output to support two-way binding on `[(activeFileIndex)]` property. */ readonly activeFileIndexChange: EventEmitter; /** Whether to hide border. */ noBorder: boolean; /** * Whether to hide header tabs. * Always `true` if there is only one file without filename. * Makes actionbar floating if tabs are hidden. */ get hideTabs(): boolean; set hideTabs(value: boolean); private _hideTabs; /** * Output to support two-way binding on `[(hideTabs)]` property. */ readonly hideTabsChange: EventEmitter; /** * Component locale configuration. * * @docs-private */ protected get localeConfiguration(): KbqCodeBlockLocaleConfiguration; private _localeConfiguration; /** * Code content tab index. * * @docs-private */ protected get codeContentTabIndex(): number; /** * Determines whether the code content can be focused. * * This checks if the scrollable code content element is present, * has a scroll, and the calculated maximum height is not set. */ private get canCodeContentBeFocused(); /** * @docs-private */ protected readonly componentColor: typeof KbqComponentColors; /** * @docs-private */ protected readonly buttonStyle: typeof KbqButtonStyles; private readonly elementRef; private readonly injector; private readonly changeDetectorRef; private readonly localeService; private readonly destroyRef; private readonly renderer; private readonly platform; private readonly focusMonitor; private readonly clipboard; private readonly domSanitizer; private readonly document; private readonly sharedResizeObserver; /** * @docs-private */ protected readonly fallbackFileName: string; private readonly window; constructor(); ngAfterViewInit(): void; /** * Toggles the `viewAll` property. * * When `viewAll` is set to `true`, the content of the code block will be * displayed in its entirety. When set to `false`, the content will be * limited to the `maxHeight` property. If the content exceeds the * `maxHeight`, it will be scrolled to the top and the `viewAll` button * will be displayed. */ toggleViewAll(): void; /** Scrolls the code content to the specified position. */ scrollTo(options: ExtendedScrollToOptions): void; /** * Toggles `softWrap` property. * * When `softWrap` is set to `true`, the content of the code block will be * wrapped if it exceeds the height of the component. When set to `false` * the content will not be wrapped. */ toggleSoftWrap(): void; /** * Handles the change of the selected tab by updating the active file index * and scrolling to the top of the scrollable content. * * @param index - The index of the newly selected tab. * * @docs-private */ protected onSelectedTabChange(index: number): void; /** * Tracks hover events to show/hide the actionbar when `hideTabs` is `true`. * Reacts to `hideTabs` changes dynamically. */ private trackHoverState; private setupContentOverflowDetection; /** * Handles the scroll event on the scrollable code content element and updates the header shadow accordingly. */ private handleScroll; /** * Adds or removes the shadow class from the code block based on the specified condition. * * @param shouldShowShadow - A boolean indicating whether to add or remove the shadow class. */ private setupHeaderShadow; /** * Adds or removes the actionbar display class from the code block based on the specified condition. * * The actionbar is always visible on mobile devices and when the tabs are visible. * Otherwise, the actionbar is only visible when the mouse is hovered over the code block. * * @param shouldShowActionbar - A boolean indicating whether the actionbar should be visible. */ private setupActionbarDisplay; /** Whether the element has scroll. */ private hasScroll; /** * Handles the enter keydown event on `viewAll` button. * * @docs-private */ protected onViewAllEnterKeydown(event: Event): void; private updateLocaleParams; /** * Copies the file code to the clipboard. * * If the copy was successful, the copy button tooltip content is updated * to show the "copied" message. * * @docs-private */ protected copyCode(): void; /** * Opens the file link in a new window. * * @docs-private */ protected openLink(): void; /** * Downloads the file as a blob. * * Creates a link with a blob as href and the file name as download attribute. * Then simulates a click event on the link to initiate the download. * * @docs-private */ protected downloadCode(): void; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵcmp: i0.ɵɵComponentDeclaration; static ngAcceptInputType_lineNumbers: unknown; static ngAcceptInputType_filled: unknown; static ngAcceptInputType_canToggleSoftWrap: unknown; static ngAcceptInputType_softWrap: unknown; static ngAcceptInputType_viewAll: unknown; static ngAcceptInputType_maxHeight: unknown; static ngAcceptInputType_canLoad: unknown; static ngAcceptInputType_canDownload: unknown; static ngAcceptInputType_canCopy: unknown; static ngAcceptInputType_activeFileIndex: unknown; static ngAcceptInputType_noBorder: unknown; static ngAcceptInputType_hideTabs: unknown; }