import type { AgDataOptions } from './agDataOptions'; import type { AgDataSourcesDefinition } from './agDataSource'; import type { AgDefaultRegistry } from './agDefaultRegistry'; import type { AgPageConfig } from './agPageConfig'; import type { AgPanelConfig } from './agPanels'; import type { AgBaseRegistry } from './agRegistry'; import type { AgStudioOverrides } from './agStudioOverrides'; import type { AgStudioApiReadyEvent, AgStudioErrorRaisedEvent, AgStudioEventType, AgStudioPreDestroyedEvent, AgStudioReadyEvent, AgStudioStateUpdatedEvent } from './agStudioPublicEvents'; import type { AgAiAssistant } from './ai/agAiAssistant'; import type { AgDataEngine } from './engine/agDataEngine'; import type { AgPageLayoutState } from './state/agPageLayoutState'; import type { AgReportState } from './state/agReportState'; import type { AgStudioGetLocaleTextParams, AgStudioLocaleText } from './studioLocaleKey'; import type { AgStudioTheme } from './theme/theme'; import type { AgWidgetsConfig } from './widgets/agCreateWidgetsParams'; export type AgStudioMode = 'view' | 'edit'; export interface AgStudioProperties { /** * Change this value to set the tabIndex order of Studio within your application. * @default 0 * @initial */ tabIndex?: number; /** * Set to `true` to operate Studio in RTL (Right to Left) mode. * @default false * @initial */ enableRtl?: boolean; /** * DOM element to use as the popup parent for Studio popups (context menus, etc.). */ popupParent?: HTMLElement | null; /** * Theme to apply to Studio. * * @default studioTheme */ theme?: AgStudioTheme; /** * If your theme uses a font that is available on Google Fonts, pass true to load it from Google's CDN. */ loadThemeGoogleFonts?: boolean; /** * The CSS layer that this theme should be rendered onto. When specified, * Studio CSS will be wrapped in a `@layer ${themeCssLayer} { ... }` block. * * NOTE: when specifying `themeCssLayer` we recommend setting * `themeStyleContainer` to `document.body` to ensure that Studio CSS * comes after your application CSS, allowing your application to set the * order of layers. * * @see https://developer.mozilla.org/en-US/docs/Web/CSS/@layer */ themeCssLayer?: string; /** * The nonce attribute to set on style elements added to the document by * themes. If "foo" is passed to this property, Studio can use the Content * Security Policy `style-src 'nonce-foo'`, instead of the less secure * `style-src 'unsafe-inline'`. * * Note: CSP nonces are global to a page, where a page has multiple Studio components, * every one must have the same styleNonce set. */ styleNonce?: string; /** * An element to insert style elements into when injecting styles into the * Studio. Styles are inserted at the start of the element. * * If undefined, styles will be added to the document head for Studio components * rendered in the main document fragment, or to Studio wrapper element * for other Studio components (e.g. those rendered in a shadow DOM or detached from the * document). * * @initial */ themeStyleContainer?: HTMLElement | (() => HTMLElement | void); /** * Allows overriding what `document` is used. * Use this when you want Studio to use a different `document` than the one available on the global scope. * This can happen if docking out components (something which Electron supports). */ getDocument?: () => Document; /** * Disables touch support (but does not remove the browser's efforts to simulate mouse events on touch). * @default false * @initial */ suppressTouch?: boolean; /** * A map of key->value pairs for localising text within Studio. * @initial */ localeText?: AgStudioLocaleText; /** * A callback for localising text within Studio. * @initial */ getLocaleText?: (params: AgStudioGetLocaleTextParams) => string; /** * Provide a custom `studioId` for this instance of Studio. Value will be set on the root DOM node using the attribute `studio-id` as well as being accessible via the `api.getStudioId()` method. * @initial */ studioId?: string; /** * Provides a context object that is provided to different callbacks Studio uses. Used for passing additional information to the callbacks used by your application. * @initial */ context?: any; /** * Initial state for Studio. Only read once on initialization. Can be used in conjunction with `api.getState()` to save and restore Studio state. * @initial */ initialState?: AgReportState; /** * Defines the data sources used by Studio. * * If updated after initially being set, only changes to synchronous data will be processed. * Any other changes will be ignored (e.g. adding/removing data sources, updating fields, etc.) */ data?: AgDataSourcesDefinition | AgDataEngine; /** * Which mode Studio is in. * @default 'view' */ mode?: AgStudioMode; /** * Default layout styling. */ layout?: Partial; /** * AI Assistant configuration. * * NOTE: The **AI Assistant** is an experimental feature. Behaviour will be * slightly different depending on the LLM being used, and results can vary across queries. * * @initial */ ai?: AgAiAssistant; /** * Data-layer configuration. Controls behaviours such as export row limits. */ dataOptions?: AgDataOptions; /** * @deprecated v1.1 Use `widgets` to customise the widget configurations and available widgets, * and `page` to customise the page setup form. * * Overrides for the layout and widget configs. */ overrides?: AgStudioOverrides; /** * Configure which panels are displayed and on which side. */ panels?: AgPanelConfig; /** * Configure page (e.g. page setup form in page tab of edit panel). */ page?: AgPageConfig | ((config: AgPageConfig) => AgPageConfig); /** * Configure widgets: * - Add custom widgets * - Override provided widgets * - Change displayed widgets * - Change default widget type when dragging fields */ widgets?: AgWidgetsConfig | ((widgets: AgWidgetsConfig) => AgWidgetsConfig); /** * Custom components (e.g. custom widget components) keyed by ID. * Used to share components which can then be referenced directly by key in the definitions. */ components?: TRegistry['components']; /** * State has been updated. */ onStateUpdated?(event: AgStudioStateUpdatedEvent): void; /** * The API has been initialised and is ready for most calls. The data engine has not been initialised yet, and the UI is not ready. */ onApiReady?(event: AgStudioApiReadyEvent): void; /** * The data engine has been initialised, and the UI has been created, but may not be fully rendered yet. */ onStudioReady?(event: AgStudioReadyEvent): void; /** * Invoked immediately before Studio is destroyed. This is useful for cleanup logic that needs to run before Studio is torn down. */ onStudioPreDestroyed?(event: AgStudioPreDestroyedEvent): void; /** * An error has occurred within Studio. */ onErrorRaised?(event: AgStudioErrorRaisedEvent): void; } export type StudioPublicEventHandlerType = `on${Capitalize}` & keyof AgStudioProperties;