@uniai-fe/uds-primitives 0.2.9 → 0.2.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.
Files changed (73) hide show
  1. package/dist/styles.css +415 -0
  2. package/package.json +2 -1
  3. package/src/components/calendar/types/calendar.ts +5 -0
  4. package/src/components/info-box/img/ban.svg +5 -0
  5. package/src/components/info-box/img/caution.svg +5 -0
  6. package/src/components/info-box/img/check.svg +4 -0
  7. package/src/components/info-box/img/info.svg +6 -0
  8. package/src/components/info-box/index.scss +1 -0
  9. package/src/components/info-box/index.tsx +4 -0
  10. package/src/components/info-box/markup/Icon.tsx +14 -0
  11. package/src/components/info-box/markup/InfoBox.tsx +65 -0
  12. package/src/components/info-box/markup/index.ts +2 -0
  13. package/src/components/info-box/styles/index.scss +2 -0
  14. package/src/components/info-box/styles/info-box.scss +61 -0
  15. package/src/components/info-box/styles/variables.scss +33 -0
  16. package/src/components/info-box/types/index.ts +1 -0
  17. package/src/components/info-box/types/props.ts +34 -0
  18. package/src/components/input/markup/date/Template.tsx +36 -5
  19. package/src/components/input/markup/date/Trigger.tsx +22 -4
  20. package/src/components/input/markup/foundation/Input.tsx +19 -11
  21. package/src/components/input/markup/foundation/Utility.tsx +11 -7
  22. package/src/components/input/styles/date.scss +21 -0
  23. package/src/components/input/styles/foundation.scss +30 -0
  24. package/src/components/input/styles/variables.scss +11 -0
  25. package/src/components/input/types/date.ts +15 -0
  26. package/src/components/input/types/foundation.ts +18 -11
  27. package/src/components/input/utils/date.ts +15 -1
  28. package/src/components/select/markup/Default.tsx +6 -3
  29. package/src/components/select/markup/foundation/Base.tsx +1 -1
  30. package/src/components/select/markup/foundation/Icon.tsx +6 -1
  31. package/src/components/select/markup/multiple/Multiple.tsx +6 -3
  32. package/src/components/select/styles/select.scss +50 -0
  33. package/src/components/select/styles/variables.scss +26 -0
  34. package/src/components/select/types/base.ts +3 -2
  35. package/src/components/select/types/icon.ts +7 -6
  36. package/src/components/select/types/props.ts +1 -0
  37. package/src/components/select/types/trigger.ts +4 -0
  38. package/src/components/table/hooks/index.ts +0 -3
  39. package/src/components/table/index.tsx +5 -3
  40. package/src/components/table/markup/Container.tsx +126 -0
  41. package/src/components/table/markup/foundation/Body.tsx +24 -0
  42. package/src/components/table/markup/foundation/Cell.tsx +72 -0
  43. package/src/components/table/markup/foundation/Col.tsx +22 -0
  44. package/src/components/table/markup/foundation/Colgroup.tsx +29 -0
  45. package/src/components/table/markup/foundation/Foot.tsx +24 -0
  46. package/src/components/table/markup/foundation/Head.tsx +24 -0
  47. package/src/components/table/markup/foundation/Root.tsx +32 -0
  48. package/src/components/table/markup/foundation/Row.tsx +32 -0
  49. package/src/components/table/markup/foundation/Td.tsx +37 -0
  50. package/src/components/table/markup/foundation/Th.tsx +39 -0
  51. package/src/components/table/markup/foundation/index.tsx +30 -0
  52. package/src/components/table/markup/index.tsx +8 -2
  53. package/src/components/table/styles/foundation.scss +247 -0
  54. package/src/components/table/styles/index.scss +2 -0
  55. package/src/components/table/styles/variables.scss +29 -0
  56. package/src/components/table/types/foundation.ts +250 -0
  57. package/src/components/table/types/index.ts +1 -4
  58. package/src/components/tooltip/img/info.svg +5 -0
  59. package/src/components/tooltip/img/information.svg +9 -0
  60. package/src/components/tooltip/index.scss +1 -0
  61. package/src/components/tooltip/index.tsx +4 -0
  62. package/src/components/tooltip/markup/Message.tsx +70 -0
  63. package/src/components/tooltip/markup/Root.tsx +32 -0
  64. package/src/components/tooltip/markup/Template.tsx +46 -0
  65. package/src/components/tooltip/markup/Trigger.tsx +32 -0
  66. package/src/components/tooltip/markup/index.tsx +18 -0
  67. package/src/components/tooltip/styles/index.scss +2 -0
  68. package/src/components/tooltip/styles/tooltip.scss +47 -0
  69. package/src/components/tooltip/styles/variables.scss +14 -0
  70. package/src/components/tooltip/types/index.ts +1 -0
  71. package/src/components/tooltip/types/props.ts +118 -0
  72. package/src/index.scss +1 -0
  73. package/src/index.tsx +2 -0
