/** * @license * Copyright 2023 Nuraly, Laabidi Aymen * SPDX-License-Identifier: MIT */ import type { ChatbotPlugin } from '../core/types.js'; import { ChatPluginBase } from './chat-plugin.js'; /** * A single selectable option within a selection choice card. */ export interface SelectionChoiceOption { /** Display text */ label: string; /** Value sent as message on click */ value: string; /** Optional subtitle */ description?: string; /** Optional icon name (for nr-icon) */ icon?: string; /** Greyed out, non-clickable */ disabled?: boolean; } /** * Data structure for a selection choice card. */ export interface SelectionChoiceData { /** Optional type marker */ type?: 'selection'; /** Optional heading above the cards */ title?: string; /** The selectable options */ options: SelectionChoiceOption[]; /** Grid columns (default 1) */ columns?: 1 | 2 | 3; } /** * Selection Card Plugin — renders clickable option cards inside bot messages. * * When the user clicks a card, the option's value is sent as a user message * (like quick replies in messaging apps). * * @example Basic usage * ```typescript * const selectionPlugin = new SelectionCardPlugin(); * controller.registerPlugin(selectionPlugin); * ``` * * @example JSON format in message * ```json * { * "type": "selection", * "title": "What would you like to do?", * "options": [ * { "label": "Check Order", "value": "check_order" }, * { "label": "Contact Support", "value": "contact_support" } * ], * "columns": 2 * } * ``` * * @example Markup format in message * ``` * [SELECTION]{ "title": "Pick one", "options": [...] }[/SELECTION] * ``` */ export declare class SelectionCardPlugin extends ChatPluginBase implements ChatbotPlugin { readonly id = "selection-card"; readonly name = "Selection Card Plugin"; readonly version = "1.0.0"; readonly htmlTags: { name: string; open: string; close: string; }[]; /** * CSS class prefix for styling */ protected cssPrefix: string; /** * Render a skeleton placeholder while the selection data is streaming */ renderHtmlBlockPlaceholder?(name: string): string; onInit(): void; /** * Process received messages and convert selection data to cards */ afterReceive(text: string): Promise; /** * Render a completed [SELECTION]...[/SELECTION] block when tokenized by the Provider/Service */ renderHtmlBlock(name: string, content: string): string; /** * Check if data object contains selection information */ protected isSelectionData(data: any): boolean; /** * Render selection choice card HTML. * Override this method to customize the card appearance. */ protected renderSelectionCard(data: SelectionChoiceData): string; /** * Escape HTML to prevent XSS */ protected escapeHtml(text: string): string; /** * Default styles for the selection card. * Override this method to provide custom styles. */ protected getStyles(): string; } //# sourceMappingURL=selection-card-plugin.d.ts.map