UNPKG

@adaptabletools/adaptable

Version:

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

189 lines (188 loc) 8.2 kB
import { GridCell } from '../Selection/GridCell'; import { AdaptableColumn } from './AdaptableColumn'; import { AdaptableModule } from './Types'; import { SelectedCellInfo } from '../Selection/SelectedCellInfo'; import { SelectedRowInfo } from '../Selection/SelectedRowInfo'; import { Column, IRowNode } from 'ag-grid-enterprise'; import { AdaptableIcon, BaseContext } from '../../types'; /** * Name of Column Menu Item provided by AdapTable */ export type AdaptableColumnMenuItemName = (typeof ADAPTABLE_COLUMN_MENU_ITEMS)[number]; /** * Name of Context Menu Item provided by AdapTable */ export type AdaptableContextMenuItemName = (typeof ADAPTABLE_CONTEXT_MENU_ITEMS)[number]; /** * List of Shipped Adaptable Column Menu Items */ export declare const ADAPTABLE_COLUMN_MENU_ITEMS: readonly ["calculated-column-edit", "cell-summary-show", "chart-show", "column-group", "column-filter-group", "column-filter-bar-hide", "column-filter-bar-show", "column-filter-clear", "column-filter-suspend", "column-filter-unsuspend", "column-info-show", "custom-sort-add", "custom-sort-edit", "dashboard-group", "dashboard-collapse", "dashboard-configure", "dashboard-dock", "dashboard-expand", "dashboard-float", "dashboard-hide", "dashboard-show", "data-import", "flashing-cell-add", "flashing-cell-delete", "format-column-add", "format-column-edit", "free-text-column-edit", "grid-group", "grid-info-show", "layout-column-caption-change", "layout-column-hide", "layout-edit", "layout-column-select", "layout-column-select-preserve", "layout-column-select-reset", "layout-grid-select", "plus-minus-add", "settings-panel-open", "styling-group", "styled-column-badge-add", "styled-column-badge-edit", "styled-column-gradient-add", "styled-column-gradient-edit", "styled-column-percent-bar-add", "styled-column-percent-bar-edit", "styled-column-sparkline-add", "styled-column-sparkline-edit", "system-status-show", "_navbar", "separator"]; /** * List of Shipped Adaptable Context Menu Items */ export declare const ADAPTABLE_CONTEXT_MENU_ITEMS: readonly ["menu-group", "alert-clear", "bulk-update-apply", "calculated-column-edit", "cell-summary-show", "column-group", "column-filter-group", "column-filter-on-cell-value", "column-filter-clear", "column-filter-suspend", "column-filter-unsuspend", "column-info-show", "comment-add", "comment-remove", "dashboard-group", "dashboard-collapse", "dashboard-configure", "dashboard-dock", "dashboard-expand", "dashboard-float", "dashboard-hide", "dashboard-show", "data-import", "edit-group", "export-group", "export-all-data", "export-all-data-excel-download", "export-all-data-visualexcel-download", "export-all-data-csv", "export-all-data-csv-download", "export-all-data-csv-clipboard", "export-all-data-json", "export-all-data-json-download", "export-all-data-json-clipboard", "export-current-layout", "export-current-layout-excel-download", "export-current-layout-visualexcel-download", "export-current-layout-csv", "export-current-layout-csv-download", "export-current-layout-csv-clipboard", "export-current-layout-json", "export-current-layout-json-download", "export-current-layout-json-clipboard", "export-selected-data", "export-selected-data-excel-download", "export-selected-data-visualexcel-download", "export-selected-data-csv", "export-selected-data-csv-download", "export-selected-data-csv-clipboard", "export-selected-data-json", "export-selected-data-json-download", "export-selected-data-json-clipboard", "fdc3-broadcast", "fdc3-raise-intent", "flashing-cell-clear", "flashing-row-clear", "grid-group", "grid-info-show", "layout-aggregated-view", "layout-auto-size", "layout-clear-selection", "layout-edit", "layout-select-all", "note-add", "note-remove", "settings-panel-open", "smart-edit-apply", "system-status-show"]; /** * Menu item used by Adaptable in Context Menus */ export type AdaptableContextMenuItem = AdaptableMenuItem<AdaptableColumnMenuItemName>; /** * Menu item used by Adaptable in Column Menus */ export type AdaptableColumnMenuItem = AdaptableMenuItem<AdaptableContextMenuItemName>; /** * Generic Menu item used by Adaptable in Column or Context Menus */ export interface AdaptableMenuItem<MENU_TYPE_NAME extends AdaptableColumnMenuItemName | AdaptableContextMenuItemName = AdaptableColumnMenuItemName | AdaptableContextMenuItemName> { /** * Unique name for the Menu Item */ name: MENU_TYPE_NAME; /** * Text that appears in the menu */ label: string; /** * Category of Adaptable Menu Item: Module, General, Group or CustomSettingsPanel */ category: MenuCategory; /** * Function to invoke when (custom) menu item is clicked */ onClick?: () => void; /** * Whether menu item is visible */ isVisible: boolean; /** * Icon to display in Menu Item */ icon?: AdaptableIcon; /** * Sub Menu Items to display */ subItems?: AdaptableMenuItem[]; } /** * Menu Item which is added to Column or Context Menu - can contain sub items */ export interface UserMenuItem<CONTEXT_TYPE extends BaseContext> { /** * Text to appear in the Menu Item */ label: string | ((context: CONTEXT_TYPE) => string); /** * Function invoked when the Menu Item is clicked */ onClick?: (menuContext: CONTEXT_TYPE) => void; /** * Function evaluating whether Menu Item is visible */ hidden?: (menuContext: CONTEXT_TYPE) => boolean; /** * Function evaluating whether Menu Item is enabled */ disabled?: (menuContext: CONTEXT_TYPE) => boolean; /** * Optional icon to display */ icon?: ((menuContext: CONTEXT_TYPE) => AdaptableIcon) | AdaptableIcon; /** * Array of Menu Items, enabling limitless levels of menus */ subMenuItems?: UserMenuItem<CONTEXT_TYPE>[]; } /** * Provides full details about the Column in which the Column Menu will appear */ export interface ColumnMenuContext<TData = any> extends BaseContext { /** * Current AdapTable Column */ adaptableColumn: AdaptableColumn<TData>; /** * Current AG Grid Column */ agGridColumn: Column; /** * Whether current Column is Row Group */ isRowGroupColumn: boolean; } /** * Provides full details about current cell (and selected cells) where the Context Menu will appear */ export interface ContextMenuContext<TData = any> extends BaseContext { /** * Cell that has been clicked; contains cell value */ gridCell: GridCell<TData>; /** * Current AdapTable Column */ adaptableColumn: AdaptableColumn<TData>; /** * Current AG Grid Column */ agGridColumn: Column; /** * Whether cell that was clicked is also currently selected */ isSelectedCell: boolean; /** * Whether Column that was clicked is only column with selected cells */ isSingleSelectedColumn: boolean; /** * Whether the clicked cell is the only selected cell */ isSingleSelectedCell: boolean; /** * Whether cell that was clicked is in a Row that is currently selected */ isSelectedRow: boolean; /** * Current AG Grid row node */ rowNode: IRowNode<TData>; /** * Whether current AG Grid row node is grouped */ isGroupedNode: boolean; /** * Whether current Column is Row Grouped */ isRowGroupColumn: boolean; /** * Value of Primary Key column in current row */ primaryKeyValue: any; /** * Currently selected cells in the grid */ selectedCellInfo: SelectedCellInfo<TData>; /** * Currently selected rows in the grid */ selectedRowInfo: SelectedRowInfo<TData>; } /** * Menu Item that is provided by AG Grid */ export interface AgGridMenuItem<MENU_TYPE> { /** * Type of Menu - always 'AgGrid' */ menuType: 'AgGrid'; /** * Name of the Menu Type */ name: MENU_TYPE; } /** * Defines the Category of for a Menu Item */ export type MenuCategory = AdaptableModule | 'General' | 'CustomSettingsPanel' | 'Group'; /** * A separator to add to Column or Context Menu */ export type MenuSeparator = '-';