import { Store, ComplexQueryExpression, QueryOptions } from 'store-api/api'; import { DataTableCollection, DataTable, DatasetItemIdsProvider } from '../__internal__/BGEg3fBn.js'; import { EventSource, Handle } from 'apprt-core/Types'; import '@arcgis/core/geometry'; import '@arcgis/core/geometry/SpatialReference'; /** Events fired by the data table service */ interface ResultViewerServiceEvents { /** * The current data property has changed. */ "current-data-changed": { shown: DataTableCollection | undefined; hidden: DataTableCollection | undefined; }; } /** * Options to control how tables are opened by the {@link ResultViewerService}. */ interface ResultViewerServiceOpenOptions { /** * True, if previously opened tables should be replaced. * False, if previously opened tables should be combined with the new ones. * Default value depends on the ResultViewerService configuration. */ replaceTables?: boolean; } /** * Provides a service to show data tables in the ui. * * The service can be injected by referencing `"result-api.ResultViewerService"`. * * Via the property `currentDataTables` the available data tables can be accessed. * * ```ts * const resultViewerService = ...; * const currentlyAvailableDataTables = resultViewerService.currentDataTables; * * // with default result-ui only one of the tables are shown, to access this table use: * const firstDataTable = currentDataTables.getFirstSelectedTable(); * * // to iterate all available data tables use, for/of: * for (const dataTable of currentDataTables){ * ... * } * * If you need an array of the tables use the `tables` property: * const tableArray = currentDataTables.tables; * // or * const tableArray = Array.from(currentDataTables); * ``` * * It is possible to watch for the event `current-data-changed`: * ```ts * const resultViewerService = ...; * resultViewerService.on("current-data-changed", ({shown, hidden})=>{ * // shown is the new currentDataTables property * resultViewerService.currentDataTables === shown; * // hidden is the old replaced collection * resultViewerService.currentDataTables !== hidden; * }) * ``` */ interface ResultViewerService extends EventSource { /** * Opens the given data tables in the UI and returns a handle that allows the caller * to hide the model again. * * This method merges previously opened tables with the given dataTables by default. * This behavior can be controlled by the given {@link options} object. * * @param dataTables The tables to be opened. * @param options Options used to open the tables. */ open(dataTables: DataTableCollection, options?: ResultViewerServiceOpenOptions): Handle; /** * As long as a ui is opened, the shown data can be accessed here. * If a ui is closed or a new call to open is performed. * The data will be replaced. */ readonly currentDataTables: DataTableCollection | undefined; /** * Provides access to a factory to assemble DataTables. */ readonly dataTableFactory: DataTableFactory; /** * Controls whether results are visualized and interactive on the map. * When enabled, result features are highlighted on the map and selecting * a data table will automatically zoom to its features. */ enableMapInteraction: boolean; } /** * Factory for data tables. */ interface DataTableFactory { /** * Creates a collection of data tables. */ createDataTableCollection(dataTables?: Iterable): DataTableCollection; /** * Creates a data table from a store and an id provider. * @param options * ```ts * { * dataTableId?: string; * dataTableTitle?: string; * dataSourceId?: string; * dataSource: Store; * idsProvider: DatasetItemIdsProvider; * allowedFieldNames?: Set | ((name: string) => boolean); * } * ``` */ createDataTableFromStore(options: { dataTableId?: string; dataTableTitle?: string; dataSourceId?: string; dataSource: Store; dataSourceProperties?: Record; idsProvider: DatasetItemIdsProvider; allowedFieldNames?: Set | ((name: string) => boolean); }): Promise; /** * Creates a data table from a store and a query expression. * @param options * ```ts * { * dataTableId?: string; * dataTableTitle?: string; * dataSourceId?: string; * dataSource: Store; * queryExpression: ComplexQueryExpression; * queryOptions?: QueryOptions; * } * ``` */ createDataTableFromStoreAndQuery(options: { dataTableId?: string; dataTableTitle?: string; dataSourceId?: string; dataSource: Store; dataSourceProperties?: Record; queryExpression: ComplexQueryExpression; queryOptions?: QueryOptions; }): Promise; } export type { DataTableFactory, ResultViewerService, ResultViewerServiceEvents, ResultViewerServiceOpenOptions };