import { EventSource, Watchable, DeepReadonly } from 'apprt-core/Types'; import { Geometry } from '@arcgis/core/geometry'; import SpatialReference from '@arcgis/core/geometry/SpatialReference'; import { AllowedIdTypes, Store, FieldData } from 'store-api/api'; type FORMATTER_ID_IDENTIFIER = "object-id"; type FORMATTER_DOMAIN_VALUE_IDENTIFIER = "use-domain-value"; type FORMATTER_COMBINED_IDENTIFIER = "combined-values"; /** * Options how numeric values are formatted. */ interface NumberFormatOptions { useGrouping?: boolean; maxFractionDigits?: number; minFractionDigits?: number; } /** * Format of a date field. * * NOTE: More union alternatives might be added in the future. */ type DateTimeFormat = "date" | "time" | "datetime" | "short-date" | "short-date-short-time" | "short-date-short-time-24" | "short-date-long-time" | "short-date-long-time-24" | "long-month-day-year" | "long-month-day-year-short-time" | "long-month-day-year-short-time-24" | "long-month-day-year-long-time" | "long-month-day-year-long-time-24" | "day-short-month-year" | "day-short-month-year-short-time" | "day-short-month-year-short-time-24" | "day-short-month-year-long-time" | "day-short-month-year-long-time-24" | "long-date" | "long-date-short-time" | "long-date-short-time-24" | "long-date-long-time" | "long-date-long-time-24" | "long-month-year" | "short-month-year" | "year"; /** * Options how date time values are formatted. */ interface DateTimeFormatOptions { dateTimeFormat?: DateTimeFormat; } /** * Options how arcade columns are formatted. */ interface ArcadeFormatOptions { fieldNames: string[]; missingFieldNames?: string[]; geometryRequired: boolean; arcadeExecutor: (args: { $feature: __esri.Graphic; }) => string; arcadeExpression?: string; } /** * Well known formatting option flags. */ type WellKnownFormatterOptions = NumberFormatOptions & DateTimeFormatOptions; /** * Options to control how values are formatted. */ type FormatterOptions = WellKnownFormatterOptions & Record; /** * A Formatter responsible to format values into a string. * Each formatter has a unique id and is referenced by this id by a column. * The interface {@link FormattingInfoProvider} is responsible to combine a column to a formatter. * * The names of the options used to control the formatting in the {@link format} method * must be disjunctive across all implemented Formatters. * * *NOTE*: This interface is a proof of concept, please provide feedback if you try it. * * A Formatter needs to be registered as `provides: result-api.Formatter`. * * @example Custom Formatter * ```ts * export class UpperCaseFormatter implements Formatter { * id = "string-to-upper-case"; * * format(values: any[], options?: FormatterOptions): string { * return values.join("").toUpperCase(); * } * ``` */ interface Formatter { /** * Identifier of a formatter. */ id: string; /** * Formats values into a string. * @param values values of any type. It is up to the configuration that a formatter is correct informed. * @param options possible configuration flags for the formatter. */ format(values: any[], options?: FormatterOptions): string; } /** * Result of the resolveFRegistration metadata of a formatter. * The resolver checks for this metadata on Formatter instances. */ interface FormattingInfo { /** the id of a formatter to trigger */ formatterId: string; /** * resolved formatting options. */ formatterOptions?: FormatterOptions; /** * Side effect. Allows control of column alignment. */ align?: Column["align"]; /** * Side effect. Allows the control of the column render type. */ renderType?: Column["renderType"]; } /** * Extension point of the FormatterFacade. * An FormattingInfoProvider is requested for each column and field combination. * It provides metadata about how a column should be rendered. * These metadata is attached to a column and used to pick the correct formatter. * * *NOTE*: This interface is a proof of concept please provide feedback if you use it. * * A FormatterInfoProvider needs to be registered as `provides: result-api.FormattingInfoProvider`. * * @example CustomFormatting * ```ts * export class CustomFormatting implements FormattingInfoProvider { * * resolveFormattingInfo( * fields: FieldData[], * context: { * dataSourceId: string; * isDomainValueField(fieldName: string): boolean; * hasFormatter(formatterId: string): boolean; * defaultFormat(field: DatasetField): FormattingInfo | undefined; * } * ): FormattingInfo | "hide" | undefined { * if (fields.length !== 1) { * // support only single field columns * return undefined; * } * * if (context.dataSourceId === "my-datasource") { * const fieldName = fields[0]!.name; * if (fieldName.startWith("Shape")){ * // hide unwanted fields * return "hide"; * } * * if (fieldName === "X-Coord" || fieldName === "Y-Coord" ){ * // show coordinates without grouping and always 3 digits * return { * formatterId: "intl-number", * align: "right", * formatterOptions: { * minFractionDigits: 3, * maxFractionDigits: 3, * useGrouping: false * } * }; * * if (fieldName === "Creation-Date"){ * return { * formatterId: "intl-datetime", * formatterOptions: { * dateTimeFormat: "date" // date | time | datetime * } * }; * } * } * } * ``` */ interface FormattingInfoProvider { /** * Resolve a formatting infos for a column, which may be a combination of multiple fields. * * @param fields the dataset fields referenced by a column. * @param context * ```ts * context: { * // dataSourceId to react to special datasets * dataSourceId: string; * // method to check if a field is a domain value field. * isDomainValueField(fieldName: string): boolean; * // method to check if a formatter is available * hasFormatter(formatterId: string): boolean; * // method to lookup the default formatting info for a field * defaultFormat(field: DatasetField): FormattingInfo | undefined; * } * ``` * * @returns * - `'hide'` if the column should complete be hidden * - `undefined` if this provider can not provide information, * this means the next provider is checked or the default format is applied * - {@link FormattingInfo} a formatting info for this column */ resolveFormattingInfo(fields: DatasetField[], context: { dataSourceId: string; isDomainValueField(fieldName: string): boolean; hasFormatter(formatterId: string): boolean; defaultFormat(field: DatasetField): FormattingInfo | undefined; }): FormattingInfo | "hide" | undefined; } /** * A facade to access the formatters from client code. * The idea is that for a column the resolveFormattingInfo method is used * to lookup a matching formatter for the column values. * This formatting infos can be used during column rendering to trigger the formatters. */ interface FormatterFacade { /** * Resolve a formatting infos for a column, which may be a combination of multiple fields. * @returns FormattingInfo or undefined. Undefined has the effect that the fields are not displayed. */ resolveFormattingInfo(fields: DatasetField[], context: { dataSourceId: string; isDomainValueField(fieldName: string): boolean; resolveDefaultOptions?(fieldName: string): FormatterOptions | undefined; }): FormattingInfo | undefined; /** Allows Testing for the existence of a given formatter id. */ hasFormatter(formatterId: string): boolean; /** * Formats values using the resolved formatter infos. * @param values values to format * @param options infos resolved by the resolveFormattingInfo method. */ format(values: any[], options: FormattingInfo): string; } /** * A DatasetItemIdsProvider provides ids which are filled inside a dataset. * The limit parameter defines the maximum allowed ids to return. */ interface DatasetItemIdsProvider { /** * @param opts options to respect during id resolving. A limit of -1 means unlimited. * @returns a promise with the ids as array. * An optional total value, which defines the full amount available ids. * An optional hasMore flag, which defines that there where more ids available. * An data lookup, which carries the concrete items. If provided a store is not requested for extra data. */ (opts: { limit: number; }): Promise<{ ids: IdType[]; total?: number; hasMore?: boolean; data?: Record>>; }>; } /** * A column provider. Is called to build columns for a dataset. */ interface ColumnProvider { /** * This function is invoked by a TableModel implementation after the dataset is initialized. * @return columns to shown in a table. */ getColumns(): Promise; } /** * Factory injected into the DataTableFactory implementation. * It is responsible to create column providers. * The default implementation is registered as `result-api.ColumnProviderFactory` at the system. */ interface ColumnProviderFactory { /** * Creates a ColumnProvider. * @param opts.dataset the dataset for which columns should be created. * @param opts.formatters available information about Formatters and FormattingInfos. * @param opts.isAllowedField a function to check if a fields should be displayed. */ createColumnProvider(opts: { dataset: Dataset; formatters: FormatterFacade; isAllowedField: (name: string) => boolean; }): ColumnProvider; } /** * Represents a common event when collection is changed. */ interface CollectionChangedEvent { /** * added items. */ readonly added: T[]; /** * removed items. */ readonly deleted: T[]; /** * Items which values are updated within the collection. */ readonly updated: T[]; } /** * Events fired by an selection instance. */ interface SelectionEvents { /** Emitted if the selection changed. */ changed: CollectionChangedEvent; } /** * Represents a selection state. */ interface Selection extends EventSource>, Iterable { /** * Adds a value to the selection. */ add(value: ItemType): this; /** * Adds all values to the selection. * @param value iterable of values. */ addAll(value: Iterable): this; /** * Removes the value. * @returns Returns true if the value existed and has been removed, or false if it does not exist. */ delete(value: ItemType): boolean; /** * Removes the values. * @returns Returns true if the all values existed and are removed, or false if a value does not exist. */ deleteAll(value: Iterable): boolean; /** * @returns a boolean indicating whether an object exists or not. */ has(value: ItemType): boolean; /** * Clears the selection. */ clear(): void; /** * Number of items in the selection. */ readonly size: number; } type DataTableId = DataTable["id"]; /** * Events fired by a DataTableCollection. */ interface DataTableCollectionEvents { /** Emitted if collection is changed. */ "changed": CollectionChangedEvent; /** Emitted if the selection is changed. */ "selection-changed": CollectionChangedEvent; /** Emitted when a data-table is focused/unfocused */ "data-table-focus-changed": { focusedTableId: DataTableId | undefined; }; /** Emitted when a data-table is clicked */ "data-table-clicked": { tableId: DataTableId; }; /** Emitted when the instance is destroyed. */ "destroyed": void; } /** * Bag of data tables. * * To access the items you can use for...of: * * ```ts * const dataTables = ...; * for (const dataTable of dataTables) { * ... * } * ``` * If you need an array use the `tables` property * * ```ts * const dataTables = ...; * const tables = dataTables.tables; * ``` * * Use the `size` property to check how many data tables are available. * * ```ts * const dataTables = ...; * const size = dataTables.size; * ``` * * Use `getFirstSelectedTable` to access the first selected data table (the one shown in the result-ui). * * ```ts * const dataTables = ...; * const dataTable = dataTables.getFirstSelectedTable(); * ``` * * You can watch the events `changed`, `selection-changed` and `destroyed`. * * ```ts * const dataTables = ...; * dataTables.on("changed",({added, deleted, updated})=> { ... }); * dataTables.on("selection-changed",({added, deleted, updated})=> { ... }); * dataTables.on("destroyed",()=> { ... }); * ``` * */ interface DataTableCollection extends EventSource, Iterable { /** * Appends a new data table. */ add(value: DataTable): this; /** * Test if data table with id is contained. * @param id */ hasId(id: DataTableId): boolean; /** * Lookup data table by id */ getById(id: DataTableId): DataTable | undefined; /** * Delete data table by id */ deleteById(id: DataTableId): DataTable | undefined; /** * Delete data table by id and destroys it. */ deleteAndDestroyById(id: DataTableId): DataTable | undefined; /** * Amount of data tables. */ readonly size: number; /** * Provides access to an array representation of the tables. * Equivalent to `Array.from(tableCollection)`. * A change to the array is not reflected in the collection. */ readonly tables: ReadonlyArray; /** * Provides a way to get all selected items. */ getSelectedTables(): Iterable; /** * Provides access to the first selected data table, if one is available. */ getFirstSelectedTable(): DataTable | undefined; /** * Provides access to all selected ids. */ getSelectedTableIds(): Iterable; /** * Provides access to the first selected data table, if one is available. */ getFirstSelectedTableId(): DataTableId | undefined; /** * true = selected tables available. * false = no tables selected. */ hasSelectedTables(): boolean; /** * Amount of selected items. */ getSelectedTablesCount(): number; /** * Clears the selection. Note: A new table will be selected automatically, a tick later. */ clearTableSelection(): void; /** * Adds all table ids to the selection. * @param ids iterable of ids. * @param selected true = select, false = deselect. If omitted true is assumed. */ selectTables(ids: Iterable, selected?: boolean): void; /** * Removes all table ids from the selection. * @param ids iterable of ids. */ deselectTables(ids: Iterable): void; /** * @returns a boolean indicating whether the given id is selected. */ isSelectedTable(id: DataTableId): boolean; /** * Emits event 'data-table-focus-changed'. * @param id id of data table */ focusTable(id: DataTableId | undefined): void; /** * Emits event 'data-table-clicked'. * @param id id of data table */ clickTable(id: DataTableId): void; /** * Destroy instance. * Delegates destruction to all data tables. */ destroy(): void; } /** * Events fired by a data table. */ interface DataTableEvents { /** Emitted when the data table is destroyed. */ destroyed: void; } /** * Dynamic properties of a data table. */ interface DataTableWatchProperties { /** title can be changed **/ title: string; } /** * A data table provides access to a dataset and an associated table model. * * The property `tableModel` gets access to the current table state. * The property `dataset` gets access to the full available data. * * You can watch for changes on the property `title`. * * ```ts * const dataTable = ...; * dataTable.watch("title",({value})=> { ... }); * ``` * * You can watch the event `destroyed`. * * ```ts * const dataTable = ...; * dataTable.on("destroyed",()=> { ... }); * ``` * */ interface DataTable extends EventSource, Watchable { /** * id of the data table. */ readonly id: string; /** * Title of the data table. */ title: string; /** The table model */ readonly tableModel: TableModel; /** The table dataset */ readonly dataset: Dataset; /** * Destroy this instance. * Delegates destruction to all datasets and tables. */ destroy(): void; } /** * The events fired by a Dataset. */ interface DatasetEvents { /** Emitted when items changed (removed or added). */ "items-changed": CollectionChangedEvent; /** Emitted when the dataset is destroyed. */ "destroyed": void; } /** * Properties which may dynamically change in a dataset. */ interface DatasetWatchProperties { /** * the title. */ title: string; /** * the itemCount. */ itemCount: ItemCount; /** * the state. */ state: DatasetState; /** an init error happened */ initError: Error; /** an update error happened */ updateError: Error; } /** * Possible id types of dataset items. */ type DatasetItemId = AllowedIdTypes; /** * Possible states of a dataset. */ type DatasetState = "not-initialized" | "initializing" | "initialized" | "init-error" | "destroyed" | "updating"; /** * A dataset references a data source. * A well known data source is a Store. */ type DataSource> = Readonly>> = Store | unknown; /** * A data set represents a subset of items of a data source. * It provides access to full displayable data. * * The `dataSource` property is the source of the available data and in most cases an instance of a store. * * You can watch the properties `title`, `itemCount`, `state`, `initError` and `updateError` for changes. * * ```ts * const dataset = ...; * dataset.watch("state", ({value})=> { * const newState = value; * // newState can be: "not-initialized" | "initializing" | "initialized" | "init-error" | "destroyed" | "updating" * }); * ``` * * You can watch for the events `items-changed`, `destroyed`. * * ```ts * const dataset = ...; * dataset.on("items-changed", ({added, deleted, updated})=> { ... }); * dataset.on("destroyed",()=> { ... }); * ``` */ interface Dataset extends EventSource>, Watchable { /** * Changeable title. * Typically initialized from data source. */ title: string; /** * Dataset id. Typically initialized and equal to id of data source (store id). */ readonly id: string; /** * The real data source. */ readonly dataSource: DataSource; /** * Service metadata about the data source if provided. */ readonly dataSourceProperties: Readonly> | undefined; /** * Capabilities of the data set. * The capabilities are only readable if the dataset is "initialized". */ readonly capabilities: DatasetCapabilities; /** * The fields of the data set. * The fields are only readable if the dataset is "initialized". */ readonly fields: ReadonlyArray; /** * The amount of items in the dataset. * The itemCount is only readable if the dataset is "initialized". */ readonly itemCount: ItemCount; /** * The current state of the dataset. */ readonly state: DatasetState; /** * A initialization error. Is available if state === "init-error". */ readonly initError: Error | undefined; /** * A update error. This error may happen if an updating process failed. */ readonly updateError: Error | undefined; /** * The default aria field for each item. * The dataset must be initialized to access this property. */ readonly defaultItemAriaField: string | undefined; /** * Provides access to the initial id provider, if not yet used to init the dataset. */ readonly initialIdsProvider: DatasetItemIdsProvider | undefined; /** * Starts dataset initialization. */ init(): void; /** Returns true if the dataset is in state initialized or updating */ isInitialized(): boolean; /** * Provides a way to convert the values of a data set item into a domain values. * Note to ensure that the method is working correctly the values of all domain fields should be provided. * * @param fieldValues fields and the matching values. * @returns converted values or the original value if not convertible. */ lookupDomainValues(fieldValues: Record): Record; /** * Provides a way to check if the values of a field can be converted into domain values. * @param fieldName name of a field. * @returns true if the values can be converted. */ isDomainValueField(fieldName: string): boolean; /** * Queries items from the dataset. * @param query the query. */ queryItems(query: QueryDefinition): QueryResult>; /** * Queries all available item ids from the dataset. */ queryAllIds(): QueryResult; /** * Removes the given items from the dataset. * Before using this method check the {@link DatasetCapabilities.supportsRemoveItems} State. * If supportsRemoveItems is false, the method will throw an error. * @param itemIds Ids which should be deleted from the dataset. */ removeItemsById(itemIds: Iterable): Promise; /** * Adds the given items to the dataset. * Before using this method check the {@link DatasetCapabilities.supportsAddItems} State. * If supportsAddItems is false, the method will throw an error. * @param itemIds Ids which will be added to the Dataset. */ addItemsById(itemIds: Iterable): Promise; /** * Adds the given items to the dataset. * Before using this method check the {@link DatasetCapabilities.supportsAddItems} State. * If supportsAddItems is false, the method will throw an error. * @param idsProvider A provider which provides new ids. */ addItemsByIdsProvider(idsProvider: DatasetItemIdsProvider): Promise; /** * Enforces the refresh of data of the given items. * Note: If one of the ids did not exist, then it is ignored. * @param itemIds Ids which data will be updated. */ updateItemsById(itemIds: Iterable): Promise; /** * Replaces all items in the dataset by the items provided by the ids provider. * All items not longer provided by the ids provider will be removed from the dataset. * @param idsProvider A provider which provides ids. */ replaceItemsByIdsProvider(idsProvider: DatasetItemIdsProvider): Promise; /** * Enforces the refresh of the data. * It may completely re-fetch item data and drop no longer existing items. * * Equivalent to: * ```ts * const allIds = await dataset.queryAllIds().toArray(); * dataset.updateItemsById(allIds); * ``` */ refresh(): Promise; /** * Removes any data from the dataset. */ clean(): Promise; /** * Destroys the dataset. */ destroy(): void; } /** * A field in the dataset. */ type DatasetField = FieldData; /** * A result of a query operation. */ interface QueryResult { /** * Full amount of items matching the query. * This may be higher as the returned items. */ total: Promise; /** * Async iterator over the result items. */ items: AsyncIterableIterator; /** * Provides convenient access to the items as array. */ toArray(): Promise; } /** * Specifies a query against a data set. */ interface QueryDefinition { /** * Lookup the given ids. */ ids?: IdType[]; /** * Defines required output fields. * Note the fields list only the attribute data. * To include geometry data please use the flag outGeometry. * If not defined "*" is assumed. * * - means all attribute fields * id - means only the id field. */ outFields?: string[] | "*" | "id"; /** * Indicates that geometry data should be included. * If omitted the DatasetItems will not have attached geometry data. */ outGeometry?: boolean; /** * Required CRS for the geometry output. * A dataset may have support for transformation but this is not a guarantee. */ outSr?: SpatialReference; /** * Request the geometry data with a limited offset value to reduce complexity. * This maybe supported for polygon data. */ outGeometryMaxAllowableOffset?: number; /** * Defines required sort order. */ sortBy?: SortSpecifier[]; /** * Pagination start index. */ start?: number; /** * Pagination size (page size). */ count?: number; } /** * An item from a {@link Dataset}. */ interface DatasetItem { /** Unique id of the item */ readonly id: IdType; /** * The attributes of the item. * Note this may only be a subset of attributes depending on the query options. */ readonly attributes: DeepReadonly>; /** Item geometry, if available */ readonly geometry?: Readonly; } /** Holds information about the number of items. */ interface ItemCount { /** * The number of available items in the dataset. */ readonly count: number; /** * The number of maximal items in the dataSource. * -1 indicates that this number is not available. */ readonly totalCount: number; /** * Indicates that count < fullCount * and that the data source has more items which can not be accessed. * */ readonly hasMore: boolean; } /** * Represents the capabilities of a {@link Dataset}. */ interface DatasetCapabilities { /** * Does the data set have items with geometry field. */ readonly supportsGeometry: boolean; /** * Flag if the dataset supports the removeItems method. */ readonly supportsRemoveItems: boolean; /** * Flag if the dataset supports the addItems method. */ readonly supportsAddItems: boolean; /** * Flag to indicate if data source supports popups. */ readonly supportsPopups: boolean; /** * Flag to indicate whether the _default highlight_ of items that are loaded in the result ui is disabled. * True by default. * * NOTE: Hover/selected highlight is not affected by this flag. */ readonly defaultHighlightEnabled: boolean; /** * Like {@link defaultHighlightEnabled} but for selected items. * * True by default. */ readonly selectedHighlightEnabled: boolean; } /** * Emitted when the focused item changes. */ interface FocusChangedEvent { /** * The id of the focused item or undefined if focus has been removed from the item. */ focusedItemId: IdType | undefined; } /** * Emitted e.g. when a row is clicked. */ interface RowEvent { /** * The id of the row item in the dataset. */ datasetItemId: IdType; } /** * A table item is a dataset item, but (normally) without geometry. */ type TableItem = DatasetItem; /** * Events fired by a TableModel. */ interface TableModelEvents { /** emitted when selection changes */ "selection-changed": CollectionChangedEvent; /** emitted when the focused item changes */ "focus-changed": FocusChangedEvent; /** emitted when the a row is clicked */ "row-clicked": RowEvent; /** emitted when row data changed */ "rows-changed": void; /** Emitted when the table model is destroyed. */ "destroyed": void; } /** * Watchable properties of a TableModel. */ interface TableModelWatchProperties { /** * Columns can be watched. */ columns: ReadonlyArray; /** * filterBy state can be watched. */ filterBy: Filter; /** * sortBy state can be watched. */ sortBy: SortSpecifier[]; /** * total state can be watched. */ total: number; /** * state can be watched. */ state: TableModelState; /** * if an error happened. */ loadError: Error; } /** * State of a table model. */ type TableModelState = "disconnected" | "loading" | "loaded" | "load-error"; /** * Represents the state of table UI. * It grants access to the formatted table data. * * You can watch the properties `columns`, `filterBy`, `sortBy`, `total`, `state` and `loadError` for changes. * * ```ts * const dataset = ...; * dataset.watch("state", ({value})=> { * const newState = value; * //newState can be: "disconnected" | "loading" | "loaded" | "load-error" * }); * ``` * * You can watch for the events `selection-changed`, `focus-changed`, `rows-changed` and `destroyed`. * * ```ts * const dataset = ...; * dataset.on("selection-changed", ({added, deleted })=> { ... }); * dataset.on("focus-changed", ({focusedItemId})=> { ... }); * dataset.on("rows-changed", ()=> { ... }); * dataset.on("destroyed",()=> { ... }); * ``` */ interface TableModel extends EventSource>, Watchable { /** * Columns of the table. */ readonly columns: ReadonlyArray; /** * Total number of items of the last query. */ readonly total: number; /** * State of the table. */ readonly state: TableModelState; /** * Load error if state === "load-error". */ readonly loadError: Error | undefined; /** * The dataset associated with the table. */ readonly dataset: Dataset; /** * Filter state. */ filterBy: Filter | undefined; /** * Sort state. */ sortBy: SortSpecifier[]; /** * The aria label of a row of the table. * This is a string like `Text: ${columnName}`. * The default UI attaches it as meta information to a row. */ readonly rowAriaLabel: string; /** * Gets currently fetched rows. * Should only be accessed if table is in state "loaded". * @param startIndex pagination start index. * @param count pagination size (page size) */ getRows(startIndex?: number, count?: number): ReadonlyArray>; /** * Provides a way to get access to the dataset item referenced by the row. * Note this item will have only the fields required by the table. * * @param datasetItemId id of a dataset item. */ getRowItem(datasetItemId: IdType): TableItem | undefined; /** * Provides a way to fetch all selected items. * A selected item may not directly be part of the rows. */ getSelectedItems(): AsyncIterable>; /** * Provides a way to fetch all selected items. * Behaves like getSelectedItems but provides a Promise with all items as an array. * A selected item may not directly be part of the rows. */ getAllSelectedItems(): Promise[]>; /** * Provides access to all selected ids. */ getSelectedIds(): IdType[]; /** * true = selected items available. * false = no item selected. */ hasSelectedIds(): boolean; /** * Amount of selected items. */ getSelectedCount(): number; /** * Clears the selection. */ clearSelection(): void; /** * Selects all currently available rows. */ selectAllAvailableRows(): Promise; /** * Selects all items available in the dataset. */ selectAllItems(): Promise; /** * Inverts the selection, reduced to currently available rows. */ invertSelectionOfAvailableRows(): Promise; /** * Inverts the selection of all available items in the dataset. */ invertSelectionOfAllItems(): Promise; /** * Adds all values to the selection. * @param datasetItemIds iterable of values. * @param selected true == select, false === deselect. If omitted this is interpreted as true. */ select(datasetItemIds: Iterable, selected?: boolean): void; /** * Removes all given values from the selection. * @param datasetItemIds iterable of values. */ deselect(datasetItemIds: Iterable): void; /** * @returns a boolean indicating whether the given id is selected. */ isSelectedId(datasetItemId: IdType): boolean; /** * Sets the focus to the given item. * If datasetItemId is undefined, the focus is removed from the item. */ focusItem(datasetItemId: IdType | undefined): void; /** * Emits a row-clicked event. * * @param datasetItemId id of row item. */ clickItem(datasetItemId: IdType): void; /** * Provides access to the data to display conversion code. * It converts a DatasetItem into a Row. * A row has column values, which are prepared to be displayed in table UI. * The column values are field data transformed by Formatters. * This method allows data conversion for dataset items currently not displayed in the table. * E.g. for CSV Export. * @param dataSetItem the item to transform * @param formatterOptionsOverrides Options how to format the output. * Can be used to override formatting of columns. * For example used to control the formatting of numeric values when exported as csv. */ convertDatasetItemToRow(dataSetItem: TableItem, formatterOptionsOverrides?: FormatterOptions): RowItem; /** * Connect this table to the dataset. * The UI may use this to ensure that a table observes dataset changes. */ connect(): void; /** * Disconnect this table from the dataset. * The UI may use this to prevent unnecessary updates as long as the table is not shown. */ disconnect(): void; /** * Destroys this table model. */ destroy(): void; /** Enforce a refresh of the rows. */ refresh(): void; /** * Limits the columns returned by the {@link columns} property to those having one of the specified names. * * @param names names of columns to be returned by the {@link columns} property, or `undefined` to let it return all columns. * */ setVisibleColumns(names?: string[]): void; } /** * A row in the table model. */ interface RowItem { /** * Referenced data set item id. */ datasetItemId: IdType; /** * The formatted column values of the row. */ columnValues: string[]; /** * The raw field values of each column. */ rawColumnValues: unknown[][]; } /** * Lists all well known filters. */ type Filter = SuggestFilter; /** * A suggest filter definition. */ interface SuggestFilter { /** * Text value to suggest. */ suggestValue: string; } /** * Allowed values for Column alignment */ type ColumnAlign = "left" | "right" | "center"; /** * A table column. */ interface Column { /** * Name of the column. */ readonly name: string; /** * Title of the column. */ readonly title: string; /** * Specifies if this column is sortable. */ readonly sortable: boolean; /** * Specifies if this column should be sorted by its original value or by its formatted display value. * The following values are allowed: * * - `undefined` (default): The column is sorted by its original value. * - `string`: The column is sorted by its formatted display value as a string. * - `string-with-number`: The column is sorted by its formatted display value, * whereby numeric parts are sorted as numbers. Example: "a1" < "a2" < "a10". */ readonly sortFormattedValue?: "string" | "string-with-number" | undefined; /** * Id of a formatter. */ readonly formatterId: string; /** * Options for the formatter identified by formatterId; */ readonly formatterOptions?: Record; /** Column alignment */ readonly align?: ColumnAlign; /** Column special names for UI rendering */ readonly renderType?: "auto" | "text" | "mail" | "link"; /** * Referenced data set fields. */ readonly dataSetFields: ReadonlyArray; } type SELECTION_COLUMN_NAME = "SELECTION_COLUMN"; /** Specifies the sort order. */ interface SortSpecifier { /** The field/column name being sorted by. */ name: string; /** True if the sort order is reversed. */ descending: boolean; } export type { ArcadeFormatOptions, CollectionChangedEvent, Column, ColumnAlign, ColumnProvider, ColumnProviderFactory, DataSource, DataTable, DataTableCollection, DataTableCollectionEvents, DataTableEvents, DataTableId, DataTableWatchProperties, Dataset, DatasetCapabilities, DatasetEvents, DatasetField, DatasetItem, DatasetItemId, DatasetItemIdsProvider, DatasetState, DatasetWatchProperties, DateTimeFormat, DateTimeFormatOptions, FORMATTER_COMBINED_IDENTIFIER, FORMATTER_DOMAIN_VALUE_IDENTIFIER, FORMATTER_ID_IDENTIFIER, Filter, FocusChangedEvent, Formatter, FormatterFacade, FormatterOptions, FormattingInfo, FormattingInfoProvider, ItemCount, NumberFormatOptions, QueryDefinition, QueryResult, RowEvent, RowItem, SELECTION_COLUMN_NAME, Selection, SelectionEvents, SortSpecifier, SuggestFilter, TableItem, TableModel, TableModelEvents, TableModelState, TableModelWatchProperties, WellKnownFormatterOptions };