UNPKG

@eclipse-scout/core

Version:
337 lines 17.8 kB
/// <reference types="jquery" /> import { AbstractGrid, Comparator, ContextMenuPopup, DoubleClickSupport, EnumObject, Filter, FilterOrFunction, FilterResult, FilterSupport, GridData, InitModelOf, KeyStrokeContext, LoadingSupport, LogicalGrid, Menu, MenuDestinations, MenuFilter, ObjectOrChildModel, ObjectOrModel, PlaceholderTile, Point, Predicate, Range, Rectangle, Resizable, ScrollToOptions, TextFilter, Tile, TileGridEventMap, TileGridLayout, TileGridLayoutConfig, TileGridModel, TileGridSelectionHandler, TileMoveHandler, UpdateFilteredElementsOptions, VirtualScrolling, Widget } from '../index'; export declare class TileGrid<TTile extends Tile = Tile> extends Widget implements TileGridModel { model: TileGridModel; eventMap: TileGridEventMap; self: TileGrid<TTile>; logicalGrid: AbstractGrid; animateTileRemoval: boolean; animateTileInsertion: boolean; comparator: Comparator<TTile>; contextMenu: ContextMenuPopup; empty: boolean; filters: Filter<TTile>[]; filteredElementsDirty: boolean; focusedTile: TTile; gridColumnCount: number; prefGridColumnCount: number; layoutConfig: TileGridLayoutConfig; menus: Menu[]; multiSelect: boolean; renderAnimationEnabled: boolean; selectable: boolean; selectedTiles: TTile[]; selectionHandler: TileGridSelectionHandler; scrollable: boolean; startupAnimationDone: boolean; startupAnimationEnabled: boolean; tileRemovalPendingCount: number; viewRangeSize: number; viewRangeRendered: Range; virtual: boolean; virtualScrolling: VirtualScrolling; withPlaceholders: boolean; placeholderProducer: () => ObjectOrModel<PlaceholderTile>; textFilterEnabled: boolean; filterSupport: FilterSupport<TTile>; createTextFilter: () => TextFilter<TTile>; updateTextFilterText: string; defaultMenuTypes: string[]; wrappable: boolean; movableProducer: (tile: Tile) => TileMoveHandler; resizableProducer: (tile: Tile) => Resizable; $filterFieldContainer: JQuery; $fillBefore: JQuery; $fillAfter: JQuery; protected _tiles: (TTile | PlaceholderTile)[]; protected _filteredTiles: (TTile | PlaceholderTile)[]; protected _doubleClickSupport: DoubleClickSupport; protected _filterMenusHandler: (menuItems: Menu[], destination: MenuDestinations) => Menu[]; protected _renderViewPortAfterAttach: boolean; protected _scrollParentScrollHandler: (event: JQuery.ScrollEvent) => void; constructor(); static MenuType: { readonly EmptySpace: "TileGrid.EmptySpace"; readonly SingleSelection: "TileGrid.SingleSelection"; readonly MultiSelection: "TileGrid.MultiSelection"; }; protected _init(model: InitModelOf<this>): void; protected _createKeyStrokeContext(): KeyStrokeContext; protected _createMovableProducer(): (tile: Tile) => TileMoveHandler; setMovableProducer(producer: (tile: Tile) => TileMoveHandler): void; protected _createResizableProducer(): (tile: Tile) => Resizable; setResizableProducer(producer: (tile: Tile) => Resizable): void; protected _initVirtualScrolling(): void; protected _createVirtualScrolling(): VirtualScrolling; protected _createLoadingSupport(): LoadingSupport; protected _initKeyStrokeContext(): void; protected _initTiles(): void; protected _initTile(tile: (TTile | PlaceholderTile)): void; protected _render(): void; protected _createLayout(): TileGridLayout; protected _renderProperties(): void; protected _remove(): void; protected _renderOnAttach(): void; protected _renderEnabled(): void; protected _updateTabbable(): void; insertTile(tile: ObjectOrChildModel<TTile>): void; insertTiles(tilesToInsert: ObjectOrChildModel<TTile> | ObjectOrChildModel<TTile>[]): void; protected _insertTilesInternal(tilesToInsert: ObjectOrChildModel<TTile | PlaceholderTile> | ObjectOrChildModel<TTile | PlaceholderTile>[], appendPlaceholders?: boolean): void; deleteTile(tile: TTile): void; deleteTiles(tilesToDelete: TTile | (TTile)[]): void; protected _deleteTilesInternal(tilesToDelete: TTile | PlaceholderTile | (TTile | PlaceholderTile)[], appendPlaceholders?: boolean): void; deleteAllTiles(): void; moveTileBefore(tileToMove: TTile, sibling: TTile): void; moveTileAfter(tileToMove: TTile, sibling: TTile): void; setTiles(tilesOrModels: ObjectOrChildModel<TTile> | ObjectOrChildModel<TTile>[]): void; protected _setTilesInternal(tilesOrModels: ObjectOrChildModel<TTile | PlaceholderTile> | ObjectOrChildModel<TTile | PlaceholderTile>[], appendPlaceholders?: boolean): void; protected _insertTiles(tiles: (TTile | PlaceholderTile)[]): void; protected _insertTile(tile: (TTile | PlaceholderTile)): void; protected _renderTile(tile: Tile): void; protected _renderInsertTiles(tiles: (TTile | PlaceholderTile)[]): void; protected _animateInsertTiles(tiles: (TTile | PlaceholderTile)[]): void; protected _removeAllTiles(): void; protected _renderAllTiles(): void; protected _deleteTiles(tiles: (TTile | PlaceholderTile)[]): void; protected _deleteTile(tile: TTile | PlaceholderTile): void; protected _animateTileRemoval(tile: TTile | PlaceholderTile): boolean; protected _animateTileInsertion(tile: TTile | PlaceholderTile): boolean; protected _onAnimatedTileRemove(tile: Tile): void; /** * Sets a comparator that is used to sort the tiles. After setting a comparator, you need to call {@link sort}. * * The tiles will be sorted automatically whenever new tiles are inserted. */ setComparator(comparator: Comparator<TTile>): void; protected _sortWhileInit(): void; sort(): void; protected _sort(tiles: (TTile | PlaceholderTile)[]): void; invalidateLayoutTree(invalidateParents?: boolean): void; /** @see TileGridModel.gridColumnCount */ setGridColumnCount(gridColumnCount: number): void; protected _setGridColumnCount(gridColumnCount: number): void; /** @see TileGridModel.layoutConfig */ setLayoutConfig(layoutConfig: ObjectOrModel<TileGridLayoutConfig>): void; protected _setLayoutConfig(layoutConfig: ObjectOrModel<TileGridLayoutConfig>): void; protected _renderLayoutConfig(): void; protected _setMenus(menus: Menu[]): void; protected _filterMenus(menus: Menu[], destination: MenuDestinations, onlyVisible?: boolean, enableDisableKeyStrokes?: boolean, notAllowedTypes?: string | string[]): Menu[]; showContextMenu(options: { pageX?: number; pageY?: number; }): void; /** * @param options may contain pageX, pageY, menuItems and menuFilter. * If these properties are not provided they are determined automatically. * @internal */ _showContextMenu(options?: { pageX?: number; pageY?: number; menuItems?: Menu[]; menuFilter?: MenuFilter; }): void; /** @see TileGridModel.scrollable */ setScrollable(scrollable: boolean): void; protected _renderScrollable(): void; protected _onScroll(event: JQuery.ScrollEvent): void; protected _onScrollParentScroll(event: JQuery.ScrollEvent): void; setWithPlaceholders(withPlaceholders: boolean): void; protected _renderWithPlaceholders(): void; setPlaceholderProducer(placeholderProducer: () => ObjectOrModel<PlaceholderTile>): void; fillUpWithPlaceholders(): void; /** * @deprecated Use {@link tiles} instead */ tilesWithoutPlaceholders(): TTile[]; /** * @returns all tiles of the tile grid without {@link PlaceholderTile}s. * @see TileGridModel.withPlaceholders */ get tiles(): TTile[]; /** * @returns all tiles of the tile grid that accept the {@link filters} without {@link PlaceholderTile}s. * @see TileGridModel.filters * @see TileGridModel.withPlaceholders */ get filteredTiles(): TTile[]; protected _tilesWithoutPlaceholders(tiles: (TTile | PlaceholderTile)[]): TTile[]; getFilteredTilesWithPlaceholders(): (TTile | PlaceholderTile)[]; protected _createPlaceholders(): PlaceholderTile[]; protected _createPlaceholder(): PlaceholderTile; protected _deleteObsoletePlaceholders(): void; protected _deleteAllPlaceholders(): void; placeholders(): PlaceholderTile[]; protected _insertMissingPlaceholders(): void; /** * @returns the deleted placeholders */ protected _deletePlaceholders(tiles: (TTile | PlaceholderTile)[]): PlaceholderTile[]; validateLogicalGrid(): void; protected _setLogicalGrid(logicalGrid: LogicalGrid | string): void; setFocusedTile(tile: TTile): void; /** @see TileGridModel.selectable */ setSelectable(selectable: boolean): void; protected _renderSelectable(): void; /** @see TileGridModel.multiSelect */ setMultiSelect(multiSelect: boolean): void; /** * Selects the given tiles and deselects the previously selected ones. * * Tiles, that are currently invisible due to an active filter, are excluded and won't be selected. */ selectTiles(tileOrIds: TTile | string | (TTile | string)[]): void; /** @see selectTiles */ selectTile(tile: TTile): void; /** * Selects all tiles. As for every selection operation: only filtered tiles are considered. */ selectAllTiles(): void; deselectTiles(tiles: TTile | TTile[]): void; deselectTile(tile: TTile): void; deselectAllTiles(): void; /** * Deselects every tile if all tiles are selected. Otherwise selects all tiles. */ toggleSelection(): void; addTilesToSelection(tiles: TTile[]): void; addTileToSelection(tile: TTile): void; isTileSelected(tile: TTile): boolean; /** * @returns true if the tile is completely or partially visible in the first scrollable parent. */ isTileInView(tile: TTile): boolean; /** @see TileGridModel.wrappable */ setWrappable(wrappable: boolean): void; protected _onTileMouseDown(event: JQuery.MouseDownEvent): boolean; protected _onTileClick(event: JQuery.ClickEvent): void; protected _triggerTileClick(tile: TTile, mouseButton: number, originalEvent: JQuery.ClickEvent): void; protected _onTileDoubleClick(event: JQuery.DoubleClickEvent): void; doTileAction(tile: TTile): void; protected _triggerTileAction(tile: TTile): void; setSelectionHandler(selectionHandler: TileGridSelectionHandler): void; protected _selectTileOnMouseDown(event: JQuery.MouseDownEvent): void; scrollTo(tile: TTile, options?: ScrollToOptions): void; /** * Brings the first selected tile into view by scrolling the first scrollable parent. */ revealSelection(): void; /** * @param filter The filters to add. * @param applyFilter Whether to apply the filters after modifying the filter list or not. Default is true. */ addFilter(filter: FilterOrFunction<TTile> | FilterOrFunction<TTile>[], applyFilter?: boolean): void; /** * @param filter The filters to remove. * @param applyFilter Whether to apply the filters after modifying the filter list or not. Default is true. */ removeFilter(filter: FilterOrFunction<TTile> | FilterOrFunction<TTile>[], applyFilter?: boolean): void; /** * @param filter The new filters. * @param applyFilter Whether to apply the filters after modifying the filter list or not. Default is true. */ setFilters(filters: FilterOrFunction<TTile> | FilterOrFunction<TTile>[], applyFilter?: boolean): void; filter(): void; protected _applyFilters(tiles: (TTile | PlaceholderTile)[], fullReset?: boolean): FilterResult<TTile>; protected _createFilterSupport(): FilterSupport<TTile>; protected _createTextFilter(): TextFilter<TTile>; protected _updateTextFilterText(filter: Filter<TTile>, text: string): boolean; /** @see TileGridModel.textFilterEnabled */ setTextFilterEnabled(textFilterEnabled: boolean): void; isTextFilterFieldVisible(): boolean; protected _renderTextFilterEnabled(): void; updateFilteredElements(result?: FilterResult<TTile>, opts?: UpdateFilteredElementsOptions): void; protected _updateEmpty(): void; setEmpty(empty: boolean): void; protected _renderEmpty(): void; /** * @returns the tiles which are accepted by the filter and therefore visible. */ protected _filterTiles<TTile extends Tile>(tiles?: TTile[]): TTile[]; findTileIndexAt(x: number, y: number, startIndex?: number, reverse?: boolean): number; findTilesInRange(viewRange: Range, filter?: Predicate<TTile>): TTile[]; /** * If the max range is used, the live list of filtered tiles is returned, because every tile has to be in the range. * @param considerPlaceholders whether placeholder tiles should be processed as well. Default is true. */ protected _findTilesInRange<T extends boolean>(viewRange: Range, filter?: Predicate<TTile>, considerPlaceholders?: T): T extends true ? (TTile | PlaceholderTile)[] : TTile[]; findTilesInRow(row: number): TTile[]; /** * @param considerPlaceholders whether placeholder tiles should be processed as well. Default is true. */ protected _findTilesInRow<T extends boolean>(row: number, considerPlaceholders?: T): T extends true ? (TTile | PlaceholderTile)[] : TTile[]; eachTileInRow(row: number, func: (tile: TTile, index: number) => void): TTile[]; /** * Executes the given function for each tile in a row. * @param considerPlaceholders whether placeholder tiles should be processed as well. Default is true. */ protected _eachTileInRow<T extends boolean>(row: number, func: (tile: TTile | PlaceholderTile, index: number) => void, considerPlaceholders?: T): T extends true ? (TTile | PlaceholderTile)[] : TTile[]; /** @see TileGridModel.virtual */ setVirtual(virtual: boolean): void; protected _setVirtual(virtual: boolean): void; protected _renderVirtual(): void; protected _updateVirtualScrollable(): void; calculateViewRangeSize(): number; /** @see TileGrid.viewRangeSize */ setViewRangeSize(viewRangeSize: number, updateViewPort?: boolean): void; protected _heightForRow(row: number): number; /** * Used for virtual scrolling to calculate the view range size. * @returns the configured rowHeight + vgap / 2. Reason: the gaps are only between rows, the first and last row therefore only have 1 gap. */ protected _minRowHeight(): number; rowCount(gridColumnCount?: number): number; /** * Calculates and renders the rows which should be visible in the current viewport based on scroll top. * @internal */ _renderViewPort(): void; /** * Renders the rows visible in the viewport and removes the other rows */ protected _renderViewRange(viewRange: Range): void; protected _renderTilesInRange(range: Range): void; /** * @returns the newly rendered tiles * @internal */ _renderTileDelta(filterResult?: FilterResult<TTile | PlaceholderTile>): (TTile | PlaceholderTile)[]; protected _removeTileByFilter(tile: TTile | PlaceholderTile): void; protected _renderTileVisibleForFilter(tile: Tile): void; protected _renderTileOrder(prevTiles: (TTile | PlaceholderTile)[]): void; protected _rowsRenderedInfo(): string; protected _removeTilesInRange(range: Range): void; protected _removeTilesInRow(row: number): void; ensureTileRendered(tile: TTile): void; protected _renderFiller(): void; protected _calculateFillerHeight(range: Range): number; /** * If virtual is false, the live list of filtered tiles is returned, because every tile has to be rendered. * If virtual is true, the rendered tiles are collected and returned. */ renderedTiles<T extends boolean>(considerPlaceholders?: T): T extends true ? (TTile | PlaceholderTile)[] : TTile[]; /** * Swaps the position ({@link gridDataHints.x}, {@link gridDataHints.y}) and size ({@link gridDataHints.w}, {@link gridDataHints.h}) of the given tiles * including their position in the {@link tiles} list. */ swapTileBounds(tile1: TTile, tile2: TTile): void; /** * Updates the {@link Tile.gridDataHints} of the tile based on the given logical bounds and moves other tiles away. * * If explicit x/y values are used in the {@link Tile.gridDataHints}, the other tiles are moved down by adjusting their x/y values explicitly, see {@link tileUtil.moveOtherTilesDown}. * Otherwise, (if the grid is arranged automatically), the resized tile will just be inserted at the correct position which will move the other tiles automatically. * * @param logicalBounds the new position and size of the tile based on the effective grid defined by {@link LogicalGridLayoutInfo.gridDataHints}. * @param ignorer If the function returns true the passed tile will be ignored and never be moved. This is typically used for placeholder tiles. */ resizeTile(tileToResize: TTile, logicalBounds: Rectangle, ignorer?: (tile: Tile) => boolean): void; protected _computeGridData(tileToResize: TTile, logicalBounds: Rectangle): GridData; protected _moveOtherTiles(tileToResize: TTile, gridData: GridData, logicalBounds: Rectangle, ignorer?: (tile: Tile) => boolean): void; protected _moveOtherTilesExplicitly(tileToResize: TTile, gridData: GridData, ignorer?: (tile: Tile) => boolean): void; /** * @returns the tile before the given position. Only tiles accepted by the filter are considered. */ protected _findTileBefore(position: Point, filter?: Predicate<Tile>): TTile; } export type TileGridMenuType = EnumObject<typeof TileGrid.MenuType>; //# sourceMappingURL=TileGrid.d.ts.map