/** * @license *------------------------------------------------------------------------------------------- * Copyright © 2026 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the package root for more information *------------------------------------------------------------------------------------------- */ import { ButtonProps } from '../../Button.js'; import { SmartPasteFormField } from './SmartPasteFormField'; /** * Represents the request data sent to the AI service for smart paste processing. */ export interface SmartPasteRequestData { /** * The clipboard content to be processed by the AI service. */ content: string; /** * An array of form fields that describe the target form structure. */ formFields: SmartPasteFormField[]; } /** * Represents the response from the AI service containing the extracted field values. */ export interface SmartPasteResponse { /** * A record of field names to their extracted values from the clipboard content. */ fieldValues: Record; } /** * Represents the click event for the SmartPasteButton component. * Extends the standard React mouse event with additional properties for smart paste functionality. */ export interface SmartPasteClickEvent extends React.MouseEvent { /** * The request data containing clipboard content and form fields. */ requestData: SmartPasteRequestData; /** * A function to set the field values to populate in the form. * Call this with the response from your API to populate the form fields. * * @param response - The response containing field values to populate */ setResponse: (response: SmartPasteResponse) => void; } /** * Represents the props for the SmartPasteButton component. * Extends ButtonProps with smart paste specific functionality for AI-powered form filling. */ export interface SmartPasteButtonProps extends Omit { /** * An array of SmartPasteFormField holding the fields info used by the form that the button resides in. */ formFields?: SmartPasteFormField[]; /** * Fires when the SmartPaste button is clicked. * The event includes the clipboard content, form fields, and a setResponse function * to populate the form with the AI service response. * * @param event - The click event with request data and response setter * * @example * ```tsx * { * const response = await fetch('/api/smartpaste', { * method: 'POST', * body: JSON.stringify(e.requestData) * }); * const data = await response.json(); * e.setResponse(data); * }} * /> * ``` */ onClick?: (event: SmartPasteClickEvent) => void; }