UNPKG

carbon-components-angular

Version:
168 lines (164 loc) 5.84 kB
/** * * carbon-angular v0.0.0 | ai-label.component.d.ts * * Copyright 2014, 2026 IBM * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { AfterViewInit, ElementRef, EventEmitter, OnChanges, OnDestroy, SimpleChanges } from "@angular/core"; import { Placement } from "@floating-ui/dom"; import * as i0 from "@angular/core"; /** * @deprecated alignments — use `Placement` names */ declare type DeprecatedAILabelAlign = "top-left" | "top-right" | "bottom-left" | "bottom-right" | "left-bottom" | "left-top" | "right-bottom" | "right-top"; /** * AI-branded toggletip control (`cds-ai-label`). Renders an "AI" badge that opens a * popover; projected content and optional actions use `ng-content`. * * Get started with importing the module: * * ```typescript * import { AILabelModule } from 'carbon-components-angular'; * ``` * * ```html * <cds-ai-label size="md"> * <div> * <p>AI Explained</p> * <h2>84%</h2> * <p>Confidence score</p> * </div> * <div cdsAILabelActions> * <button cdsButton="ghost" size="sm">View details</button> * </div> * </cds-ai-label> * ``` * * `[cdsAILabelActions]` adds `cds--toggletip-actions` and `cds--ai-label-actions` * to its host. Place it as a **sibling** of the body content, both direct * children of `<cds-ai-label>`. `[cdsAILabelContent]` is an optional marker; the * `cds--ai-label-content` / `cds--toggletip-content` classes come from this * component’s template. * * [See demo](../../?path=/story/components-ai-label--default) */ export declare class AILabelComponent implements AfterViewInit, OnChanges, OnDestroy { private elementRef; static labelCounter: number; aiLabelClass: boolean; get revertClass(): boolean; /** * Set alignment of popover. Deprecated Carbon alignments are mapped to * floating-ui placements. */ align: DeprecatedAILabelAlign | Placement; /** * Show caret at the alignment position. */ caret: boolean; /** * Enable drop shadow around the popover container. */ dropShadow: boolean; /** * Enable high contrast for popover container. */ highContrast: boolean; /** * **Experimental**: Use floating-ui to position the tooltip. */ autoAlign: boolean; /** * Whether the callout is open. */ isOpen: boolean; /** * Emits when the callout is closed. */ onClose: EventEmitter<Event>; /** * Emits when the callout is opened. */ onOpen: EventEmitter<Event>; /** * Emits when `isOpen` changes (two-way binding). */ isOpenChange: EventEmitter<boolean>; /** * Unique id used to associate the trigger button with the popover panel * via `aria-controls` / `id`. */ id: string; /** * Text inside the AI badge. */ aiText: string; /** * Extra text beside the badge when `kind` is `"inline"`. */ textLabel: string; /** * Set badge shape: `"default"` (circular) or `"inline"` (pill, optional `textLabel`). */ kind: "default" | "inline"; /** * Set badge size */ size: "mini" | "2xs" | "xs" | "sm" | "md" | "lg" | "xl"; /** * Horizontal shift along the alignment axis when `autoAlign` is on, matching * React `AILabel` (`alignmentAxisOffset={isSmallIcon ? -24 : 0}` on `Toggletip`). */ get alignmentAxisOffset(): number; /** * When `true`, shows the revert icon instead of the badge (AI-generated value * is active and can be reverted). */ revertActive: boolean; /** * Accessible label / tooltip for the revert icon button. */ revertLabel: string; /** * `aria-label` for the AI badge trigger (combined with `aiText` in `computedAriaLabel`). */ ariaLabel: string; /** * Emitted when the revert icon is clicked. */ revertClick: EventEmitter<MouseEvent>; private aiLabelPopover; private readonly documentClick; constructor(elementRef: ElementRef); onPopoverIsOpenChange(open: boolean): void; get triggerClasses(): Record<string, boolean>; /** * Trigger `aria-label`: `"${aiText} ${ariaLabel}"`, or * `"${aiText} ${textLabel}"` when `kind` is `"inline"` and `textLabel` is set. */ get computedAriaLabel(): string; ngAfterViewInit(): void; ngOnChanges(changes: SimpleChanges): void; ngOnDestroy(): void; onTriggerClick(event: MouseEvent): void; onRevertButtonClick(event: MouseEvent): void; hostkeys(event: KeyboardEvent): void; /** * Dismisses the popover when a click lands outside the host element. */ private handleOutsideClick; static ɵfac: i0.ɵɵFactoryDeclaration<AILabelComponent, never>; static ɵcmp: i0.ɵɵComponentDeclaration<AILabelComponent, "cds-ai-label, ibm-ai-label", never, { "align": "align"; "caret": "caret"; "dropShadow": "dropShadow"; "highContrast": "highContrast"; "autoAlign": "autoAlign"; "isOpen": "isOpen"; "id": "id"; "aiText": "aiText"; "textLabel": "textLabel"; "kind": "kind"; "size": "size"; "revertActive": "revertActive"; "revertLabel": "revertLabel"; "ariaLabel": "ariaLabel"; }, { "onClose": "onClose"; "onOpen": "onOpen"; "isOpenChange": "isOpenChange"; "revertClick": "revertClick"; }, never, ["*"], false>; } export {};