feat: update list
parent
7a23858cd5
commit
cc1f21845a
|
@ -21,9 +21,8 @@ export const ListItemMetaProps = {
|
||||||
title: PropTypes.any,
|
title: PropTypes.any,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Meta = (props, { slots, attrs }) => {
|
export const AListItemMeta = (props, { slots }) => {
|
||||||
const configProvider = inject('configProvider', ConfigConsumerProps);
|
const configProvider = inject('configProvider', ConfigConsumerProps);
|
||||||
const { style, class: _cls } = attrs;
|
|
||||||
const getPrefixCls = configProvider.getPrefixCls;
|
const getPrefixCls = configProvider.getPrefixCls;
|
||||||
const { prefixCls: customizePrefixCls } = props;
|
const { prefixCls: customizePrefixCls } = props;
|
||||||
const prefixCls = getPrefixCls('list', customizePrefixCls);
|
const prefixCls = getPrefixCls('list', customizePrefixCls);
|
||||||
|
@ -37,16 +36,15 @@ export const Meta = (props, { slots, attrs }) => {
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
return (
|
return (
|
||||||
<div class={`${prefixCls}-item-meta`} style={style} class={_cls}>
|
<div class={`${prefixCls}-item-meta`}>
|
||||||
{avatar && <div class={`${prefixCls}-item-meta-avatar`}>{avatar}</div>}
|
{avatar && <div class={`${prefixCls}-item-meta-avatar`}>{avatar}</div>}
|
||||||
{(title || description) && content}
|
{(title || description) && content}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
Object.assign(Meta, {
|
Object.assign(AListItemMeta, {
|
||||||
props: ListItemMetaProps,
|
props: ListItemMetaProps,
|
||||||
inheritAttrs: false,
|
|
||||||
__ANT_LIST_ITEM_META: true,
|
__ANT_LIST_ITEM_META: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -57,7 +55,7 @@ function getGrid(grid, t) {
|
||||||
export default {
|
export default {
|
||||||
name: 'AListItem',
|
name: 'AListItem',
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
Meta,
|
Meta: AListItemMeta,
|
||||||
props: ListItemProps,
|
props: ListItemProps,
|
||||||
setup() {
|
setup() {
|
||||||
const listContext = inject('listContext', {});
|
const listContext = inject('listContext', {});
|
||||||
|
@ -91,7 +89,7 @@ export default {
|
||||||
render() {
|
render() {
|
||||||
const { grid, itemLayout } = this.listContext;
|
const { grid, itemLayout } = this.listContext;
|
||||||
const { prefixCls: customizePrefixCls, $slots, $attrs } = this;
|
const { prefixCls: customizePrefixCls, $slots, $attrs } = this;
|
||||||
const { class: _className } = $attrs;
|
const { class: _className, ...restAttrs } = $attrs;
|
||||||
const getPrefixCls = this.configProvider.getPrefixCls;
|
const getPrefixCls = this.configProvider.getPrefixCls;
|
||||||
const prefixCls = getPrefixCls('list', customizePrefixCls);
|
const prefixCls = getPrefixCls('list', customizePrefixCls);
|
||||||
const extra = getComponent(this, 'extra');
|
const extra = getComponent(this, 'extra');
|
||||||
|
@ -107,11 +105,11 @@ export default {
|
||||||
))}
|
))}
|
||||||
</ul>
|
</ul>
|
||||||
);
|
);
|
||||||
const children = $slots.default && $slots.default();
|
const children = getSlot(this);
|
||||||
const Tag = grid ? 'div' : 'li';
|
const Tag = grid ? 'div' : 'li';
|
||||||
const itemChildren = (
|
const itemChildren = (
|
||||||
<Tag
|
<Tag
|
||||||
{...$attrs}
|
{...restAttrs}
|
||||||
class={classNames(`${prefixCls}-item `, _className, {
|
class={classNames(`${prefixCls}-item `, _className, {
|
||||||
[`${prefixCls}-item-no-flex`]: !this.isFlexMode(),
|
[`${prefixCls}-item-no-flex`]: !this.isFlexMode(),
|
||||||
})}
|
})}
|
||||||
|
|
|
@ -126,7 +126,7 @@ const List = {
|
||||||
|
|
||||||
this.keys[index] = key;
|
this.keys[index] = key;
|
||||||
|
|
||||||
return renderer(item, index);
|
return renderer({ item, index });
|
||||||
},
|
},
|
||||||
|
|
||||||
isSomethingAfterLastItem() {
|
isSomethingAfterLastItem() {
|
||||||
|
@ -163,7 +163,7 @@ const List = {
|
||||||
} = this;
|
} = this;
|
||||||
const getPrefixCls = this.configProvider.getPrefixCls;
|
const getPrefixCls = this.configProvider.getPrefixCls;
|
||||||
const prefixCls = getPrefixCls('list', customizePrefixCls);
|
const prefixCls = getPrefixCls('list', customizePrefixCls);
|
||||||
const { class: _cls, ...restAttrs } = $attrs;
|
const { class: className, ...restAttrs } = $attrs;
|
||||||
const loadMore = getComponent(this, 'loadMore');
|
const loadMore = getComponent(this, 'loadMore');
|
||||||
const footer = getComponent(this, 'footer');
|
const footer = getComponent(this, 'footer');
|
||||||
const header = getComponent(this, 'header');
|
const header = getComponent(this, 'header');
|
||||||
|
@ -200,7 +200,7 @@ const List = {
|
||||||
[`${prefixCls}-grid`]: grid,
|
[`${prefixCls}-grid`]: grid,
|
||||||
[`${prefixCls}-something-after-last-item`]: this.isSomethingAfterLastItem(),
|
[`${prefixCls}-something-after-last-item`]: this.isSomethingAfterLastItem(),
|
||||||
},
|
},
|
||||||
$attrs.class,
|
className,
|
||||||
);
|
);
|
||||||
const paginationProps = {
|
const paginationProps = {
|
||||||
...this.defaultPaginationProps,
|
...this.defaultPaginationProps,
|
||||||
|
@ -219,13 +219,11 @@ const List = {
|
||||||
<div class={`${prefixCls}-pagination`}>
|
<div class={`${prefixCls}-pagination`}>
|
||||||
<Pagination
|
<Pagination
|
||||||
{...{
|
{...{
|
||||||
props: omit(restProps, ['onChange']),
|
...omit(restProps, ['onChange']),
|
||||||
class: cls,
|
class: cls,
|
||||||
style,
|
style,
|
||||||
on: {
|
onChange: this.onPaginationChange,
|
||||||
change: this.onPaginationChange,
|
onShowSizeChange: this.onPaginationShowSizeChange,
|
||||||
showSizeChange: this.onPaginationShowSizeChange,
|
|
||||||
},
|
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import demo from '../antdv-demo/docs/pagination/demo/custom-changer';
|
import demo from '../antdv-demo/docs/list/demo/basic';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
|
|
|
@ -23,6 +23,9 @@ import {
|
||||||
Checkbox,
|
Checkbox,
|
||||||
Cascader,
|
Cascader,
|
||||||
Pagination,
|
Pagination,
|
||||||
|
List,
|
||||||
|
Collapse,
|
||||||
|
Avatar,
|
||||||
notification,
|
notification,
|
||||||
message,
|
message,
|
||||||
} from 'ant-design-vue';
|
} from 'ant-design-vue';
|
||||||
|
@ -66,4 +69,7 @@ app
|
||||||
.use(AutoComplete)
|
.use(AutoComplete)
|
||||||
.use(FormModel)
|
.use(FormModel)
|
||||||
.use(Cascader)
|
.use(Cascader)
|
||||||
|
.use(List)
|
||||||
|
.use(Collapse)
|
||||||
|
.use(Avatar)
|
||||||
.mount('#app');
|
.mount('#app');
|
||||||
|
|
|
@ -58,7 +58,7 @@
|
||||||
"vue-template-compiler": ">=2.6.0"
|
"vue-template-compiler": ">=2.6.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@ant-design-vue/babel-plugin-jsx": "1.0.0-alpha.6",
|
"@ant-design-vue/babel-plugin-jsx": "^1.0.0-beta.3",
|
||||||
"@babel/cli": "^7.8.4",
|
"@babel/cli": "^7.8.4",
|
||||||
"@babel/core": "^7.9.6",
|
"@babel/core": "^7.9.6",
|
||||||
"@babel/plugin-proposal-class-properties": "^7.8.3",
|
"@babel/plugin-proposal-class-properties": "^7.8.3",
|
||||||
|
|
Loading…
Reference in New Issue