/** * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options */ /** * @module ai/aicore/ui/aimodelselectorview */ import { type Locale } from "@ckeditor/ckeditor5-utils"; import { ButtonLabelView, View, type DropdownView } from "@ckeditor/ckeditor5-ui"; import { type AIModelData } from "../aiconnector.js"; import { type AIModelDisplayMode } from "../utils/getmodeldisplaymode.js"; /** * Per-feature configuration for the shared {@link module:ai/aicore/ui/aimodelselectorview~AIModelSelectorView}. */ export interface AIModelSelectorConfig { /** * The dropdown panel position (e.g. `'ne'` for AI Chat, `'se'` for AI Review). */ panelPosition: DropdownView["panelPosition"]; /** * CSS class(es) for the dropdown. */ dropdownClass: string | Array; /** * CSS class for the model-name label (shown when there is a single model). */ nameClass: string; /** * CSS classes for the dropdown item label parts. */ itemClasses: { name: string; description: string; capabilities?: string; }; /** * The dropdown button label shown before a model is selected. Optional — features that immediately * select a default model (e.g. AI Review) do not need it. */ defaultLabel?: string; /** * Optional tooltip shown on the dropdown button while the selector is disabled. When omitted, the * active model name (the button label) is used as the tooltip regardless of the enabled state. */ disabledTooltip?: string; /** * Optional tooltip position for the dropdown button. */ tooltipPosition?: "s" | "n" | "e" | "w" | "sw" | "se" | "nw" | "ne"; /** * When `true`, each dropdown item also renders the model's capabilities (web search, reasoning). * Used by AI Chat; AI Review leaves it off. */ showCapabilities?: boolean; } /** * Fired when the user picks a model from the dropdown. Parents decide what to do with the selection * (the view does not update its own {@link module:ai/aicore/ui/aimodelselectorview~AIModelSelectorView#activeModelId} * optimistically — call {@link module:ai/aicore/ui/aimodelselectorview~AIModelSelectorView#setSelectedModel} to reflect it). */ export type AIModelSelectorSelectEvent = { name: "selectModel"; args: [model: AIModelData]; }; /** * A shared model-selector: a dropdown of available models plus a single-model name label, with the * display-mode / active-model state. Used by AI Chat and AI Review; per-feature differences (CSS, * default label, chat's capability rendering) are injected via {@link ~AIModelSelectorConfig}. */ export declare class AIModelSelectorView extends View { /** * How the selector is presented: `'selector'` (dropdown), `'name'` (single model), or `'hidden'`. * * @observable */ modelDisplayMode: AIModelDisplayMode; /** * The id of the currently active model (drives the dropdown item highlight). * * @observable */ activeModelId: string | null; /** * The name of the currently active model (shown in `'name'` display mode). * * @observable */ activeModelName: string | null; /** * Whether the selector is enabled. * * @observable */ isEnabled: boolean; /** * The model-selection dropdown. */ readonly dropdownView: DropdownView; /** * The single-model name label. */ readonly nameView: ModelNameView; /** * @inheritDoc */ constructor(locale: Locale, config: AIModelSelectorConfig); /** * Populates the dropdown with the given models and updates the display mode. */ setModels(models: Array, showSelector: boolean): void; /** * Reflects the given model as the active selection (highlight, name, dropdown label). Passing `null` * clears the active selection, which lets parents derive an "is a model available" state from * {@link #activeModelId}. */ setSelectedModel(model: AIModelData | null): void; } /** * The single-model name label used by {@link module:ai/aicore/ui/aimodelselectorview~AIModelSelectorView}. */ export declare class ModelNameView extends View { /** * The text of the label. * * @observable */ text: string | undefined; /** * @observable */ isVisible: boolean; /** * @inheritDoc */ constructor(locale: Locale, cssClass: string); } /** * The dropdown item label (model name + description, plus optional extra content such as capabilities) * used by {@link module:ai/aicore/ui/aimodelselectorview~AIModelSelectorView}. */ export declare class ModelButtonLabelView extends ButtonLabelView { /** * @inheritDoc */ constructor(locale: Locale, model: AIModelData, options: { nameClass: string; descriptionClass: string; capabilitiesClass?: string; extraContent?: Array; }); }