import { DataTableCollection, DataTable, TableItem } from '../__internal__/BGEg3fBn.js'; import { EventSource } from 'apprt-core/Events'; import 'apprt-core/Types'; import '@arcgis/core/geometry'; import '@arcgis/core/geometry/SpatialReference'; import 'store-api/api'; /** * All BulkTableAction types. */ type BulkTableAction = BulkButtonTableAction; /** * All RowTableAction types. */ type RowTableAction = RowButtonTableAction; /** * All currently supported UI types. */ type TableActionUIType = "button"; /** * Base interface for BulkTableActions and RowTableActions. */ interface TableAction { /** ID used to identify this action. */ readonly id: string; /** Type of action that describes how it is rendered, e.g. as a button **/ readonly uiType: TableActionUIType; /** optional label of actions used as source of ordering. **/ readonly label?: string; /** optional flag of actions used as source of ordering. **/ readonly priority?: number; } /** * An action that is displayed as a button in a table's menu bar. */ interface BulkButtonTableAction extends TableAction { readonly uiType: "button"; /** Icon of the button that will be rendered in the menu bar. **/ readonly icon: string; /** Label that might be rendered on a button beside or instead of the icon. **/ readonly label: string; /** Tooltip that is displayed, when hovering the button. **/ readonly tooltip: string; /** * Runs the action code. * * @param actionContext the data the action can operate on. **/ trigger(actionContext: BulkActionContext): Promise; /** * Actions can optionally provide a display state that controls * if this action is visible or enabled in a table's menu bar. * * @param dataTable the table that requests the display state. */ provideDisplayState?(dataTable: DataTable): Partial; } /** * An action that is displayed as a button in the row of all table item. */ interface RowButtonTableAction extends TableAction { readonly uiType: "button"; /** Icon of the button that will be rendered in the table row **/ readonly icon: string; /** Label that might be rendered on a button beside or instead of the icon. **/ readonly label: string; /** Tooltip that is displayed, when hovering the button. **/ readonly tooltip: string; /** * Runs the action code. * * @param actionContext the data the action can operate on. **/ trigger(actionContext: RowActionContext): Promise; /** * Actions can optionally provide a display state that controls * if this action is visible or enabled for a specific row. * * @param dataTable the table that requests the display state. * @param rowItem the row item for which the state is requested. */ provideDisplayState?(dataTable: DataTable, rowItem: TableItem): Partial; } /** * Data that a {@link RowTableAction} can operate on. */ interface RowActionContext { /** * The full collection of tables inside the current view. */ readonly allDataTables: DataTableCollection; /** * The table the action is triggered for. */ readonly dataTable: DataTable; /** * The table item. */ readonly rowItem: TableItem; } /** * Data that a {@link BulkTableAction} can operate on. */ interface BulkActionContext { /** * The full collection of tables inside the current view. */ readonly allDataTables: DataTableCollection; /** * The table the action is triggered for. */ readonly dataTable: DataTable; } /** * A bridge and extension point between the requirements of a concrete UI to lookup actions * and a dynamic rendering of actions in the UI. */ interface TableActionResolver { /** * Creates a resolve context that provides access to actions. * * @param options the resolving options */ createResolverContext(options: TableActionResolverContextOptions): TableActionResolverContext; } /** * Options controlling the result of {@link TableActionResolver.createResolverContext}. */ interface TableActionResolverContextOptions { /** * IDs of {@link BulkTableAction}s to resolve. * The order of the IDs determines the order of the resolved actions. * The expression `["*"]` gets all available actions in a implementation-specific order. */ bulkActionIds: string[]; /** * IDs of {@link RowTableAction}s to resolve. * The order of the IDs determines the order of the resolved actions. * The expression `["*"]` gets all available actions in a implementation-specific order. */ rowActionIds: string[]; /** * The current data for which the actions should be resolved. */ tables: DataTableCollection; } /** * Events fired by a {@link TableActionResolverContext}. */ interface TableActionResolverContextEvents { /** Emitted after an action was added or removed **/ "bulk-actions-changed": void; /** Emitted after an row action was added or removed **/ "row-actions-changed": void; } /** * An object of this kind lives only for the time a concrete UI is displayed. * It provides a way to react to action state changes, e.g. when an action is hidden or deactivated. * Additionally, it provides a way to conditionally render row actions. */ interface TableActionResolverContext extends EventSource { /** * Gets actions available for the TableModel. */ getBulkActions(dataTable: DataTable): TableActionItem[]; /** * Gets actions available for the TableModel and TableItem. */ getRowActions(dataTable: DataTable, rowItem: TableItem): TableActionItem[]; /** * Must be called by a UI to indicate that the context is no longer required. */ destroy(): void; } /** * Links a {@link TableAction} to the "enabled" state. */ interface TableActionItem { /** A TableAction */ action: T; /** * `true` if the action enabled. */ enabled: boolean; } /** * UI state of a {@link TableAction}. */ interface TableActionDisplayState { /** * `true` if the corresponding action should be displayed. If `false`, the action is not displayed in the UI. */ visible: boolean; /** * `true` if the corresponding action should be rendered as "clickable" (if visible). * If `false` the action is rendered disabled. */ enabled: boolean; } /** Used by the {@link TableActionResolver} implementation to allow the customization * of the visible and enabled states of a row action. */ interface TableActionDisplayStateProvider { /** * Provides the UI state information for an action. * @param actionId ID of the action to decide upon. * @param dataTable the current data table. * @param rowItem the current row item. `undefined` if the state is requested for a {@link BulkTableAction}. * @returns the state. `undefined` if no state could be provided. */ provideDisplayState(actionId: string, dataTable: DataTable, rowItem?: TableItem): Partial | undefined; } export type { BulkActionContext, BulkButtonTableAction, BulkTableAction, RowActionContext, RowButtonTableAction, RowTableAction, TableAction, TableActionDisplayState, TableActionDisplayStateProvider, TableActionItem, TableActionResolver, TableActionResolverContext, TableActionResolverContextEvents, TableActionResolverContextOptions, TableActionUIType };