@tipp/ui 0.1.20 → 0.1.21
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/field-error-wrapper.cjs +99 -0
- package/dist/atoms/field-error-wrapper.cjs.map +1 -0
- package/dist/atoms/field-error-wrapper.d.cts +9 -0
- package/dist/atoms/field-error-wrapper.d.ts +9 -0
- package/dist/atoms/field-error-wrapper.js +10 -0
- package/dist/atoms/field-error-wrapper.js.map +1 -0
- package/dist/atoms/index.cjs +14 -0
- package/dist/atoms/index.cjs.map +1 -1
- package/dist/atoms/index.d.cts +1 -0
- package/dist/atoms/index.d.ts +1 -0
- package/dist/atoms/index.js +21 -17
- package/dist/atoms/pagination.js +2 -2
- package/dist/chunk-2KZSNTY7.js +23 -0
- package/dist/chunk-2KZSNTY7.js.map +1 -0
- package/dist/chunk-CNQ7RNNY.js +23 -0
- package/dist/chunk-CNQ7RNNY.js.map +1 -0
- package/dist/chunk-FFC2C2ID.js +1 -0
- package/dist/chunk-FFC2C2ID.js.map +1 -0
- package/dist/chunk-K66WIGIV.js +119 -0
- package/dist/chunk-K66WIGIV.js.map +1 -0
- package/dist/chunk-KACFRYIH.js +23 -0
- package/dist/chunk-KACFRYIH.js.map +1 -0
- package/dist/chunk-KATXJW5H.js +23 -0
- package/dist/chunk-KATXJW5H.js.map +1 -0
- package/dist/chunk-LUVANORR.js +23 -0
- package/dist/chunk-LUVANORR.js.map +1 -0
- package/dist/chunk-OZLC6KYP.js +104 -0
- package/dist/chunk-OZLC6KYP.js.map +1 -0
- package/dist/index.cjs +39 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +23 -19
- package/dist/molecules/expand-table/index.cjs +26 -23
- package/dist/molecules/expand-table/index.cjs.map +1 -1
- package/dist/molecules/expand-table/index.js +10 -9
- package/dist/molecules/expand-table/row.cjs +9 -6
- package/dist/molecules/expand-table/row.cjs.map +1 -1
- package/dist/molecules/expand-table/row.js +8 -7
- package/dist/molecules/index.cjs +26 -23
- package/dist/molecules/index.cjs.map +1 -1
- package/dist/molecules/index.js +10 -9
- package/package.json +1 -1
- package/src/atoms/field-error-wrapper.tsx +24 -0
- package/src/atoms/index.ts +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/molecules/expand-table/index.tsx"],"sourcesContent":["import type { ColumnDef, SortingState, RowData } from '@tanstack/react-table';\nimport type { CSSProperties } from 'react';\nimport {\n flexRender,\n getCoreRowModel,\n useReactTable,\n getSortedRowModel,\n createColumnHelper,\n} from '@tanstack/react-table';\nimport React, { useMemo, useState } from 'react';\nimport { Flex, Typo } from '../../atoms';\nimport { TriangleArrowDownIcon } from '../../icons/down';\nimport { TriangleArrowUpIcon } from '../../icons/up';\nimport { Row, type ExpandComp, type OnRowClick } from './row';\n\nexport type { ExpandComp, OnRowClick, ColumnDef };\nexport { createColumnHelper };\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 rowStyle?: CSSProperties;\n}\n\nexport function ExpandTable<Datum extends RowData>(\n props: ExpandTableProps<Datum>\n): React.ReactNode {\n const { data, columns, ExpandComp, placeholder, onRowClick } = props;\n\n const [sorting, setSorting] = useState<SortingState>([]);\n const { getRowModel, getHeaderGroups } = useReactTable({\n data: data || [],\n columns,\n getCoreRowModel: getCoreRowModel(),\n getSortedRowModel: getSortedRowModel(),\n state: {\n sorting,\n },\n onSortingChange: setSorting,\n });\n\n const gridColTemp = useMemo<string>(() => {\n return columns\n .map((col) => {\n if (col.meta?.autoSize) return '1fr';\n return `${col.size || 150}px`;\n })\n .join(' ');\n }, [columns]);\n\n const rowModels = getRowModel();\n\n return (\n <div className=\"expand-table\">\n <div className=\"thead\">\n {getHeaderGroups().map((headerGroup) => (\n <div\n className=\"tr\"\n key={headerGroup.id}\n style={{ gridTemplateColumns: gridColTemp }}\n >\n {headerGroup.headers.map((header) => {\n const sortable = header.column.getCanSort();\n const sortedState = header.column.getIsSorted();\n\n return (\n <div className=\"th\" key={header.id}>\n <button\n onClick={header.column.getToggleSortingHandler()}\n style={sortable ? { cursor: 'pointer' } : undefined}\n type=\"button\"\n >\n <Typo variant=\"body\">\n {flexRender(\n header.column.columnDef.header,\n header.getContext()\n )}\n </Typo>\n {sortable ? (\n <Flex\n direction=\"column\"\n style={{ marginLeft: 'var(--space-2)' }}\n >\n <TriangleArrowUpIcon\n color={\n sortedState === 'asc'\n ? 'var(--iris-10)'\n : 'var(--iris-6)'\n }\n />\n <TriangleArrowDownIcon\n color={\n sortedState === 'desc'\n ? 'var(--iris-10)'\n : 'var(--iris-6)'\n }\n />\n </Flex>\n ) : null}\n </button>\n </div>\n );\n })}\n </div>\n ))}\n </div>\n <div className=\"tbody\">\n {/* 데이터가 없을 시 표시되는 노드 */}\n {rowModels.rows.length === 0 && (\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 {/* 행을 렌더하는 로직 */}\n {rowModels.rows.map((row) => {\n return (\n <Row\n ExpandComp={ExpandComp}\n gridColTemp={gridColTemp}\n key={`row_${row.id}`}\n onRowClick={onRowClick}\n row={row}\n />\n );\n })}\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAEA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,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AA,gBACC,WACC;AAAA,kBAAC;AAAA;AAAA,oBACC,WAAU;AAAA,oBACV,OAAO,EAAE,YAAY,iBAAiB;AAAA,oBAEtC;AAAA;AAAA,wBAAC;AAAA;AAAA,0BACC,OACE,gBAAgB,QACZ,mBACA;AAAA;AAAA,sBAER;AAAA,sBACA;AAAA,wBAAC;AAAA;AAAA,0BACC,OACE,gBAAgB,SACZ,mBACA;AAAA;AAAA,sBAER;AAAA;AAAA;AAAA,gBACF,IACE;AAAA;AAAA;AAAA,UACN,KAjCuB,OAAO,EAkChC;AAAA,QAEJ,CAAC;AAAA;AAAA,MA5CI,YAAY;AAAA,IA6CnB,CACD,GACH;AAAA,IACA,qBAAC,SAAI,WAAU,SAEZ;AAAA,gBAAU,KAAK,WAAW,KACzB,oBAAC,SAAI,WAAU,MACb,8BAAC,QAAK,OAAM,UAAS,SAAQ,UAC1B,yBACC,oBAAC,QAAK,OAAM,QAAO,IAAG,KAAI,IAAG,KAAI,SAAQ,QAAO,+DAEhD,GAEJ,KAPsB,oBAQxB;AAAA,MAID,UAAU,KAAK,IAAI,CAAC,QAAQ;AAC3B,eACE;AAAA,UAAC;AAAA;AAAA,YACC;AAAA,YACA;AAAA,YAEA;AAAA,YACA;AAAA;AAAA,UAFK,OAAO,IAAI,EAAE;AAAA,QAGpB;AAAA,MAEJ,CAAC;AAAA,OACH;AAAA,KACF;AAEJ;","names":[]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Typo
|
|
3
|
+
} from "./chunk-O3XTRD7R.js";
|
|
4
|
+
import {
|
|
5
|
+
Flex
|
|
6
|
+
} from "./chunk-25HMMI7R.js";
|
|
7
|
+
|
|
8
|
+
// src/atoms/field-error-wrapper.tsx
|
|
9
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
function FieldErrorWrapper({
|
|
11
|
+
children,
|
|
12
|
+
error
|
|
13
|
+
}) {
|
|
14
|
+
return /* @__PURE__ */ jsxs(Flex, { gap: "2", direction: "column", children: [
|
|
15
|
+
children,
|
|
16
|
+
error ? /* @__PURE__ */ jsx(Typo, { color: "red", children: error }) : null
|
|
17
|
+
] });
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export {
|
|
21
|
+
FieldErrorWrapper
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=chunk-KACFRYIH.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/atoms/field-error-wrapper.tsx"],"sourcesContent":["import React from 'react';\nimport { Flex } from './flex';\nimport { Typo } from './typo';\n\nexport interface FieldErrorWrapperProps {\n children?: React.ReactNode;\n error?: React.ReactNode;\n}\n\nexport function FieldErrorWrapper({\n children,\n error,\n}: FieldErrorWrapperProps): JSX.Element {\n return (\n <Flex gap=\"2\" direction=\"column\">\n {children}\n {error ? <Typo color=\"red\">{error}</Typo> : null}\n </Flex>\n );\n}\n"],"mappings":";;;;;;;;AAcI,SAEW,KAFX;AALG,SAAS,kBAAkB;AAAA,EAChC;AAAA,EACA;AACF,GAAwC;AACtC,SACE,qBAAC,QAAK,KAAI,KAAI,WAAU,UACrB;AAAA;AAAA,IACA,QAAQ,oBAAC,QAAK,OAAM,OAAO,iBAAM,IAAU;AAAA,KAC9C;AAEJ;","names":[]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Typo
|
|
3
|
+
} from "./chunk-O3XTRD7R.js";
|
|
4
|
+
import {
|
|
5
|
+
Flex
|
|
6
|
+
} from "./chunk-25HMMI7R.js";
|
|
7
|
+
|
|
8
|
+
// src/atoms/field-error-wrapper.tsx
|
|
9
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
function FieldErrorWrapper({
|
|
11
|
+
children,
|
|
12
|
+
error
|
|
13
|
+
}) {
|
|
14
|
+
return /* @__PURE__ */ jsxs(Flex, { gap: "2", children: [
|
|
15
|
+
children,
|
|
16
|
+
error ? /* @__PURE__ */ jsx(Typo, { color: "red", children: error }) : null
|
|
17
|
+
] });
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export {
|
|
21
|
+
FieldErrorWrapper
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=chunk-KATXJW5H.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/atoms/field-error-wrapper.tsx"],"sourcesContent":["import React from 'react';\nimport { Flex } from './flex';\nimport { Typo } from './typo';\n\nexport interface FieldErrorWrapperProps {\n children?: React.ReactNode;\n error?: React.ReactNode;\n}\n\nexport function FieldErrorWrapper({\n children,\n error,\n}: FieldErrorWrapperProps): JSX.Element {\n return (\n <Flex gap=\"2\">\n {children}\n {error ? <Typo color=\"red\">{error}</Typo> : null}\n </Flex>\n );\n}\n"],"mappings":";;;;;;;;AAcI,SAEW,KAFX;AALG,SAAS,kBAAkB;AAAA,EAChC;AAAA,EACA;AACF,GAAwC;AACtC,SACE,qBAAC,QAAK,KAAI,KACP;AAAA;AAAA,IACA,QAAQ,oBAAC,QAAK,OAAM,OAAO,iBAAM,IAAU;AAAA,KAC9C;AAEJ;","names":[]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Typo
|
|
3
|
+
} from "./chunk-O3XTRD7R.js";
|
|
4
|
+
import {
|
|
5
|
+
Flex
|
|
6
|
+
} from "./chunk-25HMMI7R.js";
|
|
7
|
+
|
|
8
|
+
// src/atoms/field-error-wrapper.tsx
|
|
9
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
function FieldErrorWrapper({
|
|
11
|
+
children,
|
|
12
|
+
error
|
|
13
|
+
}) {
|
|
14
|
+
return /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: "2", children: [
|
|
15
|
+
children,
|
|
16
|
+
error ? /* @__PURE__ */ jsx(Typo, { color: "red", children: error }) : null
|
|
17
|
+
] });
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export {
|
|
21
|
+
FieldErrorWrapper
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=chunk-LUVANORR.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/atoms/field-error-wrapper.tsx"],"sourcesContent":["import React from 'react';\nimport { Flex } from './flex';\nimport { Typo } from './typo';\n\nexport interface FieldErrorWrapperProps {\n children?: React.ReactNode;\n error?: React.ReactNode;\n}\n\nexport function FieldErrorWrapper({\n children,\n error,\n}: FieldErrorWrapperProps): JSX.Element {\n return (\n <Flex direction=\"column\" gap=\"2\">\n {children}\n {error ? <Typo color=\"red\">{error}</Typo> : null}\n </Flex>\n );\n}\n"],"mappings":";;;;;;;;AAcI,SAEW,KAFX;AALG,SAAS,kBAAkB;AAAA,EAChC;AAAA,EACA;AACF,GAAwC;AACtC,SACE,qBAAC,QAAK,WAAU,UAAS,KAAI,KAC1B;AAAA;AAAA,IACA,QAAQ,oBAAC,QAAK,OAAM,OAAO,iBAAM,IAAU;AAAA,KAC9C;AAEJ;","names":[]}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import {
|
|
2
|
+
IconButton
|
|
3
|
+
} from "./chunk-O3DNDMV3.js";
|
|
4
|
+
import {
|
|
5
|
+
Typo
|
|
6
|
+
} from "./chunk-O3XTRD7R.js";
|
|
7
|
+
import {
|
|
8
|
+
Flex
|
|
9
|
+
} from "./chunk-25HMMI7R.js";
|
|
10
|
+
import {
|
|
11
|
+
ChevronLeftIcon,
|
|
12
|
+
ChevronRightIcon
|
|
13
|
+
} from "./chunk-MMAV5BRZ.js";
|
|
14
|
+
import {
|
|
15
|
+
__spreadProps,
|
|
16
|
+
__spreadValues
|
|
17
|
+
} from "./chunk-N552FDTV.js";
|
|
18
|
+
|
|
19
|
+
// src/atoms/pagination.tsx
|
|
20
|
+
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
21
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
22
|
+
function Pagination(props) {
|
|
23
|
+
const { onChange, count = 0 } = props;
|
|
24
|
+
const siblingCount = 2;
|
|
25
|
+
const [page, setPage] = useState(() => props.page || props.defaultPage || 1);
|
|
26
|
+
const visibleItems = useMemo(() => {
|
|
27
|
+
let start = Math.max(1, page - siblingCount);
|
|
28
|
+
let end = Math.min(count, page + siblingCount);
|
|
29
|
+
if (page - siblingCount <= 0 && end < count) {
|
|
30
|
+
end = Math.min(count, end + Math.abs(page - siblingCount) + 1);
|
|
31
|
+
} else if (page + siblingCount > count && start > 1) {
|
|
32
|
+
start = Math.max(1, start - (page + siblingCount - count));
|
|
33
|
+
}
|
|
34
|
+
return Array.from({ length: end - start + 1 }, (_, i) => i + start);
|
|
35
|
+
}, [count, page]);
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
onChange == null ? void 0 : onChange(page);
|
|
38
|
+
}, [onChange, page]);
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
if (props.page) {
|
|
41
|
+
setPage(props.page);
|
|
42
|
+
}
|
|
43
|
+
}, [props.page]);
|
|
44
|
+
const onClickPrev = useCallback(() => {
|
|
45
|
+
setPage((prev) => Math.max(1, prev - 1));
|
|
46
|
+
}, []);
|
|
47
|
+
const onClickNext = useCallback(() => {
|
|
48
|
+
setPage((prev) => Math.min(count, prev + 1));
|
|
49
|
+
}, [count]);
|
|
50
|
+
const moveButtonProps = {
|
|
51
|
+
variant: "ghost",
|
|
52
|
+
size: "3",
|
|
53
|
+
style: { borderRadius: "50%" }
|
|
54
|
+
};
|
|
55
|
+
const iconSize = {
|
|
56
|
+
height: 24,
|
|
57
|
+
width: 24
|
|
58
|
+
};
|
|
59
|
+
const prevDisabled = useMemo(() => {
|
|
60
|
+
return page - siblingCount <= 1;
|
|
61
|
+
}, [page]);
|
|
62
|
+
const nextDisabled = useMemo(() => {
|
|
63
|
+
return page + siblingCount >= count;
|
|
64
|
+
}, [count, page]);
|
|
65
|
+
return /* @__PURE__ */ jsxs(Flex, { align: "center", className: "tipp-pagination", gap: "4", children: [
|
|
66
|
+
/* @__PURE__ */ jsx(
|
|
67
|
+
IconButton,
|
|
68
|
+
__spreadProps(__spreadValues({
|
|
69
|
+
disabled: prevDisabled,
|
|
70
|
+
onClick: onClickPrev
|
|
71
|
+
}, moveButtonProps), {
|
|
72
|
+
children: /* @__PURE__ */ jsx(ChevronLeftIcon, __spreadValues({}, iconSize))
|
|
73
|
+
})
|
|
74
|
+
),
|
|
75
|
+
/* @__PURE__ */ jsx(Flex, { gap: "1", children: visibleItems.map((item) => {
|
|
76
|
+
return /* @__PURE__ */ jsx(
|
|
77
|
+
"button",
|
|
78
|
+
{
|
|
79
|
+
className: `page-button ${item === page ? "active" : ""}`,
|
|
80
|
+
onClick: () => {
|
|
81
|
+
setPage(item);
|
|
82
|
+
},
|
|
83
|
+
type: "button",
|
|
84
|
+
children: /* @__PURE__ */ jsx(Typo, { variant: "body", children: item })
|
|
85
|
+
},
|
|
86
|
+
item
|
|
87
|
+
);
|
|
88
|
+
}) }),
|
|
89
|
+
/* @__PURE__ */ jsx(
|
|
90
|
+
IconButton,
|
|
91
|
+
__spreadProps(__spreadValues({
|
|
92
|
+
disabled: nextDisabled,
|
|
93
|
+
onClick: onClickNext
|
|
94
|
+
}, moveButtonProps), {
|
|
95
|
+
children: /* @__PURE__ */ jsx(ChevronRightIcon, __spreadValues({}, iconSize))
|
|
96
|
+
})
|
|
97
|
+
)
|
|
98
|
+
] });
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export {
|
|
102
|
+
Pagination
|
|
103
|
+
};
|
|
104
|
+
//# sourceMappingURL=chunk-OZLC6KYP.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/atoms/pagination.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useMemo, useState } from 'react';\nimport { ChevronLeftIcon, ChevronRightIcon } from '../icon';\nimport type { IconButtonProps } from './icon-button';\nimport { IconButton } from './icon-button';\nimport { Flex } from './flex';\nimport { Typo } from './typo';\n\nexport interface PaginationProps {\n /** 현재 선택된 페이지 */\n page?: number;\n /** 기본 선택 페이지, page보다 낮은 우선 순위를 갖는다 */\n defaultPage?: number;\n /** 선택한 페이지 변경 이벤트 cb */\n onChange?: (page: number) => void;\n /** 전체 페이지의 수 */\n count?: number;\n}\n\nexport function Pagination(props: PaginationProps): React.ReactNode {\n const { onChange, count = 0 } = props;\n const siblingCount = 2;\n\n const [page, setPage] = useState(() => props.page || props.defaultPage || 1);\n\n const visibleItems = useMemo(() => {\n let start = Math.max(1, page - siblingCount);\n let end = Math.min(count, page + siblingCount);\n if (page - siblingCount <= 0 && end < count) {\n end = Math.min(count, end + Math.abs(page - siblingCount) + 1);\n } else if (page + siblingCount > count && start > 1) {\n start = Math.max(1, start - (page + siblingCount - count));\n }\n\n return Array.from({ length: end - start + 1 }, (_, i) => i + start);\n }, [count, page]);\n\n useEffect(() => {\n onChange?.(page);\n }, [onChange, page]);\n\n useEffect(() => {\n if (props.page) {\n setPage(props.page);\n }\n }, [props.page]);\n\n const onClickPrev = useCallback(() => {\n setPage((prev) => Math.max(1, prev - 1));\n }, []);\n\n const onClickNext = useCallback(() => {\n setPage((prev) => Math.min(count, prev + 1));\n }, [count]);\n\n const moveButtonProps: IconButtonProps = {\n variant: 'ghost',\n size: '3',\n style: { borderRadius: '50%' },\n };\n\n const iconSize = {\n height: 24,\n width: 24,\n };\n\n const prevDisabled = useMemo(() => {\n return page - siblingCount <= 1;\n }, [page]);\n\n const nextDisabled = useMemo(() => {\n return page + siblingCount >= count;\n }, [count, page]);\n\n return (\n <Flex align=\"center\" className=\"tipp-pagination\" gap=\"4\">\n <IconButton\n disabled={prevDisabled}\n onClick={onClickPrev}\n {...moveButtonProps}\n >\n <ChevronLeftIcon {...iconSize} />\n </IconButton>\n <Flex gap=\"1\">\n {visibleItems.map((item) => {\n return (\n <button\n className={`page-button ${item === page ? 'active' : ''}`}\n key={item}\n onClick={() => {\n setPage(item);\n }}\n type=\"button\"\n >\n <Typo variant=\"body\">{item}</Typo>\n </button>\n );\n })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89
|
ExitIcon: () => import_react_icons.ExitIcon,
|
|
90
90
|
ExpandTable: () => ExpandTable,
|
|
91
|
+
FieldErrorWrapper: () => FieldErrorWrapper,
|
|
91
92
|
Flex: () => import_themes19.Flex,
|
|
92
93
|
Grid: () => import_themes20.Grid,
|
|
93
94
|
Heading: () => Heading2,
|
|
@@ -576,17 +577,29 @@ function Pagination(props) {
|
|
|
576
577
|
] });
|
|
577
578
|
}
|
|
578
579
|
|
|
580
|
+
// src/atoms/field-error-wrapper.tsx
|
|
581
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
582
|
+
function FieldErrorWrapper({
|
|
583
|
+
children,
|
|
584
|
+
error
|
|
585
|
+
}) {
|
|
586
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_themes19.Flex, { direction: "column", gap: "1", children: [
|
|
587
|
+
children,
|
|
588
|
+
error ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Typo, { color: "red", variant: "caption", children: error }) : null
|
|
589
|
+
] });
|
|
590
|
+
}
|
|
591
|
+
|
|
579
592
|
// src/molecules/expand-table/index.tsx
|
|
580
593
|
var import_react_table2 = require("@tanstack/react-table");
|
|
581
594
|
var import_react13 = require("react");
|
|
582
595
|
|
|
583
596
|
// src/icons/down.tsx
|
|
584
597
|
var React7 = __toESM(require("react"), 1);
|
|
585
|
-
var
|
|
598
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
586
599
|
var TriangleArrowDownIcon = React7.forwardRef(
|
|
587
600
|
(_a, forwardedRef) => {
|
|
588
601
|
var _b = _a, { color = "currentColor" } = _b, props = __objRest(_b, ["color"]);
|
|
589
|
-
return /* @__PURE__ */ (0,
|
|
602
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
590
603
|
"svg",
|
|
591
604
|
__spreadProps(__spreadValues({
|
|
592
605
|
fill: "none",
|
|
@@ -596,7 +609,7 @@ var TriangleArrowDownIcon = React7.forwardRef(
|
|
|
596
609
|
xmlns: "http://www.w3.org/2000/svg"
|
|
597
610
|
}, props), {
|
|
598
611
|
ref: forwardedRef,
|
|
599
|
-
children: /* @__PURE__ */ (0,
|
|
612
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
600
613
|
"path",
|
|
601
614
|
{
|
|
602
615
|
d: "M7.10844 0.8125H0.891554C0.197392 0.8125 -0.177096 1.62672 0.274659 2.15377L3.3831 5.78029C3.70737 6.1586 4.29263 6.1586 4.6169 5.78029L7.72534 2.15377C8.1771 1.62672 7.80261 0.8125 7.10844 0.8125Z",
|
|
@@ -611,11 +624,11 @@ TriangleArrowDownIcon.displayName = "ArrowDownIcon";
|
|
|
611
624
|
|
|
612
625
|
// src/icons/up.tsx
|
|
613
626
|
var React8 = __toESM(require("react"), 1);
|
|
614
|
-
var
|
|
627
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
615
628
|
var TriangleArrowUpIcon = React8.forwardRef(
|
|
616
629
|
(_a, forwardedRef) => {
|
|
617
630
|
var _b = _a, { color = "currentColor" } = _b, props = __objRest(_b, ["color"]);
|
|
618
|
-
return /* @__PURE__ */ (0,
|
|
631
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
619
632
|
"svg",
|
|
620
633
|
__spreadProps(__spreadValues({
|
|
621
634
|
fill: "none",
|
|
@@ -625,7 +638,7 @@ var TriangleArrowUpIcon = React8.forwardRef(
|
|
|
625
638
|
xmlns: "http://www.w3.org/2000/svg"
|
|
626
639
|
}, props), {
|
|
627
640
|
ref: forwardedRef,
|
|
628
|
-
children: /* @__PURE__ */ (0,
|
|
641
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
629
642
|
"path",
|
|
630
643
|
{
|
|
631
644
|
d: "M0.891555 6.1875L7.10845 6.1875C7.80261 6.1875 8.1771 5.37328 7.72534 4.84623L4.6169 1.21971C4.29263 0.841403 3.70737 0.841403 3.3831 1.21971L0.274659 4.84623C-0.177095 5.37328 0.197393 6.1875 0.891555 6.1875Z",
|
|
@@ -641,7 +654,7 @@ TriangleArrowUpIcon.displayName = "ArrowUpIcon";
|
|
|
641
654
|
// src/molecules/expand-table/row.tsx
|
|
642
655
|
var import_react_table = require("@tanstack/react-table");
|
|
643
656
|
var import_react12 = require("react");
|
|
644
|
-
var
|
|
657
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
645
658
|
function Row(props) {
|
|
646
659
|
const { row, ExpandComp, gridColTemp } = props;
|
|
647
660
|
const [open, setOpen] = (0, import_react12.useState)(false);
|
|
@@ -650,12 +663,12 @@ function Row(props) {
|
|
|
650
663
|
(_a = props.onRowClick) == null ? void 0 : _a.call(props, row.original);
|
|
651
664
|
setOpen((prev) => !prev);
|
|
652
665
|
}, [props, row.original]);
|
|
653
|
-
return /* @__PURE__ */ (0,
|
|
666
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
654
667
|
"div",
|
|
655
668
|
{
|
|
656
669
|
className: `tr-wrapper ${ExpandComp ? "expandable" : ""}`,
|
|
657
670
|
children: [
|
|
658
|
-
/* @__PURE__ */ (0,
|
|
671
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
659
672
|
"button",
|
|
660
673
|
{
|
|
661
674
|
className: "tr",
|
|
@@ -665,7 +678,7 @@ function Row(props) {
|
|
|
665
678
|
children: row.getVisibleCells().map((cell) => {
|
|
666
679
|
var _a, _b;
|
|
667
680
|
const autoSize = (_a = cell.column.columnDef.meta) == null ? void 0 : _a.autoSize;
|
|
668
|
-
return /* @__PURE__ */ (0,
|
|
681
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
669
682
|
"div",
|
|
670
683
|
{
|
|
671
684
|
className: "td",
|
|
@@ -675,7 +688,7 @@ function Row(props) {
|
|
|
675
688
|
},
|
|
676
689
|
children: [
|
|
677
690
|
(0, import_react_table.flexRender)(cell.column.columnDef.cell, cell.getContext()),
|
|
678
|
-
((_b = cell.column.columnDef.meta) == null ? void 0 : _b.OpenBtn) ? /* @__PURE__ */ (0,
|
|
691
|
+
((_b = cell.column.columnDef.meta) == null ? void 0 : _b.OpenBtn) ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
679
692
|
cell.column.columnDef.meta.OpenBtn,
|
|
680
693
|
{
|
|
681
694
|
data: row.original,
|
|
@@ -691,7 +704,7 @@ function Row(props) {
|
|
|
691
704
|
},
|
|
692
705
|
`tr_${row.id}`
|
|
693
706
|
),
|
|
694
|
-
ExpandComp ? /* @__PURE__ */ (0,
|
|
707
|
+
ExpandComp ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Collapse, { open, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "expand-comp-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ExpandComp, { row }) }) }) : null
|
|
695
708
|
]
|
|
696
709
|
},
|
|
697
710
|
`tr-wrapper_${row.id}`
|
|
@@ -699,7 +712,7 @@ function Row(props) {
|
|
|
699
712
|
}
|
|
700
713
|
|
|
701
714
|
// src/molecules/expand-table/index.tsx
|
|
702
|
-
var
|
|
715
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
703
716
|
function ExpandTable(props) {
|
|
704
717
|
const { data, columns, ExpandComp, placeholder, onRowClick } = props;
|
|
705
718
|
const [sorting, setSorting] = (0, import_react13.useState)([]);
|
|
@@ -722,8 +735,8 @@ function ExpandTable(props) {
|
|
|
722
735
|
}).join(" ");
|
|
723
736
|
}, [columns]);
|
|
724
737
|
const rowModels = getRowModel();
|
|
725
|
-
return /* @__PURE__ */ (0,
|
|
726
|
-
/* @__PURE__ */ (0,
|
|
738
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "expand-table", children: [
|
|
739
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "thead", children: getHeaderGroups().map((headerGroup) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
727
740
|
"div",
|
|
728
741
|
{
|
|
729
742
|
className: "tr",
|
|
@@ -731,30 +744,30 @@ function ExpandTable(props) {
|
|
|
731
744
|
children: headerGroup.headers.map((header) => {
|
|
732
745
|
const sortable = header.column.getCanSort();
|
|
733
746
|
const sortedState = header.column.getIsSorted();
|
|
734
|
-
return /* @__PURE__ */ (0,
|
|
747
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "th", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
|
|
735
748
|
"button",
|
|
736
749
|
{
|
|
737
750
|
onClick: header.column.getToggleSortingHandler(),
|
|
738
751
|
style: sortable ? { cursor: "pointer" } : void 0,
|
|
739
752
|
type: "button",
|
|
740
753
|
children: [
|
|
741
|
-
/* @__PURE__ */ (0,
|
|
754
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Typo, { variant: "body", children: (0, import_react_table2.flexRender)(
|
|
742
755
|
header.column.columnDef.header,
|
|
743
756
|
header.getContext()
|
|
744
757
|
) }),
|
|
745
|
-
sortable ? /* @__PURE__ */ (0,
|
|
758
|
+
sortable ? /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
|
|
746
759
|
import_themes19.Flex,
|
|
747
760
|
{
|
|
748
761
|
direction: "column",
|
|
749
762
|
style: { marginLeft: "var(--space-2)" },
|
|
750
763
|
children: [
|
|
751
|
-
/* @__PURE__ */ (0,
|
|
764
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
752
765
|
TriangleArrowUpIcon,
|
|
753
766
|
{
|
|
754
767
|
color: sortedState === "asc" ? "var(--iris-10)" : "var(--iris-6)"
|
|
755
768
|
}
|
|
756
769
|
),
|
|
757
|
-
/* @__PURE__ */ (0,
|
|
770
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
758
771
|
TriangleArrowDownIcon,
|
|
759
772
|
{
|
|
760
773
|
color: sortedState === "desc" ? "var(--iris-10)" : "var(--iris-6)"
|
|
@@ -770,10 +783,10 @@ function ExpandTable(props) {
|
|
|
770
783
|
},
|
|
771
784
|
headerGroup.id
|
|
772
785
|
)) }),
|
|
773
|
-
/* @__PURE__ */ (0,
|
|
774
|
-
rowModels.rows.length === 0 && /* @__PURE__ */ (0,
|
|
786
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "tbody", children: [
|
|
787
|
+
rowModels.rows.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "tr", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_themes19.Flex, { align: "center", justify: "center", children: placeholder || /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Typo, { color: "gray", mb: "6", mt: "6", variant: "body", children: "\uB370\uC774\uD130\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4" }) }) }, "expand_placeholder"),
|
|
775
788
|
rowModels.rows.map((row) => {
|
|
776
|
-
return /* @__PURE__ */ (0,
|
|
789
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
777
790
|
Row,
|
|
778
791
|
{
|
|
779
792
|
ExpandComp,
|
|
@@ -790,9 +803,9 @@ function ExpandTable(props) {
|
|
|
790
803
|
|
|
791
804
|
// src/theme/theme-provider.tsx
|
|
792
805
|
var import_themes50 = require("@radix-ui/themes");
|
|
793
|
-
var
|
|
806
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
794
807
|
function ThemeProvider(props) {
|
|
795
|
-
return /* @__PURE__ */ (0,
|
|
808
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_themes50.Theme, __spreadValues({ accentColor: "iris", radius: "large" }, props));
|
|
796
809
|
}
|
|
797
810
|
|
|
798
811
|
// src/theme/use-theme.tsx
|
|
@@ -831,6 +844,7 @@ var uiProps = __toESM(require("@radix-ui/themes/dist/cjs/props/index.js"), 1);
|
|
|
831
844
|
ExclamationTriangleIcon,
|
|
832
845
|
ExitIcon,
|
|
833
846
|
ExpandTable,
|
|
847
|
+
FieldErrorWrapper,
|
|
834
848
|
Flex,
|
|
835
849
|
Grid,
|
|
836
850
|
Heading,
|