import { CompositeKey, DataSnapshot } from "@memberjunction/core"; import { BaseEventArgs } from "./component-events.js"; import { SimpleAITools, SimpleGeoDataEngine, SimpleMetadata, SimpleRunQuery, SimpleRunView, SimpleSearch } from "./shared.js"; /** * Callbacks a component can use. */ export interface ComponentCallbacks { /** * If an action occurs inside a component where it would be desirable for the containing UI to open a specific * record, if supported, this event can be listened to and the container UI can then open the record. * @param entityName - this is the Entity NAME from the Entity metadata, not the table name or base view name. Use Entity Metadata to provide the entity name here * @param key - this is an array of key/value pairs representing the primary key. The format of a Composite Key is an array of KeyValuePair objects and KeyValuePair objects simply have FieldName and Value properties. In most cases entities have single-valued primary keys but this structure is here for complex entity types that have composite primary keys */ OpenEntityRecord: (entityName: string, key: CompositeKey) => void; /** * Display a short non-blocking notification message to the user. The container will determine how best to display this message. * @param message - text to display * @param style - display styling * @param hideAfter - option to auto hide after the specified delay in milliseconds */ CreateSimpleNotification: (message: string, style: "none" | "success" | "error" | "warning" | "info", hideAfter?: number) => void; /** * Allows a component to register methods that can be called by the container. * @param methodName - Name of the method being registered * @param handler - The method implementation */ RegisterMethod: (methodName: string, handler: Function) => void; /** * Notify the container of a component event. * For cancelable events, the container can set args.cancel = true * before the await resolves. */ NotifyEvent?: (eventName: string, args: BaseEventArgs) => Promise; } /** * Defines styles for the component. Container can provide styles to a top level component. The top level component * can alter these styles based on the design documentation. Top level component will pass in its computed styles to * each sub-component and in turn sub-components do the same recursively down to all levels. Allows sub-components to inherit styles but * also make adjustments as required by the design documentation. */ export interface ComponentStyles { colors: { primary: string; primaryHover: string; primaryLight?: string; secondary: string; secondaryHover?: string; success: string; successLight?: string; warning?: string; warningLight?: string; error?: string; errorLight?: string; info?: string; infoLight?: string; background: string; surface: string; surfaceHover?: string; text: string; textSecondary: string; textTertiary?: string; textInverse?: string; border: string; borderLight?: string; borderFocus?: string; shadow?: string; shadowMedium?: string; shadowLarge?: string; [key: string]: string | undefined; }; spacing: { xs: string; sm: string; md: string; lg: string; xl: string; xxl?: string; xxxl?: string; [key: string]: string | undefined; }; typography: { fontFamily: string; fontSize: { xs?: string; sm: string; md: string; lg: string; xl: string; xxl?: string; xxxl?: string; [key: string]: string | undefined; }; fontWeight?: { light?: string; regular?: string; medium?: string; semibold?: string; bold?: string; [key: string]: string | undefined; }; lineHeight?: { tight?: string; normal?: string; relaxed?: string; [key: string]: string | undefined; }; }; borders: { radius: string | { sm?: string; md?: string; lg?: string; xl?: string; full?: string; [key: string]: string | undefined; }; width: string | { thin?: string; medium?: string; thick?: string; [key: string]: string | undefined; }; }; shadows?: { sm?: string; md?: string; lg?: string; xl?: string; inner?: string; [key: string]: string | undefined; }; transitions?: { fast?: string; normal?: string; slow?: string; [key: string]: string | undefined; }; overflow: string; } /** * This is the function signature for the print function that is provided by the component via the SkipComponentObject */ export type ComponentPrintFunction = () => void; /** * This is the function signature for the refresh function that is provided by the component via the SkipComponentObject */ export type ComponentRefreshFunction = () => void; /** * The component will create this object and it will include the members defined in this interface and return upon its main function being called. */ export interface ComponentObject { /** * The React component function that receives props including data, userState, callbacks, utilities, and styles. */ component: Function; /** * The optional print function that is called when the user clicks on the print button in the parent of the component. This function will never be called by the parent before the init function so the print function * can assume the component has been initialized; */ print?: ComponentPrintFunction; /** * The optional refresh function that is called when the user clicks on the refresh button in the parent of the component. This function will never be called by the parent before the init function so the refresh function */ refresh?: ComponentRefreshFunction; /** * Gets the current data state of the component. * Used by AI agents to understand what data is currently displayed. * Returns undefined if the component has no data to report. */ getCurrentDataState?: () => DataSnapshot | undefined; /** * Restores or applies a data state snapshot to the component. * Returns true if the snapshot was successfully applied, false otherwise. */ setDataState?: (snapshot: DataSnapshot) => boolean; /** * Validates the current state of the component. * Returns true if valid, false or validation errors otherwise. */ validate?: () => boolean | { valid: boolean; errors?: string[]; }; /** * Checks if the component has unsaved changes. */ isDirty?: () => boolean; /** * Resets the component to its initial state. */ reset?: () => void; /** * Scrolls to a specific element or position within the component. * @param target - Element selector, element reference, or scroll options */ scrollTo?: (target: string | HTMLElement | { top?: number; left?: number; }) => void; /** * Sets focus to a specific element within the component. * @param target - Element selector or element reference */ focus?: (target?: string | HTMLElement) => void; /** * Generic method invoker for custom methods * @param methodName - Name of the method to invoke * @param args - Arguments to pass to the method * @returns The result of the method call, or undefined if method doesn't exist */ invokeMethod?: (methodName: string, ...args: any[]) => any; /** * Check if a method is registered on the component * @param methodName - Name of the method to check * @returns true if the method exists */ hasMethod?: (methodName: string) => boolean; } /** * This interface defines the utilities that are available to the component at runtime. These utilities are used to interact with the host MJ system to * retrieve metadata, run views, and run queries. The utilities are passed into the ComponentInitFunction by the container. */ export interface ComponentUtilities { md: SimpleMetadata; rv: SimpleRunView; rq: SimpleRunQuery; /** * Access to AI tools. This will not always be available in all environments and security contexts, ensure * component code has fallbacks when this property is undefined */ ai?: SimpleAITools; /** * Access to unified search across vector, full-text, entity, and storage sources. * This will not always be available in all environments — ensure component code * has fallbacks when this property is undefined. */ search?: SimpleSearch; /** * Access to GeoDataEngine for coordinate-based geographic resolution. * Used by map components to resolve lat/lng to country/state via point-in-polygon. * This will not always be available — ensure component code has fallbacks when undefined. */ geoDataEngine?: SimpleGeoDataEngine; } //# sourceMappingURL=runtime-types.d.ts.map