import type { BlockStdScope, EventName, UIEventHandler } from '@blockeditor/block-std'; import type { Disposable, Slot } from '@blockeditor/global/utils'; import type { Page } from '@blockeditor/store'; import type { UniComponent } from '../../_common/components/uni-component/uni-component.js'; import type { DataViewSelection } from '../../_common/utils/index.js'; import type { DatabaseBlockModel } from '../database-model.js'; import type { InsertToPosition } from '../types.js'; import type { DataViewManager } from './data-view-manager.js'; export type DataViewHeaderComponentProp = UniComponent<{ viewMethods: DataViewExpose; view: T; }>; export interface DataViewProps { header?: DataViewHeaderComponentProp; view: T; bindHotkey: (hotkeys: Record) => Disposable; handleEvent: (name: EventName, handler: UIEventHandler) => Disposable; setSelection: (selection?: Selection) => void; selectionUpdated: Slot; onDrag?: (evt: MouseEvent, id: string) => () => void; getFlag?: Page['awarenessStore']['getFlag']; std: BlockStdScope; } export interface DataViewExpose { addRow?(position: InsertToPosition | number): void; getSelection?(): DataViewSelection | undefined; focusFirstCell(): void; showIndicator?(evt: MouseEvent): boolean; hideIndicator?(): void; moveTo?(id: string, evt: MouseEvent): void; } declare global { export interface DataViewDataTypeMap { } } type CommonViewDataType = { id: string; name: string; }; export type RealDataViewDataTypeMap = { [K in keyof DataViewDataTypeMap]: DataViewDataTypeMap[K] & CommonViewDataType & { mode: K; }; }; export type DefaultViewDataType = CommonViewDataType & { mode: string; }; type FallBack = [T] extends [never] ? DefaultViewDataType : T; export type DataViewDataType = FallBack; export type DataViewTypes = DataViewDataType['mode']; export interface DataViewConfig { type: DataViewTypes; defaultName: string; init(model: DatabaseBlockModel, id: string, name: string): Data; } export type DataViewToolsProps = { view: Manager; viewMethod: DataViewExpose; }; export interface DataViewRendererConfig<_Data extends DataViewDataType = DataViewDataType> { type: DataViewTypes; view: UniComponent; icon: UniComponent; tools?: UniComponent[]; } export declare class ViewManager { private map; getView(type: string): DataViewConfig; register(type: Type, config: Omit, 'type'>): void; get all(): DataViewConfig<(import("../table/define.js").TableViewData & CommonViewDataType & { mode: "table"; }) | (import("../kanban/define.js").KanbanViewData & CommonViewDataType & { mode: "kanban"; })>[]; } export declare const viewManager: ViewManager; export declare class ViewRendererManager { private map; getView(type: string): DataViewRendererConfig; register(type: Type, config: Omit, 'type'>): void; get all(): DataViewRendererConfig<(import("../table/define.js").TableViewData & CommonViewDataType & { mode: "table"; }) | (import("../kanban/define.js").KanbanViewData & CommonViewDataType & { mode: "kanban"; })>[]; } export declare const viewRendererManager: ViewRendererManager; export {}; //# sourceMappingURL=data-view.d.ts.map