From 639d2e15253a73c0235d16c6721864961a7510c0 Mon Sep 17 00:00:00 2001 From: Vben Date: Thu, 26 Sep 2024 23:09:17 +0800 Subject: [PATCH] feat: add pagination component (#4522) * feat: add pagination component * chore: update --- packages/@core/ui-kit/shadcn-ui/package.json | 1 - .../ui-kit/shadcn-ui/src/components/index.ts | 2 + .../src/components/pagination/index.ts | 2 + .../src/components/pagination/pagination.ts | 41 +++++++ .../src/components/pagination/pagination.vue | 111 ++++++++++++++++++ .../ui/accordion/AccordionTrigger.vue | 4 +- .../ui/breadcrumb/BreadcrumbEllipsis.vue | 4 +- .../ui/breadcrumb/BreadcrumbSeparator.vue | 4 +- .../src/components/ui/button/Button.vue | 2 +- .../src/components/ui/checkbox/Checkbox.vue | 4 +- .../context-menu/ContextMenuCheckboxItem.vue | 4 +- .../ui/context-menu/ContextMenuRadioItem.vue | 4 +- .../ui/context-menu/ContextMenuSubTrigger.vue | 4 +- .../components/ui/dialog/DialogContent.vue | 4 +- .../ui/dialog/DialogScrollContent.vue | 3 +- .../DropdownMenuCheckboxItem.vue | 4 +- .../dropdown-menu/DropdownMenuRadioItem.vue | 4 +- .../dropdown-menu/DropdownMenuSubTrigger.vue | 4 +- .../ui/pagination/PaginationEllipsis.vue | 27 +++++ .../ui/pagination/PaginationFirst.vue | 33 ++++++ .../ui/pagination/PaginationLast.vue | 33 ++++++ .../ui/pagination/PaginationNext.vue | 33 ++++++ .../ui/pagination/PaginationPrev.vue | 33 ++++++ .../src/components/ui/pagination/index.ts | 10 ++ .../ui/pin-input/PinInputSeparator.vue | 4 +- .../ui/radio-group/RadioGroupItem.vue | 4 +- .../src/components/ui/select/SelectItem.vue | 4 +- .../ui/select/SelectScrollDownButton.vue | 4 +- .../ui/select/SelectScrollUpButton.vue | 4 +- .../components/ui/select/SelectTrigger.vue | 4 +- .../src/components/ui/toast/ToastClose.vue | 4 +- pnpm-lock.yaml | 15 --- pnpm-workspace.yaml | 1 - 33 files changed, 364 insertions(+), 55 deletions(-) create mode 100644 packages/@core/ui-kit/shadcn-ui/src/components/pagination/index.ts create mode 100644 packages/@core/ui-kit/shadcn-ui/src/components/pagination/pagination.ts create mode 100644 packages/@core/ui-kit/shadcn-ui/src/components/pagination/pagination.vue create mode 100644 packages/@core/ui-kit/shadcn-ui/src/components/ui/pagination/PaginationEllipsis.vue create mode 100644 packages/@core/ui-kit/shadcn-ui/src/components/ui/pagination/PaginationFirst.vue create mode 100644 packages/@core/ui-kit/shadcn-ui/src/components/ui/pagination/PaginationLast.vue create mode 100644 packages/@core/ui-kit/shadcn-ui/src/components/ui/pagination/PaginationNext.vue create mode 100644 packages/@core/ui-kit/shadcn-ui/src/components/ui/pagination/PaginationPrev.vue create mode 100644 packages/@core/ui-kit/shadcn-ui/src/components/ui/pagination/index.ts diff --git a/packages/@core/ui-kit/shadcn-ui/package.json b/packages/@core/ui-kit/shadcn-ui/package.json index 1150065e123..e32c40d6640 100644 --- a/packages/@core/ui-kit/shadcn-ui/package.json +++ b/packages/@core/ui-kit/shadcn-ui/package.json @@ -40,7 +40,6 @@ } }, "dependencies": { - "@radix-icons/vue": "catalog:", "@vben-core/composables": "workspace:*", "@vben-core/icons": "workspace:*", "@vben-core/shared": "workspace:*", diff --git a/packages/@core/ui-kit/shadcn-ui/src/components/index.ts b/packages/@core/ui-kit/shadcn-ui/src/components/index.ts index b4099279e40..c6a3e6806b7 100644 --- a/packages/@core/ui-kit/shadcn-ui/src/components/index.ts +++ b/packages/@core/ui-kit/shadcn-ui/src/components/index.ts @@ -14,6 +14,7 @@ export * from './input-password'; export * from './link'; export * from './logo'; export * from './menu-badge'; +export * from './pagination'; export * from './pin-input'; export * from './popover'; export * from './render-content'; @@ -38,6 +39,7 @@ export * from './ui/hover-card'; export * from './ui/input'; export * from './ui/label'; export * from './ui/number-field'; +export * from './ui/pagination'; export * from './ui/pin-input'; export * from './ui/popover'; export * from './ui/radio-group'; diff --git a/packages/@core/ui-kit/shadcn-ui/src/components/pagination/index.ts b/packages/@core/ui-kit/shadcn-ui/src/components/pagination/index.ts new file mode 100644 index 00000000000..5b875294400 --- /dev/null +++ b/packages/@core/ui-kit/shadcn-ui/src/components/pagination/index.ts @@ -0,0 +1,2 @@ +export type { PaginationProps as VbenPaginationProps } from './pagination'; +export { default as VbenPagination } from './pagination.vue'; diff --git a/packages/@core/ui-kit/shadcn-ui/src/components/pagination/pagination.ts b/packages/@core/ui-kit/shadcn-ui/src/components/pagination/pagination.ts new file mode 100644 index 00000000000..a14d3867e53 --- /dev/null +++ b/packages/@core/ui-kit/shadcn-ui/src/components/pagination/pagination.ts @@ -0,0 +1,41 @@ +export interface PaginationProps { + /** + * 是否禁用 + */ + disabled?: boolean; + /** + * 每页记录数选项 + */ + pageSizeOptions?: number[]; + /** + * 当 时true,始终显示第一页、最后一页和省略号 + */ + showEdges?: boolean; + /** + * 显示当前页选择下拉框 + */ + showRowsPerPage?: boolean; + /** + * 显示总条数文本 + */ + showTotalText?: boolean; + /** + * 当前页面周围应显示的兄弟页面数量 + */ + siblingCount?: number; + /** + * 组件尺寸 + */ + size?: 'default' | 'large' | 'small'; + + /** + * 总条数 + */ + total?: number; +} + +export const SIZE_CLASS_MAP = { + default: 'size-8', + large: 'size-9', + small: 'size-7', +}; diff --git a/packages/@core/ui-kit/shadcn-ui/src/components/pagination/pagination.vue b/packages/@core/ui-kit/shadcn-ui/src/components/pagination/pagination.vue new file mode 100644 index 00000000000..37f1ba3901d --- /dev/null +++ b/packages/@core/ui-kit/shadcn-ui/src/components/pagination/pagination.vue @@ -0,0 +1,111 @@ + + + diff --git a/packages/@core/ui-kit/shadcn-ui/src/components/ui/accordion/AccordionTrigger.vue b/packages/@core/ui-kit/shadcn-ui/src/components/ui/accordion/AccordionTrigger.vue index ed40834cda6..48d65e6f63a 100644 --- a/packages/@core/ui-kit/shadcn-ui/src/components/ui/accordion/AccordionTrigger.vue +++ b/packages/@core/ui-kit/shadcn-ui/src/components/ui/accordion/AccordionTrigger.vue @@ -3,7 +3,7 @@ import { computed } from 'vue'; import { cn } from '@vben-core/shared/utils'; -import { ChevronDownIcon } from '@radix-icons/vue'; +import { ChevronDown } from 'lucide-vue-next'; import { AccordionHeader, AccordionTrigger, @@ -32,7 +32,7 @@ const delegatedProps = computed(() => { > - diff --git a/packages/@core/ui-kit/shadcn-ui/src/components/ui/breadcrumb/BreadcrumbEllipsis.vue b/packages/@core/ui-kit/shadcn-ui/src/components/ui/breadcrumb/BreadcrumbEllipsis.vue index e0a6a7c844b..b98f99e8bb7 100644 --- a/packages/@core/ui-kit/shadcn-ui/src/components/ui/breadcrumb/BreadcrumbEllipsis.vue +++ b/packages/@core/ui-kit/shadcn-ui/src/components/ui/breadcrumb/BreadcrumbEllipsis.vue @@ -1,7 +1,7 @@ + + diff --git a/packages/@core/ui-kit/shadcn-ui/src/components/ui/pagination/PaginationFirst.vue b/packages/@core/ui-kit/shadcn-ui/src/components/ui/pagination/PaginationFirst.vue new file mode 100644 index 00000000000..ea5ca42d206 --- /dev/null +++ b/packages/@core/ui-kit/shadcn-ui/src/components/ui/pagination/PaginationFirst.vue @@ -0,0 +1,33 @@ + + + diff --git a/packages/@core/ui-kit/shadcn-ui/src/components/ui/pagination/PaginationLast.vue b/packages/@core/ui-kit/shadcn-ui/src/components/ui/pagination/PaginationLast.vue new file mode 100644 index 00000000000..d6b24fd87c3 --- /dev/null +++ b/packages/@core/ui-kit/shadcn-ui/src/components/ui/pagination/PaginationLast.vue @@ -0,0 +1,33 @@ + + + diff --git a/packages/@core/ui-kit/shadcn-ui/src/components/ui/pagination/PaginationNext.vue b/packages/@core/ui-kit/shadcn-ui/src/components/ui/pagination/PaginationNext.vue new file mode 100644 index 00000000000..cc67596314e --- /dev/null +++ b/packages/@core/ui-kit/shadcn-ui/src/components/ui/pagination/PaginationNext.vue @@ -0,0 +1,33 @@ + + + diff --git a/packages/@core/ui-kit/shadcn-ui/src/components/ui/pagination/PaginationPrev.vue b/packages/@core/ui-kit/shadcn-ui/src/components/ui/pagination/PaginationPrev.vue new file mode 100644 index 00000000000..4996e687be2 --- /dev/null +++ b/packages/@core/ui-kit/shadcn-ui/src/components/ui/pagination/PaginationPrev.vue @@ -0,0 +1,33 @@ + + + diff --git a/packages/@core/ui-kit/shadcn-ui/src/components/ui/pagination/index.ts b/packages/@core/ui-kit/shadcn-ui/src/components/ui/pagination/index.ts new file mode 100644 index 00000000000..ce93dc4ea12 --- /dev/null +++ b/packages/@core/ui-kit/shadcn-ui/src/components/ui/pagination/index.ts @@ -0,0 +1,10 @@ +export { default as PaginationEllipsis } from './PaginationEllipsis.vue'; +export { default as PaginationFirst } from './PaginationFirst.vue'; +export { default as PaginationLast } from './PaginationLast.vue'; +export { default as PaginationNext } from './PaginationNext.vue'; +export { default as PaginationPrev } from './PaginationPrev.vue'; +export { + PaginationList, + PaginationListItem, + PaginationRoot as Pagination, +} from 'radix-vue'; diff --git a/packages/@core/ui-kit/shadcn-ui/src/components/ui/pin-input/PinInputSeparator.vue b/packages/@core/ui-kit/shadcn-ui/src/components/ui/pin-input/PinInputSeparator.vue index e8c86f7231c..d6b867a7f79 100644 --- a/packages/@core/ui-kit/shadcn-ui/src/components/ui/pin-input/PinInputSeparator.vue +++ b/packages/@core/ui-kit/shadcn-ui/src/components/ui/pin-input/PinInputSeparator.vue @@ -1,5 +1,5 @@