diff --git a/src/components/data-container/data-grid/TDataGrid.interface.ts b/src/components/data-container/data-grid/TDataGrid.interface.ts index d24d62ef..c2783c59 100644 --- a/src/components/data-container/data-grid/TDataGrid.interface.ts +++ b/src/components/data-container/data-grid/TDataGrid.interface.ts @@ -18,6 +18,7 @@ export interface TDataGridProps extends TBaseProps, AgReactUiProps { height?: string, leftAction?: ReactElement + centerAction?: ReactElement, rightAction?: ReactElement onChange?: (value: any[]) => void @@ -28,6 +29,9 @@ export interface TDataGridProps extends TBaseProps, AgReactUiProps { paging?: TPageResponseVO, maxRowsWithoutScroll?: number, + noJumper?: boolean, + jumperText?: string, + noDataText?: string, noDataContent?: { title: string, diff --git a/src/components/data-container/data-grid/TDataGrid.tsx b/src/components/data-container/data-grid/TDataGrid.tsx index 5fea1a76..54d498cb 100644 --- a/src/components/data-container/data-grid/TDataGrid.tsx +++ b/src/components/data-container/data-grid/TDataGrid.tsx @@ -5,6 +5,7 @@ import {SelectionChangedEvent} from 'ag-grid-community'; import {TDataGridProps} from './TDataGrid.interface'; import TButton from '../../button/button/TButton'; import TPagination from '../pagination/TPagination'; +import TActionBar from '~/data-container/action-bar/TActionBar'; const TDataGrid = forwardRef((props: TDataGridProps, ref: Ref) => { @@ -73,11 +74,11 @@ const TDataGrid = forwardRef((props: TDataGridProps, ref: Ref) => { const noRowsOverlayComponent = useCallback(() => (<>
- - + - - + + { @@ -107,7 +108,7 @@ const TDataGrid = forwardRef((props: TDataGridProps, ref: Ref) => {
{ !props.noHeader && ( -
+
{ !props.noTotalRows && (
@@ -125,17 +126,11 @@ const TDataGrid = forwardRef((props: TDataGridProps, ref: Ref) => { } { - props.leftAction && ( -
- {props.leftAction} -
- ) - } - { - props.rightAction && ( -
- {props.rightAction} -
+ (props.leftAction || props.rightAction || props.centerAction) && ( + ) }
@@ -143,7 +138,7 @@ const TDataGrid = forwardRef((props: TDataGridProps, ref: Ref) => { } -
) => { totalPages={props.paging?.totalPages || 1} pageNumber={props.paging?.pageNumber || 1} onChangePageNumber={(value) => props.onChangePageNumber(value)} + noJumper={props.noJumper} + jumperText={props.jumperText} /> ) } @@ -180,8 +177,8 @@ TDataGrid.defaultProps = { suppressRowClickSelection: true, enableCellTextSelection: true, noDataText: '검색 조건에 맞는 데이터가 없습니다', - headerHeight: 48, - rowHeight: 76, + headerHeight: 32, + rowHeight: 40, }; TDataGrid.displayName = 'TDataGrid'; diff --git a/src/components/data-container/pagination/TPagination.interface.ts b/src/components/data-container/pagination/TPagination.interface.ts index 6380f3e9..afceeba4 100644 --- a/src/components/data-container/pagination/TPagination.interface.ts +++ b/src/components/data-container/pagination/TPagination.interface.ts @@ -4,6 +4,8 @@ export interface TPaginationProps extends TBaseProps { totalPages: number, pageNumber: number, + noJumper?: boolean, + jumperText?: string, onChangePageNumber(value: number): void, } diff --git a/src/components/data-container/pagination/TPagination.tsx b/src/components/data-container/pagination/TPagination.tsx index 0bbb4458..0ca11d47 100644 --- a/src/components/data-container/pagination/TPagination.tsx +++ b/src/components/data-container/pagination/TPagination.tsx @@ -1,7 +1,10 @@ -import {CSSProperties, forwardRef, Ref, useCallback, useEffect, useImperativeHandle, useMemo, useState} from 'react'; +import {CSSProperties, forwardRef, Ref, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState} from 'react'; import {TPaginationProps, TPaginationRef} from './TPagination.interface'; import TIcon from '../../icon/TIcon'; +import TButton from '~/button/button/TButton'; +import TNumberField from '~/input/number-field/TNumberField'; +import rule from '@/common/validator/TValidatorRule'; const TPagination = forwardRef((props: TPaginationProps, ref: Ref) => { @@ -16,10 +19,13 @@ const TPagination = forwardRef((props: TPaginationProps, ref: Ref({min: 1, max: 1}); - + const [jumperPage, setJumperPage] = useState(props.pageNumber); + const numberFieldRef = useRef(null); + const jumperTextFieldMin = 1; // endregion @@ -49,7 +55,6 @@ const TPagination = forwardRef((props: TPaginationProps, ref: Ref { const min = Math.floor((currentPage - 1) / 10) * 10 + 1; const max = Math.min(totalPages, min + 9); - return {min, max}; }, []); @@ -108,6 +113,14 @@ const TPagination = forwardRef((props: TPaginationProps, ref: Ref { + setJumperPage(Number(pageNumber)); + }, [pageRange]); + + const onClickJumperButton = useCallback(() => { + const validResult = numberFieldRef.current?.validate(); + if (validResult === true && onChangePageNumber) { onChangePageNumber(jumperPage); } + }, [jumperPage, pageRange, onChangePageNumber]); // endregion @@ -116,14 +129,14 @@ const TPagination = forwardRef((props: TPaginationProps, ref: Ref { const range = getPageRange(props.pageNumber, props.totalPages); setPageRange(range); + setJumperPage(props.pageNumber); }, [getPageRange, props.pageNumber, props.totalPages]); - // endregion return ( -