@daeryun/dr_components 1.1.50 → 1.1.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/PaginationForGroup/PaginationForGroup.d.ts +10 -0
- package/dist/components/PaginationForGroup/PaginationForGroup.jsx +67 -0
- package/dist/components/PaginationForGroup/PaginationForGroup.stories.d.ts +6 -0
- package/dist/components/PaginationForGroup/PaginationForGroup.stories.jsx +18 -0
- package/dist/components/PaginationForGroup/PaginationForGroup.stories.tsx +25 -0
- package/dist/components/PaginationForGroup/PaginationForGroup.tsx +132 -0
- package/dist/components/index.js +1 -0
- package/dist/components/index.ts +1 -0
- package/dist/components/page/Broadcast/BroadcastList.jsx +3 -2
- package/dist/components/page/Broadcast/BroadcastList.tsx +3 -1
- package/dist/styles/globals.css +8 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface PaginationProps {
|
|
3
|
+
total: number;
|
|
4
|
+
size: number;
|
|
5
|
+
currentPage: number;
|
|
6
|
+
className?: string;
|
|
7
|
+
query?: string;
|
|
8
|
+
}
|
|
9
|
+
declare const PaginationForGroup: ({ total, size, currentPage, className }: PaginationProps) => React.JSX.Element;
|
|
10
|
+
export default PaginationForGroup;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
import Link from 'next/link';
|
|
14
|
+
import React, { useEffect, useState } from 'react';
|
|
15
|
+
import { usePathname, useSearchParams } from 'next/navigation';
|
|
16
|
+
// import IconArrow from '@/public/images/svg/left_arrow.svg';
|
|
17
|
+
import arrowLeft from '../../asset/images/myCase/pagination/arrow_l_on.webp';
|
|
18
|
+
import arrowRight from '../../asset/images/myCase/pagination/arrow_r_on.webp';
|
|
19
|
+
import Image from 'next/image';
|
|
20
|
+
const PaginationForGroup = ({ total, size, currentPage, className }) => {
|
|
21
|
+
const totalPages = Math.ceil(total / size);
|
|
22
|
+
const pathname = usePathname();
|
|
23
|
+
const searchParams = useSearchParams();
|
|
24
|
+
const [query, setQuery] = useState({});
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
const params = Object.fromEntries(searchParams);
|
|
27
|
+
const filteredQuery = Object.assign({}, Object.fromEntries(Object.entries(params).filter(([key, value]) => !(key === 'search' && value === '') && key !== 'page')));
|
|
28
|
+
setQuery(filteredQuery);
|
|
29
|
+
}, [pathname, searchParams]);
|
|
30
|
+
const groupSize = 5;
|
|
31
|
+
const currentGroup = Math.floor((currentPage - 1) / groupSize);
|
|
32
|
+
const startPage = currentGroup * groupSize + 1;
|
|
33
|
+
const endPage = Math.min(startPage + groupSize - 1, totalPages);
|
|
34
|
+
const pages = Array.from({ length: endPage - startPage + 1 }, (_, i) => startPage + i);
|
|
35
|
+
return (<div className={`flex h-[40px] justify-center gap-[6px] font-[500] text-black max-md:h-[35px] max-md:gap-2 ${className}`}>
|
|
36
|
+
{totalPages >= 1 && (<>
|
|
37
|
+
{/* 이전 그룹 버튼 */}
|
|
38
|
+
<PageBtn disabled={currentPage <= 1} index={<Image src={arrowLeft} width={26} height={26} alt={''} className={'pb-1 max-sm:scale-[0.8]'}/>} href={{
|
|
39
|
+
pathname,
|
|
40
|
+
query: Object.assign({ page: currentPage - 1 }, query)
|
|
41
|
+
}} alwaysBg/>
|
|
42
|
+
|
|
43
|
+
{/* 그룹 내 페이지 버튼 */}
|
|
44
|
+
{pages.map(page => (<PageBtn index={<div className={'flex aspect-square h-[30px] items-center justify-center'}>{page}</div>} key={`${pathname}_${page}`} href={{
|
|
45
|
+
pathname,
|
|
46
|
+
query: Object.assign({ page }, query)
|
|
47
|
+
}} active={page === currentPage}>
|
|
48
|
+
{page}
|
|
49
|
+
</PageBtn>))}
|
|
50
|
+
|
|
51
|
+
{/* 다음 그룹 버튼 */}
|
|
52
|
+
<PageBtn disabled={currentPage >= totalPages} index={<Image src={arrowRight} width={26} height={26} alt={''} className={'pb-1 max-sm:scale-[0.8]'}/>} href={{
|
|
53
|
+
pathname,
|
|
54
|
+
query: Object.assign({ page: currentPage + 1 }, query)
|
|
55
|
+
}} alwaysBg/>
|
|
56
|
+
</>)}
|
|
57
|
+
</div>);
|
|
58
|
+
};
|
|
59
|
+
export default PaginationForGroup;
|
|
60
|
+
const PageBtn = (_a) => {
|
|
61
|
+
var { index, active, disabled, alwaysBg } = _a, props = __rest(_a, ["index", "active", "disabled", "alwaysBg"]);
|
|
62
|
+
return (<Link {...props} className={'flex items-center justify-center text-lg leading-none max-sm:text-base ' +
|
|
63
|
+
`${active ? 'font-[800] ' : ''}` +
|
|
64
|
+
`${disabled ? 'pointer-events-none opacity-20 ' : ''}`}>
|
|
65
|
+
{index}
|
|
66
|
+
</Link>);
|
|
67
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import PaginationForGroup from './PaginationForGroup';
|
|
2
|
+
const meta = {
|
|
3
|
+
component: PaginationForGroup,
|
|
4
|
+
title: 'PaginationForGroup'
|
|
5
|
+
};
|
|
6
|
+
export default meta;
|
|
7
|
+
export const Default = {
|
|
8
|
+
render: args => {
|
|
9
|
+
return (<div className={'w-full font-[SUIT]'}>
|
|
10
|
+
<PaginationForGroup {...args}/>
|
|
11
|
+
</div>);
|
|
12
|
+
},
|
|
13
|
+
args: {
|
|
14
|
+
currentPage: 1,
|
|
15
|
+
size: 10,
|
|
16
|
+
total: 1000
|
|
17
|
+
}
|
|
18
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import PaginationForGroup from './PaginationForGroup';
|
|
3
|
+
|
|
4
|
+
const meta: Meta<typeof PaginationForGroup> = {
|
|
5
|
+
component: PaginationForGroup,
|
|
6
|
+
title: 'PaginationForGroup'
|
|
7
|
+
};
|
|
8
|
+
export default meta;
|
|
9
|
+
|
|
10
|
+
type Story = StoryObj<typeof meta>;
|
|
11
|
+
|
|
12
|
+
export const Default: Story = {
|
|
13
|
+
render: args => {
|
|
14
|
+
return (
|
|
15
|
+
<div className={'w-full font-[SUIT]'}>
|
|
16
|
+
<PaginationForGroup {...args} />
|
|
17
|
+
</div>
|
|
18
|
+
);
|
|
19
|
+
},
|
|
20
|
+
args: {
|
|
21
|
+
currentPage: 1,
|
|
22
|
+
size: 10,
|
|
23
|
+
total: 1000
|
|
24
|
+
}
|
|
25
|
+
};
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import Link, { LinkProps } from 'next/link';
|
|
4
|
+
import React, { useEffect, useState } from 'react';
|
|
5
|
+
import { usePathname, useSearchParams } from 'next/navigation';
|
|
6
|
+
// import IconArrow from '@/public/images/svg/left_arrow.svg';
|
|
7
|
+
|
|
8
|
+
import arrowLeft from '../../asset/images/myCase/pagination/arrow_l_on.webp';
|
|
9
|
+
import arrowRight from '../../asset/images/myCase/pagination/arrow_r_on.webp';
|
|
10
|
+
import arrowLeftOff from '../../asset/images/myCase/pagination/arrow_l_off.webp';
|
|
11
|
+
import arrowRightOff from '../../asset/images/myCase/pagination/arrow_r_off.webp';
|
|
12
|
+
import Image from 'next/image';
|
|
13
|
+
|
|
14
|
+
interface PaginationProps {
|
|
15
|
+
total: number;
|
|
16
|
+
size: number;
|
|
17
|
+
currentPage: number;
|
|
18
|
+
className?: string;
|
|
19
|
+
query?: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const PaginationForGroup = ({ total, size, currentPage, className }: PaginationProps) => {
|
|
23
|
+
const totalPages = Math.ceil(total / size);
|
|
24
|
+
const pathname = usePathname();
|
|
25
|
+
const searchParams = useSearchParams();
|
|
26
|
+
const [query, setQuery] = useState<Record<string, string>>({});
|
|
27
|
+
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
const params = Object.fromEntries(searchParams);
|
|
30
|
+
const filteredQuery = {
|
|
31
|
+
...Object.fromEntries(
|
|
32
|
+
Object.entries(params).filter(([key, value]) => !(key === 'search' && value === '') && key !== 'page')
|
|
33
|
+
)
|
|
34
|
+
};
|
|
35
|
+
setQuery(filteredQuery);
|
|
36
|
+
}, [pathname, searchParams]);
|
|
37
|
+
|
|
38
|
+
const groupSize = 5;
|
|
39
|
+
const currentGroup = Math.floor((currentPage - 1) / groupSize);
|
|
40
|
+
const startPage = currentGroup * groupSize + 1;
|
|
41
|
+
const endPage = Math.min(startPage + groupSize - 1, totalPages);
|
|
42
|
+
const pages = Array.from({ length: endPage - startPage + 1 }, (_, i) => startPage + i);
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<div
|
|
46
|
+
className={`flex h-[40px] justify-center gap-[6px] font-[500] text-black max-md:h-[35px] max-md:gap-2 ${className}`}
|
|
47
|
+
>
|
|
48
|
+
{totalPages >= 1 && (
|
|
49
|
+
<>
|
|
50
|
+
{/* 이전 그룹 버튼 */}
|
|
51
|
+
<PageBtn
|
|
52
|
+
disabled={currentPage <= 1}
|
|
53
|
+
index={
|
|
54
|
+
<Image
|
|
55
|
+
src={arrowLeft}
|
|
56
|
+
width={26}
|
|
57
|
+
height={26}
|
|
58
|
+
alt={''}
|
|
59
|
+
className={'pb-1 max-sm:scale-[0.8]'}
|
|
60
|
+
/>
|
|
61
|
+
}
|
|
62
|
+
href={{
|
|
63
|
+
pathname,
|
|
64
|
+
query: { page: currentPage - 1, ...query }
|
|
65
|
+
}}
|
|
66
|
+
alwaysBg
|
|
67
|
+
/>
|
|
68
|
+
|
|
69
|
+
{/* 그룹 내 페이지 버튼 */}
|
|
70
|
+
{pages.map(page => (
|
|
71
|
+
<PageBtn
|
|
72
|
+
index={
|
|
73
|
+
<div className={'flex aspect-square h-[30px] items-center justify-center'}>{page}</div>
|
|
74
|
+
}
|
|
75
|
+
key={`${pathname}_${page}`}
|
|
76
|
+
href={{
|
|
77
|
+
pathname,
|
|
78
|
+
query: { page, ...query }
|
|
79
|
+
}}
|
|
80
|
+
active={page === currentPage}
|
|
81
|
+
>
|
|
82
|
+
{page}
|
|
83
|
+
</PageBtn>
|
|
84
|
+
))}
|
|
85
|
+
|
|
86
|
+
{/* 다음 그룹 버튼 */}
|
|
87
|
+
<PageBtn
|
|
88
|
+
disabled={currentPage >= totalPages}
|
|
89
|
+
index={
|
|
90
|
+
<Image
|
|
91
|
+
src={arrowRight}
|
|
92
|
+
width={26}
|
|
93
|
+
height={26}
|
|
94
|
+
alt={''}
|
|
95
|
+
className={'pb-1 max-sm:scale-[0.8]'}
|
|
96
|
+
/>
|
|
97
|
+
}
|
|
98
|
+
href={{
|
|
99
|
+
pathname,
|
|
100
|
+
query: { page: currentPage + 1, ...query }
|
|
101
|
+
}}
|
|
102
|
+
alwaysBg
|
|
103
|
+
/>
|
|
104
|
+
</>
|
|
105
|
+
)}
|
|
106
|
+
</div>
|
|
107
|
+
);
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
export default PaginationForGroup;
|
|
111
|
+
|
|
112
|
+
interface PageBtnProps extends Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, 'href'>, LinkProps {
|
|
113
|
+
index: React.ReactNode;
|
|
114
|
+
active?: boolean;
|
|
115
|
+
disabled?: boolean;
|
|
116
|
+
alwaysBg?: boolean;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const PageBtn = ({ index, active, disabled, alwaysBg, ...props }: PageBtnProps) => {
|
|
120
|
+
return (
|
|
121
|
+
<Link
|
|
122
|
+
{...props}
|
|
123
|
+
className={
|
|
124
|
+
'flex items-center justify-center text-lg leading-none max-sm:text-base ' +
|
|
125
|
+
`${active ? 'font-[800] ' : ''}` +
|
|
126
|
+
`${disabled ? 'pointer-events-none opacity-20 ' : ''}`
|
|
127
|
+
}
|
|
128
|
+
>
|
|
129
|
+
{index}
|
|
130
|
+
</Link>
|
|
131
|
+
);
|
|
132
|
+
};
|
package/dist/components/index.js
CHANGED
|
@@ -48,3 +48,4 @@ export { default as PostNavigation } from './postNavigation/PostNavigation';
|
|
|
48
48
|
export { default as ListBottomKeywd } from './ListBottomKeywd/ListBottomKeywd';
|
|
49
49
|
export { RouteType } from './ListBottomKeywd/RouteType';
|
|
50
50
|
export * from '../components/common/types/strength_new';
|
|
51
|
+
export { default as PaginationForGroup } from './PaginationForGroup/PaginationForGroup';
|
package/dist/components/index.ts
CHANGED
|
@@ -48,3 +48,4 @@ export { default as PostNavigation } from './postNavigation/PostNavigation';
|
|
|
48
48
|
export { default as ListBottomKeywd } from './ListBottomKeywd/ListBottomKeywd';
|
|
49
49
|
export { RouteType } from './ListBottomKeywd/RouteType';
|
|
50
50
|
export * from '../components/common/types/strength_new';
|
|
51
|
+
export { default as PaginationForGroup } from './PaginationForGroup/PaginationForGroup';
|
|
@@ -6,7 +6,7 @@ import { useEffect, useState } from 'react';
|
|
|
6
6
|
import Link from 'next/link';
|
|
7
7
|
import Image from 'next/image';
|
|
8
8
|
import { htmlTagRemove } from '../../../lib';
|
|
9
|
-
import
|
|
9
|
+
import { PaginationForGroup } from '../../index';
|
|
10
10
|
const BroadcastList = ({ search, page, count, size, broadcastList }) => {
|
|
11
11
|
const router = useRouter();
|
|
12
12
|
const [searchInput, setSearchInput] = useState('');
|
|
@@ -85,7 +85,8 @@ const BroadcastList = ({ search, page, count, size, broadcastList }) => {
|
|
|
85
85
|
})}
|
|
86
86
|
</div>) : (<div className={'h-[300px] text-center text-[20px] leading-[300px]'}>정보 조회 중입니다.</div>)}
|
|
87
87
|
</div>
|
|
88
|
-
<
|
|
88
|
+
<PaginationForGroup total={count} size={size} currentPage={page}/>
|
|
89
|
+
{/*<PaginationComponent onChange={onChange} current={page} total={count} pageSize={size} />*/}
|
|
89
90
|
</PageWrapper>);
|
|
90
91
|
};
|
|
91
92
|
export default BroadcastList;
|
|
@@ -7,6 +7,7 @@ import Link from 'next/link';
|
|
|
7
7
|
import Image from 'next/image';
|
|
8
8
|
import { htmlTagRemove } from '../../../lib';
|
|
9
9
|
import PaginationComponent from '../MyCase/_component/_pagination/PaginationComponent';
|
|
10
|
+
import { PaginationForGroup } from '../../index';
|
|
10
11
|
|
|
11
12
|
interface BroadCastData {
|
|
12
13
|
id: number;
|
|
@@ -179,7 +180,8 @@ const BroadcastList = ({
|
|
|
179
180
|
<div className={'h-[300px] text-center text-[20px] leading-[300px]'}>정보 조회 중입니다.</div>
|
|
180
181
|
)}
|
|
181
182
|
</div>
|
|
182
|
-
<
|
|
183
|
+
<PaginationForGroup total={count} size={size} currentPage={page} />
|
|
184
|
+
{/*<PaginationComponent onChange={onChange} current={page} total={count} pageSize={size} />*/}
|
|
183
185
|
</PageWrapper>
|
|
184
186
|
);
|
|
185
187
|
};
|
package/dist/styles/globals.css
CHANGED
|
@@ -8914,6 +8914,10 @@ html {
|
|
|
8914
8914
|
opacity: 1;
|
|
8915
8915
|
}
|
|
8916
8916
|
|
|
8917
|
+
.opacity-20 {
|
|
8918
|
+
opacity: 0.2;
|
|
8919
|
+
}
|
|
8920
|
+
|
|
8917
8921
|
.opacity-25 {
|
|
8918
8922
|
opacity: 0.25;
|
|
8919
8923
|
}
|
|
@@ -15200,6 +15204,10 @@ body {
|
|
|
15200
15204
|
height: 350px;
|
|
15201
15205
|
}
|
|
15202
15206
|
|
|
15207
|
+
.max-md\:h-\[35px\] {
|
|
15208
|
+
height: 35px;
|
|
15209
|
+
}
|
|
15210
|
+
|
|
15203
15211
|
.max-md\:h-\[380px\] {
|
|
15204
15212
|
height: 380px;
|
|
15205
15213
|
}
|