mirror of
https://gitee.com/baidu/amis.git
synced 2024-11-29 18:48:45 +08:00
补充Schema
This commit is contained in:
parent
3798822759
commit
89272480d4
@ -5,16 +5,9 @@ import {autobind} from '../utils/helper';
|
||||
import {Icon} from '../components/icons';
|
||||
import {resolveVariable} from '../utils/tpl-builtin';
|
||||
import {filter} from '../utils/tpl';
|
||||
import {AudioSchema} from '../schemas/Audio';
|
||||
|
||||
export interface AudioProps extends RendererProps {
|
||||
className?: string;
|
||||
inline?: boolean;
|
||||
src?: string;
|
||||
autoPlay?: boolean;
|
||||
loop?: boolean;
|
||||
rates?: number[];
|
||||
controls?: string[];
|
||||
}
|
||||
export interface AudioProps extends RendererProps, AudioSchema {}
|
||||
|
||||
export interface AudioState {
|
||||
src?: string;
|
||||
|
@ -1,10 +1,11 @@
|
||||
import React from 'react';
|
||||
import {Renderer, RendererProps} from '../factory';
|
||||
import {Action} from '../types';
|
||||
import {ButtonToolbarSchema} from '../schemas/ButtonToolbar';
|
||||
|
||||
export interface ButtonToolbarProps extends RendererProps {
|
||||
buttons: Array<Action>;
|
||||
}
|
||||
export interface ButtonToolbarProps
|
||||
extends RendererProps,
|
||||
ButtonToolbarSchema {}
|
||||
|
||||
export default class ButtonToolbar extends React.Component<
|
||||
ButtonToolbarProps,
|
||||
|
@ -13,8 +13,9 @@ import PopOver from './PopOver';
|
||||
import {TableCell} from './Table';
|
||||
import Copyable from './Copyable';
|
||||
import {Icon} from '../components/icons';
|
||||
import {CardSchema} from '../schemas/Card';
|
||||
|
||||
export interface CardProps extends RendererProps {
|
||||
export interface CardProps extends RendererProps, CardSchema {
|
||||
onCheck: (item: IItem) => void;
|
||||
itemIndex?: number;
|
||||
multiple?: boolean;
|
||||
@ -305,7 +306,7 @@ export class Card extends React.Component<CardProps> {
|
||||
const descPlaceholder =
|
||||
header.descriptionPlaceholder || header.descPlaceholder;
|
||||
|
||||
const highlight = !!evalExpression(highlightTpl, data as object);
|
||||
const highlight = !!evalExpression(highlightTpl!, data as object);
|
||||
const avatar = filter(avatarTpl, data, '| raw');
|
||||
const avatarText = filter(avatarTextTpl, data);
|
||||
const title = filter(titleTpl, data);
|
||||
@ -367,7 +368,7 @@ export class Card extends React.Component<CardProps> {
|
||||
header.subTitleClassName || subTitleClassName
|
||||
)}
|
||||
>
|
||||
{render('sub-title', subTitle || subTitlePlaceholder, {
|
||||
{render('sub-title', subTitle || subTitlePlaceholder!, {
|
||||
className: cx(!subTitle ? 'Card-placeholder' : undefined)
|
||||
})}
|
||||
</div>
|
||||
@ -377,10 +378,12 @@ export class Card extends React.Component<CardProps> {
|
||||
<div
|
||||
className={cx(
|
||||
'Card-desc',
|
||||
header.descClassName || descClassName
|
||||
header.descriptionClassName ||
|
||||
header.descClassName ||
|
||||
descClassName
|
||||
)}
|
||||
>
|
||||
{render('desc', desc || descPlaceholder, {
|
||||
{render('desc', desc || descPlaceholder!, {
|
||||
className: !desc ? 'text-muted' : undefined
|
||||
})}
|
||||
</div>
|
||||
|
26
src/schemas/Alert.ts
Normal file
26
src/schemas/Alert.ts
Normal file
@ -0,0 +1,26 @@
|
||||
import {BaseSchema, SchemaCollection} from './Schema';
|
||||
|
||||
/**
|
||||
* Alert 提示渲染器,文档:https://baidu.gitee.io/amis/docs/components/alert
|
||||
*/
|
||||
export interface AlertSchema extends BaseSchema {
|
||||
/**
|
||||
* 指定为提示框类型
|
||||
*/
|
||||
type: 'alert';
|
||||
|
||||
/**
|
||||
* 内容区域
|
||||
*/
|
||||
body: SchemaCollection;
|
||||
|
||||
/**
|
||||
* 提示类型
|
||||
*/
|
||||
level?: 'info' | 'warning' | 'error' | 'danger';
|
||||
|
||||
/**
|
||||
* 是否显示关闭按钮
|
||||
*/
|
||||
showCloseButton?: boolean;
|
||||
}
|
41
src/schemas/Audio.ts
Normal file
41
src/schemas/Audio.ts
Normal file
@ -0,0 +1,41 @@
|
||||
import {BaseSchema, SchemaCollection, SchemaUrlPath} from './Schema';
|
||||
|
||||
/**
|
||||
* Audio 音频渲染器,文档:https://baidu.gitee.io/amis/docs/components/audio
|
||||
*/
|
||||
export interface AudioSchema extends BaseSchema {
|
||||
/**
|
||||
* 指定为音频播放器
|
||||
*/
|
||||
type: 'audio';
|
||||
|
||||
/**
|
||||
* 是否是内联模式
|
||||
*/
|
||||
inline: boolean;
|
||||
|
||||
/**
|
||||
* "视频播放地址, 支持 $ 取变量。
|
||||
*/
|
||||
src?: SchemaUrlPath;
|
||||
|
||||
/**
|
||||
* 是否循环播放
|
||||
*/
|
||||
loop?: boolean;
|
||||
|
||||
/**
|
||||
* 是否自动播放
|
||||
*/
|
||||
autoPlay?: boolean;
|
||||
|
||||
/**
|
||||
* 配置可选播放倍速
|
||||
*/
|
||||
rates?: Array<number>;
|
||||
|
||||
/**
|
||||
* 可以配置控制器
|
||||
*/
|
||||
controls?: Array<'rates' | 'play' | 'time' | 'process' | 'volume'>;
|
||||
}
|
47
src/schemas/ButtonGroup.ts
Normal file
47
src/schemas/ButtonGroup.ts
Normal file
@ -0,0 +1,47 @@
|
||||
import {BaseSchema, SchemaClassName, SchemaExpression} from './Schema';
|
||||
import {ActionSchema} from './Action';
|
||||
|
||||
/**
|
||||
* Button Group 渲染器,文档:https://baidu.gitee.io/amis/docs/components/button-group
|
||||
*/
|
||||
export interface ButtonGroupSchema extends BaseSchema {
|
||||
/**
|
||||
* 指定为提交按钮类型
|
||||
*/
|
||||
type: 'button-group';
|
||||
|
||||
/**
|
||||
* 给 Button 配置 className。
|
||||
*/
|
||||
btnClassName?: SchemaClassName;
|
||||
|
||||
/**
|
||||
* 按钮集合
|
||||
*/
|
||||
buttons?: Array<ActionSchema>;
|
||||
|
||||
/**
|
||||
* 是否为禁用状态。
|
||||
*/
|
||||
disabled?: boolean;
|
||||
|
||||
/**
|
||||
* 通过 JS 表达式来配置当前表单项的禁用状态。
|
||||
*/
|
||||
disabledOn?: SchemaExpression;
|
||||
|
||||
/**
|
||||
* 是否显示
|
||||
*/
|
||||
visible?: boolean;
|
||||
|
||||
/**
|
||||
* 通过 JS 表达式来配置当前表单项是否显示
|
||||
*/
|
||||
visibleOn?: SchemaExpression;
|
||||
|
||||
/**
|
||||
* 按钮大小
|
||||
*/
|
||||
size?: 'xs' | 'sm' | 'md' | 'lg';
|
||||
}
|
14
src/schemas/ButtonToolbar.ts
Normal file
14
src/schemas/ButtonToolbar.ts
Normal file
@ -0,0 +1,14 @@
|
||||
import {BaseSchema} from './Schema';
|
||||
import {ActionSchema} from './Action';
|
||||
|
||||
/**
|
||||
* Button Toolar 渲染器,文档:https://baidu.gitee.io/amis/docs/components/button-toolbar
|
||||
*/
|
||||
export interface ButtonToolbarSchema extends BaseSchema {
|
||||
/**
|
||||
* 指定为按钮工具集合类型
|
||||
*/
|
||||
type: 'button-toolbar';
|
||||
|
||||
buttons: Array<ActionSchema>;
|
||||
}
|
103
src/schemas/Card.ts
Normal file
103
src/schemas/Card.ts
Normal file
@ -0,0 +1,103 @@
|
||||
import {
|
||||
BaseSchema,
|
||||
SchemaClassName,
|
||||
SchemaTpl,
|
||||
SchemaUrlPath,
|
||||
SchemaExpression,
|
||||
SchemaCollection
|
||||
} from './Schema';
|
||||
import {ActionSchema} from './Action';
|
||||
|
||||
/**
|
||||
* Card 渲染器,格式说明,文档:https://baidu.gitee.io/amis/docs/components/card
|
||||
*/
|
||||
export interface CardSchema extends BaseSchema {
|
||||
/**
|
||||
* 指定为 card 类型
|
||||
*/
|
||||
type: 'card';
|
||||
|
||||
/**
|
||||
* 头部配置
|
||||
*/
|
||||
header?: {
|
||||
className?: SchemaClassName;
|
||||
|
||||
/**
|
||||
* 标题
|
||||
*/
|
||||
title?: SchemaTpl;
|
||||
titleClassName?: string;
|
||||
|
||||
/**
|
||||
* 副标题
|
||||
*/
|
||||
subTitle?: SchemaTpl;
|
||||
subTitleClassName?: SchemaClassName;
|
||||
subTitlePlaceholder?: string;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
description?: SchemaTpl;
|
||||
|
||||
/**
|
||||
* 描述占位内容
|
||||
*/
|
||||
descriptionPlaceholder?: string;
|
||||
|
||||
/**
|
||||
* 描述占位类名
|
||||
*/
|
||||
descriptionClassName?: string;
|
||||
|
||||
/**
|
||||
* @deprecated 建议用 description
|
||||
*/
|
||||
desc?: SchemaTpl;
|
||||
|
||||
/**
|
||||
* @deprecated 建议用 descriptionPlaceholder
|
||||
*/
|
||||
descPlaceholder?: SchemaTpl;
|
||||
|
||||
/**
|
||||
* @deprecated 建议用 descriptionClassName
|
||||
*/
|
||||
descClassName?: SchemaClassName;
|
||||
|
||||
/**
|
||||
* 图片地址
|
||||
*/
|
||||
avatar?: SchemaUrlPath;
|
||||
|
||||
avatarText?: SchemaTpl;
|
||||
avatarTextClassName?: SchemaClassName;
|
||||
|
||||
/**
|
||||
* 图片包括层类名
|
||||
*/
|
||||
avatarClassName?: SchemaClassName;
|
||||
|
||||
/**
|
||||
* 图片类名。
|
||||
*/
|
||||
imageClassName?: SchemaClassName;
|
||||
|
||||
/**
|
||||
* 是否点亮
|
||||
*/
|
||||
highlight?: SchemaExpression;
|
||||
highlightClassName?: SchemaClassName;
|
||||
};
|
||||
|
||||
/**
|
||||
* 内容区域
|
||||
*/
|
||||
body?: SchemaCollection;
|
||||
|
||||
/**
|
||||
* 底部按钮集合。
|
||||
*/
|
||||
actions?: Array<ActionSchema>;
|
||||
}
|
@ -3,6 +3,10 @@ import {FormSchema} from './Form';
|
||||
import {TplSchema} from './Tpl';
|
||||
import {RemarkSchema} from './Remark';
|
||||
import {ActionSchema} from './Action';
|
||||
import {AlertSchema} from './Alert';
|
||||
import {AudioSchema} from './Audio';
|
||||
import {ButtonGroupSchema} from './ButtonGroup';
|
||||
import {ButtonToolbarSchema} from './ButtonToolbar';
|
||||
|
||||
// 每加个类型,这补充一下。
|
||||
export type SchemaType =
|
||||
@ -13,14 +17,24 @@ export type SchemaType =
|
||||
| 'remark'
|
||||
| 'button'
|
||||
| 'submit'
|
||||
| 'reset';
|
||||
| 'reset'
|
||||
| 'alert'
|
||||
| 'audio'
|
||||
| 'button-group'
|
||||
| 'button-toolbar'
|
||||
| 'card';
|
||||
|
||||
export type SchemaObject =
|
||||
| PageSchema
|
||||
| FormSchema
|
||||
| TplSchema
|
||||
| RemarkSchema
|
||||
| ActionSchema;
|
||||
| ActionSchema
|
||||
| AlertSchema
|
||||
| AudioSchema
|
||||
| ButtonGroupSchema
|
||||
| ButtonToolbarSchema
|
||||
| CardSchema;
|
||||
|
||||
export type SchemaCollection = SchemaObject | Array<SchemaObject> | SchemaTpl;
|
||||
|
||||
@ -61,7 +75,7 @@ export interface SchemaApiObject {
|
||||
/**
|
||||
* API 发送目标地址
|
||||
*/
|
||||
url: string;
|
||||
url: SchemaUrlPath;
|
||||
|
||||
/**
|
||||
* 用来控制携带数据. 当key 为 `&` 值为 `$$` 时, 将所有原始数据打平设置到 data 中. 当值为 $$ 将所有原始数据赋值到对应的 key 中. 当值为 $ 打头时, 将变量值设置到 key 中.
|
||||
@ -163,6 +177,10 @@ export type SchemaSchema = string;
|
||||
*/
|
||||
export type SchemaIcon = string;
|
||||
|
||||
export type TokenizeableString = string;
|
||||
|
||||
export type SchemaUrlPath = TokenizeableString;
|
||||
|
||||
export type SchemaTooltip =
|
||||
| string
|
||||
| {
|
||||
|
Loading…
Reference in New Issue
Block a user