UNPKG

jamis

Version:

一种支持通过JSON配置方式生成页面的组件库

199 lines (198 loc) 4.81 kB
import type { BaseSchemaScoped, IServiceStore, RendererProps, SchemaBoolean, SchemaMessage } from 'jamis-core'; import type { CSSProperties } from 'react'; import type { SchemaApi, SchemaClassName, SchemaCollection, SchemaExpression, SchemaRemark, TourConfig } from '../types'; /** * 样式属性名及值 */ export interface Declaration { [property: string]: string; } /** * css 定义 */ export interface CSSRule { [selector: string]: Declaration; } /** * amis Page 渲染器。详情请见:https://baidu.gitee.io/amis/docs/components/page */ export interface PageSchema extends BaseSchemaScoped { /** * 指定为 page 渲染器。 */ type: 'page'; /** * json schema校验地址 */ $schema?: string; /** * 页面标题 */ title?: string; /** * 页面副标题 */ subTitle?: string; /** * 页面描述, 标题旁边会出现个小图标,放上去会显示这个属性配置的内容。 */ remark?: SchemaRemark; /** * 内容区域 */ body?: SchemaCollection; /** * 内容区 css 类名 */ bodyClassName?: SchemaClassName; /** * 定制面包屑的样式 */ breadcrumbClassName?: SchemaClassName; bodyStyle?: CSSProperties; /** * 边栏区域 */ aside?: SchemaCollection; /** * 边栏是否允许拖动 */ asideResizor?: boolean; /** * 边栏是否可以收缩 */ asideCollapsable?: boolean; /** * 边栏初始是否折叠 */ asideCollapsed?: boolean; /** * 边栏初始是否折叠表达式 */ asideCollapsedOn?: SchemaExpression; /** * 边栏内容是否粘住,即不跟随滚动。 * * @default true */ asideSticky?: boolean; /** * 边栏最小宽度 */ asideMinWidth?: number; /** * 边栏最小宽度 */ asideMaxWidth?: number; /** * 边栏区 css 类名 */ asideClassName?: SchemaClassName; asideConfig?: { style?: CSSProperties; /** * 边栏区 css 类名 */ className?: SchemaClassName; /** * 边栏是否允许拖动 */ resizor?: boolean; /** * 边栏是否可以收缩 */ collapsable?: boolean; /** * 边栏初始是否折叠 */ collapsed?: boolean; /** * 边栏初始是否折叠表达式 */ collapsedOn?: SchemaExpression; /** * 边栏内容是否粘住,即不跟随滚动。 * * @default true */ sticky?: boolean; /** * 边栏最小宽度 */ minWidth?: number; /** * 边栏最小宽度 */ maxWidth?: number; }; /** * 配置容器 className */ className?: SchemaClassName; /** * 配置 header 容器 className */ headerClassName?: SchemaClassName; /** * 页面初始化的时候,可以设置一个 API 让其取拉取,发送数据会携带当前 data 数据(包含地址栏参数),获取得数据会合并到 data 中,供组件内使用。 */ initApi?: SchemaApi; /** * 是否默认就拉取? */ initFetch?: boolean; /** * 是否默认就拉取表达式 */ initFetchOn?: SchemaExpression; messages?: SchemaMessage; /** * 页面顶部区域,当存在 title 时在右上角显示。 */ toolbar?: SchemaCollection; /** * 配置 toolbar 容器 className */ toolbarClassName?: SchemaClassName; definitions?: any; /** * 配置轮询间隔,配置后 initApi 将轮询加载。 */ interval?: number; /** * 是否要静默加载,也就是说不显示进度 */ silentPolling?: boolean; /** * 配置停止轮询的条件。 */ stopAutoRefreshWhen?: SchemaExpression; /** * 是否显示错误信息,默认是显示的。 */ showErrorMsg?: boolean; showLoading?: boolean; showLoadingOn?: SchemaBoolean; /** * 默认不设置自动根据内容来决定要不要展示这些区域 * 如果配置了,以配置为主。 */ regions?: Array<'aside' | 'body' | 'toolbar' | 'header'>; /** * 下拉刷新配置 */ pullRefresh?: { disabled?: boolean; pullingText?: string; loosingText?: string; }; tour?: boolean; tourOn?: SchemaBoolean; tourConfig?: TourConfig; } export interface PageProps extends RendererProps, Omit<PageSchema, 'type' | 'className' | '$schema'> { data: any; store: IServiceStore; location?: Location; tour?: boolean; }