@tipp/ui 2.3.10 → 2.3.11
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/app/index.cjs +4 -3
- package/dist/app/index.cjs.map +1 -1
- package/dist/app/index.js +85 -85
- package/dist/app/platform/coach-question-list.js +31 -31
- package/dist/app/platform/contents-card.js +31 -31
- package/dist/app/platform/curriculum-card.js +5 -5
- package/dist/app/platform/edit-coaching-time.cjs +4 -3
- package/dist/app/platform/edit-coaching-time.cjs.map +1 -1
- package/dist/app/platform/edit-coaching-time.js +69 -69
- package/dist/app/platform/edit-service-type.cjs +4 -3
- package/dist/app/platform/edit-service-type.cjs.map +1 -1
- package/dist/app/platform/edit-service-type.js +70 -70
- package/dist/app/platform/goal-manage-card-edit.cjs +4 -3
- package/dist/app/platform/goal-manage-card-edit.cjs.map +1 -1
- package/dist/app/platform/goal-manage-card-edit.js +69 -69
- package/dist/app/platform/goal-manage-card-read.js +31 -31
- package/dist/app/platform/on-offline-radio-card.cjs +77 -76
- package/dist/app/platform/on-offline-radio-card.cjs.map +1 -1
- package/dist/app/platform/on-offline-radio-card.js +69 -69
- package/dist/app/platform/report-card.js +31 -31
- package/dist/app/platform/reservation-card.cjs +4 -3
- package/dist/app/platform/reservation-card.cjs.map +1 -1
- package/dist/app/platform/reservation-card.js +70 -70
- package/dist/app/platform/session-card.cjs +4 -3
- package/dist/app/platform/session-card.cjs.map +1 -1
- package/dist/app/platform/session-card.js +72 -72
- package/dist/app/platform/session-review-simple-read.js +31 -31
- package/dist/app/platform/userInfos/coaching-customer-info/index.js +34 -34
- package/dist/app/platform/userInfos/coaching-customer-info/large.js +31 -31
- package/dist/app/platform/userInfos/coaching-customer-info/medium.js +31 -31
- package/dist/app/platform/userInfos/coaching-customer-info/small.js +31 -31
- package/dist/app/platform/userInfos/session-user-info-detail.js +31 -31
- package/dist/app/platform/userInfos/utils.js +30 -30
- package/dist/atoms/bullet-text.js +2 -2
- package/dist/atoms/dialog.js +2 -2
- package/dist/atoms/field-error-wrapper.js +2 -2
- package/dist/atoms/index.js +62 -62
- package/dist/atoms/list.js +2 -2
- package/dist/atoms/pagination.js +3 -3
- package/dist/chunk-HHZ4HLP6.js +221 -0
- package/dist/chunk-HHZ4HLP6.js.map +1 -0
- package/dist/chunk-NMRNR5OA.js +221 -0
- package/dist/chunk-NMRNR5OA.js.map +1 -0
- package/dist/chunk-QMPSKZJ2.js +221 -0
- package/dist/chunk-QMPSKZJ2.js.map +1 -0
- package/dist/chunk-WGQGVPGZ.js +222 -0
- package/dist/chunk-WGQGVPGZ.js.map +1 -0
- package/dist/chunk-YEGT662X.js +221 -0
- package/dist/chunk-YEGT662X.js.map +1 -0
- package/dist/chunk-ZBZ7IGBT.js +222 -0
- package/dist/chunk-ZBZ7IGBT.js.map +1 -0
- package/dist/context/index.js +5 -5
- package/dist/index.cjs +12 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +13 -9
- package/dist/index.js +127 -127
- package/dist/molecules/curriculumV2/CurriculumContents/CurriculumReviewSteps/ReviewQuestion/index.js +18 -18
- package/dist/molecules/curriculumV2/CurriculumContents/CurriculumReviewSteps/ReviewQuestion/review-comp.js +4 -4
- package/dist/molecules/curriculumV2/CurriculumContents/CurriculumReviewSteps/ReviewQuestion/review-question-body.js +11 -11
- package/dist/molecules/curriculumV2/CurriculumContents/CurriculumReviewSteps/ReviewQuestion/review-question-footer.js +2 -2
- package/dist/molecules/curriculumV2/CurriculumContents/CurriculumReviewSteps/ReviewQuestion/review-question-header.js +3 -3
- package/dist/molecules/curriculumV2/CurriculumContents/CurriculumReviewSteps/ReviewQuestion/review-question-layout.js +2 -2
- package/dist/molecules/curriculumV2/CurriculumContents/CurriculumReviewSteps/ReviewQuestion/review-question-radio.js +6 -6
- package/dist/molecules/curriculumV2/CurriculumContents/CurriculumReviewSteps/ReviewQuestion/review-question-satisfaction-option.js +5 -5
- package/dist/molecules/curriculumV2/CurriculumContents/CurriculumReviewSteps/ReviewQuestion/review-question-satisfaction-text.js +5 -5
- package/dist/molecules/curriculumV2/CurriculumContents/CurriculumReviewSteps/ReviewQuestion/review-question-text.js +5 -5
- package/dist/molecules/curriculumV2/CurriculumContents/CurriculumReviewSteps/complete-review.js +4 -4
- package/dist/molecules/curriculumV2/CurriculumContents/CurriculumReviewSteps/index.js +21 -21
- package/dist/molecules/curriculumV2/CurriculumContents/CurriculumReviewSteps/start-review.js +6 -6
- package/dist/molecules/curriculumV2/CurriculumContents/curriculum-ai-traning.js +3 -3
- package/dist/molecules/curriculumV2/CurriculumContents/curriculum-review.js +23 -23
- package/dist/molecules/curriculumV2/CurriculumContents/index.js +26 -26
- package/dist/molecules/curriculumV2/CurriculumSidebar/Items/curriculum-item-title.js +2 -2
- package/dist/molecules/curriculumV2/CurriculumSidebar/Items/section-item.js +4 -4
- package/dist/molecules/curriculumV2/CurriculumSidebar/index.js +7 -7
- package/dist/molecules/curriculumV2/CurriculumSidebar/sidebar-item.js +5 -5
- package/dist/molecules/curriculumV2/curriculum-sub-nav.js +4 -4
- package/dist/molecules/curriculumV2/curriculum-v2-layout.js +2 -2
- package/dist/molecules/curriculumV2/index.js +33 -33
- package/dist/molecules/date-picker/date-picker-button.js +6 -6
- package/dist/molecules/date-picker/index.js +5 -5
- package/dist/molecules/download-card.js +2 -2
- package/dist/molecules/dynamic-field.js +5 -5
- package/dist/molecules/dynamic-form.js +6 -6
- package/dist/molecules/expand-table/index.cjs +4 -3
- package/dist/molecules/expand-table/index.cjs.map +1 -1
- package/dist/molecules/expand-table/index.js +5 -5
- package/dist/molecules/force-refresh.js +2 -2
- package/dist/molecules/ghost-post.js +4 -4
- package/dist/molecules/index.cjs +141 -140
- package/dist/molecules/index.cjs.map +1 -1
- package/dist/molecules/index.js +61 -61
- package/dist/molecules/learning-post.js +6 -6
- package/dist/molecules/navigation.js +3 -3
- package/dist/molecules/one-on-one-guide-list.js +3 -3
- package/dist/molecules/stepper.js +4 -4
- package/dist/molecules/tag-selector.js +5 -5
- package/package.json +1 -1
- package/src/molecules/expand-table/index.tsx +13 -12
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Row
|
|
3
|
+
} from "./chunk-JCG2AUFJ.js";
|
|
4
|
+
import {
|
|
5
|
+
Spinner
|
|
6
|
+
} from "./chunk-FR2GDOU2.js";
|
|
7
|
+
import {
|
|
8
|
+
Pagination
|
|
9
|
+
} from "./chunk-FG3WT6OL.js";
|
|
10
|
+
import {
|
|
11
|
+
Typo
|
|
12
|
+
} from "./chunk-PMJIFLDT.js";
|
|
13
|
+
import {
|
|
14
|
+
Flex
|
|
15
|
+
} from "./chunk-25HMMI7R.js";
|
|
16
|
+
import {
|
|
17
|
+
TriangleArrowUpIcon
|
|
18
|
+
} from "./chunk-2O45FRFQ.js";
|
|
19
|
+
import {
|
|
20
|
+
TriangleArrowDownIcon
|
|
21
|
+
} from "./chunk-776WBOKL.js";
|
|
22
|
+
|
|
23
|
+
// src/molecules/expand-table/index.tsx
|
|
24
|
+
import {
|
|
25
|
+
flexRender,
|
|
26
|
+
getCoreRowModel,
|
|
27
|
+
useReactTable,
|
|
28
|
+
getSortedRowModel,
|
|
29
|
+
createColumnHelper,
|
|
30
|
+
getPaginationRowModel
|
|
31
|
+
} from "@tanstack/react-table";
|
|
32
|
+
import { useCallback, useMemo, useState } from "react";
|
|
33
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
34
|
+
var sortButtonColorMapper = {
|
|
35
|
+
card: {
|
|
36
|
+
selected: "var(--iris-10)",
|
|
37
|
+
unselected: "var(--iris-6)"
|
|
38
|
+
},
|
|
39
|
+
sprite: {
|
|
40
|
+
// selected: 'var(--gray-a12)',
|
|
41
|
+
// unselected: 'var(--gray-a6)',
|
|
42
|
+
selected: "var(--iris-10)",
|
|
43
|
+
unselected: "var(--iris-6)"
|
|
44
|
+
},
|
|
45
|
+
"sprite-border": {
|
|
46
|
+
selected: "var(--iris-10)",
|
|
47
|
+
unselected: "var(--iris-6)"
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
function ExpandTable(props) {
|
|
51
|
+
const {
|
|
52
|
+
data,
|
|
53
|
+
columns,
|
|
54
|
+
ExpandComp,
|
|
55
|
+
placeholder,
|
|
56
|
+
onRowClick,
|
|
57
|
+
tableStyle,
|
|
58
|
+
showPagination = true,
|
|
59
|
+
isLoading,
|
|
60
|
+
pageIndex = 0,
|
|
61
|
+
pageSize = 10,
|
|
62
|
+
siblingCount = 2,
|
|
63
|
+
getRowStyle,
|
|
64
|
+
getCellStyle,
|
|
65
|
+
variant = "card"
|
|
66
|
+
} = props;
|
|
67
|
+
const defaultAlign = "left";
|
|
68
|
+
const [pagination, setPagination] = useState({
|
|
69
|
+
pageIndex: pageIndex || 0,
|
|
70
|
+
pageSize: pageSize || 9999
|
|
71
|
+
});
|
|
72
|
+
const [sorting, setSorting] = useState([]);
|
|
73
|
+
const { getRowModel, getHeaderGroups, setPageIndex } = useReactTable({
|
|
74
|
+
data: data || [],
|
|
75
|
+
columns,
|
|
76
|
+
getCoreRowModel: getCoreRowModel(),
|
|
77
|
+
getSortedRowModel: getSortedRowModel(),
|
|
78
|
+
state: {
|
|
79
|
+
sorting,
|
|
80
|
+
pagination
|
|
81
|
+
},
|
|
82
|
+
onSortingChange: setSorting,
|
|
83
|
+
getPaginationRowModel: getPaginationRowModel(),
|
|
84
|
+
onPaginationChange: setPagination
|
|
85
|
+
});
|
|
86
|
+
const gridTemplateColumns = useMemo(() => {
|
|
87
|
+
return columns.map((col) => {
|
|
88
|
+
var _a;
|
|
89
|
+
if ((_a = col.meta) == null ? void 0 : _a.autoSize) return `minmax(${col.size || 50}px, 1fr)`;
|
|
90
|
+
return `${col.size || 150}px`;
|
|
91
|
+
}).join(" ");
|
|
92
|
+
}, [columns]);
|
|
93
|
+
const rowModels = getRowModel();
|
|
94
|
+
const onChangePagination = useCallback(
|
|
95
|
+
(page) => {
|
|
96
|
+
setPageIndex(page - 1);
|
|
97
|
+
},
|
|
98
|
+
[setPageIndex]
|
|
99
|
+
);
|
|
100
|
+
const helpCompRender = useCallback(
|
|
101
|
+
(rowLength) => {
|
|
102
|
+
if (isLoading) {
|
|
103
|
+
return /* @__PURE__ */ jsx(
|
|
104
|
+
Flex,
|
|
105
|
+
{
|
|
106
|
+
align: "center",
|
|
107
|
+
height: "100%",
|
|
108
|
+
justify: "center",
|
|
109
|
+
p: "5",
|
|
110
|
+
width: "100%",
|
|
111
|
+
children: /* @__PURE__ */ jsx(Spinner, {})
|
|
112
|
+
}
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
if (rowLength === 0) {
|
|
116
|
+
return /* @__PURE__ */ jsx("div", { className: "tr", children: /* @__PURE__ */ jsx(Flex, { align: "center", justify: "center", children: placeholder || /* @__PURE__ */ jsx(Typo, { color: "gray", mb: "6", mt: "6", variant: "body", children: "\uB370\uC774\uD130\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4" }) }) }, "expand_placeholder");
|
|
117
|
+
}
|
|
118
|
+
return null;
|
|
119
|
+
},
|
|
120
|
+
[isLoading, placeholder]
|
|
121
|
+
);
|
|
122
|
+
const pageCount = useMemo(() => {
|
|
123
|
+
if (!data) return 0;
|
|
124
|
+
return Math.ceil(data.length / pageSize);
|
|
125
|
+
}, [data, pageSize]);
|
|
126
|
+
return /* @__PURE__ */ jsxs("div", { className: `expand-table-wrapper ${variant}`, children: [
|
|
127
|
+
/* @__PURE__ */ jsxs("div", { className: "expand-table", style: tableStyle, children: [
|
|
128
|
+
/* @__PURE__ */ jsx("div", { className: "thead", children: getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsx(
|
|
129
|
+
"div",
|
|
130
|
+
{
|
|
131
|
+
className: "tr",
|
|
132
|
+
style: { gridTemplateColumns },
|
|
133
|
+
children: headerGroup.headers.map((header) => {
|
|
134
|
+
var _a;
|
|
135
|
+
const sortable = header.column.getCanSort();
|
|
136
|
+
const sortedState = header.column.getIsSorted();
|
|
137
|
+
const justifyContent = ((_a = header.column.columnDef.meta) == null ? void 0 : _a.align) || defaultAlign;
|
|
138
|
+
if (sortable) {
|
|
139
|
+
return /* @__PURE__ */ jsx("div", { className: `${justifyContent} th`, children: /* @__PURE__ */ jsxs(
|
|
140
|
+
"button",
|
|
141
|
+
{
|
|
142
|
+
onClick: header.column.getToggleSortingHandler(),
|
|
143
|
+
style: { cursor: "pointer" },
|
|
144
|
+
type: "button",
|
|
145
|
+
children: [
|
|
146
|
+
/* @__PURE__ */ jsx(Typo, { as: "div", variant: "body", children: flexRender(
|
|
147
|
+
header.column.columnDef.header,
|
|
148
|
+
header.getContext()
|
|
149
|
+
) }),
|
|
150
|
+
/* @__PURE__ */ jsxs(
|
|
151
|
+
Flex,
|
|
152
|
+
{
|
|
153
|
+
direction: "column",
|
|
154
|
+
style: { marginLeft: "var(--space-2)" },
|
|
155
|
+
children: [
|
|
156
|
+
sortedState === false && /* @__PURE__ */ jsx(
|
|
157
|
+
TriangleArrowDownIcon,
|
|
158
|
+
{
|
|
159
|
+
color: sortButtonColorMapper[variant].unselected
|
|
160
|
+
}
|
|
161
|
+
),
|
|
162
|
+
sortedState === "asc" && /* @__PURE__ */ jsx(
|
|
163
|
+
TriangleArrowUpIcon,
|
|
164
|
+
{
|
|
165
|
+
color: sortButtonColorMapper[variant].selected
|
|
166
|
+
}
|
|
167
|
+
),
|
|
168
|
+
sortedState === "desc" && /* @__PURE__ */ jsx(
|
|
169
|
+
TriangleArrowDownIcon,
|
|
170
|
+
{
|
|
171
|
+
color: sortButtonColorMapper[variant].selected
|
|
172
|
+
}
|
|
173
|
+
)
|
|
174
|
+
]
|
|
175
|
+
}
|
|
176
|
+
)
|
|
177
|
+
]
|
|
178
|
+
}
|
|
179
|
+
) }, header.id);
|
|
180
|
+
}
|
|
181
|
+
return /* @__PURE__ */ jsx("div", { className: `${justifyContent} th`, children: /* @__PURE__ */ jsx(Typo, { as: "div", variant: "body", children: flexRender(
|
|
182
|
+
header.column.columnDef.header,
|
|
183
|
+
header.getContext()
|
|
184
|
+
) }) }, header.id);
|
|
185
|
+
})
|
|
186
|
+
},
|
|
187
|
+
headerGroup.id
|
|
188
|
+
)) }),
|
|
189
|
+
/* @__PURE__ */ jsx("div", { className: "tbody", children: helpCompRender(rowModels.rows.length) || rowModels.rows.map((row) => {
|
|
190
|
+
return /* @__PURE__ */ jsx(
|
|
191
|
+
Row,
|
|
192
|
+
{
|
|
193
|
+
ExpandComp,
|
|
194
|
+
defaultAlign,
|
|
195
|
+
getCellStyle,
|
|
196
|
+
getRowStyle,
|
|
197
|
+
gridTemplateColumns,
|
|
198
|
+
onRowClick,
|
|
199
|
+
row
|
|
200
|
+
},
|
|
201
|
+
`row_${row.id}`
|
|
202
|
+
);
|
|
203
|
+
}) })
|
|
204
|
+
] }),
|
|
205
|
+
showPagination ? /* @__PURE__ */ jsx(Flex, { justify: "end", pt: "4", width: "100%", children: /* @__PURE__ */ jsx(
|
|
206
|
+
Pagination,
|
|
207
|
+
{
|
|
208
|
+
count: pageCount,
|
|
209
|
+
onChange: onChangePagination,
|
|
210
|
+
page: pagination.pageIndex + 1,
|
|
211
|
+
siblingCount
|
|
212
|
+
}
|
|
213
|
+
) }) : null
|
|
214
|
+
] });
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
export {
|
|
218
|
+
createColumnHelper,
|
|
219
|
+
ExpandTable
|
|
220
|
+
};
|
|
221
|
+
//# sourceMappingURL=chunk-NMRNR5OA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/molecules/expand-table/index.tsx"],"sourcesContent":["import type {\n ColumnDef,\n SortingState,\n RowData,\n Row as RowType,\n PaginationState,\n} from '@tanstack/react-table';\nimport type { CSSProperties } from 'react';\nimport {\n flexRender,\n getCoreRowModel,\n useReactTable,\n getSortedRowModel,\n createColumnHelper,\n getPaginationRowModel,\n} from '@tanstack/react-table';\nimport React, { useCallback, useMemo, useState } from 'react';\nimport { Flex } from '@/atoms/flex';\nimport { Pagination } from '@/atoms/pagination';\nimport { Spinner } from '@/atoms/spinner';\nimport { Typo } from '@/atoms/typo';\nimport { TriangleArrowDownIcon } from '../../icons/down';\nimport { TriangleArrowUpIcon } from '../../icons/up';\nimport { Row, type ExpandComp, type OnRowClick } from './row';\n\nexport type { ExpandComp, OnRowClick, ColumnDef, RowType as Row };\nexport { createColumnHelper };\n\ntype Variant = 'card' | 'sprite' | 'sprite-border';\nconst sortButtonColorMapper: Record<\n Variant,\n { selected: string; unselected: string }\n> = {\n card: {\n selected: 'var(--iris-10)',\n unselected: 'var(--iris-6)',\n },\n sprite: {\n // selected: 'var(--gray-a12)',\n // unselected: 'var(--gray-a6)',\n selected: 'var(--iris-10)',\n unselected: 'var(--iris-6)',\n },\n 'sprite-border': {\n selected: 'var(--iris-10)',\n unselected: 'var(--iris-6)',\n },\n};\n\nexport interface ExpandTableProps<Datum extends RowData> {\n /** 렌더할 데이터 배열 */\n data?: Datum[];\n /** 테이블 컬럼의 메타 데이터 */\n columns: ColumnDef<Datum>[];\n /** Row의 open이 true인 경우 하단의 collapse에 렌더할 컴포넌트 */\n ExpandComp?: ExpandComp<Datum>;\n /** 데이테가 없을 시 화면에 표시할 컴포넌트 */\n placeholder?: React.ReactNode;\n /** 행 클릭 시 실행할 콜백 */\n onRowClick?: OnRowClick<Datum>;\n getRowStyle?: (data: Datum) => CSSProperties;\n getCellStyle?: (data: Datum) => CSSProperties;\n tableStyle?: CSSProperties;\n isLoading?: boolean;\n\n /** pagination - 표시 유무, 기본값 true */\n showPagination?: boolean;\n /** pagination - 현재 선택된 페이지, 0부터 시작 */\n pageIndex?: number;\n /** pagination - 한 페이지에 표시될 컬럼 개수, 기본값 10 */\n pageSize?: number;\n /** pagination - */\n siblingCount?: number;\n variant?: Variant;\n}\n\nexport function ExpandTable<Datum extends RowData>(\n props: ExpandTableProps<Datum>\n): React.ReactNode {\n const {\n data,\n columns,\n ExpandComp,\n placeholder,\n onRowClick,\n tableStyle,\n showPagination = true,\n isLoading,\n pageIndex = 0,\n pageSize = 10,\n siblingCount = 2,\n getRowStyle,\n getCellStyle,\n variant = 'card',\n } = props;\n const defaultAlign = 'left';\n const [pagination, setPagination] = useState<PaginationState>({\n pageIndex: pageIndex || 0,\n pageSize: pageSize || 9999,\n });\n\n const [sorting, setSorting] = useState<SortingState>([]);\n const { getRowModel, getHeaderGroups, setPageIndex } = useReactTable({\n data: data || [],\n columns,\n getCoreRowModel: getCoreRowModel(),\n getSortedRowModel: getSortedRowModel(),\n state: {\n sorting,\n pagination,\n },\n onSortingChange: setSorting,\n getPaginationRowModel: getPaginationRowModel(),\n onPaginationChange: setPagination,\n });\n\n const gridTemplateColumns = useMemo<string>(() => {\n return columns\n .map((col) => {\n if (col.meta?.autoSize) return `minmax(${col.size || 50}px, 1fr)`;\n return `${col.size || 150}px`;\n })\n .join(' ');\n }, [columns]);\n\n const rowModels = getRowModel();\n\n const onChangePagination = useCallback(\n (page: number) => {\n setPageIndex(page - 1);\n },\n [setPageIndex]\n );\n\n const helpCompRender = useCallback(\n (rowLength: number) => {\n if (isLoading) {\n return (\n <Flex\n align=\"center\"\n height=\"100%\"\n justify=\"center\"\n p=\"5\"\n width=\"100%\"\n >\n <Spinner />\n </Flex>\n );\n }\n if (rowLength === 0) {\n return (\n <div className=\"tr\" key=\"expand_placeholder\">\n <Flex align=\"center\" justify=\"center\">\n {placeholder || (\n <Typo color=\"gray\" mb=\"6\" mt=\"6\" variant=\"body\">\n 데이터가 없습니다\n </Typo>\n )}\n </Flex>\n </div>\n );\n }\n return null;\n },\n [isLoading, placeholder]\n );\n\n const pageCount = useMemo(() => {\n if (!data) return 0;\n return Math.ceil(data.length / pageSize);\n }, [data, pageSize]);\n\n return (\n <div className={`expand-table-wrapper ${variant}`}>\n <div className=\"expand-table\" style={tableStyle}>\n <div className=\"thead\">\n {getHeaderGroups().map((headerGroup) => (\n <div\n className=\"tr\"\n key={headerGroup.id}\n style={{ gridTemplateColumns }}\n >\n {headerGroup.headers.map((header) => {\n const sortable = header.column.getCanSort();\n const sortedState = header.column.getIsSorted();\n const justifyContent =\n header.column.columnDef.meta?.align || defaultAlign;\n\n if (sortable) {\n return (\n <div className={`${justifyContent} th`} key={header.id}>\n <button\n onClick={header.column.getToggleSortingHandler()}\n style={{ cursor: 'pointer' }}\n type=\"button\"\n >\n <Typo as=\"div\" variant=\"body\">\n {flexRender(\n header.column.columnDef.header,\n header.getContext()\n )}\n </Typo>\n <Flex\n direction=\"column\"\n style={{ marginLeft: 'var(--space-2)' }}\n >\n {sortedState === false && (\n <TriangleArrowDownIcon\n color={sortButtonColorMapper[variant].unselected}\n />\n )}\n {sortedState === 'asc' && (\n <TriangleArrowUpIcon\n color={sortButtonColorMapper[variant].selected}\n />\n )}\n {sortedState === 'desc' && (\n <TriangleArrowDownIcon\n color={sortButtonColorMapper[variant].selected}\n />\n )}\n </Flex>\n </button>\n </div>\n );\n }\n\n return (\n <div className={`${justifyContent} th`} key={header.id}>\n <Typo as=\"div\" variant=\"body\">\n {flexRender(\n header.column.columnDef.header,\n header.getContext()\n )}\n </Typo>\n </div>\n );\n })}\n </div>\n ))}\n </div>\n <div className=\"tbody\">\n {/* 조건에 따라 placeholder 또는 loading 렌더*/}\n {helpCompRender(rowModels.rows.length) ||\n rowModels.rows.map((row) => {\n return (\n <Row\n ExpandComp={ExpandComp}\n defaultAlign={defaultAlign}\n getCellStyle={getCellStyle}\n getRowStyle={getRowStyle}\n gridTemplateColumns={gridTemplateColumns}\n key={`row_${row.id}`}\n onRowClick={onRowClick}\n row={row}\n />\n );\n })}\n </div>\n </div>\n {showPagination ? (\n <Flex justify=\"end\" pt=\"4\" width=\"100%\">\n <Pagination\n count={pageCount}\n onChange={onChangePagination}\n page={pagination.pageIndex + 1}\n siblingCount={siblingCount}\n />\n </Flex>\n ) : null}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAQA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;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AAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YAEA;AAAA,YACA;AAAA;AAAA,UAFK,OAAO,IAAI,EAAE;AAAA,QAGpB;AAAA,MAEJ,CAAC,GACL;AAAA,OACF;AAAA,IACC,iBACC,oBAAC,QAAK,SAAQ,OAAM,IAAG,KAAI,OAAM,QAC/B;AAAA,MAAC;AAAA;AAAA,QACC,OAAO;AAAA,QACP,UAAU;AAAA,QACV,MAAM,WAAW,YAAY;AAAA,QAC7B;AAAA;AAAA,IACF,GACF,IACE;AAAA,KACN;AAEJ;","names":[]}
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Row
|
|
3
|
+
} from "./chunk-JCG2AUFJ.js";
|
|
4
|
+
import {
|
|
5
|
+
Spinner
|
|
6
|
+
} from "./chunk-FR2GDOU2.js";
|
|
7
|
+
import {
|
|
8
|
+
Pagination
|
|
9
|
+
} from "./chunk-SBJOKO35.js";
|
|
10
|
+
import {
|
|
11
|
+
Flex
|
|
12
|
+
} from "./chunk-25HMMI7R.js";
|
|
13
|
+
import {
|
|
14
|
+
TriangleArrowUpIcon
|
|
15
|
+
} from "./chunk-2O45FRFQ.js";
|
|
16
|
+
import {
|
|
17
|
+
TriangleArrowDownIcon
|
|
18
|
+
} from "./chunk-776WBOKL.js";
|
|
19
|
+
import {
|
|
20
|
+
Typo
|
|
21
|
+
} from "./chunk-PMJIFLDT.js";
|
|
22
|
+
|
|
23
|
+
// src/molecules/expand-table/index.tsx
|
|
24
|
+
import {
|
|
25
|
+
flexRender,
|
|
26
|
+
getCoreRowModel,
|
|
27
|
+
useReactTable,
|
|
28
|
+
getSortedRowModel,
|
|
29
|
+
createColumnHelper,
|
|
30
|
+
getPaginationRowModel
|
|
31
|
+
} from "@tanstack/react-table";
|
|
32
|
+
import { useCallback, useMemo, useState } from "react";
|
|
33
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
34
|
+
var sortButtonColorMapper = {
|
|
35
|
+
card: {
|
|
36
|
+
selected: "var(--iris-10)",
|
|
37
|
+
unselected: "var(--iris-6)"
|
|
38
|
+
},
|
|
39
|
+
sprite: {
|
|
40
|
+
// selected: 'var(--gray-a12)',
|
|
41
|
+
// unselected: 'var(--gray-a6)',
|
|
42
|
+
selected: "var(--iris-10)",
|
|
43
|
+
unselected: "var(--iris-6)"
|
|
44
|
+
},
|
|
45
|
+
"sprite-border": {
|
|
46
|
+
selected: "var(--iris-10)",
|
|
47
|
+
unselected: "var(--iris-6)"
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
function ExpandTable(props) {
|
|
51
|
+
const {
|
|
52
|
+
data,
|
|
53
|
+
columns,
|
|
54
|
+
ExpandComp,
|
|
55
|
+
placeholder,
|
|
56
|
+
onRowClick,
|
|
57
|
+
tableStyle,
|
|
58
|
+
showPagination = true,
|
|
59
|
+
isLoading,
|
|
60
|
+
pageIndex = 0,
|
|
61
|
+
pageSize = 10,
|
|
62
|
+
siblingCount = 2,
|
|
63
|
+
getRowStyle,
|
|
64
|
+
getCellStyle,
|
|
65
|
+
variant = "card"
|
|
66
|
+
} = props;
|
|
67
|
+
const defaultAlign = "left";
|
|
68
|
+
const [pagination, setPagination] = useState({
|
|
69
|
+
pageIndex: pageIndex || 0,
|
|
70
|
+
pageSize: pageSize || 9999
|
|
71
|
+
});
|
|
72
|
+
const [sorting, setSorting] = useState([]);
|
|
73
|
+
const { getRowModel, getHeaderGroups, setPageIndex } = useReactTable({
|
|
74
|
+
data: data || [],
|
|
75
|
+
columns,
|
|
76
|
+
getCoreRowModel: getCoreRowModel(),
|
|
77
|
+
getSortedRowModel: getSortedRowModel(),
|
|
78
|
+
state: {
|
|
79
|
+
sorting,
|
|
80
|
+
pagination
|
|
81
|
+
},
|
|
82
|
+
onSortingChange: setSorting,
|
|
83
|
+
getPaginationRowModel: getPaginationRowModel(),
|
|
84
|
+
onPaginationChange: setPagination
|
|
85
|
+
});
|
|
86
|
+
const gridTemplateColumns = useMemo(() => {
|
|
87
|
+
return columns.map((col) => {
|
|
88
|
+
var _a;
|
|
89
|
+
if ((_a = col.meta) == null ? void 0 : _a.autoSize) return `minmax(${col.size || 50}px, 1fr)`;
|
|
90
|
+
return `${col.size || 150}px`;
|
|
91
|
+
}).join(" ");
|
|
92
|
+
}, [columns]);
|
|
93
|
+
const rowModels = getRowModel();
|
|
94
|
+
const onChangePagination = useCallback(
|
|
95
|
+
(page) => {
|
|
96
|
+
setPageIndex(page - 1);
|
|
97
|
+
},
|
|
98
|
+
[setPageIndex]
|
|
99
|
+
);
|
|
100
|
+
const helpCompRender = useCallback(
|
|
101
|
+
(rowLength) => {
|
|
102
|
+
if (isLoading) {
|
|
103
|
+
return /* @__PURE__ */ jsx(
|
|
104
|
+
Flex,
|
|
105
|
+
{
|
|
106
|
+
align: "center",
|
|
107
|
+
height: "100%",
|
|
108
|
+
justify: "center",
|
|
109
|
+
p: "5",
|
|
110
|
+
width: "100%",
|
|
111
|
+
children: /* @__PURE__ */ jsx(Spinner, {})
|
|
112
|
+
}
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
if (rowLength === 0) {
|
|
116
|
+
return /* @__PURE__ */ jsx("div", { className: "tr", children: /* @__PURE__ */ jsx(Flex, { align: "center", justify: "center", children: placeholder || /* @__PURE__ */ jsx(Typo, { color: "gray", mb: "6", mt: "6", variant: "body", children: "\uB370\uC774\uD130\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4" }) }) }, "expand_placeholder");
|
|
117
|
+
}
|
|
118
|
+
return null;
|
|
119
|
+
},
|
|
120
|
+
[isLoading, placeholder]
|
|
121
|
+
);
|
|
122
|
+
const pageCount = useMemo(() => {
|
|
123
|
+
if (!data) return 0;
|
|
124
|
+
return Math.ceil(data.length / pageSize);
|
|
125
|
+
}, [data, pageSize]);
|
|
126
|
+
return /* @__PURE__ */ jsxs("div", { className: `expand-table-wrapper ${variant}`, children: [
|
|
127
|
+
/* @__PURE__ */ jsxs("div", { className: "expand-table", style: tableStyle, children: [
|
|
128
|
+
/* @__PURE__ */ jsx("div", { className: "thead", children: getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsx(
|
|
129
|
+
"div",
|
|
130
|
+
{
|
|
131
|
+
className: "tr",
|
|
132
|
+
style: { gridTemplateColumns },
|
|
133
|
+
children: headerGroup.headers.map((header) => {
|
|
134
|
+
var _a;
|
|
135
|
+
const sortable = header.column.getCanSort();
|
|
136
|
+
const sortedState = header.column.getIsSorted();
|
|
137
|
+
const justifyContent = ((_a = header.column.columnDef.meta) == null ? void 0 : _a.align) || defaultAlign;
|
|
138
|
+
if (sortable) {
|
|
139
|
+
return /* @__PURE__ */ jsx("div", { className: `${justifyContent} th`, children: /* @__PURE__ */ jsxs(
|
|
140
|
+
"button",
|
|
141
|
+
{
|
|
142
|
+
onClick: header.column.getToggleSortingHandler(),
|
|
143
|
+
style: { cursor: "pointer" },
|
|
144
|
+
type: "button",
|
|
145
|
+
children: [
|
|
146
|
+
/* @__PURE__ */ jsx(Typo, { as: "div", variant: "body", children: flexRender(
|
|
147
|
+
header.column.columnDef.header,
|
|
148
|
+
header.getContext()
|
|
149
|
+
) }),
|
|
150
|
+
/* @__PURE__ */ jsxs(
|
|
151
|
+
Flex,
|
|
152
|
+
{
|
|
153
|
+
direction: "column",
|
|
154
|
+
style: { marginLeft: "var(--space-2)" },
|
|
155
|
+
children: [
|
|
156
|
+
sortedState === false && /* @__PURE__ */ jsx(
|
|
157
|
+
TriangleArrowDownIcon,
|
|
158
|
+
{
|
|
159
|
+
color: sortButtonColorMapper[variant].unselected
|
|
160
|
+
}
|
|
161
|
+
),
|
|
162
|
+
sortedState === "asc" && /* @__PURE__ */ jsx(
|
|
163
|
+
TriangleArrowUpIcon,
|
|
164
|
+
{
|
|
165
|
+
color: sortButtonColorMapper[variant].selected
|
|
166
|
+
}
|
|
167
|
+
),
|
|
168
|
+
sortedState === "desc" && /* @__PURE__ */ jsx(
|
|
169
|
+
TriangleArrowDownIcon,
|
|
170
|
+
{
|
|
171
|
+
color: sortButtonColorMapper[variant].selected
|
|
172
|
+
}
|
|
173
|
+
)
|
|
174
|
+
]
|
|
175
|
+
}
|
|
176
|
+
)
|
|
177
|
+
]
|
|
178
|
+
}
|
|
179
|
+
) }, header.id);
|
|
180
|
+
}
|
|
181
|
+
return /* @__PURE__ */ jsx("div", { className: `${justifyContent} th`, children: /* @__PURE__ */ jsx("div", { style: { cursor: "default" }, children: /* @__PURE__ */ jsx(Typo, { as: "div", variant: "body", children: flexRender(
|
|
182
|
+
header.column.columnDef.header,
|
|
183
|
+
header.getContext()
|
|
184
|
+
) }) }) }, header.id);
|
|
185
|
+
})
|
|
186
|
+
},
|
|
187
|
+
headerGroup.id
|
|
188
|
+
)) }),
|
|
189
|
+
/* @__PURE__ */ jsx("div", { className: "tbody", children: helpCompRender(rowModels.rows.length) || rowModels.rows.map((row) => {
|
|
190
|
+
return /* @__PURE__ */ jsx(
|
|
191
|
+
Row,
|
|
192
|
+
{
|
|
193
|
+
ExpandComp,
|
|
194
|
+
defaultAlign,
|
|
195
|
+
getCellStyle,
|
|
196
|
+
getRowStyle,
|
|
197
|
+
gridTemplateColumns,
|
|
198
|
+
onRowClick,
|
|
199
|
+
row
|
|
200
|
+
},
|
|
201
|
+
`row_${row.id}`
|
|
202
|
+
);
|
|
203
|
+
}) })
|
|
204
|
+
] }),
|
|
205
|
+
showPagination ? /* @__PURE__ */ jsx(Flex, { justify: "end", pt: "4", width: "100%", children: /* @__PURE__ */ jsx(
|
|
206
|
+
Pagination,
|
|
207
|
+
{
|
|
208
|
+
count: pageCount,
|
|
209
|
+
onChange: onChangePagination,
|
|
210
|
+
page: pagination.pageIndex + 1,
|
|
211
|
+
siblingCount
|
|
212
|
+
}
|
|
213
|
+
) }) : null
|
|
214
|
+
] });
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
export {
|
|
218
|
+
createColumnHelper,
|
|
219
|
+
ExpandTable
|
|
220
|
+
};
|
|
221
|
+
//# sourceMappingURL=chunk-QMPSKZJ2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/molecules/expand-table/index.tsx"],"sourcesContent":["import type {\n ColumnDef,\n SortingState,\n RowData,\n Row as RowType,\n PaginationState,\n} from '@tanstack/react-table';\nimport type { CSSProperties } from 'react';\nimport {\n flexRender,\n getCoreRowModel,\n useReactTable,\n getSortedRowModel,\n createColumnHelper,\n getPaginationRowModel,\n} from '@tanstack/react-table';\nimport React, { useCallback, useMemo, useState } from 'react';\nimport { Flex } from '@/atoms/flex';\nimport { Pagination } from '@/atoms/pagination';\nimport { Spinner } from '@/atoms/spinner';\nimport { Typo } from '@/atoms/typo';\nimport { TriangleArrowDownIcon } from '../../icons/down';\nimport { TriangleArrowUpIcon } from '../../icons/up';\nimport { Row, type ExpandComp, type OnRowClick } from './row';\n\nexport type { ExpandComp, OnRowClick, ColumnDef, RowType as Row };\nexport { createColumnHelper };\n\n\ntype Variant = 'card' | 'sprite' | 'sprite-border';\nconst sortButtonColorMapper: Record<Variant, { selected: string; unselected: string }> = {\n card: {\n selected: 'var(--iris-10)',\n unselected: 'var(--iris-6)',\n },\n sprite: {\n // selected: 'var(--gray-a12)',\n // unselected: 'var(--gray-a6)',\n selected: 'var(--iris-10)',\n unselected: 'var(--iris-6)',\n },\n 'sprite-border': {\n selected: 'var(--iris-10)',\n unselected: 'var(--iris-6)',\n },\n};\n\nexport interface ExpandTableProps<Datum extends RowData> {\n /** 렌더할 데이터 배열 */\n data?: Datum[];\n /** 테이블 컬럼의 메타 데이터 */\n columns: ColumnDef<Datum>[];\n /** Row의 open이 true인 경우 하단의 collapse에 렌더할 컴포넌트 */\n ExpandComp?: ExpandComp<Datum>;\n /** 데이테가 없을 시 화면에 표시할 컴포넌트 */\n placeholder?: React.ReactNode;\n /** 행 클릭 시 실행할 콜백 */\n onRowClick?: OnRowClick<Datum>;\n getRowStyle?: (data: Datum) => CSSProperties;\n getCellStyle?: (data: Datum) => CSSProperties;\n tableStyle?: CSSProperties;\n isLoading?: boolean;\n\n /** pagination - 표시 유무, 기본값 true */\n showPagination?: boolean;\n /** pagination - 현재 선택된 페이지, 0부터 시작 */\n pageIndex?: number;\n /** pagination - 한 페이지에 표시될 컬럼 개수, 기본값 10 */\n pageSize?: number;\n /** pagination - */\n siblingCount?: number;\n variant?: Variant;\n}\n\nexport function ExpandTable<Datum extends RowData>(\n props: ExpandTableProps<Datum>\n): React.ReactNode {\n const {\n data,\n columns,\n ExpandComp,\n placeholder,\n onRowClick,\n tableStyle,\n showPagination = true,\n isLoading,\n pageIndex = 0,\n pageSize = 10,\n siblingCount = 2,\n getRowStyle,\n getCellStyle,\n variant = 'card',\n } = props;\n const defaultAlign = 'left';\n const [pagination, setPagination] = useState<PaginationState>({\n pageIndex: pageIndex || 0,\n pageSize: pageSize || 9999,\n });\n\n const [sorting, setSorting] = useState<SortingState>([]);\n const { getRowModel, getHeaderGroups, setPageIndex } = useReactTable({\n data: data || [],\n columns,\n getCoreRowModel: getCoreRowModel(),\n getSortedRowModel: getSortedRowModel(),\n state: {\n sorting,\n pagination,\n },\n onSortingChange: setSorting,\n getPaginationRowModel: getPaginationRowModel(),\n onPaginationChange: setPagination,\n });\n\n const gridTemplateColumns = useMemo<string>(() => {\n return columns\n .map((col) => {\n if (col.meta?.autoSize) return `minmax(${col.size || 50}px, 1fr)`;\n return `${col.size || 150}px`;\n })\n .join(' ');\n }, [columns]);\n\n const rowModels = getRowModel();\n\n const onChangePagination = useCallback(\n (page: number) => {\n setPageIndex(page - 1);\n },\n [setPageIndex]\n );\n\n const helpCompRender = useCallback(\n (rowLength: number) => {\n if (isLoading) {\n return (\n <Flex\n align=\"center\"\n height=\"100%\"\n justify=\"center\"\n p=\"5\"\n width=\"100%\"\n >\n <Spinner />\n </Flex>\n );\n }\n if (rowLength === 0) {\n return (\n <div className=\"tr\" key=\"expand_placeholder\">\n <Flex align=\"center\" justify=\"center\">\n {placeholder || (\n <Typo color=\"gray\" mb=\"6\" mt=\"6\" variant=\"body\">\n 데이터가 없습니다\n </Typo>\n )}\n </Flex>\n </div>\n );\n }\n return null;\n },\n [isLoading, placeholder]\n );\n\n const pageCount = useMemo(() => {\n if (!data) return 0;\n return Math.ceil(data.length / pageSize);\n }, [data, pageSize]);\n\n return (\n <div className={`expand-table-wrapper ${variant}`}>\n <div className=\"expand-table\" style={tableStyle}>\n <div className=\"thead\">\n {getHeaderGroups().map((headerGroup) => (\n <div\n className=\"tr\"\n key={headerGroup.id}\n style={{ gridTemplateColumns }}\n >\n {headerGroup.headers.map((header) => {\n const sortable = header.column.getCanSort();\n const sortedState = header.column.getIsSorted();\n const justifyContent =\n header.column.columnDef.meta?.align || defaultAlign;\n\n if (sortable) {\n return (\n <div className={`${justifyContent} th`} key={header.id}>\n <button\n onClick={header.column.getToggleSortingHandler()}\n style={{ cursor: 'pointer' }}\n type=\"button\"\n >\n <Typo as=\"div\" variant=\"body\">\n {flexRender(\n header.column.columnDef.header,\n header.getContext()\n )}\n </Typo>\n <Flex\n direction=\"column\"\n style={{ marginLeft: 'var(--space-2)' }}\n >\n {sortedState === false && (\n <TriangleArrowDownIcon\n color={sortButtonColorMapper[variant].unselected}\n />\n )}\n {sortedState === 'asc' && (\n <TriangleArrowUpIcon\n color={sortButtonColorMapper[variant].selected}\n />\n )}\n {sortedState === 'desc' && (\n <TriangleArrowDownIcon\n color={sortButtonColorMapper[variant].selected}\n />\n )}\n </Flex>\n </button>\n </div>\n );\n }\n\n return (\n <div className={`${justifyContent} th`} key={header.id}>\n <div style={{ cursor: 'default' }}>\n <Typo as=\"div\" variant=\"body\">\n {flexRender(\n header.column.columnDef.header,\n header.getContext()\n )}\n </Typo>\n </div>\n </div>\n );\n })}\n </div>\n ))}\n </div>\n <div className=\"tbody\">\n {/* 조건에 따라 placeholder 또는 loading 렌더*/}\n {helpCompRender(rowModels.rows.length) ||\n rowModels.rows.map((row) => {\n return (\n <Row\n ExpandComp={ExpandComp}\n defaultAlign={defaultAlign}\n getCellStyle={getCellStyle}\n getRowStyle={getRowStyle}\n gridTemplateColumns={gridTemplateColumns}\n key={`row_${row.id}`}\n onRowClick={onRowClick}\n row={row}\n />\n );\n })}\n </div>\n </div>\n {showPagination ? (\n <Flex justify=\"end\" pt=\"4\" width=\"100%\">\n <Pagination\n count={pageCount}\n onChange={onChangePagination}\n page={pagination.pageIndex + 1}\n siblingCount={siblingCount}\n />\n </Flex>\n ) : null}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAQA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAgB,aAAa,SAAS,gBAAgB;AA+H1C,cAyDY,YAzDZ;AAjHZ,IAAM,wBAAmF;AAAA,EACvF,MAAM;AAAA,IACJ,UAAU;AAAA,IACV,YAAY;AAAA,EACd;AAAA,EACA,QAAQ;AAAA;AAAA;AAAA,IAGN,UAAU;AAAA,IACV,YAAY;AAAA,EACd;AAAA,EACA,iBAAiB;AAAA,IACf,UAAU;AAAA,IACV,YAAY;AAAA,EACd;AACF;AA6BO,SAAS,YACd,OACiB;AACjB,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,iBAAiB;AAAA,IACjB;AAAA,IACA,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,eAAe;AAAA,IACf;AAAA,IACA;AAAA,IACA,UAAU;AAAA,EACZ,IAAI;AACJ,QAAM,eAAe;AACrB,QAAM,CAAC,YAAY,aAAa,IAAI,SAA0B;AAAA,IAC5D,WAAW,aAAa;AAAA,IACxB,UAAU,YAAY;AAAA,EACxB,CAAC;AAED,QAAM,CAAC,SAAS,UAAU,IAAI,SAAuB,CAAC,CAAC;AACvD,QAAM,EAAE,aAAa,iBAAiB,aAAa,IAAI,cAAc;AAAA,IACnE,MAAM,QAAQ,CAAC;AAAA,IACf;AAAA,IACA,iBAAiB,gBAAgB;AAAA,IACjC,mBAAmB,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