@daeryun/dr_components 1.1.38 → 1.1.40

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.
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  import { usePathname, useRouter } from 'next/navigation';
12
- import { useEffect, useRef, useState } from 'react';
12
+ import React, { useEffect, useRef, useState } from 'react';
13
13
  import HeaderWrapper from './HeaderWrapper';
14
14
  import Link from 'next/link';
15
15
  import Image from 'next/image';
@@ -18,7 +18,8 @@ import SearchBlack from '../../asset/images/header/search_black.webp';
18
18
  import MenuWhite from '../../asset/images/header/h_menu.webp';
19
19
  import MenuBlack from '../../asset/images/header/h_menu_b.webp';
20
20
  import IconNewLink from '../../asset/images/header/head_link.svg';
21
- const PcHeader = ({ isNotSubPage, pcRoutes, isTextWhite, isBgOpacityZero, isBgGray, isBgWhite, handleMenuToggle, centerName, isUnderBorder }) => {
21
+ import HeaderWrapperNew from './HeaderWrapperNew';
22
+ const PcHeader = ({ isNotSubPage, pcRoutes, isTextWhite, isBgOpacityZero, isBgGray, isBgWhite, handleMenuToggle, centerName, isUnderBorder, isWhiteSpacePreWrap, isNewWrapper }) => {
22
23
  const router = useRouter();
23
24
  const pathname = usePathname();
24
25
  const [isHover, setIsHover] = useState(false);
@@ -44,7 +45,10 @@ const PcHeader = ({ isNotSubPage, pcRoutes, isTextWhite, isBgOpacityZero, isBgGr
44
45
  return () => clearTimeout(heightSet);
45
46
  }
46
47
  }, [isHover]);
47
- return (<header ref={headerRef} className={'relative w-full transition-colors duration-300 max-sm:hidden'} onMouseEnter={() => {
48
+ const Wrapper = (props) => {
49
+ return isNewWrapper ? (<HeaderWrapperNew className={props.className}>{props.children}</HeaderWrapperNew>) : (<HeaderWrapper className={props.className}>{props.children}</HeaderWrapper>);
50
+ };
51
+ return (<header ref={headerRef} className={'relative w-full transition-colors duration-300 max-sm:hidden '} onMouseEnter={() => {
48
52
  if (isNotSubPage)
49
53
  return;
50
54
  setIsHover(true);
@@ -62,7 +66,7 @@ const PcHeader = ({ isNotSubPage, pcRoutes, isTextWhite, isBgOpacityZero, isBgGr
62
66
  {/*하단배경 (세부 nav)*/}
63
67
  <div className={'z-1 absolute bottom-0 left-0 h-[calc(100%-80px)] w-full transition-colors duration-300 ' +
64
68
  `${isHover ? 'bg-[#545454] bg-opacity-90 ' : ''}`}/>
65
- <HeaderWrapper className={'flex min-h-[80px] items-start justify-between pt-[22px] ' +
69
+ <Wrapper className={'flex min-h-[80px] items-start justify-between pt-[22px] ' +
66
70
  //1024px
67
71
  'max-lg:items-center max-lg:pt-0 '}>
68
72
  <Link href={`/`} className={'relative h-[38px] w-[230px] shrink-0 max-xl:h-[32px]'}>
@@ -88,6 +92,7 @@ const PcHeader = ({ isNotSubPage, pcRoutes, isTextWhite, isBgOpacityZero, isBgGr
88
92
  {pcRoute.routes.map(inRoute => (<Link key={'in_route_' + inRoute.name} href={inRoute.path} target={inRoute.newTab ? '_blank' : ''} className={'break-keep text-center text-[16px] font-[500] leading-[1.2] tracking-[-0.6px] text-[#C4C4C4] transition-opacity ' +
89
93
  'hover:text-white ' +
90
94
  `${isHover ? '' : 'opacity-0 '}` +
95
+ `${isWhiteSpacePreWrap ? ' whitespace-pre-wrap ' : ''}` +
91
96
  //1280px
92
97
  'max-xl:break-all max-xl:text-[14px]'}>
93
98
  {inRoute.name}
@@ -118,7 +123,7 @@ const PcHeader = ({ isNotSubPage, pcRoutes, isTextWhite, isBgOpacityZero, isBgGr
118
123
  <Image id={'menu'} src={isTextWhite || isHover ? MenuWhite : MenuBlack} alt="전체메뉴 열기" width={38} height={20} className={'h-full w-full object-contain'}/>
119
124
  </button>)}
120
125
  </span>
121
- </HeaderWrapper>
126
+ </Wrapper>
122
127
  </header>);
123
128
  };
124
129
  export default PcHeader;
@@ -2,7 +2,7 @@
2
2
 
3
3
  import { IRoute } from '../common';
4
4
  import { usePathname, useRouter } from 'next/navigation';
5
- import { useEffect, useRef, useState } from 'react';
5
+ import React, { ReactNode, useEffect, useRef, useState } from 'react';
6
6
  import HeaderWrapper from './HeaderWrapper';
7
7
  import Link from 'next/link';
8
8
  import Image from 'next/image';
@@ -12,6 +12,7 @@ import SearchBlack from '../../asset/images/header/search_black.webp';
12
12
  import MenuWhite from '../../asset/images/header/h_menu.webp';
13
13
  import MenuBlack from '../../asset/images/header/h_menu_b.webp';
14
14
  import IconNewLink from '../../asset/images/header/head_link.svg';
15
+ import HeaderWrapperNew from './HeaderWrapperNew';
15
16
 
16
17
  const PcHeader = ({
17
18
  isNotSubPage,
@@ -22,7 +23,9 @@ const PcHeader = ({
22
23
  isBgWhite,
23
24
  handleMenuToggle,
24
25
  centerName,
25
- isUnderBorder
26
+ isUnderBorder,
27
+ isWhiteSpacePreWrap,
28
+ isNewWrapper
26
29
  }: {
27
30
  isNotSubPage?: boolean;
28
31
  pcRoutes: IRoute[];
@@ -33,6 +36,8 @@ const PcHeader = ({
33
36
  handleMenuToggle: (url?: string | undefined) => void;
34
37
  centerName: string;
35
38
  isUnderBorder?: boolean;
39
+ isWhiteSpacePreWrap?: boolean;
40
+ isNewWrapper?: boolean;
36
41
  }) => {
37
42
  const router = useRouter();
38
43
  const pathname = usePathname();
@@ -62,10 +67,18 @@ const PcHeader = ({
62
67
  }
63
68
  }, [isHover]);
64
69
 
70
+ const Wrapper = (props: { children: ReactNode; className?: string }) => {
71
+ return isNewWrapper ? (
72
+ <HeaderWrapperNew className={props.className}>{props.children}</HeaderWrapperNew>
73
+ ) : (
74
+ <HeaderWrapper className={props.className}>{props.children}</HeaderWrapper>
75
+ );
76
+ };
77
+
65
78
  return (
66
79
  <header
67
80
  ref={headerRef}
68
- className={'relative w-full transition-colors duration-300 max-sm:hidden'}
81
+ className={'relative w-full transition-colors duration-300 max-sm:hidden '}
69
82
  onMouseEnter={() => {
70
83
  if (isNotSubPage) return;
71
84
  setIsHover(true);
@@ -92,7 +105,7 @@ const PcHeader = ({
92
105
  `${isHover ? 'bg-[#545454] bg-opacity-90 ' : ''}`
93
106
  }
94
107
  />
95
- <HeaderWrapper
108
+ <Wrapper
96
109
  className={
97
110
  'flex min-h-[80px] items-start justify-between pt-[22px] ' +
98
111
  //1024px
@@ -156,6 +169,7 @@ const PcHeader = ({
156
169
  'break-keep text-center text-[16px] font-[500] leading-[1.2] tracking-[-0.6px] text-[#C4C4C4] transition-opacity ' +
157
170
  'hover:text-white ' +
158
171
  `${isHover ? '' : 'opacity-0 '}` +
172
+ `${isWhiteSpacePreWrap ? ' whitespace-pre-wrap ' : ''}` +
159
173
  //1280px
160
174
  'max-xl:break-all max-xl:text-[14px]'
161
175
  }
@@ -227,7 +241,7 @@ const PcHeader = ({
227
241
  </button>
228
242
  )}
229
243
  </span>
230
- </HeaderWrapper>
244
+ </Wrapper>
231
245
  </header>
232
246
  );
233
247
  };
@@ -14,37 +14,14 @@ interface INoticeTypes {
14
14
  top_count?: number;
15
15
  timestamp?: string;
16
16
  }
17
- interface ISearchBarProps {
18
- handleInputChange: (e: React.FormEvent<HTMLInputElement>) => void;
19
- handleSearch: () => void;
20
- searchInput: string;
21
- }
22
- interface IPaginationProps {
23
- onPaginationChange: (pageNum: number) => void;
24
- currentPage: number;
25
- totalCount: number;
17
+ interface NoticeCategory {
18
+ code: string;
19
+ code_name: string | null;
20
+ [key: string]: any;
26
21
  }
27
22
  interface NoticeListProps {
28
- SearchBarProps: ISearchBarProps;
29
- PaginationProps: IPaginationProps;
30
- noticeName: {
31
- code: string;
32
- code_name: string | null;
33
- [key: string]: any;
34
- }[];
35
23
  noticeList: INoticeTypes[];
36
- currentCodeDesc?: string;
37
- isUseHeaderComponent?: boolean;
38
- nameFilter: {
39
- code_name: string;
40
- code: string;
41
- };
42
- search: string;
43
- indexOfFirstPost: number;
44
- indexOfLastPost: number;
45
- postPerPage: number;
46
- currentPage: number;
47
- router: any;
24
+ noticeName: NoticeCategory[];
48
25
  }
49
- declare const NoticeList: ({ SearchBarProps, PaginationProps, noticeName, noticeList, currentCodeDesc, isUseHeaderComponent, nameFilter, search, indexOfFirstPost, indexOfLastPost, postPerPage, currentPage, router }: NoticeListProps) => React.JSX.Element;
26
+ declare const NoticeList: ({ noticeList, noticeName }: NoticeListProps) => React.JSX.Element;
50
27
  export default NoticeList;
@@ -1,12 +1,78 @@
1
1
  'use client';
2
- import React from 'react';
2
+ import React, { useState, useEffect } from 'react';
3
+ import { useRouter } from 'next/router';
3
4
  import Link from 'next/link';
4
- import Pagination from '../../Pagination/Pagination';
5
+ import SearchBar from '../../SearchBar/SearchBar';
6
+ import PaginationComponent from '../../page/MyCase/_component/_pagination/PaginationComponent';
5
7
  import PageTitleBox from '../../PageTitleBox/PageTitleBox';
6
8
  import { ImgTypes } from '../../PageTitleBox/ImgTypes';
7
9
  import PageWrapper from '../../Layout/PageWrapper';
8
- import SearchBar from '../../SearchBar/SearchBar';
9
- const NoticeList = ({ SearchBarProps, PaginationProps, noticeName, noticeList, currentCodeDesc, isUseHeaderComponent, nameFilter, search, indexOfFirstPost, indexOfLastPost, postPerPage, currentPage, router }) => {
10
+ const NoticeList = ({ noticeList, noticeName }) => {
11
+ const router = useRouter();
12
+ // 내부 상태 관리
13
+ const [search, setSearch] = useState('');
14
+ const [searchInput, setSearchInput] = useState('');
15
+ const [nameFilter, setNameFilter] = useState({
16
+ code_name: '전체',
17
+ code: ''
18
+ });
19
+ const [currentPage, setCurrentPage] = useState(1);
20
+ const [filteredList, setFilteredList] = useState(noticeList);
21
+ const [total, setTotal] = useState(noticeList.length);
22
+ const postPerPage = 10;
23
+ const indexOfLastPost = currentPage * postPerPage;
24
+ const indexOfFirstPost = indexOfLastPost - postPerPage;
25
+ // 검색 및 필터링 로직
26
+ useEffect(() => {
27
+ var _a;
28
+ const searchTxt = String(router.query.search || '').toLowerCase();
29
+ const searchFilter = String(router.query.nameFilter || '');
30
+ let searchResultList = [];
31
+ if (!searchFilter || searchFilter === '전체') {
32
+ searchResultList = noticeList === null || noticeList === void 0 ? void 0 : noticeList.filter((item) => { var _a, _b; return ((_a = item.title) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes(searchTxt)) || ((_b = item.summary) === null || _b === void 0 ? void 0 : _b.toLowerCase().includes(searchTxt)); });
33
+ setNameFilter({ code_name: '전체', code: '' });
34
+ }
35
+ else {
36
+ const filterNameList = noticeList.filter((item) => item.code_name === searchFilter);
37
+ searchResultList = filterNameList === null || filterNameList === void 0 ? void 0 : filterNameList.filter((item) => { var _a, _b; return ((_a = item.title) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes(searchTxt)) || ((_b = item.summary) === null || _b === void 0 ? void 0 : _b.toLowerCase().includes(searchTxt)); });
38
+ const code = ((_a = noticeName.find((name) => name.code_name === searchFilter)) === null || _a === void 0 ? void 0 : _a.code) || '';
39
+ setNameFilter({ code_name: searchFilter, code });
40
+ }
41
+ setFilteredList(searchResultList);
42
+ setTotal(searchResultList.length);
43
+ setSearch(searchTxt || '');
44
+ setSearchInput(searchTxt || '');
45
+ setCurrentPage(Number(router.query.page) || 1);
46
+ }, [router.query.search, router.query.nameFilter, router.query.page, noticeList, noticeName]);
47
+ // 핸들러 함수들
48
+ const handleInputChange = (e) => {
49
+ setSearchInput(e.currentTarget.value);
50
+ };
51
+ const handleSearch = () => {
52
+ router.push({
53
+ pathname: '/notice',
54
+ query: searchInput
55
+ ? { page: 1, search: searchInput, nameFilter: nameFilter.code_name }
56
+ : { page: 1, nameFilter: nameFilter.code_name }
57
+ });
58
+ setSearch(searchInput);
59
+ };
60
+ const handlePaginationChange = (pageNum) => {
61
+ router.push({
62
+ pathname: '/notice',
63
+ query: search
64
+ ? { page: pageNum, search: search, nameFilter: nameFilter.code_name }
65
+ : { page: pageNum, nameFilter: nameFilter.code_name }
66
+ });
67
+ };
68
+ const handleCategoryClick = (categoryName) => {
69
+ router.push({
70
+ pathname: '/notice',
71
+ query: search
72
+ ? { page: 1, search: search, nameFilter: categoryName }
73
+ : { page: 1, nameFilter: categoryName }
74
+ });
75
+ };
10
76
  return (<>
11
77
  <PageTitleBox titleTxt={'공지사항'} subTxt={<>
12
78
  법무법인(유한) 대륜의
@@ -14,46 +80,22 @@ const NoticeList = ({ SearchBarProps, PaginationProps, noticeName, noticeList, c
14
80
  다양한 새소식을 전달합니다
15
81
  </>} imgType={ImgTypes.NOTICE} isUseHeaderComponent/>
16
82
  <PageWrapper>
17
- <SearchBar label={'검색어를 입력해주세요.'} onChange={SearchBarProps.handleInputChange} onClick={SearchBarProps.handleSearch} search={SearchBarProps.searchInput} placeholder={'검색어를 입력해주세요.'} isKeyPress={true} marginTop={[70, 50, 50]}/>
83
+ <SearchBar label={'검색어를 입력해주세요.'} onChange={handleInputChange} onClick={handleSearch} search={searchInput} placeholder={'검색어를 입력해주세요.'} isKeyPress={true} marginTop={[70, 50, 50]}/>
18
84
  <div className={'mb-10 flex w-full cursor-pointer border-[1px] border-solid border-[#DBDBDB] text-center '}>
19
85
  <div tabIndex={0} className={`${nameFilter.code_name === '전체'
20
86
  ? 'bg-[#285FA7] text-[#fff]'
21
- : "after:absolute after:right-[-1px] after:z-[-1] after:h-[45%] after:w-[1px] after:bg-[#DBDBDB] after:content-['']"} relative w-[20%] py-3 text-[13px] 2xs:text-[16px] xs:py-4 sm:text-[22px]`} onClick={() => {
22
- router.push({
23
- pathname: '/notice',
24
- query: search
25
- ? { page: 1, search: search, nameFilter: '전체' }
26
- : { page: 1, nameFilter: '전체' }
27
- });
28
- }} onKeyDown={(e) => {
87
+ : "after:absolute after:right-[-1px] after:z-[-1] after:h-[45%] after:w-[1px] after:bg-[#DBDBDB] after:content-['']"} relative w-[20%] py-3 text-[13px] 2xs:text-[16px] xs:py-4 sm:text-[22px]`} onClick={() => handleCategoryClick('전체')} onKeyDown={(e) => {
29
88
  if (e.key === 'Enter') {
30
- router.push({
31
- pathname: '/notice',
32
- query: search
33
- ? { page: 1, search: search, nameFilter: '전체' }
34
- : { page: 1, nameFilter: '전체' }
35
- });
89
+ handleCategoryClick('전체');
36
90
  }
37
91
  }}>
38
92
  전체
39
93
  </div>
40
94
  {noticeName.map((item, index) => (<div tabIndex={0} key={index} className={`${nameFilter.code_name === item.code_name
41
95
  ? 'bg-[#285FA7] text-[#fff] '
42
- : "after:absolute after:right-[-1px] after:z-[-1] after:h-[45%] after:w-[1px] after:bg-[#DBDBDB] after:content-['']"} relative w-[20%] py-3 text-[13px] 2xs:text-[16px] xs:py-4 sm:text-[22px]`} onClick={() => {
43
- router.push({
44
- pathname: '/notice',
45
- query: search
46
- ? { page: 1, search: search, nameFilter: item.code_name }
47
- : { page: 1, nameFilter: item.code_name }
48
- });
49
- }} onKeyDown={(e) => {
96
+ : "after:absolute after:right-[-1px] after:z-[-1] after:h-[45%] after:w-[1px] after:bg-[#DBDBDB] after:content-['']"} relative w-[20%] py-3 text-[13px] 2xs:text-[16px] xs:py-4 sm:text-[22px]`} onClick={() => handleCategoryClick(item.code_name)} onKeyDown={(e) => {
50
97
  if (e.key === 'Enter') {
51
- router.push({
52
- pathname: '/notice',
53
- query: search
54
- ? { page: 1, search: search, nameFilter: item.code_name }
55
- : { page: 1, nameFilter: item.code_name }
56
- });
98
+ handleCategoryClick(item.code_name);
57
99
  }
58
100
  }}>
59
101
  {item.code_name}
@@ -64,7 +106,6 @@ const NoticeList = ({ SearchBarProps, PaginationProps, noticeName, noticeList, c
64
106
  <colgroup className={''}>
65
107
  <col className={'sm:w-[10%]'}/>
66
108
  <col width="55" className={'w-[75%] max-xs:w-[70%]'}/>
67
- {/* <col className={'w-[15%] max-xs:w-[20%]'} /> */}
68
109
  </colgroup>
69
110
 
70
111
  <thead>
@@ -75,40 +116,28 @@ const NoticeList = ({ SearchBarProps, PaginationProps, noticeName, noticeList, c
75
116
  <th scope="col" className={'border-b-[1px] border-solid border-[#d2d2d2] py-[15px] text-[16px] font-[800] max-sm:text-xs'}>
76
117
  제목
77
118
  </th>
78
- {/* <th
79
- scope="col"
80
- className={
81
- 'py-[15px] border-b-[1px] border-[#d2d2d2] border-solid text-[16px] font-[800] max-sm:text-xs'
82
- }
83
- >
84
- 작성일
85
- </th> */}
86
119
  </tr>
87
120
  </thead>
88
121
 
89
122
  <tbody>
90
- {noticeList.length > 0 && noticeList.slice(indexOfFirstPost, indexOfLastPost).length > 0 ? (noticeList.slice(indexOfFirstPost, indexOfLastPost).map((item, index) => (<tr key={item.id} className={''}>
91
- <td className={'border-b-[1px] border-solid border-[#d2d2d2] py-[15px] text-center sm:text-[16px]'}>
92
- {noticeList.length -
123
+ {filteredList.length > 0 &&
124
+ filteredList.slice(indexOfFirstPost, indexOfLastPost).length > 0 ? (filteredList
125
+ .slice(indexOfFirstPost, indexOfLastPost)
126
+ .map((item, index) => (<tr key={item.id} className={''}>
127
+ <td className={'border-b-[1px] border-solid border-[#d2d2d2] py-[15px] text-center sm:text-[16px]'}>
128
+ {filteredList.length -
93
129
  (index + 1 + currentPage * postPerPage) +
94
130
  postPerPage +
95
131
  1}
96
- </td>
97
- <td className={'border-b-[1px] border-solid border-[#d2d2d2] py-[15px] sm:text-[16px]'}>
98
- <Link href={'/notice/' + item.id}>
99
- <div>
100
- <div className={'truncate'}>{item.title}</div>
101
- </div>
102
- </Link>
103
- </td>
104
- {/* <td
105
- className={
106
- 'text-center py-[15px] border-b-[1px] border-[#d2d2d2] border-solid sm:text-[16px] tracking-[-1px]'
107
- }
108
- >
109
- {item.timestamp}
110
- </td> */}
111
- </tr>))) : noticeList.length < 1 ? (<tr>
132
+ </td>
133
+ <td className={'border-b-[1px] border-solid border-[#d2d2d2] py-[15px] sm:text-[16px]'}>
134
+ <Link href={'/notice/' + item.id}>
135
+ <div>
136
+ <div className={'truncate'}>{item.title}</div>
137
+ </div>
138
+ </Link>
139
+ </td>
140
+ </tr>))) : filteredList.length < 1 ? (<tr>
112
141
  <td colSpan={2} className={'border-b-[1px] border-[#d2d2d2] py-[15px] ' +
113
142
  'order-solid text-[16px] font-[400]'}>
114
143
  <div className={'text-center'}>
@@ -124,9 +153,7 @@ const NoticeList = ({ SearchBarProps, PaginationProps, noticeName, noticeList, c
124
153
  </tr>)}
125
154
  </tbody>
126
155
  </table>
127
- {noticeList && noticeList.length > 0 ? (<div className={'mb-[100px] max-lg:mb-[70px] max-xs:mb-[64px]'}>
128
- <Pagination currentPage={PaginationProps.currentPage} onPageChange={PaginationProps.onPaginationChange} totalPages={Math.ceil(PaginationProps.totalCount / 9)}/>
129
- </div>) : (<></>)}
156
+ <PaginationComponent pageSize={postPerPage} total={total} onChange={handlePaginationChange} current={currentPage}/>
130
157
  </div>
131
158
  </PageWrapper>
132
159
  </>);
@@ -4,6 +4,4 @@ declare const meta: Meta<typeof NoticeList>;
4
4
  export default meta;
5
5
  type Story = StoryObj<typeof meta>;
6
6
  export declare const Default: Story;
7
- export declare const WithSearch: Story;
8
- export declare const WithFilter: Story;
9
7
  export declare const EmptyList: Story;