@tipp/ui 1.3.2 → 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.
Files changed (79) hide show
  1. package/dist/atoms/field-error-wrapper.js +2 -2
  2. package/dist/atoms/index.cjs +0 -2
  3. package/dist/atoms/index.cjs.map +1 -1
  4. package/dist/atoms/index.js +33 -33
  5. package/dist/atoms/pagination.cjs +0 -2
  6. package/dist/atoms/pagination.cjs.map +1 -1
  7. package/dist/atoms/pagination.d.cts +2 -1
  8. package/dist/atoms/pagination.d.ts +2 -1
  9. package/dist/atoms/pagination.js +2 -2
  10. package/dist/chunk-62IB66PR.js +184 -0
  11. package/dist/chunk-62IB66PR.js.map +1 -0
  12. package/dist/chunk-7AFF4LYR.js +193 -0
  13. package/dist/chunk-7AFF4LYR.js.map +1 -0
  14. package/dist/chunk-7RLG3G7T.js +186 -0
  15. package/dist/chunk-7RLG3G7T.js.map +1 -0
  16. package/dist/chunk-AAMXDT5H.js +164 -0
  17. package/dist/chunk-AAMXDT5H.js.map +1 -0
  18. package/dist/chunk-CFZMZBKT.js +186 -0
  19. package/dist/chunk-CFZMZBKT.js.map +1 -0
  20. package/dist/chunk-FRIZG47J.js +186 -0
  21. package/dist/chunk-FRIZG47J.js.map +1 -0
  22. package/dist/chunk-FSGGYY2H.js +191 -0
  23. package/dist/chunk-FSGGYY2H.js.map +1 -0
  24. package/dist/chunk-G2WTBLEA.js +164 -0
  25. package/dist/chunk-G2WTBLEA.js.map +1 -0
  26. package/dist/chunk-GQ2UAYG2.js +193 -0
  27. package/dist/chunk-GQ2UAYG2.js.map +1 -0
  28. package/dist/chunk-MNIMT6IW.js +186 -0
  29. package/dist/chunk-MNIMT6IW.js.map +1 -0
  30. package/dist/chunk-N2FQDKJE.js +169 -0
  31. package/dist/chunk-N2FQDKJE.js.map +1 -0
  32. package/dist/chunk-N62PCPTB.js +164 -0
  33. package/dist/chunk-N62PCPTB.js.map +1 -0
  34. package/dist/chunk-N6LVZDYO.js +188 -0
  35. package/dist/chunk-N6LVZDYO.js.map +1 -0
  36. package/dist/chunk-NLTCJLYN.js +183 -0
  37. package/dist/chunk-NLTCJLYN.js.map +1 -0
  38. package/dist/chunk-PEPRIOFR.js +191 -0
  39. package/dist/chunk-PEPRIOFR.js.map +1 -0
  40. package/dist/chunk-SHKCVWJI.js +191 -0
  41. package/dist/chunk-SHKCVWJI.js.map +1 -0
  42. package/dist/chunk-TNPXDOME.js +340 -0
  43. package/dist/chunk-TNPXDOME.js.map +1 -0
  44. package/dist/chunk-UU4VN75U.js +185 -0
  45. package/dist/chunk-UU4VN75U.js.map +1 -0
  46. package/dist/chunk-VZ2XRNJY.js +191 -0
  47. package/dist/chunk-VZ2XRNJY.js.map +1 -0
  48. package/dist/chunk-WVYT25TW.js +185 -0
  49. package/dist/chunk-WVYT25TW.js.map +1 -0
  50. package/dist/chunk-XGPMAJED.js +164 -0
  51. package/dist/chunk-XGPMAJED.js.map +1 -0
  52. package/dist/chunk-YQJGVOUT.js +188 -0
  53. package/dist/chunk-YQJGVOUT.js.map +1 -0
  54. package/dist/chunk-ZWNOY7LD.js +192 -0
  55. package/dist/chunk-ZWNOY7LD.js.map +1 -0
  56. package/dist/chunk-ZXLMP5PK.js +185 -0
  57. package/dist/chunk-ZXLMP5PK.js.map +1 -0
  58. package/dist/index.cjs +78 -22
  59. package/dist/index.cjs.map +1 -1
  60. package/dist/index.css +2 -0
  61. package/dist/index.css.map +1 -1
  62. package/dist/index.js +65 -65
  63. package/dist/molecules/date-picker/index.js +2 -2
  64. package/dist/molecules/expand-table/index.cjs +226 -53
  65. package/dist/molecules/expand-table/index.cjs.map +1 -1
  66. package/dist/molecules/expand-table/index.d.cts +9 -0
  67. package/dist/molecules/expand-table/index.d.ts +9 -0
  68. package/dist/molecules/expand-table/index.js +18 -18
  69. package/dist/molecules/expand-table/row.js +15 -15
  70. package/dist/molecules/index.cjs +348 -181
  71. package/dist/molecules/index.cjs.map +1 -1
  72. package/dist/molecules/index.js +23 -23
  73. package/dist/molecules/learning-post.js +4 -4
  74. package/dist/molecules/navigation.js +16 -16
  75. package/dist/molecules/stepper.js +3 -3
  76. package/dist/molecules/tag-selector.js +16 -16
  77. package/package.json +3 -3
  78. package/src/atoms/pagination.tsx +2 -3
  79. package/src/molecules/expand-table/index.tsx +106 -31
@@ -1,63 +1,63 @@
1
1
  import {
2
2
  TagSelector
3
- } from "../chunk-MKYNSWMI.js";
3
+ } from "../chunk-P7633BEQ.js";
4
4
  import "../chunk-76JGDATZ.js";
