gentics-ui-core
Version:
This is the common core framework for the Gentics CMS and Mesh UI, and other Angular applications.
90 lines (89 loc) • 3.31 kB
TypeScript
import { EventEmitter, InjectionToken } from '@angular/core';
import { Observable } from 'rxjs';
import { DragStateTrackerFactory, FileDragState } from './drag-state-tracker.service';
import * as i0 from "@angular/core";
/**
* A token that can be used to inject a mock into the service
* @internal
*/
export declare const PAGE_FILE_DRAG_EVENT_TARGET: InjectionToken<unknown>;
/**
* A helper service that listens for dragenter/dragleave/drop events on the window
* and tracks when files are dragged into or out of the active tab.
*
* When files are accidentally dropped on the tab outside of a drop zone, the drop
* can be cancelled to prevent the browser from opening/downloading the file.
* See {@link gtxPreventFileDrop} for details.
*/
export declare class PageFileDragHandler {
/**
* Fires when a file is dragged into the current tab, dragged out or dropped.
* @exmample
* class Component {
* constructor(private pageDrag: PageFileDragStatusService) { }
* }
*
* <ul *ngIf="pageDrag.filesDragged$ | async"> ... </ul>
*/
filesDragged$: Observable<FileDragState>;
/**
* Emits a list when a file is dragged into the current tab.
* The list contains `{ "type": string }` elements.
*/
dragEnter: Observable<FileDragState>;
/**
* Emits false when a file is dragged out of the current tab.
*/
dragStop: Observable<boolean>;
/**
* Fires when a drop event is prevented.
*/
dropPrevented: EventEmitter<void>;
private _filesDragged;
private _subscription;
private _eventTarget;
private _eventsBound;
private _componentsWantingToPreventFileDrop;
private _preventAccidentalFileDrop;
/**
* Returns true if a file is dragged over the current page/tab.
* @example
* class Component {
* constructor(private pageDragStatus: PageFileDragStatusService) {}
* }
*
* <ul *ngIf="pageDragStatus.filesDragged"> ... </ul>
*/
get filesDragged(): FileDragState;
/**
* Returns true if files are dragged over the current tab and any file matches the specified mime type.
* @example
* class Component {
* constructor(private pageDragStatus: PageFileDragStatusService) {}
* }
*
* <ul *ngIf="pageDragStatus.anyDraggedFileIs('image/*')"> ... </ul>
*/
anyDraggedFileIs(allowedTypes: string): boolean;
/**
* Returns true if files are dragged over the current page and all files match the specified mime type.
* @example
* class Component {
* constructor(private pageDragStatus: PageFileDragStatusService) {}
* }
*
* <ul *ngIf="pageDragStatus.allDraggedFilesAre('image/*')"> ... </ul>
*/
allDraggedFilesAre(allowedTypes: string): boolean;
constructor(eventTarget: any, dragState: DragStateTrackerFactory);
destroy(): void;
/** @internal */
bindEvents(): void;
/** @internal */
unbindEvents(): void;
/** @internal */
preventFileDropOnPageFor(directive: any, prevent: boolean): void;
private preventAccidentalDrop;
static ɵfac: i0.ɵɵFactoryDeclaration<PageFileDragHandler, [{ optional: true; }, null]>;
static ɵprov: i0.ɵɵInjectableDeclaration<PageFileDragHandler>;
}