mirror of
https://gitee.com/baidu/amis.git
synced 2024-11-30 19:08:45 +08:00
更新 Schema 配置
This commit is contained in:
parent
5ae8fb6b85
commit
7b6d4943de
@ -9,6 +9,8 @@ import {ButtonToolbarSchema} from './renderers/ButtonToolbar';
|
||||
import {CardSchema} from './renderers/Card';
|
||||
import {CardsSchema} from './renderers/Cards';
|
||||
import {FormSchema} from './renderers/Form';
|
||||
import {CarouselSchema} from './renderers/Carousel';
|
||||
import {ChartSchema} from './renderers/Chart';
|
||||
|
||||
// 每加个类型,这补充一下。
|
||||
export type SchemaType =
|
||||
@ -25,7 +27,9 @@ export type SchemaType =
|
||||
| 'button-group'
|
||||
| 'button-toolbar'
|
||||
| 'card'
|
||||
| 'cards';
|
||||
| 'cards'
|
||||
| 'carousel'
|
||||
| 'chart';
|
||||
|
||||
export type SchemaObject =
|
||||
| PageSchema
|
||||
@ -38,7 +42,9 @@ export type SchemaObject =
|
||||
| ButtonGroupSchema
|
||||
| ButtonToolbarSchema
|
||||
| CardSchema
|
||||
| CardsSchema;
|
||||
| CardsSchema
|
||||
| CarouselSchema
|
||||
| ChartSchema;
|
||||
|
||||
export type SchemaCollection = SchemaObject | Array<SchemaObject> | SchemaTpl;
|
||||
|
||||
@ -181,9 +187,9 @@ export type SchemaSchema = string;
|
||||
*/
|
||||
export type SchemaIcon = string;
|
||||
|
||||
export type TokenizeableString = string;
|
||||
export type SchemaTokenizeableString = string;
|
||||
|
||||
export type SchemaUrlPath = TokenizeableString;
|
||||
export type SchemaUrlPath = SchemaTokenizeableString;
|
||||
|
||||
export type SchemaTooltip =
|
||||
| string
|
||||
@ -199,6 +205,8 @@ export type SchemaTooltip =
|
||||
content: string;
|
||||
};
|
||||
|
||||
export type SchemaFunction = string | Function;
|
||||
|
||||
export interface BaseSchema {
|
||||
$schema?: SchemaSchema;
|
||||
type: SchemaType;
|
@ -283,7 +283,7 @@ import {
|
||||
SchemaReload,
|
||||
SchemaTooltip,
|
||||
SchemaTpl
|
||||
} from '../Schemas';
|
||||
} from '../Schema';
|
||||
|
||||
export interface ActionProps
|
||||
extends ButtonSchema,
|
||||
|
@ -1,7 +1,7 @@
|
||||
import {Renderer, RendererProps} from '../factory';
|
||||
import React from 'react';
|
||||
import Alert, {AlertProps} from '../components/Alert2';
|
||||
import {BaseSchema, SchemaCollection} from '../Schemas';
|
||||
import {BaseSchema, SchemaCollection} from '../Schema';
|
||||
|
||||
/**
|
||||
* Alert 提示渲染器,文档:https://baidu.gitee.io/amis/docs/components/alert
|
||||
|
@ -5,7 +5,7 @@ import {autobind} from '../utils/helper';
|
||||
import {Icon} from '../components/icons';
|
||||
import {resolveVariable} from '../utils/tpl-builtin';
|
||||
import {filter} from '../utils/tpl';
|
||||
import {BaseSchema, SchemaUrlPath} from '../Schemas';
|
||||
import {BaseSchema, SchemaUrlPath} from '../Schema';
|
||||
|
||||
/**
|
||||
* Audio 音频渲染器,文档:https://baidu.gitee.io/amis/docs/components/audio
|
||||
|
@ -1,7 +1,7 @@
|
||||
import React from 'react';
|
||||
import ButtonGroup from './Form/ButtonGroup';
|
||||
import {Renderer} from '../factory';
|
||||
import {BaseSchema, SchemaClassName, SchemaExpression} from '../Schemas';
|
||||
import {BaseSchema, SchemaClassName, SchemaExpression} from '../Schema';
|
||||
import {ActionSchema} from './Action';
|
||||
|
||||
/**
|
||||
|
@ -1,6 +1,6 @@
|
||||
import React from 'react';
|
||||
import {Renderer, RendererProps} from '../factory';
|
||||
import {BaseSchema} from '../Schemas';
|
||||
import {BaseSchema} from '../Schema';
|
||||
import {ActionSchema} from './Action';
|
||||
|
||||
/**
|
||||
|
@ -20,11 +20,11 @@ import {
|
||||
SchemaExpression,
|
||||
SchemaTpl,
|
||||
SchemaUrlPath
|
||||
} from '../Schemas';
|
||||
} from '../Schema';
|
||||
import {ActionSchema} from './Action';
|
||||
|
||||
/**
|
||||
* Card 渲染器,格式说明,文档:https://baidu.gitee.io/amis/docs/components/card
|
||||
* Card 卡片渲染器,格式说明,文档:https://baidu.gitee.io/amis/docs/components/card
|
||||
*/
|
||||
export interface CardSchema extends BaseSchema {
|
||||
/**
|
||||
|
@ -22,11 +22,11 @@ import {
|
||||
SchemaExpression,
|
||||
SchemaTpl,
|
||||
TokenizeableString
|
||||
} from '../Schemas';
|
||||
} from '../Schema';
|
||||
import {CardSchema} from './Card';
|
||||
|
||||
/**
|
||||
* Card 渲染器,格式说明,文档:https://baidu.gitee.io/amis/docs/components/card
|
||||
* Cards 卡片集合渲染器,格式说明,文档:https://baidu.gitee.io/amis/docs/components/card
|
||||
*/
|
||||
export interface CardsSchema extends BaseSchema {
|
||||
/**
|
||||
|
@ -13,6 +13,71 @@ import {
|
||||
isArrayChildrenModified
|
||||
} from '../utils/helper';
|
||||
import {Icon} from '../components/icons';
|
||||
import {BaseSchema, SchemaName, SchemaObject, SchemaTpl} from '../Schema';
|
||||
|
||||
/**
|
||||
* Carousel 轮播图渲染器,格式说明,文档:https://baidu.gitee.io/amis/docs/components/carousel
|
||||
*/
|
||||
export interface CarouselSchema extends BaseSchema {
|
||||
/**
|
||||
* 指定为轮播图类型
|
||||
*/
|
||||
type: 'carousel';
|
||||
|
||||
/**
|
||||
* 是否自动播放
|
||||
*/
|
||||
auto?: boolean;
|
||||
|
||||
/**
|
||||
* 轮播间隔时间
|
||||
*/
|
||||
interval?: number;
|
||||
|
||||
/**
|
||||
* 动画时长
|
||||
*/
|
||||
duration?: number;
|
||||
|
||||
/**
|
||||
* 设置宽度
|
||||
*/
|
||||
width?: number;
|
||||
|
||||
/**
|
||||
* 设置高度
|
||||
*/
|
||||
height?: number;
|
||||
|
||||
controlsTheme?: 'light' | 'dark';
|
||||
|
||||
/**
|
||||
* 占位
|
||||
*/
|
||||
placeholder?: string;
|
||||
|
||||
/**
|
||||
* 配置控件内容
|
||||
*/
|
||||
controls?: Array<'dots' | 'arrows'>;
|
||||
|
||||
/**
|
||||
* 动画类型
|
||||
*/
|
||||
animation?: 'fade' | 'slide';
|
||||
|
||||
/**
|
||||
* 配置单条呈现模板
|
||||
*/
|
||||
itemSchema?: SchemaObject | SchemaTpl;
|
||||
|
||||
name?: SchemaName;
|
||||
|
||||
/**
|
||||
* 配置固定值
|
||||
*/
|
||||
options?: Array<any>;
|
||||
}
|
||||
|
||||
const animationStyles: {
|
||||
[propName: string]: string;
|
||||
@ -22,18 +87,8 @@ const animationStyles: {
|
||||
[EXITING]: 'out'
|
||||
};
|
||||
|
||||
export interface CarouselProps extends RendererProps {
|
||||
className?: string;
|
||||
auto?: boolean;
|
||||
export interface CarouselProps extends RendererProps, CarouselSchema {
|
||||
value?: any;
|
||||
placeholder?: any;
|
||||
width?: number;
|
||||
height?: number;
|
||||
controls: string[];
|
||||
interval: number;
|
||||
duration: number;
|
||||
controlsTheme: 'light' | 'dark';
|
||||
animation: 'fade' | 'slide';
|
||||
}
|
||||
|
||||
export interface CarouselState {
|
||||
@ -74,8 +129,8 @@ const defaultSchema = {
|
||||
|
||||
export class Carousel extends React.Component<CarouselProps, CarouselState> {
|
||||
wrapperRef: React.RefObject<HTMLDivElement> = React.createRef();
|
||||
intervalTimeout: NodeJS.Timer;
|
||||
durationTimeout: NodeJS.Timer;
|
||||
intervalTimeout: NodeJS.Timer | number;
|
||||
durationTimeout: NodeJS.Timer | number;
|
||||
|
||||
static defaultProps: Pick<
|
||||
CarouselProps,
|
||||
@ -212,8 +267,8 @@ export class Carousel extends React.Component<CarouselProps, CarouselState> {
|
||||
|
||||
@autobind
|
||||
clearAutoTimeout() {
|
||||
clearTimeout(this.intervalTimeout);
|
||||
clearTimeout(this.durationTimeout);
|
||||
clearTimeout(this.intervalTimeout as number);
|
||||
clearTimeout(this.durationTimeout as number);
|
||||
}
|
||||
|
||||
renderDots() {
|
||||
@ -293,8 +348,8 @@ export class Carousel extends React.Component<CarouselProps, CarouselState> {
|
||||
width ? (carouselStyles.width = width + 'px') : '';
|
||||
height ? (carouselStyles.height = height + 'px') : '';
|
||||
const [dots, arrows] = [
|
||||
controls.indexOf('dots') > -1,
|
||||
controls.indexOf('arrows') > -1
|
||||
controls!.indexOf('dots') > -1,
|
||||
controls!.indexOf('arrows') > -1
|
||||
];
|
||||
const animationName = nextAnimation || animation;
|
||||
|
||||
@ -338,7 +393,7 @@ export class Carousel extends React.Component<CarouselProps, CarouselState> {
|
||||
data,
|
||||
isObject(option)
|
||||
? option
|
||||
: {item: option, [name]: option}
|
||||
: {item: option, [name!]: option}
|
||||
)
|
||||
}
|
||||
)}
|
||||
|
@ -12,18 +12,90 @@ import {isApiOutdated, isEffectiveApi} from '../utils/api';
|
||||
import {ScopedContext, IScopedContext} from '../Scoped';
|
||||
import {createObject} from '../utils/helper';
|
||||
import Spinner from '../components/Spinner';
|
||||
import {
|
||||
BaseSchema,
|
||||
SchemaApi,
|
||||
SchemaExpression,
|
||||
SchemaFunction,
|
||||
SchemaName,
|
||||
SchemaTokenizeableString
|
||||
} from '../Schema';
|
||||
import {ActionSchema} from './Action';
|
||||
|
||||
export interface ChartProps extends RendererProps {
|
||||
/**
|
||||
* Chart 图表渲染器,格式说明,文档:https://baidu.gitee.io/amis/docs/components/carousel
|
||||
*/
|
||||
export interface ChartSchema extends BaseSchema {
|
||||
/**
|
||||
* 指定为 chart 类型
|
||||
*/
|
||||
type: 'chart';
|
||||
|
||||
/**
|
||||
* 图表配置接口
|
||||
*/
|
||||
api?: SchemaApi;
|
||||
|
||||
/**
|
||||
* 是否初始加载。
|
||||
* @deprecated 建议直接配置 api 的 sendOn
|
||||
*/
|
||||
initFetch?: boolean;
|
||||
|
||||
/**
|
||||
* 是否初始加载用表达式来配置
|
||||
* @deprecated 建议用 api.sendOn 属性。
|
||||
*/
|
||||
initFetchOn?: SchemaExpression;
|
||||
|
||||
/**
|
||||
* 配置echart的config
|
||||
*/
|
||||
config?: any;
|
||||
|
||||
/**
|
||||
* 宽度设置
|
||||
*/
|
||||
width?: number;
|
||||
|
||||
/**
|
||||
* 高度设置
|
||||
*/
|
||||
height?: number;
|
||||
|
||||
/**
|
||||
* 刷新时间
|
||||
*/
|
||||
interval?: number;
|
||||
|
||||
name?: SchemaName;
|
||||
|
||||
/**
|
||||
* style样式
|
||||
*/
|
||||
style?: {
|
||||
[propName: string]: any;
|
||||
};
|
||||
|
||||
dataFilter?: SchemaFunction;
|
||||
|
||||
source?: SchemaTokenizeableString;
|
||||
|
||||
/**
|
||||
* 点击行为配置,可以用来满足下钻操作等。
|
||||
*/
|
||||
clickAction?: ActionSchema;
|
||||
|
||||
/**
|
||||
* 默认配置时追加的,如果更新配置想完全替换配置请配置为 true.
|
||||
*/
|
||||
replaceChartOption?: boolean;
|
||||
}
|
||||
|
||||
export interface ChartProps extends RendererProps, ChartSchema {
|
||||
chartRef?: (echart: any) => void;
|
||||
onDataFilter?: (config: any, echarts: any) => any;
|
||||
dataFilter?: string;
|
||||
api?: Api;
|
||||
source?: string;
|
||||
config?: object;
|
||||
initFetch?: boolean;
|
||||
store: IServiceStore;
|
||||
clickAction?: Action;
|
||||
replaceChartOption: boolean;
|
||||
}
|
||||
export class Chart extends React.Component<ChartProps> {
|
||||
static defaultProps: Partial<ChartProps> = {
|
||||
|
@ -35,7 +35,7 @@ import {isAlive} from 'mobx-state-tree';
|
||||
import {asFormItem} from './Item';
|
||||
import {SimpleMap} from '../../utils/SimpleMap';
|
||||
import {trace} from 'mobx';
|
||||
import {BaseSchema, SchemaApi, SchemaDefaultData} from '../../Schemas';
|
||||
import {BaseSchema, SchemaApi, SchemaDefaultData} from '../../Schema';
|
||||
import {ActionSchema} from '../Action';
|
||||
|
||||
/**
|
||||
|
@ -27,7 +27,7 @@ import {
|
||||
SchemaApi,
|
||||
SchemaExpression,
|
||||
SchemaName
|
||||
} from '../Schemas';
|
||||
} from '../Schema';
|
||||
import {SchemaRemark} from './Remark';
|
||||
|
||||
/**
|
||||
|
@ -6,7 +6,7 @@ import TooltipWrapper from '../components/TooltipWrapper';
|
||||
import {filter} from '../utils/tpl';
|
||||
import {themeable} from '../theme';
|
||||
import {Icon} from '../components/icons';
|
||||
import {BaseSchema, SchemaIcon, SchemaTpl} from '../Schemas';
|
||||
import {BaseSchema, SchemaIcon, SchemaTpl} from '../Schema';
|
||||
|
||||
/**
|
||||
* 提示渲染器,默认会显示个小图标,鼠标放上来的时候显示配置的内容。
|
||||
|
@ -4,7 +4,7 @@ import {filter} from '../utils/tpl';
|
||||
import cx from 'classnames';
|
||||
import {anyChanged} from '../utils/helper';
|
||||
import {escapeHtml} from '../utils/tpl-builtin';
|
||||
import {BaseSchema, SchemaTpl} from '../Schemas';
|
||||
import {BaseSchema, SchemaTpl} from '../Schema';
|
||||
|
||||
/**
|
||||
* tpl 渲染器
|
||||
|
@ -1,4 +1,4 @@
|
||||
import {SchemaApiObject} from './Schemas';
|
||||
import {SchemaApiObject} from './Schema';
|
||||
|
||||
export interface ApiObject extends SchemaApiObject {
|
||||
config?: {
|
||||
|
@ -419,7 +419,7 @@ export function pickValues(names: string, data: object) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
export const resolveVariable = (path: string, data: any = {}): any => {
|
||||
export const resolveVariable = (path?: string, data: any = {}): any => {
|
||||
if (!path) {
|
||||
return undefined;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user