list 模式支持按钮在左侧 & 修复 multiple 透传问题 (#1543)

* list 模式支持按钮在左侧 & 修复 multiple 透传问题

* 补充属性表
This commit is contained in:
liaoxuezhi 2021-02-05 10:37:26 +08:00 committed by GitHub
parent a6cdb9d33d
commit 9ffe9a237c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 5 deletions

View File

@ -95,3 +95,4 @@ order: 56
| listItem.desc | [模板](../../docs/concepts/template) | | 描述 | | listItem.desc | [模板](../../docs/concepts/template) | | 描述 |
| listItem.body | `Array` | | 内容容器,主要用来放置非表单项组件 | | listItem.body | `Array` | | 内容容器,主要用来放置非表单项组件 |
| listItem.actions | Array<[Action](./action)> | | 按钮区域 | | listItem.actions | Array<[Action](./action)> | | 按钮区域 |
| listItem.actionsPosition | 'left' or 'right' | 默认在右侧 | 按钮位置 |

View File

@ -165,6 +165,11 @@
float: right; float: right;
} }
&--actions-at-left &-actions {
float: left;
margin-right: var(--gap-base);
}
&-title { &-title {
margin: 0; margin: 0;
padding: 0; padding: 0;

View File

@ -173,7 +173,6 @@ export class Card extends React.Component<CardProps> {
}; };
static propsList: Array<string> = [ static propsList: Array<string> = [
'multiple',
'avatarClassName', 'avatarClassName',
'bodyClassName', 'bodyClassName',
'actionsCount', 'actionsCount',
@ -553,7 +552,9 @@ export class Card extends React.Component<CardProps> {
test: /(^|\/)card$/, test: /(^|\/)card$/,
name: 'card' name: 'card'
}) })
export class CardRenderer extends Card {} export class CardRenderer extends Card {
static propsList = ['multiple', ...Card.propsList];
}
@Renderer({ @Renderer({
test: /(^|\/)card-item-field$/, test: /(^|\/)card-item-field$/,

View File

@ -76,6 +76,11 @@ export type ListBodyField = SchemaObject & ListBodyFieldObject;
export interface ListItemSchema extends Omit<BaseSchema, 'type'> { export interface ListItemSchema extends Omit<BaseSchema, 'type'> {
actions?: Array<ActionSchema>; actions?: Array<ActionSchema>;
/**
*
*/
actionsPosition?: 'left' | 'right';
/** /**
* *
*/ */
@ -1240,7 +1245,8 @@ export class ListItem extends React.Component<ListItemProps> {
checkOnItemClick, checkOnItemClick,
render, render,
checkable, checkable,
classnames: cx classnames: cx,
actionsPosition
} = this.props; } = this.props;
const avatar = filter(avatarTpl, data); const avatar = filter(avatarTpl, data);
@ -1251,7 +1257,10 @@ export class ListItem extends React.Component<ListItemProps> {
return ( return (
<div <div
onClick={checkOnItemClick && checkable ? this.handleClick : undefined} onClick={checkOnItemClick && checkable ? this.handleClick : undefined}
className={cx('ListItem', className)} className={cx(
`ListItem ListItem--actions-at-${actionsPosition || 'right'}`,
className
)}
> >
{this.renderLeft()} {this.renderLeft()}
{this.renderRight()} {this.renderRight()}
@ -1281,7 +1290,9 @@ export class ListItem extends React.Component<ListItemProps> {
test: /(^|\/)(?:list|list-group)\/(?:.*\/)?list-item$/, test: /(^|\/)(?:list|list-group)\/(?:.*\/)?list-item$/,
name: 'list-item' name: 'list-item'
}) })
export class ListItemRenderer extends ListItem {} export class ListItemRenderer extends ListItem {
static propsList = ['multiple', ...ListItem.propsList];
}
@Renderer({ @Renderer({
test: /(^|\/)list-item-field$/, test: /(^|\/)list-item-field$/,