@idbrnd/design-system 1.0.0 → 1.1.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 +406 -0
- package/dist/components/Control/CheckBox/CheckBox.d.ts +15 -0
- package/dist/components/Control/Radio/Radio.d.ts +13 -0
- package/dist/components/Control/ToggleSwitch/ToggleSwitch.d.ts +10 -0
- package/dist/components/Input/Input.d.ts +1 -1
- package/dist/components/Input/Input.types.d.ts +4 -3
- package/dist/components/Input/useInputState.d.ts +1 -3
- package/dist/components/SearchBar/SearchBar.d.ts +7 -2
- package/dist/index.d.ts +34 -28
- package/dist/index.js +916 -692
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,406 @@
|
|
|
1
|
+
# @idbrnd/design-system
|
|
2
|
+
|
|
3
|
+
React 기반 IDB 디자인 시스템 컴포넌트 라이브러리입니다.
|
|
4
|
+
|
|
5
|
+
## 설치
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @idbrnd/design-system
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
`peerDependencies`
|
|
12
|
+
|
|
13
|
+
- `react@^18.3.1`
|
|
14
|
+
- `react-dom@^18.3.1`
|
|
15
|
+
|
|
16
|
+
## 시작하기
|
|
17
|
+
|
|
18
|
+
엔트리 파일(예: `src/main.tsx`)에서 스타일을 먼저 로드한 뒤 컴포넌트를 사용합니다.
|
|
19
|
+
|
|
20
|
+
```tsx
|
|
21
|
+
import "@idbrnd/design-system/style.css";
|
|
22
|
+
import { FillButton } from "@idbrnd/design-system";
|
|
23
|
+
|
|
24
|
+
export default function App() {
|
|
25
|
+
return <FillButton>확인</FillButton>;
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## 제공 컴포넌트 / API
|
|
30
|
+
|
|
31
|
+
- 버튼
|
|
32
|
+
- `FillButton`
|
|
33
|
+
- `OutlineButton`
|
|
34
|
+
- `TextButton`
|
|
35
|
+
- `WeakButton`
|
|
36
|
+
- `BasicIconButton`
|
|
37
|
+
- `FillIconButton`
|
|
38
|
+
- `OutlineIconButton`
|
|
39
|
+
- 입력
|
|
40
|
+
- `Input`
|
|
41
|
+
- `SearchBar`
|
|
42
|
+
- 컨트롤
|
|
43
|
+
- `CheckBox`
|
|
44
|
+
- `Radio`
|
|
45
|
+
- `ToggleSwitch`
|
|
46
|
+
- 피드백
|
|
47
|
+
- `showToast`, `dismissToast`
|
|
48
|
+
- `showSnackbar`, `dismissSnackbar`
|
|
49
|
+
- `Spinner`, `CustomSpinner`, `Clip`, `FadeSpinner`
|
|
50
|
+
- 기타
|
|
51
|
+
- `PushBadge`
|
|
52
|
+
|
|
53
|
+
## 사용 예시
|
|
54
|
+
|
|
55
|
+
### 1. Fill / Outline / Text / Weak Button
|
|
56
|
+
|
|
57
|
+
```tsx
|
|
58
|
+
import {
|
|
59
|
+
FillButton,
|
|
60
|
+
OutlineButton,
|
|
61
|
+
TextButton,
|
|
62
|
+
WeakButton,
|
|
63
|
+
} from "@idbrnd/design-system";
|
|
64
|
+
|
|
65
|
+
function ButtonExample() {
|
|
66
|
+
return (
|
|
67
|
+
<>
|
|
68
|
+
<FillButton variant="primary">저장</FillButton>
|
|
69
|
+
<OutlineButton variant="secondary">취소</OutlineButton>
|
|
70
|
+
<TextButton size="small" variant="assistive">
|
|
71
|
+
텍스트 버튼
|
|
72
|
+
</TextButton>
|
|
73
|
+
<WeakButton size="xsmall" variant="error">
|
|
74
|
+
삭제
|
|
75
|
+
</WeakButton>
|
|
76
|
+
</>
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### 2. Icon Button + PushBadge
|
|
82
|
+
|
|
83
|
+
```tsx
|
|
84
|
+
import {
|
|
85
|
+
BasicIconButton,
|
|
86
|
+
FillIconButton,
|
|
87
|
+
OutlineIconButton,
|
|
88
|
+
PushBadge,
|
|
89
|
+
} from "@idbrnd/design-system";
|
|
90
|
+
|
|
91
|
+
function IconButtonExample() {
|
|
92
|
+
return (
|
|
93
|
+
<>
|
|
94
|
+
<div style={{ position: "relative", width: "fit-content" }}>
|
|
95
|
+
<BasicIconButton>+</BasicIconButton>
|
|
96
|
+
<PushBadge variant="dot" />
|
|
97
|
+
</div>
|
|
98
|
+
|
|
99
|
+
<FillIconButton variant="primary" size="large">
|
|
100
|
+
+
|
|
101
|
+
</FillIconButton>
|
|
102
|
+
|
|
103
|
+
<OutlineIconButton size="medium">+</OutlineIconButton>
|
|
104
|
+
</>
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
`PushBadge` 단독 사용:
|
|
110
|
+
|
|
111
|
+
```tsx
|
|
112
|
+
import { PushBadge } from "@idbrnd/design-system";
|
|
113
|
+
|
|
114
|
+
function PushBadgeExample() {
|
|
115
|
+
return (
|
|
116
|
+
<>
|
|
117
|
+
<PushBadge variant="number" count={32} />
|
|
118
|
+
<PushBadge variant="info" />
|
|
119
|
+
<PushBadge variant="dot" />
|
|
120
|
+
</>
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### 3. Input (Controlled)
|
|
126
|
+
|
|
127
|
+
`Input`은 `value` + `onChange`를 받는 controlled 컴포넌트입니다.
|
|
128
|
+
|
|
129
|
+
```tsx
|
|
130
|
+
import { useState } from "react";
|
|
131
|
+
import { Input } from "@idbrnd/design-system";
|
|
132
|
+
|
|
133
|
+
function InputExample() {
|
|
134
|
+
const [email, setEmail] = useState("");
|
|
135
|
+
|
|
136
|
+
return (
|
|
137
|
+
<Input
|
|
138
|
+
headingContent="이메일"
|
|
139
|
+
placeholder="이메일을 입력하세요"
|
|
140
|
+
value={email}
|
|
141
|
+
onChange={(event) => setEmail(event.target.value)}
|
|
142
|
+
description="가입 안내 메일을 받을 주소입니다."
|
|
143
|
+
/>
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
유의사항:
|
|
149
|
+
|
|
150
|
+
- `heading={false}`이면 상단 라벨과 `required` 별표 표시는 렌더링되지 않습니다. 다만 실제 `<input>`의 `required` 속성은 그대로 적용됩니다.
|
|
151
|
+
- `description`은 문자열뿐 아니라 JSX도 받을 수 있습니다. `variant="error"`일 때는 `description` 대신 `errorMessage`가 우선 노출됩니다.
|
|
152
|
+
- `errorMessage`도 문자열뿐 아니라 JSX를 받을 수 있습니다.
|
|
153
|
+
- `leadingIcon`, `headingContent`, `trailingContent`는 모두 JSX를 넣을 수 있습니다. 특히 `trailingContent`에는 버튼, 텍스트, 아이콘 조합 등 원하는 형태의 trailing UI를 구성할 수 있습니다.
|
|
154
|
+
- `width`는 `number | string`을 지원하며, 지정하지 않으면 기본값은 `100%`입니다.
|
|
155
|
+
- `variant`를 지정하지 않으면 값 존재 여부에 따라 내부적으로 `basic` 또는 `typed` 상태가 자동 적용됩니다.
|
|
156
|
+
|
|
157
|
+
### 4. SearchBar
|
|
158
|
+
|
|
159
|
+
`SearchBar`는 `Enter` 입력 또는 우측 검색 버튼 클릭 시 `onSearch`를 호출합니다.
|
|
160
|
+
우측 삭제 버튼은 입력값이 있을 때만 표시되며, `onClear`를 전달하면 커스텀 삭제 동작을 사용할 수 있습니다.
|
|
161
|
+
`variant="default"`는 내부 `Input`의 `basic`에 매핑되며, `onTyping`/`typed`/`error`도 각각 대응됩니다.
|
|
162
|
+
|
|
163
|
+
```tsx
|
|
164
|
+
import { useState } from "react";
|
|
165
|
+
import { SearchBar } from "@idbrnd/design-system";
|
|
166
|
+
|
|
167
|
+
function SearchExample() {
|
|
168
|
+
const [keyword, setKeyword] = useState("");
|
|
169
|
+
|
|
170
|
+
return (
|
|
171
|
+
<SearchBar
|
|
172
|
+
value={keyword}
|
|
173
|
+
onChange={(event) => setKeyword(event.target.value)}
|
|
174
|
+
onSearch={(value) => {
|
|
175
|
+
console.log("search:", value);
|
|
176
|
+
}}
|
|
177
|
+
placeholder="검색어를 입력하세요"
|
|
178
|
+
/>
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### 5. CheckBox
|
|
184
|
+
|
|
185
|
+
`CheckBox`는 `checked` + `onChange`를 받는 controlled 컴포넌트입니다.
|
|
186
|
+
`indeterminate`는 `checked={true}`와 함께 사용하면 체크 아이콘 대신 대시(–) 아이콘을 표시합니다.
|
|
187
|
+
|
|
188
|
+
```tsx
|
|
189
|
+
import { useState } from "react";
|
|
190
|
+
import { CheckBox } from "@idbrnd/design-system";
|
|
191
|
+
|
|
192
|
+
function CheckBoxExample() {
|
|
193
|
+
const [checked, setChecked] = useState(false);
|
|
194
|
+
const [indeterminate, setIndeterminate] = useState(false);
|
|
195
|
+
|
|
196
|
+
return (
|
|
197
|
+
<>
|
|
198
|
+
{/* 기본 */}
|
|
199
|
+
<CheckBox checked={checked} onChange={(value) => setChecked(value)} />
|
|
200
|
+
|
|
201
|
+
{/* indeterminate: checked와 함께 사용 */}
|
|
202
|
+
<CheckBox
|
|
203
|
+
checked={indeterminate}
|
|
204
|
+
indeterminate={indeterminate}
|
|
205
|
+
onChange={(value) => setIndeterminate(value)}
|
|
206
|
+
/>
|
|
207
|
+
|
|
208
|
+
{/* variant / size / density */}
|
|
209
|
+
<CheckBox variant="assistive" size="small" density="compact" checked />
|
|
210
|
+
|
|
211
|
+
{/* disabled */}
|
|
212
|
+
<CheckBox checked disabled />
|
|
213
|
+
</>
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
유의사항:
|
|
219
|
+
|
|
220
|
+
- `indeterminate={true}`는 `checked={true}`일 때만 대시 아이콘을 표시합니다. `checked={false}`이면 빈 박스로 표시됩니다.
|
|
221
|
+
- `variant`는 `"primary"(기본값)` | `"assistive"`를 지원합니다.
|
|
222
|
+
- `density="compact"`은 wrapper 크기만 줄이며, 아이콘은 box width에 맞춰 `size` 기준으로 그대로 표시됩니다.
|
|
223
|
+
|
|
224
|
+
### 6. Radio
|
|
225
|
+
|
|
226
|
+
`Radio`는 그룹 내 단일 선택을 위한 controlled 컴포넌트입니다.
|
|
227
|
+
브라우저 기본 `name` 그룹 동작에 의존하지 않으며, `checked` prop으로 직접 선택 상태를 제어합니다.
|
|
228
|
+
|
|
229
|
+
```tsx
|
|
230
|
+
import { useState } from "react";
|
|
231
|
+
import { Radio } from "@idbrnd/design-system";
|
|
232
|
+
|
|
233
|
+
function RadioGroupExample() {
|
|
234
|
+
const [selected, setSelected] = useState("");
|
|
235
|
+
|
|
236
|
+
return (
|
|
237
|
+
<>
|
|
238
|
+
{["A", "B", "C"].map((v) => (
|
|
239
|
+
<label
|
|
240
|
+
key={v}
|
|
241
|
+
style={{ display: "flex", alignItems: "center", gap: 6 }}
|
|
242
|
+
>
|
|
243
|
+
<Radio
|
|
244
|
+
name="group"
|
|
245
|
+
value={v}
|
|
246
|
+
checked={selected === v}
|
|
247
|
+
onChange={(isChecked) => isChecked && setSelected(v)}
|
|
248
|
+
/>
|
|
249
|
+
Option {v}
|
|
250
|
+
</label>
|
|
251
|
+
))}
|
|
252
|
+
</>
|
|
253
|
+
);
|
|
254
|
+
}
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
유의사항:
|
|
258
|
+
|
|
259
|
+
- `name`이 같아도 자동으로 하나만 선택되지 않습니다. `checked={selected === value}` 비교로 직접 제어해야 합니다.
|
|
260
|
+
- `onChange`는 `(checked: boolean) => void` 시그니처이며, 클릭 시 `true`가 전달됩니다. `isChecked && setSelected(v)` 패턴으로 true일 때만 state를 변경합니다.
|
|
261
|
+
- `variant`는 `"primary"(기본값)` | `"assistive"`를 지원합니다.
|
|
262
|
+
|
|
263
|
+
### 7. ToggleSwitch
|
|
264
|
+
|
|
265
|
+
`ToggleSwitch`는 `active` + `onChange`를 받는 controlled 컴포넌트입니다.
|
|
266
|
+
|
|
267
|
+
```tsx
|
|
268
|
+
import { useState } from "react";
|
|
269
|
+
import { ToggleSwitch } from "@idbrnd/design-system";
|
|
270
|
+
|
|
271
|
+
function ToggleSwitchExample() {
|
|
272
|
+
const [active, setActive] = useState(false);
|
|
273
|
+
|
|
274
|
+
return (
|
|
275
|
+
<>
|
|
276
|
+
<ToggleSwitch active={active} onChange={(value) => setActive(value)} />
|
|
277
|
+
|
|
278
|
+
{/* size */}
|
|
279
|
+
<ToggleSwitch size="small" active={active} onChange={setActive} />
|
|
280
|
+
<ToggleSwitch size="large" active={active} onChange={setActive} />
|
|
281
|
+
|
|
282
|
+
{/* disabled */}
|
|
283
|
+
<ToggleSwitch active disabled />
|
|
284
|
+
</>
|
|
285
|
+
);
|
|
286
|
+
}
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
유의사항:
|
|
290
|
+
|
|
291
|
+
- 체크 상태를 나타내는 prop 이름이 `checked`가 아닌 `active`입니다.
|
|
292
|
+
- `size`는 `"small"` | `"medium"(기본값)` | `"large"`를 지원합니다.
|
|
293
|
+
|
|
294
|
+
### 9. Spinner
|
|
295
|
+
|
|
296
|
+
```tsx
|
|
297
|
+
import {
|
|
298
|
+
Spinner,
|
|
299
|
+
CustomSpinner,
|
|
300
|
+
Clip,
|
|
301
|
+
FadeSpinner,
|
|
302
|
+
} from "@idbrnd/design-system";
|
|
303
|
+
|
|
304
|
+
function SpinnerExample() {
|
|
305
|
+
return (
|
|
306
|
+
<div style={{ display: "flex", gap: "12px", alignItems: "center" }}>
|
|
307
|
+
<Spinner />
|
|
308
|
+
<CustomSpinner size={12} />
|
|
309
|
+
<Clip size={24} color="var(--semantic-primary-default)" />
|
|
310
|
+
<FadeSpinner width={4} height={12} />
|
|
311
|
+
</div>
|
|
312
|
+
);
|
|
313
|
+
}
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
### 10. Toast
|
|
317
|
+
|
|
318
|
+
```tsx
|
|
319
|
+
import { FillButton, showToast, dismissToast } from "@idbrnd/design-system";
|
|
320
|
+
|
|
321
|
+
function ToastExample() {
|
|
322
|
+
return (
|
|
323
|
+
<>
|
|
324
|
+
<FillButton
|
|
325
|
+
onClick={() =>
|
|
326
|
+
showToast({
|
|
327
|
+
variant: "positive",
|
|
328
|
+
message: "저장되었습니다.",
|
|
329
|
+
})
|
|
330
|
+
}
|
|
331
|
+
>
|
|
332
|
+
Toast 열기
|
|
333
|
+
</FillButton>
|
|
334
|
+
|
|
335
|
+
<FillButton variant="assistive" onClick={() => dismissToast()}>
|
|
336
|
+
Toast 닫기
|
|
337
|
+
</FillButton>
|
|
338
|
+
</>
|
|
339
|
+
);
|
|
340
|
+
}
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
### 11. Snackbar
|
|
344
|
+
|
|
345
|
+
```tsx
|
|
346
|
+
import {
|
|
347
|
+
FillButton,
|
|
348
|
+
showSnackbar,
|
|
349
|
+
dismissSnackbar,
|
|
350
|
+
} from "@idbrnd/design-system";
|
|
351
|
+
|
|
352
|
+
function SnackbarExample() {
|
|
353
|
+
return (
|
|
354
|
+
<>
|
|
355
|
+
<FillButton
|
|
356
|
+
onClick={() =>
|
|
357
|
+
showSnackbar({
|
|
358
|
+
variant: "basic",
|
|
359
|
+
heading: "Message deleted.",
|
|
360
|
+
description: "You can undo this action.",
|
|
361
|
+
actionLabel: "실행 취소",
|
|
362
|
+
onActionClick: () => console.log("undo"),
|
|
363
|
+
closeButton: true,
|
|
364
|
+
})
|
|
365
|
+
}
|
|
366
|
+
>
|
|
367
|
+
Snackbar 열기
|
|
368
|
+
</FillButton>
|
|
369
|
+
|
|
370
|
+
<FillButton variant="assistive" onClick={() => dismissSnackbar()}>
|
|
371
|
+
Snackbar 닫기
|
|
372
|
+
</FillButton>
|
|
373
|
+
</>
|
|
374
|
+
);
|
|
375
|
+
}
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
## TypeScript
|
|
379
|
+
|
|
380
|
+
모든 컴포넌트의 Props 타입을 패키지에서 직접 import 할 수 있습니다.
|
|
381
|
+
|
|
382
|
+
```tsx
|
|
383
|
+
import type {
|
|
384
|
+
FillButtonProps,
|
|
385
|
+
InputProps,
|
|
386
|
+
CheckBoxProps,
|
|
387
|
+
CheckBoxVariant,
|
|
388
|
+
CheckBoxSize,
|
|
389
|
+
CheckBoxDensity,
|
|
390
|
+
RadioProps,
|
|
391
|
+
RadioVariant,
|
|
392
|
+
RadioSize,
|
|
393
|
+
RadioDensity,
|
|
394
|
+
ToggleSwitchProps,
|
|
395
|
+
ToggleSwitchSize,
|
|
396
|
+
ToastShowOptions,
|
|
397
|
+
} from "@idbrnd/design-system";
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
## 주의사항
|
|
401
|
+
|
|
402
|
+
- `Input`, `SearchBar`, `CheckBox`, `Radio`, `ToggleSwitch`는 controlled 방식으로 사용해야 합니다.
|
|
403
|
+
- `Radio`는 `name` prop만으로 단일 선택이 보장되지 않습니다. `checked={selected === value}` 비교로 직접 제어해야 합니다.
|
|
404
|
+
- `CheckBox`의 `indeterminate={true}`는 `checked={true}`와 함께 사용해야 대시 아이콘이 표시됩니다.
|
|
405
|
+
- `showToast`, `showSnackbar`는 내부적으로 `document.body`에 포털을 생성하므로 브라우저 환경에서 호출해야 합니다.
|
|
406
|
+
- CSS 변수/타이포그래피를 포함한 스타일을 위해 `@idbrnd/design-system/style.css` import를 권장합니다.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type CSSProperties, type InputHTMLAttributes } from "react";
|
|
2
|
+
export type CheckBoxVariant = "primary" | "assistive";
|
|
3
|
+
export type CheckBoxSize = "medium" | "small";
|
|
4
|
+
export type CheckBoxDensity = "default" | "compact";
|
|
5
|
+
export interface CheckBoxProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "style" | "size" | "type" | "checked" | "defaultChecked" | "onChange"> {
|
|
6
|
+
variant?: CheckBoxVariant;
|
|
7
|
+
size?: CheckBoxSize;
|
|
8
|
+
density?: CheckBoxDensity;
|
|
9
|
+
customStyle?: CSSProperties;
|
|
10
|
+
checked?: boolean;
|
|
11
|
+
indeterminate?: boolean;
|
|
12
|
+
onChange?: (checked: boolean) => void;
|
|
13
|
+
}
|
|
14
|
+
declare function CheckBox({ variant, size, density, disabled, customStyle, className, checked, indeterminate, onChange, ...rest }: CheckBoxProps): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export default CheckBox;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type CSSProperties, type InputHTMLAttributes } from "react";
|
|
2
|
+
export type RadioVariant = "primary" | "assistive";
|
|
3
|
+
export type RadioSize = "medium" | "small";
|
|
4
|
+
export type RadioDensity = "default" | "compact";
|
|
5
|
+
export interface RadioProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "style" | "size" | "type" | "onChange"> {
|
|
6
|
+
variant?: RadioVariant;
|
|
7
|
+
size?: RadioSize;
|
|
8
|
+
density?: RadioDensity;
|
|
9
|
+
customStyle?: CSSProperties;
|
|
10
|
+
onChange?: (checked: boolean) => void;
|
|
11
|
+
}
|
|
12
|
+
declare function Radio({ variant, size, density, disabled, checked, customStyle, className, onChange, ...rest }: RadioProps): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export default Radio;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type CSSProperties, type InputHTMLAttributes } from "react";
|
|
2
|
+
export type ToggleSwitchSize = "small" | "medium" | "large";
|
|
3
|
+
export interface ToggleSwitchProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "style" | "size" | "type" | "checked" | "defaultChecked" | "onChange"> {
|
|
4
|
+
size?: ToggleSwitchSize;
|
|
5
|
+
active?: boolean;
|
|
6
|
+
customStyle?: CSSProperties;
|
|
7
|
+
onChange?: (active: boolean) => void;
|
|
8
|
+
}
|
|
9
|
+
declare function ToggleSwitch({ size, active, disabled, customStyle, className, onChange, ...rest }: ToggleSwitchProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export default ToggleSwitch;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { InputProps } from './Input.types';
|
|
2
|
-
export type { InputProps, InputSize, InputVariant,
|
|
2
|
+
export type { InputProps, InputSize, InputVariant, DesignType } from './Input.types';
|
|
3
3
|
declare function Input({ type, // input HTML 타입
|
|
4
4
|
designType, // 인풋 외형 타입
|
|
5
5
|
size, // 인풋 높이 크기
|
|
@@ -3,7 +3,7 @@ import type { CSSProperties, HTMLInputTypeAttribute, InputHTMLAttributes, ReactN
|
|
|
3
3
|
* Input 컨테이너의 시각 스타일 타입.
|
|
4
4
|
* @defaultValue `'outline'`
|
|
5
5
|
*/
|
|
6
|
-
export type
|
|
6
|
+
export type DesignType = 'outline' | 'fill';
|
|
7
7
|
/**
|
|
8
8
|
* Input 높이 타입.
|
|
9
9
|
* @defaultValue `'default'`
|
|
@@ -31,7 +31,7 @@ export interface InputProps extends Omit<InputHTMLAttributes<HTMLInputElement>,
|
|
|
31
31
|
* Input 컨테이너 외형 타입.
|
|
32
32
|
* @defaultValue `'outline'`
|
|
33
33
|
*/
|
|
34
|
-
designType?:
|
|
34
|
+
designType?: DesignType;
|
|
35
35
|
/**
|
|
36
36
|
* Input 높이.
|
|
37
37
|
* - `default`: 44px
|
|
@@ -41,7 +41,8 @@ export interface InputProps extends Omit<InputHTMLAttributes<HTMLInputElement>,
|
|
|
41
41
|
size?: InputSize;
|
|
42
42
|
/**
|
|
43
43
|
* Input 상태 variant.
|
|
44
|
-
* 미지정 시
|
|
44
|
+
* 미지정 시 값 존재 여부에 따라 `basic`/`typed`를 자동 계산한다.
|
|
45
|
+
* 포커스 시각 상태는 CSS interaction으로 처리한다.
|
|
45
46
|
*/
|
|
46
47
|
variant?: InputVariant;
|
|
47
48
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ChangeEvent, FocusEvent } from 'react';
|
|
2
2
|
import type { InputProps } from './Input.types';
|
|
3
3
|
interface UseInputStateParams {
|
|
4
4
|
value: InputProps['value'];
|
|
@@ -8,8 +8,6 @@ interface UseInputStateParams {
|
|
|
8
8
|
}
|
|
9
9
|
export interface UseInputStateResult {
|
|
10
10
|
currentValue: InputProps['value'];
|
|
11
|
-
isFocused: boolean;
|
|
12
|
-
isTyping: boolean;
|
|
13
11
|
handleFocus: (event: FocusEvent<HTMLInputElement>) => void;
|
|
14
12
|
handleBlur: (event: FocusEvent<HTMLInputElement>) => void;
|
|
15
13
|
handleChange: (event: ChangeEvent<HTMLInputElement>) => void;
|
|
@@ -1,19 +1,23 @@
|
|
|
1
1
|
import type { InputProps, InputSize } from '../Input/Input';
|
|
2
2
|
export type SearchBarSize = InputSize;
|
|
3
|
-
export
|
|
3
|
+
export type SearchBarVariant = 'default' | 'onTyping' | 'typed' | 'error';
|
|
4
|
+
export interface SearchBarProps extends Omit<InputProps, 'type' | 'value' | 'onChange' | 'variant'> {
|
|
4
5
|
value: string;
|
|
5
6
|
onChange: NonNullable<InputProps['onChange']>;
|
|
6
7
|
onSearch: (value: string) => void;
|
|
8
|
+
onClear?: () => void;
|
|
9
|
+
variant?: SearchBarVariant;
|
|
7
10
|
}
|
|
8
11
|
declare function SearchBar({ value, // 검색어 값
|
|
9
12
|
onChange, // 입력 변경 핸들러
|
|
10
13
|
onSearch, // 검색 실행 핸들러
|
|
14
|
+
onClear, // 입력내용 전체 삭제 핸들러(미전달 시 기본 삭제 동작)
|
|
11
15
|
size, // 인풋 크기
|
|
12
16
|
width, // 컴포넌트 너비
|
|
13
17
|
designType, // 인풋 외형 타입
|
|
14
18
|
heading, // 라벨 표시 여부
|
|
15
19
|
headingContent, // 라벨 내용
|
|
16
|
-
variant, //
|
|
20
|
+
variant, // SearchBar 상태 variant
|
|
17
21
|
description, // 하단 안내 문구
|
|
18
22
|
fixedDescriptionHeight, // 하단 문구 영역 높이 고정 여부
|
|
19
23
|
disabled, // 전체 비활성화 여부
|
|
@@ -22,6 +26,7 @@ id, // input id
|
|
|
22
26
|
name, // input name
|
|
23
27
|
placeholder, // placeholder 텍스트
|
|
24
28
|
leadingIcon, // 좌측 아이콘 슬롯
|
|
29
|
+
trailingContent, // 우측 trailing 콘텐츠(미지정 시 검색 버튼 사용)
|
|
25
30
|
maxLength, // 최대 입력 길이
|
|
26
31
|
required, // 필수 입력 여부
|
|
27
32
|
errorMessage, // 에러 상태 문구
|
package/dist/index.d.ts
CHANGED
|
@@ -1,28 +1,34 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
export { default as BasicIconButton } from
|
|
4
|
-
export { default as FillButton } from
|
|
5
|
-
export { default as FillIconButton } from
|
|
6
|
-
export { default as Input } from
|
|
7
|
-
export { default as OutlineButton } from
|
|
8
|
-
export { default as OutlineIconButton } from
|
|
9
|
-
export { default as PushBadge } from
|
|
10
|
-
export { default as SearchBar } from
|
|
11
|
-
export { dismissSnackbar, showSnackbar } from
|
|
12
|
-
export { default as Spinner, Clip, CustomSpinner, FadeSpinner } from
|
|
13
|
-
export { dismissToast, showToast } from
|
|
14
|
-
export { default as TextButton } from
|
|
15
|
-
export { default as WeakButton } from
|
|
16
|
-
export
|
|
17
|
-
export
|
|
18
|
-
export
|
|
19
|
-
export type {
|
|
20
|
-
export type {
|
|
21
|
-
export type {
|
|
22
|
-
export type {
|
|
23
|
-
export type {
|
|
24
|
-
export type {
|
|
25
|
-
export type {
|
|
26
|
-
export type {
|
|
27
|
-
export type {
|
|
28
|
-
export type {
|
|
1
|
+
import "./styles/variables.css";
|
|
2
|
+
import "./styles/font-metrics.css";
|
|
3
|
+
export { default as BasicIconButton } from "./components/Button/BasicIcon/BasicIconButton";
|
|
4
|
+
export { default as FillButton } from "./components/Button/Fill/FillButton";
|
|
5
|
+
export { default as FillIconButton } from "./components/Button/FillIcon/FillIconButton";
|
|
6
|
+
export { default as Input } from "./components/Input/Input";
|
|
7
|
+
export { default as OutlineButton } from "./components/Button/Outline/OutlineButton";
|
|
8
|
+
export { default as OutlineIconButton } from "./components/Button/OutlineIcon/OutlineIconButton";
|
|
9
|
+
export { default as PushBadge } from "./components/PushBadge/PushBadge";
|
|
10
|
+
export { default as SearchBar } from "./components/SearchBar/SearchBar";
|
|
11
|
+
export { dismissSnackbar, showSnackbar } from "./components/Snackbar/Snackbar";
|
|
12
|
+
export { default as Spinner, Clip, CustomSpinner, FadeSpinner, } from "./components/Spinner/Spinner";
|
|
13
|
+
export { dismissToast, showToast } from "./components/Toast/Toast";
|
|
14
|
+
export { default as TextButton } from "./components/Button/Text/TextButton";
|
|
15
|
+
export { default as WeakButton } from "./components/Button/Weak/WeakButton";
|
|
16
|
+
export { default as CheckBox } from "./components/Control/CheckBox/CheckBox";
|
|
17
|
+
export { default as Radio } from "./components/Control/Radio/Radio";
|
|
18
|
+
export { default as ToggleSwitch } from "./components/Control/ToggleSwitch/ToggleSwitch";
|
|
19
|
+
export type { BasicIconButtonProps, BasicIconButtonSize, } from "./components/Button/BasicIcon/BasicIconButton";
|
|
20
|
+
export type { FillButtonProps, FillButtonSize, FillButtonVariant, FillButtonWidthType, } from "./components/Button/Fill/FillButton";
|
|
21
|
+
export type { FillIconButtonProps, FillIconButtonSize, FillIconButtonVariant, } from "./components/Button/FillIcon/FillIconButton";
|
|
22
|
+
export type { InputProps, InputSize, DesignType, InputVariant, } from "./components/Input/Input";
|
|
23
|
+
export type { PushBadgeProps, PushBadgeVariant, } from "./components/PushBadge/PushBadge";
|
|
24
|
+
export type { SearchBarProps, SearchBarSize, SearchBarVariant, } from "./components/SearchBar/SearchBar";
|
|
25
|
+
export type { SnackbarShowOptions, SnackbarVariant, } from "./components/Snackbar/Snackbar";
|
|
26
|
+
export type { ClipProps, CustomSpinnerProps, FadeSpinnerProps, } from "./components/Spinner/Spinner";
|
|
27
|
+
export type { ToastShowOptions, ToastVariant } from "./components/Toast/Toast";
|
|
28
|
+
export type { OutlineButtonProps, OutlineButtonSize, OutlineButtonVariant, OutlineButtonWidthType, } from "./components/Button/Outline/OutlineButton";
|
|
29
|
+
export type { OutlineIconButtonProps, OutlineIconButtonSize, } from "./components/Button/OutlineIcon/OutlineIconButton";
|
|
30
|
+
export type { TextButtonProps, TextButtonSize, TextButtonVariant, TextButtonWidthType, } from "./components/Button/Text/TextButton";
|
|
31
|
+
export type { WeakButtonProps, WeakButtonSize, WeakButtonVariant, WeakButtonWidthType, } from "./components/Button/Weak/WeakButton";
|
|
32
|
+
export type { CheckBoxProps, CheckBoxVariant, CheckBoxSize, CheckBoxDensity, } from "./components/Control/CheckBox/CheckBox";
|
|
33
|
+
export type { RadioProps, RadioVariant, RadioSize, RadioDensity, } from "./components/Control/Radio/Radio";
|
|
34
|
+
export type { ToggleSwitchProps, ToggleSwitchSize, } from "./components/Control/ToggleSwitch/ToggleSwitch";
|