From 819c3cf78816081eef738b7f7ae6abb5f7f131e2 Mon Sep 17 00:00:00 2001 From: Cheton Wu Date: Mon, 16 Sep 2024 14:36:12 +0800 Subject: [PATCH] feat(react/pagination): apply default props --- packages/react/src/pagination/Pagination.js | 9 ++++----- packages/react/src/pagination/PaginationItem.js | 9 ++++----- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/packages/react/src/pagination/Pagination.js b/packages/react/src/pagination/Pagination.js index 6b5558b402..9fd2774c1f 100644 --- a/packages/react/src/pagination/Pagination.js +++ b/packages/react/src/pagination/Pagination.js @@ -1,11 +1,12 @@ import React, { Fragment, forwardRef } from 'react'; import { Box } from '../box'; +import { useDefaultProps } from '../default-props'; import { usePaginationStyle } from './styles'; import PaginationItem from './PaginationItem'; import usePagination from './usePagination'; -const Pagination = forwardRef(( - { +const Pagination = forwardRef((inProps, ref) => { + const { boundaryCount = 1, count = 1, defaultPage = 1, @@ -16,9 +17,7 @@ const Pagination = forwardRef(( siblingCount = 1, slot, ...rest - }, - ref, -) => { + } = useDefaultProps({ props: inProps, name: 'Pagination' }); const { items } = usePagination({ boundaryCount, count, diff --git a/packages/react/src/pagination/PaginationItem.js b/packages/react/src/pagination/PaginationItem.js index 2e498da296..41b99a687b 100644 --- a/packages/react/src/pagination/PaginationItem.js +++ b/packages/react/src/pagination/PaginationItem.js @@ -8,6 +8,7 @@ import { import { ariaAttr } from '@tonic-ui/utils'; import React, { forwardRef } from 'react'; import { Button } from '../button'; +import { useDefaultProps } from '../default-props'; import { usePaginationItemStyle, } from './styles'; @@ -34,8 +35,8 @@ const getAriaLabel = ({ type, page, selected }) => { return `Go to ${type} page`; }; -const PaginationItem = forwardRef(( - { +const PaginationItem = forwardRef((inProps, ref) => { + const { 'aria-label': ariaLabel, disabled = false, type = 'page', @@ -44,9 +45,7 @@ const PaginationItem = forwardRef(( slot: slotProp, variant = 'ghost', ...rest - }, - ref, -) => { + } = useDefaultProps({ props: inProps, name: 'PaginationItem' }); const slot = { ...defaultSlot, ...slotProp,