5
+ import "../chunk-FR2GDOU2.js";
6
+ import "../chunk-74DX4CU7.js";
5
7
  import "../chunk-OYM4XCHQ.js";
6
8
  import "../chunk-YJ7ZFOYL.js";
7
9
  import "../chunk-5ZITU5L7.js";
8
10
  import "../chunk-ILRUXI2E.js";
9
11
  import "../chunk-JPIZP2PZ.js";
10
12
  import "../chunk-CYYWMYE7.js";
13
+ import "../chunk-6DJOIRMF.js";
14
+ import "../chunk-FPD73OHW.js";
11
15
  import "../chunk-ZKZDVS7G.js";
12
16
  import "../chunk-MUNMDHRF.js";
13
17
  import "../chunk-TVDKGMBI.js";
14
18
  import "../chunk-3JRNKBMN.js";
15
19
  import "../chunk-HYITAA4J.js";
16
20
  import "../chunk-5H3YPCZK.js";
17
- import "../chunk-FR2GDOU2.js";
18
- import "../chunk-74DX4CU7.js";
21
+ import "../chunk-XQOL7UBI.js";
22
+ import "../chunk-TULWX7D6.js";
19
23
  import "../chunk-SIM6HKVI.js";
20
- import "../chunk-RJMSUTBQ.js";
24
+ import "../chunk-5X3BCQPR.js";
21
25
  import "../chunk-5AVBYDPB.js";
22
26
  import "../chunk-365QMK4D.js";
23
27
  import "../chunk-YO3BQW6S.js";
24
28
  import "../chunk-6IVCARWS.js";
25
- import "../chunk-6DJOIRMF.js";
26
- import "../chunk-FPD73OHW.js";
29
+ import "../chunk-DJN2IEY6.js";
30
+ import "../chunk-25HMMI7R.js";
27
31
  import "../chunk-2CVXGGI5.js";
28
32
  import "../chunk-EGEQY3KT.js";
29
33
  import "../chunk-HK224ADT.js";
30
34
  import "../chunk-O3T3TM3V.js";
31
35
  import "../chunk-O3DNDMV3.js";
32
- import "../chunk-XQOL7UBI.js";
33
- import "../chunk-TULWX7D6.js";
36
+ import "../chunk-LZJR77Q2.js";
37
+ import "../chunk-Q37G2GS6.js";
34
38
  import "../chunk-VTJZMOSP.js";
35
39
  import "../chunk-6AJTMXLJ.js";
36
40
  import "../chunk-HJQQMAUB.js";
37
41
  import "../chunk-4WFMOFN2.js";
38
42
  import "../chunk-WKFZ5MMN.js";
39
43
  import "../chunk-ACVANQJ4.js";
40
- import "../chunk-2DZ2Y3JI.js";
41
- import "../chunk-QDZS4B6A.js";
42
44
  import "../chunk-52MVZ6AN.js";
43
- import "../chunk-25HMMI7R.js";
45
+ import "../chunk-2DZ2Y3JI.js";
46
+ import "../chunk-4Y5BEXVN.js";
47
+ import "../chunk-P3YCIJUP.js";
44
48
  import "../chunk-B6XJN6EC.js";
45
49
  import "../chunk-UVKNLJDZ.js";
46
50
  import "../chunk-MIMJ7LON.js";
47
51
  import "../chunk-IQEEPHOY.js";
48
52
  import "../chunk-LHCDPZ5E.js";
49
53
  import "../chunk-OHMOP5PV.js";
50
- import "../chunk-LZJR77Q2.js";
51
- import "../chunk-Q37G2GS6.js";
54
+ import "../chunk-66C4U3BG.js";
52
55
  import "../chunk-J242TTFH.js";
53
56
  import "../chunk-EAXUQEO5.js";
54
57
  import "../chunk-YJCCE5WP.js";
55
58
  import "../chunk-3SSSCLJ5.js";
56
59
  import "../chunk-EWD4AO5N.js";
57
60
  import "../chunk-YGL6SWKN.js";
58
- import "../chunk-4Y5BEXVN.js";
59
- import "../chunk-P3YCIJUP.js";
60
- import "../chunk-66C4U3BG.js";
61
61
  import "../chunk-N552FDTV.js";
62
62
  export {
63
63
  TagSelector
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tipp/ui",
3
- "version": "1.3.2",
3
+ "version": "1.4.0",
4
4
  "private": false,
5
5
  "sideEffects": false,
6
6
  "type": "module",
@@ -54,8 +54,8 @@
54
54
  "postcss-nesting": "12.0.2",
55
55
  "tsup": "^8.0.2",
56
56
  "typescript": "^5.3.3",
57
- "@tipp/typescript-config": "1.0.0",
58
- "@tipp/eslint-config": "1.0.0"
57
+ "@tipp/eslint-config": "1.0.0",
58
+ "@tipp/typescript-config": "1.0.0"
59
59
  },
60
60
  "scripts": {
61
61
  "build": "pnpm run build:js && pnpm run build:css",
@@ -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 { data, columns, ExpandComp, placeholder, onRowClick, tableStyle } =
43
- props;
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 === 0 && (
127
- <div className="tr" key="expand_placeholder">
128
- <Flex align="center" justify="center">
129
- {placeholder || (
130
- <Typo color="gray" mb="6" mt="6" variant="body">
131
- 데이터가 없습니다
132
- </Typo>
133
- )}
134
- </Flex>
135
- </div>
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
  }