jamis
Version:
一种支持通过JSON配置方式生成页面的组件库
64 lines (63 loc) • 2.65 kB
TypeScript
import React from 'react';
import type { ActionObject, IScopedContext } from 'jamis-core';
import { ScopedContext } from 'jamis-core';
import type { TabSchema, TabSource, TabsProps } from '../types';
interface TabsState {
activeKey: string | number;
prevKey: any;
localTabs: Array<TabSource>;
/**
* 是否从 source 数据中生成
*/
isFromSource: boolean;
}
export declare class TabsRenderer extends React.Component<TabsProps, TabsState> {
static defaultProps: Partial<TabsProps>;
static contextType: React.Context<IScopedContext<import("jamis-core").ScopedComponentType>>;
context: React.ContextType<typeof ScopedContext>;
renderTab?: (tab: TabSchema, props: TabsProps, index: number) => JSX.Element;
activeKey?: string | number;
constructor(props: TabsProps, context: IScopedContext);
componentWillUnmount(): void;
/**
* 根据当前地址栏的hash和qs来匹配activeKey
*/
getActiveKeyFromLocation: (location: any, tabs: TabsProps["tabs"]) => string | number | undefined;
/**
* 初始化 tabs 数组,当从 source 获取数据源时
*/
initTabArray: (tabs: Array<TabSource>, source?: string, data?: any) => [Array<TabSource>, boolean];
componentDidMount(): void;
componentDidUpdate(prevProps: TabsProps, prevState: TabsState): void;
/**
* 同步hash或者qs到地址栏
*/
syncLocation: (activeKey: string | number | undefined, localTabs: TabsProps["tabs"]) => void;
resolveTabByKey(key: string | number | undefined): TabSource | undefined;
resolveKeyByValue(value: any): string | number | undefined;
autoJumpToNeighbour: (key: string | number | undefined) => void;
handleAdd: (tab?: TabSchema, switchTo?: boolean) => Promise<void>;
/**
* 处理新增或者激活指定的tab, 当tabKey存在时激活, 不存在时新增tab
*/
handleAddOrActiveTab: (tab: TabSchema) => Promise<void>;
/**
* 刷新tab
*/
handleRefreshTab: (index: number) => void;
handleClose: (key: string | number, activeKeyAfterClose?: string | number) => Promise<void>;
handleEdit: (index: number, text: string) => void;
handleDragChange: (e: any) => Promise<void>;
handleSelect: (key: number | string | undefined) => Promise<void>;
/**
* 动作处理
*/
doAction(action: ActionObject, args?: any): Promise<void>;
switchTo: (index: number) => void;
currentIndex: () => number;
renderToolbar(): JSX.Element | null;
renderTabContent: (tab: TabSource, index: number) => JSX.Element;
renderTabs(): JSX.Element;
render(): JSX.Element;
}
export {};