@idbrnd/design-system 1.3.4 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +69 -3
- package/dist/components/Select/Select.d.ts +1 -1
- package/dist/components/Select/Select.types.d.ts +1 -1
- package/dist/components/Tooltip/Tooltip.d.ts +10 -0
- package/dist/components/Tooltip/Tooltip.types.d.ts +97 -0
- package/dist/components/Tooltip/useTooltip.d.ts +11 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1335 -1149
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @idbrnd/design-system
|
|
2
2
|
|
|
3
|
-

|
|
4
4
|

|
|
5
5
|

|
|
6
6
|

|
|
@@ -55,6 +55,7 @@ export default function App() {
|
|
|
55
55
|
- [Toast](#toast)
|
|
56
56
|
- [Snackbar](#snackbar)
|
|
57
57
|
- [PushBadge](#pushbadge)
|
|
58
|
+
- [Tooltip](#tooltip)
|
|
58
59
|
- [Select](#select)
|
|
59
60
|
- [Dropdown](#dropdown)
|
|
60
61
|
- [Content](#content)
|
|
@@ -480,6 +481,66 @@ import { PushBadge } from "@idbrnd/design-system";
|
|
|
480
481
|
| `count` | `number` | — | `variant="number"` 시 표시할 숫자 |
|
|
481
482
|
| `customStyle` | `CSSProperties` | — | 추가 인라인 스타일 |
|
|
482
483
|
|
|
484
|
+
### Tooltip
|
|
485
|
+
|
|
486
|
+
트리거 엘리먼트에 마우스를 올리거나 클릭하면 말풍선 형태의 안내 텍스트를 표시하는 컴포넌트입니다.
|
|
487
|
+
|
|
488
|
+
```tsx
|
|
489
|
+
import { Tooltip } from "@idbrnd/design-system";
|
|
490
|
+
|
|
491
|
+
<Tooltip content="안녕하세요!" position="top">
|
|
492
|
+
<button>Hover me</button>
|
|
493
|
+
</Tooltip>
|
|
494
|
+
```
|
|
495
|
+
|
|
496
|
+
**클릭 트리거 + render function**
|
|
497
|
+
|
|
498
|
+
```tsx
|
|
499
|
+
<Tooltip
|
|
500
|
+
trigger="click"
|
|
501
|
+
position="bottom"
|
|
502
|
+
content={(close) => (
|
|
503
|
+
<div>
|
|
504
|
+
<span>메시지를 작성해요.</span>
|
|
505
|
+
<button onClick={close}>닫기</button>
|
|
506
|
+
</div>
|
|
507
|
+
)}
|
|
508
|
+
>
|
|
509
|
+
<button>Click me</button>
|
|
510
|
+
</Tooltip>
|
|
511
|
+
```
|
|
512
|
+
|
|
513
|
+
**말줄임 시에만 표시**
|
|
514
|
+
|
|
515
|
+
```tsx
|
|
516
|
+
<Tooltip content="긴 텍스트 전체 내용" visibleOnEllipsis>
|
|
517
|
+
<span style={{ overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }}>
|
|
518
|
+
긴 텍스트 전체 내용
|
|
519
|
+
</span>
|
|
520
|
+
</Tooltip>
|
|
521
|
+
```
|
|
522
|
+
|
|
523
|
+
| Prop | 타입 | 기본값 | 설명 |
|
|
524
|
+
| ------------------ | -------------------------------------------------------------------------------------------------- | ----------- | ----------------------------------------------------------------- |
|
|
525
|
+
| `content` | `ReactNode \| ((close: () => void) => ReactNode)` | — | **(필수)** 툴팁에 표시할 내용. render function 전달 시 `close` 콜백 사용 가능 |
|
|
526
|
+
| `trigger` | `"hover"` \| `"click"` | `"hover"` | 트리거 방식 |
|
|
527
|
+
| `variant` | `"default"` \| `"compact"` | `"default"` | 크기 변형. default: 8px 12px, compact: 4px 12px |
|
|
528
|
+
| `position` | `"top"` \| `"top-left"` \| `"top-right"` \| `"bottom"` \| `"bottom-left"` \| `"bottom-right"` \| `"left"` \| `"left-top"` \| `"left-bottom"` \| `"right"` \| `"right-top"` \| `"right-bottom"` | `"top"` | 툴팁 표시 위치 (12방향) |
|
|
529
|
+
| `arrow` | `boolean` | `true` | 화살표(꼬리표) 표시 여부 |
|
|
530
|
+
| `as` | `keyof JSX.IntrinsicElements` | `"span"` | 트리거 래퍼 HTML 태그 |
|
|
531
|
+
| `visibleOnEllipsis`| `boolean` | `false` | `true` 시 자식에 말줄임이 발생했을 때만 툴팁 표시 |
|
|
532
|
+
| `backgroundColor` | `string` | — | 툴팁 배경색 커스터마이징 |
|
|
533
|
+
| `contentColor` | `string` | — | 툴팁 텍스트 색상 커스터마이징 |
|
|
534
|
+
| `customStyle` | `CSSProperties` | — | 툴팁 박스에 적용할 추가 인라인 스타일 |
|
|
535
|
+
| `children` | `ReactNode` | — | **(필수)** 툴팁을 트리거할 자식 엘리먼트 |
|
|
536
|
+
|
|
537
|
+
유의사항:
|
|
538
|
+
|
|
539
|
+
- `trigger="click"` 시 외부 클릭, 스크롤, 리사이즈 시 자동으로 닫힙니다.
|
|
540
|
+
- `position`의 첫 번째 단어는 툴팁이 놓이는 방향, 두 번째 단어는 화살표가 치우치는 방향입니다.
|
|
541
|
+
- `content`에 render function을 전달하면 닫기 버튼 등 인터랙션을 구현할 수 있습니다.
|
|
542
|
+
- 툴팁은 `document.body`에 포탈로 렌더링됩니다.
|
|
543
|
+
|
|
483
544
|
---
|
|
484
545
|
|
|
485
546
|
## Select
|
|
@@ -506,7 +567,7 @@ function SelectExample() {
|
|
|
506
567
|
heading="과일 선택"
|
|
507
568
|
placeholder="선택해주세요."
|
|
508
569
|
options={options}
|
|
509
|
-
|
|
570
|
+
selectedValue={selected}
|
|
510
571
|
onSelect={setSelected}
|
|
511
572
|
/>
|
|
512
573
|
);
|
|
@@ -544,7 +605,7 @@ function SelectExample() {
|
|
|
544
605
|
| Prop | 타입 | 기본값 | 설명 |
|
|
545
606
|
| ---------------- | -------------------------------------------------------- | ----------------- | ------------------------------------------------------------- |
|
|
546
607
|
| `options` | `DropdownOption[]` | `[]` | 드롭다운에 표시할 옵션 배열. `{ label, value, icon? }` 형태 |
|
|
547
|
-
| `
|
|
608
|
+
| `selectedValue` | `DropdownOption \| null` | — | 현재 선택된 옵션 |
|
|
548
609
|
| `onSelect` | `(option: DropdownOption) => void` | — | 옵션 선택 시 호출되는 콜백 |
|
|
549
610
|
| `variant` | `"default"` \| `"choosing"` \| `"error"` \| `"selected"` | `"default"` | 트리거 상태. `choosing`/`selected`는 자동 적용 |
|
|
550
611
|
| `size` | `"large"` \| `"medium"` \| `"small"` | `"medium"` | 트리거 높이. large: 44px, medium: 40px, small: 36px |
|
|
@@ -778,6 +839,11 @@ import type {
|
|
|
778
839
|
ToggleSwitchSize,
|
|
779
840
|
ToastShowOptions,
|
|
780
841
|
SnackbarShowOptions,
|
|
842
|
+
TooltipProps,
|
|
843
|
+
TooltipPosition,
|
|
844
|
+
TooltipVariant,
|
|
845
|
+
TooltipTrigger,
|
|
846
|
+
TooltipContent,
|
|
781
847
|
ContentBadgeProps,
|
|
782
848
|
ContentBadgeVariant,
|
|
783
849
|
ContentBadgeSize,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { SelectProps } from './Select.types';
|
|
2
2
|
export type { SelectAlign, SelectProps, SelectSize, SelectType, SelectVariant, } from './Select.types';
|
|
3
|
-
declare function Select({ variant, size, heading, required, leadingContent, description, disabled, placeholder,
|
|
3
|
+
declare function Select({ variant, size, heading, required, leadingContent, description, disabled, placeholder, selectedValue, onSelect, options, type, align, content, buttonWidth, descriptionWidth, customStyle, textColor, }: SelectProps): import("react/jsx-runtime").JSX.Element;
|
|
4
4
|
export default Select;
|
|
@@ -44,7 +44,7 @@ export interface SelectProps {
|
|
|
44
44
|
*/
|
|
45
45
|
placeholder?: ReactNode;
|
|
46
46
|
/** 현재 선택된 옵션. */
|
|
47
|
-
|
|
47
|
+
selectedValue?: DropdownOption | null;
|
|
48
48
|
/** 옵션 선택 시 콜백. */
|
|
49
49
|
onSelect?: (option: DropdownOption) => void;
|
|
50
50
|
/** 드롭다운 옵션 목록. (기본값: 빈 배열) */
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { TooltipProps, TooltipState } from './Tooltip.types';
|
|
2
|
+
export interface TooltipPortalProps {
|
|
3
|
+
tooltip: TooltipState | null;
|
|
4
|
+
backgroundColor?: string;
|
|
5
|
+
contentColor?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function TooltipPortal({ tooltip, backgroundColor, contentColor }: TooltipPortalProps): import("react").ReactPortal | null;
|
|
8
|
+
declare function Tooltip({ content, trigger, variant, position, arrow, as, visibleOnEllipsis, // 자식 엘리먼트에 말줄임(ellipsis)이 발생했을 때만 툴팁을 표시.
|
|
9
|
+
backgroundColor, contentColor, customStyle, children, }: TooltipProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export default Tooltip;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import type { CSSProperties, ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* 툴팁이 표시될 위치 (12방향).
|
|
4
|
+
*
|
|
5
|
+
* 첫 번째 단어 = 툴팁이 놓이는 방향
|
|
6
|
+
* 두 번째 단어 = 화살표가 치우치는 방향
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* 'top' → 트리거 위 중앙
|
|
10
|
+
* 'top-left' → 트리거 위, 왼쪽 정렬
|
|
11
|
+
* 'right-bottom' → 트리거 오른쪽, 아래 정렬
|
|
12
|
+
*/
|
|
13
|
+
export type TooltipPosition = 'top-left' | 'top' | 'top-right' | 'right-top' | 'right' | 'right-bottom' | 'bottom-left' | 'bottom' | 'bottom-right' | 'left-top' | 'left' | 'left-bottom';
|
|
14
|
+
/**
|
|
15
|
+
* 툴팁 크기 변형.
|
|
16
|
+
* - `'default'` : 넉넉한 패딩 (8px 12px)
|
|
17
|
+
* - `'compact'` : 작은 패딩 (4px 12px)
|
|
18
|
+
*/
|
|
19
|
+
export type TooltipVariant = 'default' | 'compact';
|
|
20
|
+
/**
|
|
21
|
+
* 툴팁 트리거 방식.
|
|
22
|
+
* - `'hover'` : 마우스를 올리면 표시, 벗어나면 숨김
|
|
23
|
+
* - `'click'` : 클릭하면 토글, 외부 클릭 시 숨김
|
|
24
|
+
*/
|
|
25
|
+
export type TooltipTrigger = 'hover' | 'click';
|
|
26
|
+
/**
|
|
27
|
+
* 툴팁 콘텐츠 타입.
|
|
28
|
+
*
|
|
29
|
+
* - `ReactNode` — 단순 텍스트나 JSX를 바로 전달
|
|
30
|
+
* - `(close) => ReactNode` — 툴팁을 닫는 `close` 콜백을 받는 render function.
|
|
31
|
+
* 닫기 버튼이나 액션 버튼 등 인터랙션이 필요할 때 사용.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* // 단순 텍스트
|
|
35
|
+
* content="안녕하세요"
|
|
36
|
+
*
|
|
37
|
+
* // render function — 닫기 버튼 + 액션
|
|
38
|
+
* content={(close) => (
|
|
39
|
+
* <div>
|
|
40
|
+
* <span>메시지</span>
|
|
41
|
+
* <button onClick={close}>닫기</button>
|
|
42
|
+
* </div>
|
|
43
|
+
* )}
|
|
44
|
+
*/
|
|
45
|
+
export type TooltipContent = ReactNode | ((close: () => void) => ReactNode);
|
|
46
|
+
export interface TooltipProps {
|
|
47
|
+
/**
|
|
48
|
+
* 툴팁에 표시할 내용.
|
|
49
|
+
* 문자열·JSX를 직접 전달하거나, `(close) => ReactNode` 형태의 render function을 전달.
|
|
50
|
+
*/
|
|
51
|
+
content: TooltipContent;
|
|
52
|
+
/**
|
|
53
|
+
* 트리거 방식.
|
|
54
|
+
* @default 'hover'
|
|
55
|
+
*/
|
|
56
|
+
trigger?: TooltipTrigger;
|
|
57
|
+
/**
|
|
58
|
+
* 크기 변형.
|
|
59
|
+
* @default 'default'
|
|
60
|
+
*/
|
|
61
|
+
variant?: TooltipVariant;
|
|
62
|
+
/**
|
|
63
|
+
* 툴팁이 표시될 위치 (12방향).
|
|
64
|
+
* @default 'top'
|
|
65
|
+
*/
|
|
66
|
+
position?: TooltipPosition;
|
|
67
|
+
/**
|
|
68
|
+
* 화살표(꼬리표) 표시 여부.
|
|
69
|
+
* @default true
|
|
70
|
+
*/
|
|
71
|
+
arrow?: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* 트리거를 감싸는 래퍼 HTML 태그.
|
|
74
|
+
* 기본값은 `'span'`. 테이블 셀 등에서는 `'td'`, `'div'` 등으로 변경.
|
|
75
|
+
* @default 'span'
|
|
76
|
+
*/
|
|
77
|
+
as?: keyof JSX.IntrinsicElements;
|
|
78
|
+
/**
|
|
79
|
+
* `true`이면 자식 엘리먼트에 말줄임(ellipsis)이 발생했을 때만 툴팁을 표시.
|
|
80
|
+
* @default false
|
|
81
|
+
*/
|
|
82
|
+
visibleOnEllipsis?: boolean;
|
|
83
|
+
/** 툴팁 배경색 커스터마이징. 미지정 시 디자인 토큰 기본색 사용. */
|
|
84
|
+
backgroundColor?: string;
|
|
85
|
+
/** 툴팁 텍스트·아이콘 색상 커스터마이징. 미지정 시 디자인 토큰 기본색 사용. */
|
|
86
|
+
contentColor?: string;
|
|
87
|
+
/** 툴팁 박스에 적용할 추가 인라인 스타일. */
|
|
88
|
+
customStyle?: CSSProperties;
|
|
89
|
+
/** 툴팁을 트리거할 자식 엘리먼트. */
|
|
90
|
+
children: ReactNode;
|
|
91
|
+
}
|
|
92
|
+
/** 내부용 — useTooltip hook이 관리하는 툴팁 상태. */
|
|
93
|
+
export interface TooltipState {
|
|
94
|
+
content: ReactNode;
|
|
95
|
+
rect: DOMRect;
|
|
96
|
+
position: TooltipPosition;
|
|
97
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { TooltipPosition, TooltipState } from './Tooltip.types';
|
|
3
|
+
export declare function calcTooltipPosition(rect: DOMRect, tooltipEl: HTMLDivElement, position: TooltipPosition): {
|
|
4
|
+
top: number;
|
|
5
|
+
left: number;
|
|
6
|
+
};
|
|
7
|
+
export declare function useTooltip(): {
|
|
8
|
+
readonly tooltip: TooltipState | null;
|
|
9
|
+
readonly showTooltip: (el: HTMLElement, content: ReactNode, position: TooltipPosition) => void;
|
|
10
|
+
readonly hideTooltip: () => void;
|
|
11
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -40,3 +40,5 @@ export { default as Select } from "./components/Select/Select";
|
|
|
40
40
|
export type { SelectProps, SelectVariant, SelectSize, SelectType, SelectAlign, } from "./components/Select/Select";
|
|
41
41
|
export { default as Dropdown } from "./components/Dropdown/Dropdown";
|
|
42
42
|
export type { DropdownProps, DropdownType, DropdownAlign, DropdownOption, } from "./components/Dropdown/Dropdown.types";
|
|
43
|
+
export { default as Tooltip } from "./components/Tooltip/Tooltip";
|
|
44
|
+
export type { TooltipProps, TooltipPosition, TooltipVariant, TooltipTrigger, TooltipContent, } from "./components/Tooltip/Tooltip.types";
|