@@ -0,0 +1,250 @@
1
+ import type { ComponentPropsWithoutRef } from "react";
2
+
3
+ export const TABLE_CELL_ALIGN_OPTIONS = ["left", "center", "right"] as const;
4
+ export const TABLE_CELL_ALIGN_Y_OPTIONS = ["top", "center", "bottom"] as const;
5
+ export const TABLE_CELL_PADDING_OPTIONS = ["default", "none"] as const;
6
+ export const TABLE_SECTIONS = ["head", "body", "foot"] as const;
7
+ export const TABLE_LAYOUT_OPTIONS = ["line", "grid"] as const;
8
+
9
+ /**
10
+ * Table Types; Cell 정렬 값 타입
11
+ * @typedef {"left" | "center" | "right"} TableCellAlign
12
+ */
13
+ export type TableCellAlign = (typeof TABLE_CELL_ALIGN_OPTIONS)[number];
14
+ /**
15
+ * Table Types; Cell 세로 정렬 값 타입
16
+ * @typedef {"top" | "center" | "bottom"} TableCellAlignY
17
+ */
18
+ export type TableCellAlignY = (typeof TABLE_CELL_ALIGN_Y_OPTIONS)[number];
19
+ /**
20
+ * Table Types; Cell padding 제어 타입
21
+ * @typedef {"default" | "none"} TableCellPadding
22
+ */
23
+ export type TableCellPadding = (typeof TABLE_CELL_PADDING_OPTIONS)[number];
24
+ /**
25
+ * Table Types; section 식별 타입
26
+ * @typedef {"head" | "body" | "foot"} TableSection
27
+ */
28
+ export type TableSection = (typeof TABLE_SECTIONS)[number];
29
+ /**
30
+ * Table Types; layout 식별 타입
31
+ * @typedef {"line" | "grid"} TableLayout
32
+ */
33
+ export type TableLayout = (typeof TABLE_LAYOUT_OPTIONS)[number];
34
+
35
+ /**
36
+ * Table Types; Root props
37
+ * @property {string} [className] table 루트 className
38
+ * @property {"line" | "grid"} [layout] 테이블 스타일 축
39
+ * @property {React.ReactNode} [children] table 내부 콘텐츠
40
+ */
41
+ export interface TableRootProps extends ComponentPropsWithoutRef<"table"> {
42
+ /**
43
+ * 테이블 스타일 축
44
+ */
45
+ layout?: TableLayout;
46
+ }
47
+
48
+ /**
49
+ * Table Types; Colgroup props
50
+ * @property {string} [className] colgroup className
51
+ * @property {React.ReactNode} [children] col 목록
52
+ */
53
+ export interface TableColgroupProps extends ComponentPropsWithoutRef<"colgroup"> {}
54
+
55
+ /**
56
+ * Table Types; Colgroup column item
57
+ * @property {string} key column 고유 key
58
+ * @property {number | string} [width] width 값
59
+ * @property {string} [dataKey] data-key attr 값
60
+ * @property {string} [className] col className
61
+ * @property {number} [span] col span 값
62
+ */
63
+ export interface TableColgroupColumn {
64
+ /**
65
+ * column 고유 key
66
+ */
67
+ key: string;
68
+ /**
69
+ * width 값
70
+ */
71
+ width?: number | string;
72
+ /**
73
+ * data-key attr 값
74
+ */
75
+ dataKey?: string;
76
+ /**
77
+ * col className
78
+ */
79
+ className?: string;
80
+ /**
81
+ * col span 값
82
+ */
83
+ span?: number;
84
+ }
85
+
86
+ /**
87
+ * Table Types; Template column item
88
+ * @property {string} key column 고유 key
89
+ * @property {number | string} [width] width 값
90
+ * @property {string} [dataKey] data-key attr 값
91
+ * @property {string} [dataName] 헤더 식별자
92
+ * @property {React.ReactNode} [headContent] 헤더 셀 콘텐츠
93
+ * @property {React.ReactNode} [cellContents] ui-legacy 호환 헤더 콘텐츠
94
+ * @property {React.ReactNode} [cellChildren] 서비스 호환 헤더 콘텐츠
95
+ * @property {"left" | "center" | "right"} [align] 헤더 정렬
96
+ */
97
+ export interface TableTemplateColumn extends TableColgroupColumn {
98
+ /**
99
+ * 헤더 식별자
100
+ */
101
+ dataName?: string;
102
+ /**
103
+ * 헤더 셀 콘텐츠
104
+ */
105
+ headContent?: React.ReactNode;
106
+ /**
107
+ * ui-legacy 호환 헤더 콘텐츠
108
+ */
109
+ cellContents?: React.ReactNode;
110
+ /**
111
+ * 서비스 호환 헤더 콘텐츠
112
+ */
113
+ cellChildren?: React.ReactNode;
114
+ /**
115
+ * 헤더 정렬
116
+ */
117
+ align?: TableCellAlign;
118
+ }
119
+
120
+ /**
121
+ * Table Types; Template props
122
+ * @property {TableTemplateColumn[]} [columns] colgroup/head 자동 렌더링용 column 데이터
123
+ * @property {boolean} [isCustomBody] true면 body wrapper 없이 children을 직접 렌더링
124
+ * @property {"legacy-rem" | "raw"} [widthMode] number width 해석 방식
125
+ * @property {React.ReactNode} [footer] footer 노드
126
+ * @property {React.ReactNode} [children] body 콘텐츠
127
+ */
128
+ export interface TableTemplateProps extends TableRootProps {
129
+ /**
130
+ * colgroup/head 자동 렌더링용 column 데이터
131
+ */
132
+ columns?: TableTemplateColumn[];
133
+ /**
134
+ * true면 body wrapper 없이 children을 직접 렌더링
135
+ */
136
+ isCustomBody?: boolean;
137
+ /**
138
+ * number width 해석 방식
139
+ */
140
+ widthMode?: "legacy-rem" | "raw";
141
+ /**
142
+ * footer 노드
143
+ */
144
+ footer?: React.ReactNode;
145
+ }
146
+
147
+ /**
148
+ * Table Types; Col props
149
+ * @property {string} [className] col className
150
+ */
151
+ export interface TableColProps extends ComponentPropsWithoutRef<"col"> {}
152
+
153
+ /**
154
+ * Table Types; Thead props
155
+ * @property {string} [className] thead className
156
+ * @property {React.ReactNode} [children] thead 내부 콘텐츠
157
+ */
158
+ export interface TableHeadProps extends ComponentPropsWithoutRef<"thead"> {}
159
+
160
+ /**
161
+ * Table Types; Tbody props
162
+ * @property {string} [className] tbody className
163
+ * @property {React.ReactNode} [children] tbody 내부 콘텐츠
164
+ */
165
+ export interface TableBodyProps extends ComponentPropsWithoutRef<"tbody"> {}
166
+
167
+ /**
168
+ * Table Types; Tfoot props
169
+ * @property {string} [className] tfoot className
170
+ * @property {React.ReactNode} [children] tfoot 내부 콘텐츠
171
+ */
172
+ export interface TableFootProps extends ComponentPropsWithoutRef<"tfoot"> {}
173
+
174
+ /**
175
+ * Table Types; Tr props
176
+ * @property {"head" | "body" | "foot"} [section] row 상위 섹션
177
+ * @property {string} [className] tr className
178
+ * @property {React.ReactNode} [children] row 내부 콘텐츠
179
+ */
180
+ export interface TableRowProps extends ComponentPropsWithoutRef<"tr"> {
181
+ /**
182
+ * row 상위 섹션
183
+ */
184
+ section?: TableSection;
185
+ }
186
+
187
+ /**
188
+ * Table Types; Th props
189
+ * @property {string} [className] th className
190
+ * @property {React.ReactNode} [children] header cell 콘텐츠
191
+ */
192
+ export interface TableThProps extends ComponentPropsWithoutRef<"th"> {}
193
+
194
+ /**
195
+ * Table Types; Td props
196
+ * @property {string} [className] td className
197
+ * @property {React.ReactNode} [children] body cell 콘텐츠
198
+ */
199
+ export interface TableTdProps extends ComponentPropsWithoutRef<"td"> {}
200
+
201
+ /**
202
+ * Table Types; Cell content props
203
+ * @property {"head" | "body" | "foot"} [section] cell 상위 섹션
204
+ * @property {"left" | "center" | "right"} [alignX] cell 콘텐츠 가로 정렬
205
+ * @property {"top" | "center" | "bottom"} [alignY] cell 콘텐츠 세로 정렬
206
+ * @property {boolean} [noPadding] true면 cell 내부 padding 제거
207
+ * @property {"default" | "none"} [padding] cell 내부 padding 제어
208
+ * @property {"left" | "center" | "right"} [align] cell 콘텐츠 가로 정렬(호환 alias)
209
+ * @property {string} [className] cell content className
210
+ * @property {React.ReactNode} [children] cell 내부 콘텐츠
211
+ */
212
+ export interface TableCellContentProps extends ComponentPropsWithoutRef<"div"> {
213
+ /**
214
+ * cell 상위 섹션
215
+ */
216
+ section?: TableSection;
217
+ /**
218
+ * cell 콘텐츠 가로 정렬
219
+ */
220
+ alignX?: TableCellAlign;
221
+ /**
222
+ * cell 콘텐츠 세로 정렬
223
+ */
224
+ alignY?: TableCellAlignY;
225
+ /**
226
+ * true면 cell 내부 padding 제거
227
+ */
228
+ noPadding?: boolean;
229
+ /**
230
+ * cell 내부 padding 제어
231
+ */
232
+ padding?: TableCellPadding;
233
+ /**
234
+ * cell 콘텐츠 가로 정렬(호환 alias)
235
+ * @deprecated `alignX` 사용을 권장한다.
236
+ */
237
+ align?: TableCellAlign;
238
+ }
239
+
240
+ /**
241
+ * Table Types; HeadCell props (deprecated alias)
242
+ * @deprecated `TableThProps` 사용을 권장한다.
243
+ */
244
+ export interface TableHeadCellProps extends TableThProps {}
245
+
246
+ /**
247
+ * Table Types; Body Cell props (deprecated alias)
248
+ * @deprecated `TableTdProps` 사용을 권장한다.
249
+ */
250
+ export interface TableCellProps extends TableTdProps {}
@@ -1,4 +1 @@
1
- /**
2
- * TODO(table): variant/slot 타입 정의를 작성한다.
3
- */
4
- export {};
1
+ export * from "./foundation";
@@ -0,0 +1,5 @@
1
+ <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M8.00004 6.7998C8.29459 6.7998 8.53324 7.03846 8.53324 7.33301V10.6663C8.53324 10.9609 8.29459 11.1995 8.00004 11.1995C7.70549 11.1995 7.46684 10.9609 7.46684 10.6663V7.33301C7.46684 7.03846 7.70549 6.7998 8.00004 6.7998Z" fill="#94989E"/>
3
+ <path d="M8.00004 4.66634C8.36823 4.66634 8.66671 4.96482 8.66671 5.33301C8.66671 5.7012 8.36823 5.99967 8.00004 5.99967C7.63185 5.99967 7.33337 5.7012 7.33337 5.33301C7.33337 4.96482 7.63185 4.66634 8.00004 4.66634Z" fill="#94989E"/>
4
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M8.00004 1.33301C11.6819 1.33301 14.6667 4.31778 14.6667 7.99967C14.6667 11.6816 11.6819 14.6663 8.00004 14.6663C4.31814 14.6663 1.33337 11.6816 1.33337 7.99967C1.33337 4.31778 4.31814 1.33301 8.00004 1.33301ZM8.00004 2.39941C4.90725 2.39941 2.39978 4.90688 2.39978 7.99967C2.39978 11.0925 4.90725 13.5999 8.00004 13.5999C11.0928 13.5999 13.6003 11.0925 13.6003 7.99967C13.6003 4.90688 11.0928 2.39941 8.00004 2.39941Z" fill="#94989E"/>
5
+ </svg>
@@ -0,0 +1,9 @@
1
+ <svg preserveAspectRatio="none" width="100%" height="100%" overflow="visible" style="display: block;" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <g id="Icon/Information/Line">
3
+ <g id="Union">
4
+ <path d="M8 6.80013C8.29455 6.80013 8.5332 7.03878 8.5332 7.33333V10.6667C8.5332 10.9612 8.29455 11.1999 8 11.1999C7.70545 11.1999 7.4668 10.9612 7.4668 10.6667V7.33333C7.4668 7.03878 7.70545 6.80013 8 6.80013Z" fill="var(--fill-0, #94989E)"/>
5
+ <path d="M8 4.66667C8.36819 4.66667 8.66667 4.96514 8.66667 5.33333C8.66667 5.70152 8.36819 6 8 6C7.63181 6 7.33333 5.70152 7.33333 5.33333C7.33333 4.96514 7.63181 4.66667 8 4.66667Z" fill="var(--fill-0, #94989E)"/>
6
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M8 1.33333C11.6819 1.33333 14.6667 4.3181 14.6667 8C14.6667 11.6819 11.6819 14.6667 8 14.6667C4.3181 14.6667 1.33333 11.6819 1.33333 8C1.33333 4.3181 4.3181 1.33333 8 1.33333ZM8 2.39974C4.90721 2.39974 2.39974 4.90721 2.39974 8C2.39974 11.0928 4.90721 13.6003 8 13.6003C11.0928 13.6003 13.6003 11.0928 13.6003 8C13.6003 4.90721 11.0928 2.39974 8 2.39974Z" fill="var(--fill-0, #94989E)"/>
7
+ </g>
8
+ </g>
9
+ </svg>
@@ -0,0 +1 @@
1
+ @use "./styles/index.scss";
@@ -0,0 +1,4 @@
1
+ import "./index.scss";
2
+
3
+ export * from "./markup";
4
+ export type * from "./types";
@@ -0,0 +1,70 @@
1
+ "use client";
2
+
3
+ import clsx from "clsx";
4
+ import * as TooltipPrimitive from "@radix-ui/react-tooltip";
5
+ import { forwardRef } from "react";
6
+ import type { TooltipMessageProps } from "../types";
7
+
8
+ /**
9
+ * Tooltip Message.
10
+ * @component
11
+ * @param {TooltipMessageProps} props Message props
12
+ * @param {React.ReactNode} props.children Tooltip 메시지 콘텐츠
13
+ * @param {string} [props.className] Content className
14
+ * @param {boolean} [props.withPortal=true] Portal 사용 여부
15
+ * @param {HTMLElement | null} [props.portalContainer] Portal 컨테이너
16
+ * @param {boolean} [props.withArrow=true] Arrow 렌더링 여부
17
+ * @param {string} [props.arrowClassName] Arrow className
18
+ * @example
19
+ * <Tooltip.Message sideOffset={8}>툴팁 메시지</Tooltip.Message>
20
+ */
21
+ const TooltipMessage = forwardRef<HTMLDivElement, TooltipMessageProps>(
22
+ (
23
+ {
24
+ children,
25
+ className,
26
+ withPortal = true,
27
+ portalContainer,
28
+ withArrow = true,
29
+ arrowClassName,
30
+ arrowProps,
31
+ sideOffset = 6,
32
+ ...restProps
33
+ },
34
+ ref,
35
+ ) => {
36
+ // 변경: Message는 Content+Arrow를 기본으로 제공해 호출부에서 반복 마크업을 줄인다.
37
+ const contentNode = (
38
+ <TooltipPrimitive.Content
39
+ ref={ref}
40
+ className={clsx("tooltip-message", className)}
41
+ sideOffset={sideOffset}
42
+ {...restProps}
43
+ >
44
+ <span className="tooltip-message-text">{children}</span>
45
+ {withArrow ? (
46
+ <TooltipPrimitive.Arrow
47
+ className={clsx("tooltip-message-arrow", arrowClassName)}
48
+ width={7}
49
+ height={9}
50
+ {...arrowProps}
51
+ />
52
+ ) : null}
53
+ </TooltipPrimitive.Content>
54
+ );
55
+
56
+ if (!withPortal) {
57
+ return contentNode;
58
+ }
59
+
60
+ return (
61
+ <TooltipPrimitive.Portal container={portalContainer ?? undefined}>
62
+ {contentNode}
63
+ </TooltipPrimitive.Portal>
64
+ );
65
+ },
66
+ );
67
+
68
+ TooltipMessage.displayName = "TooltipMessage";
69
+
70
+ export default TooltipMessage;
@@ -0,0 +1,32 @@
1
+ "use client";
2
+
3
+ import * as TooltipPrimitive from "@radix-ui/react-tooltip";
4
+ import type { TooltipRootProps } from "../types";
5
+
6
+ /**
7
+ * Tooltip Root.
8
+ * @component
9
+ * @param {TooltipRootProps} props Root props
10
+ * @param {React.ReactNode} props.children Tooltip 하위 노드
11
+ * @param {TooltipProviderProps} [props.providerProps] Provider 전달 props
12
+ * @param {boolean} [props.open] 제어형 open 상태
13
+ * @param {boolean} [props.defaultOpen] 비제어 초기 open 상태
14
+ * @param {(open: boolean) => void} [props.onOpenChange] open 상태 변경 핸들러
15
+ * @example
16
+ * <Tooltip.Root>
17
+ * <Tooltip.Trigger asChild><button>trigger</button></Tooltip.Trigger>
18
+ * <Tooltip.Message>메시지</Tooltip.Message>
19
+ * </Tooltip.Root>
20
+ */
21
+ export default function TooltipRoot({
22
+ children,
23
+ providerProps,
24
+ ...restProps
25
+ }: TooltipRootProps) {
26
+ // 변경: 기본 hover delay를 0으로 고정해 즉시 표시를 기본 동작으로 제공한다.
27
+ return (
28
+ <TooltipPrimitive.Provider delayDuration={0} {...providerProps}>
29
+ <TooltipPrimitive.Root {...restProps}>{children}</TooltipPrimitive.Root>
30
+ </TooltipPrimitive.Provider>
31
+ );
32
+ }
@@ -0,0 +1,46 @@
1
+ "use client";
2
+
3
+ // 변경: Tooltip 기본 아이콘 에셋을 info.svg로 교체한다.
4
+ import InformationIcon from "../img/info.svg";
5
+ import type { TooltipTemplateProps } from "../types";
6
+ import TooltipMessage from "./Message";
7
+ import TooltipRoot from "./Root";
8
+ import TooltipTrigger from "./Trigger";
9
+
10
+ /**
11
+ * Tooltip Template.
12
+ * @component
13
+ * @param {TooltipTemplateProps} props Template props
14
+ * @param {React.ReactNode} props.message Tooltip 메시지 콘텐츠
15
+ * @param {string} [props.triggerAriaLabel="정보 툴팁"] 기본 Trigger aria-label
16
+ * @param {TooltipRootProps} [props.rootProps] Tooltip.Root 전달 props
17
+ * @param {TooltipTriggerProps} [props.triggerProps] Tooltip.Trigger 전달 props
18
+ * @param {TooltipMessageProps} [props.messageProps] Tooltip.Message 전달 props
19
+ * @example
20
+ * <Tooltip.Template message="사육 공간을 제외한 나머지 공간의 크기 입니다." />
21
+ */
22
+ const TooltipTemplate = ({
23
+ message,
24
+ triggerAriaLabel = "정보 툴팁",
25
+ rootProps,
26
+ triggerProps,
27
+ messageProps,
28
+ }: TooltipTemplateProps) => {
29
+ return (
30
+ <TooltipRoot {...rootProps}>
31
+ <TooltipTrigger asChild {...triggerProps}>
32
+ {/* 변경: Template은 Figma 기준 정보 아이콘 trigger를 기본 제공한다. */}
33
+ <button
34
+ type="button"
35
+ aria-label={triggerAriaLabel}
36
+ className="tooltip-template-trigger"
37
+ >
38
+ <InformationIcon aria-hidden />
39
+ </button>
40
+ </TooltipTrigger>
41
+ <TooltipMessage {...messageProps}>{message}</TooltipMessage>
42
+ </TooltipRoot>
43
+ );
44
+ };
45
+
46
+ export default TooltipTemplate;
@@ -0,0 +1,32 @@
1
+ "use client";
2
+
3
+ import clsx from "clsx";
4
+ import * as TooltipPrimitive from "@radix-ui/react-tooltip";
5
+ import { forwardRef } from "react";
6
+ import type { TooltipTriggerProps } from "../types";
7
+
8
+ /**
9
+ * Tooltip Trigger.
10
+ * @component
11
+ * @param {TooltipTriggerProps} props Trigger props
12
+ * @param {React.ReactNode} [props.children] Trigger 콘텐츠
13
+ * @param {boolean} [props.asChild] child를 trigger로 사용할지 여부
14
+ * @param {string} [props.className] Trigger className
15
+ * @example
16
+ * <Tooltip.Trigger asChild><button>trigger</button></Tooltip.Trigger>
17
+ */
18
+ const TooltipTrigger = forwardRef<HTMLButtonElement, TooltipTriggerProps>(
19
+ ({ children, className, ...restProps }, ref) => (
20
+ <TooltipPrimitive.Trigger
21
+ ref={ref}
22
+ className={clsx("tooltip-trigger", className)}
23
+ {...restProps}
24
+ >
25
+ {children}
26
+ </TooltipPrimitive.Trigger>
27
+ ),
28
+ );
29
+
30
+ TooltipTrigger.displayName = "TooltipTrigger";
31
+
32
+ export default TooltipTrigger;
@@ -0,0 +1,18 @@
1
+ import TooltipMessage from "./Message";
2
+ import TooltipRoot from "./Root";
3
+ import TooltipTemplate from "./Template";
4
+ import TooltipTrigger from "./Trigger";
5
+
6
+ /**
7
+ * Tooltip namespace.
8
+ * - Message
9
+ * - Trigger
10
+ * - Root
11
+ * - Template
12
+ */
13
+ export const Tooltip = {
14
+ Message: TooltipMessage,
15
+ Trigger: TooltipTrigger,
16
+ Root: TooltipRoot,
17
+ Template: TooltipTemplate,
18
+ };
@@ -0,0 +1,2 @@
1
+ @use "./variables.scss";
2
+ @use "./tooltip.scss";
@@ -0,0 +1,47 @@
1
+ .tooltip-trigger {
2
+ display: inline-flex;
3
+ align-items: center;
4
+ justify-content: center;
5
+ }
6
+
7
+ .tooltip-template-trigger {
8
+ display: inline-flex;
9
+ width: var(--tooltip-trigger-icon-size);
10
+ height: var(--tooltip-trigger-icon-size);
11
+ align-items: center;
12
+ justify-content: center;
13
+ padding: 0;
14
+ border: 0;
15
+ background-color: transparent;
16
+ color: var(--tooltip-trigger-icon-color);
17
+ cursor: pointer;
18
+ }
19
+
20
+ .tooltip-template-trigger svg {
21
+ width: 100%;
22
+ height: 100%;
23
+ display: block;
24
+ }
25
+
26
+ .tooltip-message {
27
+ max-width: min(20rem, calc(100vw - 1.5rem));
28
+ box-sizing: border-box;
29
+ border-radius: var(--tooltip-message-radius);
30
+ background-color: var(--tooltip-message-background);
31
+ padding: var(--tooltip-message-padding-block)
32
+ var(--tooltip-message-padding-inline);
33
+ }
34
+
35
+ .tooltip-message-text {
36
+ display: block;
37
+ color: var(--tooltip-message-foreground);
38
+ font-size: var(--tooltip-message-font-size);
39
+ line-height: var(--tooltip-message-line-height);
40
+ letter-spacing: var(--tooltip-message-letter-spacing);
41
+ font-weight: var(--tooltip-message-font-weight);
42
+ white-space: normal;
43
+ }
44
+
45
+ .tooltip-message-arrow {
46
+ fill: var(--tooltip-message-background);
47
+ }
@@ -0,0 +1,14 @@
1
+ :root {
2
+ --tooltip-message-background: var(--color-cool-gray-20);
3
+ --tooltip-message-foreground: var(--color-common-100);
4
+ --tooltip-message-radius: var(--theme-radius-medium-3);
5
+ --tooltip-message-padding-inline: var(--spacing-padding-5);
6
+ --tooltip-message-padding-block: var(--spacing-padding-4);
7
+ --tooltip-message-font-size: var(--font-caption-large-size);
8
+ --tooltip-message-line-height: var(--font-caption-large-line-height);
9
+ --tooltip-message-letter-spacing: var(--font-caption-large-letter-spacing);
10
+ --tooltip-message-font-weight: 400;
11
+
12
+ --tooltip-trigger-icon-size: 16px;
13
+ --tooltip-trigger-icon-color: var(--color-label-alternative);
14
+ }
@@ -0,0 +1 @@
1
+ export type * from "./props";
@@ -0,0 +1,118 @@
1
+ import type {
2
+ TooltipArrowProps as RadixTooltipArrowProps,
3
+ TooltipContentProps as RadixTooltipContentProps,
4
+ TooltipProps as RadixTooltipProps,
5
+ TooltipProviderProps as RadixTooltipProviderProps,
6
+ TooltipTriggerProps as RadixTooltipTriggerProps,
7
+ } from "@radix-ui/react-tooltip";
8
+ import type { ReactNode } from "react";
9
+
10
+ /**
11
+ * Tooltip Root props.
12
+ * @property {ReactNode} children Tooltip 하위 노드
13
+ * @property {RadixTooltipProviderProps} [providerProps] Radix Tooltip Provider 전달 props
14
+ * @see Radix TooltipProps
15
+ */
16
+ export interface TooltipRootProps extends RadixTooltipProps {
17
+ /**
18
+ * Tooltip 하위 노드
19
+ */
20
+ children: ReactNode;
21
+ /**
22
+ * Radix Tooltip Provider 전달 props
23
+ */
24
+ providerProps?: RadixTooltipProviderProps;
25
+ }
26
+
27
+ /**
28
+ * Tooltip Trigger props.
29
+ * @property {ReactNode} [children] Trigger 내부 콘텐츠
30
+ * @property {string} [className] Trigger className
31
+ * @see Radix TooltipTriggerProps
32
+ */
33
+ export interface TooltipTriggerProps extends RadixTooltipTriggerProps {
34
+ /**
35
+ * Trigger 내부 콘텐츠
36
+ */
37
+ children?: ReactNode;
38
+ /**
39
+ * Trigger className
40
+ */
41
+ className?: string;
42
+ }
43
+
44
+ /**
45
+ * Tooltip Message props.
46
+ * @property {ReactNode} children Tooltip 본문 콘텐츠
47
+ * @property {string} [className] Content className
48
+ * @property {boolean} [withPortal=true] Portal 사용 여부
49
+ * @property {HTMLElement | null} [portalContainer] Portal 컨테이너
50
+ * @property {boolean} [withArrow=true] Arrow 렌더링 여부
51
+ * @property {string} [arrowClassName] Arrow className
52
+ * @property {RadixTooltipArrowProps} [arrowProps] Arrow 전달 props
53
+ * @see Radix TooltipContentProps
54
+ */
55
+ export interface TooltipMessageProps extends Omit<
56
+ RadixTooltipContentProps,
57
+ "children"
58
+ > {
59
+ /**
60
+ * Tooltip 본문 콘텐츠
61
+ */
62
+ children: ReactNode;
63
+ /**
64
+ * Content className
65
+ */
66
+ className?: string;
67
+ /**
68
+ * Portal 사용 여부
69
+ */
70
+ withPortal?: boolean;
71
+ /**
72
+ * Portal 컨테이너
73
+ */
74
+ portalContainer?: HTMLElement | null;
75
+ /**
76
+ * Arrow 렌더링 여부
77
+ */
78
+ withArrow?: boolean;
79
+ /**
80
+ * Arrow className
81
+ */
82
+ arrowClassName?: string;
83
+ /**
84
+ * Arrow 전달 props
85
+ */
86
+ arrowProps?: RadixTooltipArrowProps;
87
+ }
88
+
89
+ /**
90
+ * Tooltip Template props.
91
+ * @property {ReactNode} message Tooltip 메시지 콘텐츠
92
+ * @property {string} [triggerAriaLabel="정보 툴팁"] 기본 Trigger aria-label
93
+ * @property {TooltipRootProps} [rootProps] Tooltip.Root 전달 props
94
+ * @property {TooltipTriggerProps} [triggerProps] Tooltip.Trigger 전달 props
95
+ * @property {TooltipMessageProps} [messageProps] Tooltip.Message 전달 props
96
+ */
97
+ export interface TooltipTemplateProps {
98
+ /**
99
+ * Tooltip 메시지 콘텐츠
100
+ */
101
+ message: ReactNode;
102
+ /**
103
+ * 기본 Trigger aria-label
104
+ */
105
+ triggerAriaLabel?: string;
106
+ /**
107
+ * Tooltip.Root 전달 props
108
+ */
109
+ rootProps?: Omit<TooltipRootProps, "children">;
110
+ /**
111
+ * Tooltip.Trigger 전달 props
112
+ */
113
+ triggerProps?: Omit<TooltipTriggerProps, "children" | "asChild">;
114
+ /**
115
+ * Tooltip.Message 전달 props
116
+ */
117
+ messageProps?: Omit<TooltipMessageProps, "children">;
118
+ }
package/src/index.scss CHANGED
@@ -7,6 +7,7 @@
7
7
  @use "./components/drawer";
8
8
  @use "./components/dropdown";
9
9
  @use "./components/pop-over";
10
+ @use "./components/tooltip";
10
11
  @use "./components/label";
11
12
  @use "./components/input";
12
13
  @use "./components/select";