feat: pagination add responsive
parent
00cf241315
commit
85197c4b50
|
@ -23,7 +23,7 @@
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
color: @heading-color;
|
color: @heading-color;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
font-size: @font-size-lg;
|
font-size: @modal-confirm-title-font-size;
|
||||||
line-height: 1.4;
|
line-height: 1.4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ import VcPagination from '../vc-pagination';
|
||||||
import enUS from '../vc-pagination/locale/en_US';
|
import enUS from '../vc-pagination/locale/en_US';
|
||||||
import classNames from '../_util/classNames';
|
import classNames from '../_util/classNames';
|
||||||
import useConfigInject from '../_util/hooks/useConfigInject';
|
import useConfigInject from '../_util/hooks/useConfigInject';
|
||||||
|
import useBreakpoint from '../_util/hooks/useBreakpoint';
|
||||||
|
|
||||||
export const paginationProps = () => ({
|
export const paginationProps = () => ({
|
||||||
total: Number,
|
total: Number,
|
||||||
|
@ -43,6 +44,7 @@ export const paginationProps = () => ({
|
||||||
}) => any
|
}) => any
|
||||||
>,
|
>,
|
||||||
role: String,
|
role: String,
|
||||||
|
responsive: Boolean,
|
||||||
showLessItems: { type: Boolean, default: undefined },
|
showLessItems: { type: Boolean, default: undefined },
|
||||||
onChange: Function as PropType<(page: number, pageSize: number) => void>,
|
onChange: Function as PropType<(page: number, pageSize: number) => void>,
|
||||||
onShowSizeChange: Function as PropType<(current: number, size: number) => void>,
|
onShowSizeChange: Function as PropType<(current: number, size: number) => void>,
|
||||||
|
@ -82,6 +84,7 @@ export default defineComponent({
|
||||||
const selectPrefixCls = computed(() =>
|
const selectPrefixCls = computed(() =>
|
||||||
configProvider.getPrefixCls('select', props.selectPrefixCls),
|
configProvider.getPrefixCls('select', props.selectPrefixCls),
|
||||||
);
|
);
|
||||||
|
const breakpoint = useBreakpoint();
|
||||||
const [locale] = useLocaleReceiver('Pagination', enUS, toRef(props, 'locale'));
|
const [locale] = useLocaleReceiver('Pagination', enUS, toRef(props, 'locale'));
|
||||||
const getIconsProps = (pre: string) => {
|
const getIconsProps = (pre: string) => {
|
||||||
const ellipsis = <span class={`${pre}-item-ellipsis`}>•••</span>;
|
const ellipsis = <span class={`${pre}-item-ellipsis`}>•••</span>;
|
||||||
|
@ -132,10 +135,11 @@ export default defineComponent({
|
||||||
itemRender = slots.itemRender,
|
itemRender = slots.itemRender,
|
||||||
buildOptionText = slots.buildOptionText,
|
buildOptionText = slots.buildOptionText,
|
||||||
selectComponentClass,
|
selectComponentClass,
|
||||||
|
responsive,
|
||||||
...restProps
|
...restProps
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
const isSmall = size === 'small';
|
const isSmall = size === 'small' || !!(breakpoint.value?.xs && !size && responsive);
|
||||||
const paginationProps = {
|
const paginationProps = {
|
||||||
...restProps,
|
...restProps,
|
||||||
...getIconsProps(prefixCls.value),
|
...getIconsProps(prefixCls.value),
|
||||||
|
|
|
@ -18,10 +18,10 @@ Customize dropdown options such as adding all options
|
||||||
<template>
|
<template>
|
||||||
<a-pagination
|
<a-pagination
|
||||||
v-model:current="current"
|
v-model:current="current"
|
||||||
|
v-model:page-size="pageSize"
|
||||||
:page-size-options="pageSizeOptions"
|
:page-size-options="pageSizeOptions"
|
||||||
:total="total"
|
:total="total"
|
||||||
show-size-changer
|
show-size-changer
|
||||||
:page-size="pageSize"
|
|
||||||
@showSizeChange="onShowSizeChange"
|
@showSizeChange="onShowSizeChange"
|
||||||
>
|
>
|
||||||
<template #buildOptionText="props">
|
<template #buildOptionText="props">
|
||||||
|
|
|
@ -19,16 +19,16 @@ You can show the total number of data by setting `showTotal`.
|
||||||
<div>
|
<div>
|
||||||
<a-pagination
|
<a-pagination
|
||||||
v-model:current="current1"
|
v-model:current="current1"
|
||||||
|
v-model:page-size="pageSize1"
|
||||||
:total="85"
|
:total="85"
|
||||||
:show-total="total => `Total ${total} items`"
|
:show-total="total => `Total ${total} items`"
|
||||||
:page-size="20"
|
|
||||||
/>
|
/>
|
||||||
<br />
|
<br />
|
||||||
<a-pagination
|
<a-pagination
|
||||||
v-model:current="current2"
|
v-model:current="current2"
|
||||||
|
v-model:page-size="pageSize2"
|
||||||
:total="85"
|
:total="85"
|
||||||
:show-total="(total, range) => `${range[0]}-${range[1]} of ${total} items`"
|
:show-total="(total, range) => `${range[0]}-${range[1]} of ${total} items`"
|
||||||
:page-size="20"
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -38,12 +38,16 @@ export default defineComponent({
|
||||||
setup() {
|
setup() {
|
||||||
const current1 = ref<number>(1);
|
const current1 = ref<number>(1);
|
||||||
const current2 = ref<number>(2);
|
const current2 = ref<number>(2);
|
||||||
|
const pageSize1 = ref<number>(20);
|
||||||
|
const pageSize2 = ref<number>(20);
|
||||||
const onChange = (pageNumber: number) => {
|
const onChange = (pageNumber: number) => {
|
||||||
console.log('Page: ', pageNumber);
|
console.log('Page: ', pageNumber);
|
||||||
};
|
};
|
||||||
return {
|
return {
|
||||||
current1,
|
current1,
|
||||||
current2,
|
current2,
|
||||||
|
pageSize1,
|
||||||
|
pageSize2,
|
||||||
onChange,
|
onChange,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
|
@ -29,6 +29,7 @@ A long list can be divided into several pages using `Pagination`, and only one p
|
||||||
| itemRender | to customize item innerHTML | (page, type: 'page' \| 'prev' \| 'next', originalElement) => vNode \| v-slot | - | |
|
| itemRender | to customize item innerHTML | (page, type: 'page' \| 'prev' \| 'next', originalElement) => vNode \| v-slot | - | |
|
||||||
| pageSize(v-model) | number of data items per page | number | - | |
|
| pageSize(v-model) | number of data items per page | number | - | |
|
||||||
| pageSizeOptions | specify the sizeChanger options | string\[] | \['10', '20', '30', '40'] | |
|
| pageSizeOptions | specify the sizeChanger options | string\[] | \['10', '20', '30', '40'] | |
|
||||||
|
| responsive | If `size` is not specified, `Pagination` would resize according to the width of the window | boolean | - | 3.1 |
|
||||||
| showLessItems | Show less page items | boolean | false | 1.5.0 |
|
| showLessItems | Show less page items | boolean | false | 1.5.0 |
|
||||||
| showQuickJumper | determine whether you can jump to pages directly | boolean | false | |
|
| showQuickJumper | determine whether you can jump to pages directly | boolean | false | |
|
||||||
| showSizeChanger | determine whether `pageSize` can be changed | boolean | false | |
|
| showSizeChanger | determine whether `pageSize` can be changed | boolean | false | |
|
||||||
|
|
|
@ -24,6 +24,7 @@ cover: https://gw.alipayobjects.com/zos/alicdn/1vqv2bj68/Pagination.svg
|
||||||
| itemRender | 用于自定义页码的结构,可用于优化 SEO | ({page, type: 'page' \| 'prev' \| 'next', originalElement}) => vNode \| v-slot | - | |
|
| itemRender | 用于自定义页码的结构,可用于优化 SEO | ({page, type: 'page' \| 'prev' \| 'next', originalElement}) => vNode \| v-slot | - | |
|
||||||
| pageSize(v-model) | 每页条数 | number | - | |
|
| pageSize(v-model) | 每页条数 | number | - | |
|
||||||
| pageSizeOptions | 指定每页可以显示多少条 | string\[] | \['10', '20', '30', '40'] | |
|
| pageSizeOptions | 指定每页可以显示多少条 | string\[] | \['10', '20', '30', '40'] | |
|
||||||
|
| responsive | 当 size 未指定时,根据屏幕宽度自动调整尺寸 | boolean | - | 3.1 |
|
||||||
| showLessItems | 是否显示较少页面内容 | boolean | false | 1.5.0 |
|
| showLessItems | 是否显示较少页面内容 | boolean | false | 1.5.0 |
|
||||||
| showQuickJumper | 是否可以快速跳转至某页 | boolean | false | |
|
| showQuickJumper | 是否可以快速跳转至某页 | boolean | false | |
|
||||||
| showSizeChanger | 是否可以改变 pageSize | boolean | false | |
|
| showSizeChanger | 是否可以改变 pageSize | boolean | false | |
|
||||||
|
|
|
@ -59,7 +59,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&:focus-visible,
|
|
||||||
&:hover {
|
&:hover {
|
||||||
border-color: @primary-color;
|
border-color: @primary-color;
|
||||||
transition: all 0.3s;
|
transition: all 0.3s;
|
||||||
|
@ -69,6 +68,17 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// cannot merge with `&:hover`
|
||||||
|
// see https://github.com/ant-design/ant-design/pull/34002
|
||||||
|
&:focus-visible {
|
||||||
|
border-color: @primary-color;
|
||||||
|
transition: all 0.3s;
|
||||||
|
|
||||||
|
a {
|
||||||
|
color: @primary-color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
&-active {
|
&-active {
|
||||||
font-weight: @pagination-font-weight-active;
|
font-weight: @pagination-font-weight-active;
|
||||||
background: @pagination-item-bg-active;
|
background: @pagination-item-bg-active;
|
||||||
|
@ -78,15 +88,21 @@
|
||||||
color: @primary-color;
|
color: @primary-color;
|
||||||
}
|
}
|
||||||
|
|
||||||
&:focus-visible,
|
|
||||||
&:hover {
|
&:hover {
|
||||||
border-color: @primary-5;
|
border-color: @primary-5;
|
||||||
}
|
}
|
||||||
|
|
||||||
&:focus-visible a,
|
&:focus-visible {
|
||||||
|
border-color: @primary-5;
|
||||||
|
}
|
||||||
|
|
||||||
&:hover a {
|
&:hover a {
|
||||||
color: @primary-5;
|
color: @primary-5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&:focus-visible a {
|
||||||
|
color: @primary-5;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,7 +146,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&:focus-visible,
|
|
||||||
&:hover {
|
&:hover {
|
||||||
.@{pagination-prefix-cls}-item-link-icon {
|
.@{pagination-prefix-cls}-item-link-icon {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
|
@ -139,6 +154,15 @@
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&:focus-visible {
|
||||||
|
.@{pagination-prefix-cls}-item-link-icon {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
.@{pagination-prefix-cls}-item-ellipsis {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&-prev,
|
&-prev,
|
||||||
|
@ -194,7 +218,11 @@
|
||||||
transition: all 0.3s;
|
transition: all 0.3s;
|
||||||
}
|
}
|
||||||
|
|
||||||
&:focus-visible .@{pagination-prefix-cls}-item-link,
|
&:focus-visible .@{pagination-prefix-cls}-item-link {
|
||||||
|
color: @primary-color;
|
||||||
|
border-color: @primary-color;
|
||||||
|
}
|
||||||
|
|
||||||
&:hover .@{pagination-prefix-cls}-item-link {
|
&:hover .@{pagination-prefix-cls}-item-link {
|
||||||
color: @primary-color;
|
color: @primary-color;
|
||||||
border-color: @primary-color;
|
border-color: @primary-color;
|
||||||
|
@ -203,7 +231,15 @@
|
||||||
|
|
||||||
&-disabled {
|
&-disabled {
|
||||||
&,
|
&,
|
||||||
&:hover,
|
&:hover {
|
||||||
|
cursor: not-allowed;
|
||||||
|
.@{pagination-prefix-cls}-item-link {
|
||||||
|
color: @disabled-color;
|
||||||
|
border-color: @border-color-base;
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
&:focus-visible {
|
&:focus-visible {
|
||||||
cursor: not-allowed;
|
cursor: not-allowed;
|
||||||
.@{pagination-prefix-cls}-item-link {
|
.@{pagination-prefix-cls}-item-link {
|
||||||
|
|
Loading…
Reference in New Issue