UNPKG

@adaptabletools/adaptable

Version:

Powerful AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements

151 lines (150 loc) 5.48 kB
import { AdaptableButton } from '../AdaptableState/Common/AdaptableButton'; import { DashboardState } from '../AdaptableState/DashboardState'; import { BaseContext, CustomRenderContext } from '../types'; import { AdaptableFrameworkComponent } from '../agGrid/AdaptableFrameworkComponent'; import { AdaptableForm, AdaptableFormData, AdaptableFormErrors } from '../AdaptableState/Common/AdaptableForm'; /** * Options related to the Dashboard in Adaptable. */ export interface DashboardOptions { /** * Whether the Dashboard can be floated; if true (the default), double-clicking Dashboard puts it in float mode * * @defaultValue true * @noCodeItem */ canFloat?: boolean; /** * Shows Quick Search input in Dashboard Header * * @defaultValue true * @noCodeItem */ showQuickSearchInHeader?: boolean; /** * Custom Adaptable Buttons to appear in Dashboard */ customDashboardButtons?: AdaptableButton<DashboardButtonContext>[]; /** * Toolbars provided by Users which contain custom content */ customToolbars?: CustomToolbar[]; /** * Where in Dashboard to display Module and Custom Buttons * @defaultValue 'right' * @noCodeItem */ buttonsLocation?: DashboardButtonsLocation; } /** * Custom Toolbar (which AdapTable will manage) enabling devs to populate * Dashboard with bespoke content. * * @typeParam TData - Optional shape of the toolbar form's data. Defaults to * {@link AdaptableFormData}; declare a stricter shape * here for fully-typed `formData` in callbacks. */ export interface CustomToolbar<TData extends AdaptableFormData = AdaptableFormData> { /** * How Toolbar is referenced (e.g. in Dashboard Popup when managing toolbars) */ name: string; /** * Title to display in Toolbar; if unset or empty string, nothing will show */ title?: string; /** * Actions available in a Custom Dashboard Toolbar */ toolbarActions?: ToolbarActions; /** * Optional set of buttons to show in the Toolbar */ toolbarButtons?: AdaptableButton<CustomToolbarButtonContext>[]; /** * Optional inline form to render in the Toolbar (e.g. selects, checkboxes, * inputs). * * Use this when you want to expose interactive controls - rather than just * buttons - in your Custom Toolbar without resorting to bespoke `render` * or `frameworkComponent` content. * * The form's `fields` are rendered side-by-side using the `inline` form * layout. When the user changes any value the {@link onToolbarFormChange} * callback is invoked. Buttons declared on the form receive a * {@link CustomToolbarFormContext} which includes the current `formData`. */ toolbarForm?: AdaptableForm<CustomToolbarFormContext<TData>, TData>; /** * Callback invoked whenever the user changes a value in the toolbar form * * @param formData The latest form data, keyed by field `name` * @param context Adaptable context, including the hosting Custom Toolbar */ onToolbarFormChange?: (formData: TData, context: CustomToolbarFormContext<TData>) => void; /** * Function to provide custom content when NOT using a Framework wrapper */ render?: (customRenderContext: CustomRenderContext) => string | null; /** * The Framework-specific (Angular, React or Vue) component to be rendered */ frameworkComponent?: AdaptableFrameworkComponent; } /** * Context required by functions when using a Dashboard Button */ export interface DashboardButtonContext extends BaseContext { /** * Current Dashboard State */ dashboardState: DashboardState; } /** * Context required by functions when using a Custom Toolbar Button */ export interface CustomToolbarButtonContext extends DashboardButtonContext { /** * Custom Toolbar which hosts the Button */ customToolbar: CustomToolbar; } /** * Context provided to {@link CustomToolbar.onToolbarFormChange} and to any * Adaptable Buttons declared on a {@link CustomToolbar.toolbarForm}. * * It extends {@link CustomToolbarButtonContext} with the current `formData` * value, the form's overall validity (`formIsValid`) and any per-field * validation errors (`formErrors`), so handlers can react to - or gate on - * the current state of the controls rendered in the toolbar. */ export interface CustomToolbarFormContext<TData extends AdaptableFormData = AdaptableFormData> extends CustomToolbarButtonContext { /** * Current values of the form fields, keyed by field `name`. Strongly * typed as `TData` when the hosting `CustomToolbar` supplies an explicit * data shape. */ formData: TData; /** * `true` when every (non-hidden) field's value satisfies its validation * rules (`required`, `min`, `max`, `pattern`, custom `validate`). */ formIsValid: boolean; /** * Per-field validation errors keyed by field `name`. Empty when the form * is valid. */ formErrors: AdaptableFormErrors; } /** * Where Dashboard Buttons are displayed */ export type DashboardButtonsLocation = 'left' | 'right'; /** * List of Actions available in Custom Toolbar */ export type ToolbarActions = ToolbarAction[]; /** * Action available in Custom Toolbar - Close or Configure */ export type ToolbarAction = 'close' | 'configure';