@tipp/ui 1.3.1 → 1.4.0
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/atoms/index.cjs +0 -2
- package/dist/atoms/index.cjs.map +1 -1
- package/dist/atoms/index.js +1 -1
- package/dist/atoms/pagination.cjs +0 -2
- package/dist/atoms/pagination.cjs.map +1 -1
- package/dist/atoms/pagination.d.cts +2 -1
- package/dist/atoms/pagination.d.ts +2 -1
- package/dist/atoms/pagination.js +1 -1
- package/dist/chunk-62IB66PR.js +184 -0
- package/dist/chunk-62IB66PR.js.map +1 -0
- package/dist/chunk-7AFF4LYR.js +193 -0
- package/dist/chunk-7AFF4LYR.js.map +1 -0
- package/dist/chunk-7RLG3G7T.js +186 -0
- package/dist/chunk-7RLG3G7T.js.map +1 -0
- package/dist/chunk-AAMXDT5H.js +164 -0
- package/dist/chunk-AAMXDT5H.js.map +1 -0
- package/dist/chunk-CFZMZBKT.js +186 -0
- package/dist/chunk-CFZMZBKT.js.map +1 -0
- package/dist/chunk-FRIZG47J.js +186 -0
- package/dist/chunk-FRIZG47J.js.map +1 -0
- package/dist/chunk-FSGGYY2H.js +191 -0
- package/dist/chunk-FSGGYY2H.js.map +1 -0
- package/dist/chunk-G2WTBLEA.js +164 -0
- package/dist/chunk-G2WTBLEA.js.map +1 -0
- package/dist/chunk-GQ2UAYG2.js +193 -0
- package/dist/chunk-GQ2UAYG2.js.map +1 -0
- package/dist/chunk-GTRSAGDQ.js +164 -0
- package/dist/chunk-GTRSAGDQ.js.map +1 -0
- package/dist/chunk-MNIMT6IW.js +186 -0
- package/dist/chunk-MNIMT6IW.js.map +1 -0
- package/dist/chunk-N2FQDKJE.js +169 -0
- package/dist/chunk-N2FQDKJE.js.map +1 -0
- package/dist/chunk-N62PCPTB.js +164 -0
- package/dist/chunk-N62PCPTB.js.map +1 -0
- package/dist/chunk-N6LVZDYO.js +188 -0
- package/dist/chunk-N6LVZDYO.js.map +1 -0
- package/dist/chunk-NLTCJLYN.js +183 -0
- package/dist/chunk-NLTCJLYN.js.map +1 -0
- package/dist/chunk-PEPRIOFR.js +191 -0
- package/dist/chunk-PEPRIOFR.js.map +1 -0
- package/dist/chunk-SHKCVWJI.js +191 -0
- package/dist/chunk-SHKCVWJI.js.map +1 -0
- package/dist/chunk-TNPXDOME.js +340 -0
- package/dist/chunk-TNPXDOME.js.map +1 -0
- package/dist/chunk-UU4VN75U.js +185 -0
- package/dist/chunk-UU4VN75U.js.map +1 -0
- package/dist/chunk-VZ2XRNJY.js +191 -0
- package/dist/chunk-VZ2XRNJY.js.map +1 -0
- package/dist/chunk-WVYT25TW.js +185 -0
- package/dist/chunk-WVYT25TW.js.map +1 -0
- package/dist/chunk-XGPMAJED.js +164 -0
- package/dist/chunk-XGPMAJED.js.map +1 -0
- package/dist/chunk-YQJGVOUT.js +188 -0
- package/dist/chunk-YQJGVOUT.js.map +1 -0
- package/dist/chunk-ZWNOY7LD.js +192 -0
- package/dist/chunk-ZWNOY7LD.js.map +1 -0
- package/dist/chunk-ZXLMP5PK.js +185 -0
- package/dist/chunk-ZXLMP5PK.js.map +1 -0
- package/dist/index.cjs +78 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +2 -0
- package/dist/index.css.map +1 -1
- package/dist/index.js +21 -21
- package/dist/molecules/expand-table/index.cjs +226 -53
- package/dist/molecules/expand-table/index.cjs.map +1 -1
- package/dist/molecules/expand-table/index.d.cts +9 -0
- package/dist/molecules/expand-table/index.d.ts +9 -0
- package/dist/molecules/expand-table/index.js +2 -2
- package/dist/molecules/expand-table/row.js +1 -1
- package/dist/molecules/index.cjs +348 -181
- package/dist/molecules/index.cjs.map +1 -1
- package/dist/molecules/index.js +9 -9
- package/dist/molecules/learning-post.cjs.map +1 -1
- package/dist/molecules/learning-post.d.cts +1 -1
- package/dist/molecules/learning-post.d.ts +1 -1
- package/dist/molecules/learning-post.js +1 -1
- package/dist/molecules/navigation.js +1 -1
- package/dist/molecules/tag-selector.js +1 -1
- package/dist/utils/index.js +3 -3
- package/package.json +3 -3
- package/src/atoms/pagination.tsx +2 -3
- package/src/molecules/expand-table/index.tsx +106 -31
- package/src/molecules/learning-post.tsx +1 -1
package/src/atoms/pagination.tsx
CHANGED
|
@@ -11,7 +11,7 @@ import { Flex } from './flex';
|
|
|
11
11
|
import { Typo } from './typo';
|
|
12
12
|
|
|
13
13
|
export interface PaginationProps {
|
|
14
|
-
/** 현재 선택된
|
|
14
|
+
/** 현재 선택된 페이지, 1부터 시작 */
|
|
15
15
|
page?: number;
|
|
16
16
|
/** 기본 선택 페이지, page보다 낮은 우선 순위를 갖는다 */
|
|
17
17
|
defaultPage?: number;
|
|
@@ -19,6 +19,7 @@ export interface PaginationProps {
|
|
|
19
19
|
onChange?: (page: number) => void;
|
|
20
20
|
/** 전체 페이지의 수 */
|
|
21
21
|
count?: number;
|
|
22
|
+
/** 표시할 페이지 버튼의 개수 */
|
|
22
23
|
siblingCount?: number;
|
|
23
24
|
}
|
|
24
25
|
|
|
@@ -98,8 +99,6 @@ export function Pagination(props: PaginationProps): React.ReactNode {
|
|
|
98
99
|
style: { borderRadius: '50%' },
|
|
99
100
|
};
|
|
100
101
|
|
|
101
|
-
if (!page) return null;
|
|
102
|
-
|
|
103
102
|
return (
|
|
104
103
|
<Flex align="center" className="tipp-pagination" gap="4">
|
|
105
104
|
<IconButton
|
|
@@ -3,6 +3,7 @@ import type {
|
|
|
3
3
|
SortingState,
|
|
4
4
|
RowData,
|
|
5
5
|
Row as RowType,
|
|
6
|
+
PaginationState,
|
|
6
7
|
} from '@tanstack/react-table';
|
|
7
8
|
import type { CSSProperties } from 'react';
|
|
8
9
|
import {
|
|
@@ -11,9 +12,10 @@ import {
|
|
|
11
12
|
useReactTable,
|
|
12
13
|
getSortedRowModel,
|
|
13
14
|
createColumnHelper,
|
|
15
|
+
getPaginationRowModel,
|
|
14
16
|
} from '@tanstack/react-table';
|
|
15
|
-
import React, { useMemo, useState } from 'react';
|
|
16
|
-
import { Flex, Typo } from '../../atoms';
|
|
17
|
+
import React, { useCallback, useMemo, useState } from 'react';
|
|
18
|
+
import { Flex, Pagination, Spinner, Typo } from '../../atoms';
|
|
17
19
|
import { TriangleArrowDownIcon } from '../../icons/down';
|
|
18
20
|
import { TriangleArrowUpIcon } from '../../icons/up';
|
|
19
21
|
import { Row, type ExpandComp, type OnRowClick } from './row';
|
|
@@ -34,24 +36,53 @@ export interface ExpandTableProps<Datum extends RowData> {
|
|
|
34
36
|
onRowClick?: OnRowClick<Datum>;
|
|
35
37
|
rowStyle?: CSSProperties;
|
|
36
38
|
tableStyle?: CSSProperties;
|
|
39
|
+
isLoading?: boolean;
|
|
40
|
+
|
|
41
|
+
/** pagination - 표시 유무 */
|
|
42
|
+
showPagination?: boolean;
|
|
43
|
+
/** pagination - 현재 선택된 페이지, 0부터 시작 */
|
|
44
|
+
pageIndex?: number;
|
|
45
|
+
/** pagination - 한 페이지에 표시될 컬럼 개수 */
|
|
46
|
+
pageSize?: number;
|
|
47
|
+
/** pagination - */
|
|
48
|
+
siblingCount?: number;
|
|
37
49
|
}
|
|
38
50
|
|
|
39
51
|
export function ExpandTable<Datum extends RowData>(
|
|
40
52
|
props: ExpandTableProps<Datum>
|
|
41
53
|
): React.ReactNode {
|
|
42
|
-
const {
|
|
43
|
-
|
|
54
|
+
const {
|
|
55
|
+
data,
|
|
56
|
+
columns,
|
|
57
|
+
ExpandComp,
|
|
58
|
+
placeholder,
|
|
59
|
+
onRowClick,
|
|
60
|
+
tableStyle,
|
|
61
|
+
showPagination,
|
|
62
|
+
isLoading,
|
|
63
|
+
pageIndex = 0,
|
|
64
|
+
pageSize = 10,
|
|
65
|
+
siblingCount = 2,
|
|
66
|
+
} = props;
|
|
44
67
|
const defaultAlign = 'left';
|
|
68
|
+
const [pagination, setPagination] = useState<PaginationState>({
|
|
69
|
+
pageIndex: pageIndex || 0,
|
|
70
|
+
pageSize: pageSize || 9999,
|
|
71
|
+
});
|
|
72
|
+
|
|
45
73
|
const [sorting, setSorting] = useState<SortingState>([]);
|
|
46
|
-
const { getRowModel, getHeaderGroups } = useReactTable({
|
|
74
|
+
const { getRowModel, getHeaderGroups, setPageIndex } = useReactTable({
|
|
47
75
|
data: data || [],
|
|
48
76
|
columns,
|
|
49
77
|
getCoreRowModel: getCoreRowModel(),
|
|
50
78
|
getSortedRowModel: getSortedRowModel(),
|
|
51
79
|
state: {
|
|
52
80
|
sorting,
|
|
81
|
+
pagination,
|
|
53
82
|
},
|
|
54
83
|
onSortingChange: setSorting,
|
|
84
|
+
getPaginationRowModel: getPaginationRowModel(),
|
|
85
|
+
onPaginationChange: setPagination,
|
|
55
86
|
});
|
|
56
87
|
|
|
57
88
|
const gridColTemp = useMemo<string>(() => {
|
|
@@ -65,6 +96,51 @@ export function ExpandTable<Datum extends RowData>(
|
|
|
65
96
|
|
|
66
97
|
const rowModels = getRowModel();
|
|
67
98
|
|
|
99
|
+
const onChangePagination = useCallback(
|
|
100
|
+
(page: number) => {
|
|
101
|
+
setPageIndex(page - 1);
|
|
102
|
+
},
|
|
103
|
+
[setPageIndex]
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
const helpCompRender = useCallback(
|
|
107
|
+
(rowLength: number) => {
|
|
108
|
+
if (isLoading) {
|
|
109
|
+
return (
|
|
110
|
+
<Flex
|
|
111
|
+
align="center"
|
|
112
|
+
height="100%"
|
|
113
|
+
justify="center"
|
|
114
|
+
p="5"
|
|
115
|
+
width="100%"
|
|
116
|
+
>
|
|
117
|
+
<Spinner />
|
|
118
|
+
</Flex>
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
if (rowLength === 0) {
|
|
122
|
+
return (
|
|
123
|
+
<div className="tr" key="expand_placeholder">
|
|
124
|
+
<Flex align="center" justify="center">
|
|
125
|
+
{placeholder || (
|
|
126
|
+
<Typo color="gray" mb="6" mt="6" variant="body">
|
|
127
|
+
데이터가 없습니다
|
|
128
|
+
</Typo>
|
|
129
|
+
)}
|
|
130
|
+
</Flex>
|
|
131
|
+
</div>
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
return null;
|
|
135
|
+
},
|
|
136
|
+
[isLoading, placeholder]
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
const pageCount = useMemo(() => {
|
|
140
|
+
if (!data) return 0;
|
|
141
|
+
return Math.ceil(data.length / pageSize);
|
|
142
|
+
}, [data, pageSize]);
|
|
143
|
+
|
|
68
144
|
return (
|
|
69
145
|
<div className="expand-table" style={tableStyle}>
|
|
70
146
|
<div className="thead">
|
|
@@ -122,33 +198,32 @@ export function ExpandTable<Datum extends RowData>(
|
|
|
122
198
|
))}
|
|
123
199
|
</div>
|
|
124
200
|
<div className="tbody">
|
|
125
|
-
{/*
|
|
126
|
-
{rowModels.rows.length
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
{rowModels.rows.map((row) => {
|
|
140
|
-
return (
|
|
141
|
-
<Row
|
|
142
|
-
ExpandComp={ExpandComp}
|
|
143
|
-
defaultAlign={defaultAlign}
|
|
144
|
-
gridColTemp={gridColTemp}
|
|
145
|
-
key={`row_${row.id}`}
|
|
146
|
-
onRowClick={onRowClick}
|
|
147
|
-
row={row}
|
|
148
|
-
/>
|
|
149
|
-
);
|
|
150
|
-
})}
|
|
201
|
+
{/* 조건에 따라 placeholder 또는 loading 렌더*/}
|
|
202
|
+
{helpCompRender(rowModels.rows.length) ||
|
|
203
|
+
rowModels.rows.map((row) => {
|
|
204
|
+
return (
|
|
205
|
+
<Row
|
|
206
|
+
ExpandComp={ExpandComp}
|
|
207
|
+
defaultAlign={defaultAlign}
|
|
208
|
+
gridColTemp={gridColTemp}
|
|
209
|
+
key={`row_${row.id}`}
|
|
210
|
+
onRowClick={onRowClick}
|
|
211
|
+
row={row}
|
|
212
|
+
/>
|
|
213
|
+
);
|
|
214
|
+
})}
|
|
151
215
|
</div>
|
|
216
|
+
|
|
217
|
+
{showPagination ? (
|
|
218
|
+
<Flex justify="end" pt="3" width="100%">
|
|
219
|
+
<Pagination
|
|
220
|
+
count={pageCount}
|
|
221
|
+
onChange={onChangePagination}
|
|
222
|
+
page={pagination.pageIndex + 1}
|
|
223
|
+
siblingCount={siblingCount}
|
|
224
|
+
/>
|
|
225
|
+
</Flex>
|
|
226
|
+
) : null}
|
|
152
227
|
</div>
|
|
153
228
|
);
|
|
154
229
|
}
|
|
@@ -26,7 +26,7 @@ export interface LearningPostProps {
|
|
|
26
26
|
onPageBack?: () => void;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
export function LearningPost(props: LearningPostProps): React.
|
|
29
|
+
export function LearningPost(props: LearningPostProps): React.ReactElement {
|
|
30
30
|
const {
|
|
31
31
|
defaultThemeProps,
|
|
32
32
|
html,
|