@ceed/cds 1.28.1 → 1.29.0-next.1
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/components/CurrencyInput/CurrencyInput.d.ts +1 -1
- package/dist/components/CurrencyInput/hooks/use-currency-setting.d.ts +2 -2
- package/dist/components/SearchBar/SearchBar.d.ts +21 -0
- package/dist/components/SearchBar/index.d.ts +3 -0
- package/dist/components/data-display/DataTable.md +1 -1
- package/dist/components/data-display/InfoSign.md +91 -74
- package/dist/components/data-display/Typography.md +94 -411
- package/dist/components/feedback/Dialog.md +62 -76
- package/dist/components/feedback/Modal.md +138 -430
- package/dist/components/feedback/llms.txt +0 -2
- package/dist/components/index.d.ts +2 -1
- package/dist/components/inputs/Autocomplete.md +107 -356
- package/dist/components/inputs/ButtonGroup.md +104 -115
- package/dist/components/inputs/CurrencyInput.md +5 -183
- package/dist/components/inputs/DatePicker.md +431 -108
- package/dist/components/inputs/DateRangePicker.md +492 -131
- package/dist/components/inputs/FilterableCheckboxGroup.md +19 -145
- package/dist/components/inputs/IconButton.md +88 -137
- package/dist/components/inputs/Input.md +73 -204
- package/dist/components/inputs/MonthPicker.md +422 -95
- package/dist/components/inputs/MonthRangePicker.md +466 -89
- package/dist/components/inputs/PercentageInput.md +16 -185
- package/dist/components/inputs/RadioButton.md +35 -163
- package/dist/components/inputs/SearchBar.md +44 -0
- package/dist/components/inputs/Select.md +326 -222
- package/dist/components/inputs/Switch.md +376 -143
- package/dist/components/inputs/Textarea.md +10 -213
- package/dist/components/inputs/Uploader/Uploader.md +66 -145
- package/dist/components/inputs/llms.txt +1 -4
- package/dist/components/navigation/Breadcrumbs.md +308 -57
- package/dist/components/navigation/Drawer.md +0 -180
- package/dist/components/navigation/Dropdown.md +215 -98
- package/dist/components/navigation/IconMenuButton.md +502 -40
- package/dist/components/navigation/InsetDrawer.md +650 -281
- package/dist/components/navigation/Link.md +348 -31
- package/dist/components/navigation/Menu.md +285 -92
- package/dist/components/navigation/MenuButton.md +448 -55
- package/dist/components/navigation/Pagination.md +338 -47
- package/dist/components/navigation/Stepper.md +28 -160
- package/dist/components/navigation/Tabs.md +316 -57
- package/dist/components/surfaces/Accordions.md +804 -49
- package/dist/components/surfaces/Card.md +157 -97
- package/dist/components/surfaces/Divider.md +234 -83
- package/dist/components/surfaces/Sheet.md +328 -153
- package/dist/index.cjs +411 -574
- package/dist/index.d.ts +1 -1
- package/dist/index.js +400 -507
- package/dist/llms.txt +1 -9
- package/framer/index.js +1 -1
- package/package.json +17 -22
- package/dist/chunks/rehype-accent-FZRUD7VI.js +0 -39
- package/dist/components/RadioTileGroup/RadioTileGroup.d.ts +0 -56
- package/dist/components/RadioTileGroup/index.d.ts +0 -3
- package/dist/components/feedback/CircularProgress.md +0 -257
- package/dist/components/feedback/Skeleton.md +0 -280
- package/dist/components/inputs/FormControl.md +0 -361
- package/dist/components/inputs/RadioList.md +0 -241
- package/dist/components/inputs/RadioTileGroup.md +0 -507
- package/dist/components/inputs/Slider.md +0 -334
- package/dist/guides/ThemeProvider.md +0 -89
- package/dist/guides/llms.txt +0 -9
- package/dist/index.browser.js +0 -224
- package/dist/index.browser.js.map +0 -7
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## Introduction
|
|
4
4
|
|
|
5
|
-
ButtonGroup
|
|
6
|
-
|
|
7
|
-
By applying shared props like `color`, `variant`, `size`, and `orientation` at the group level, you ensure visual consistency without having to repeat props on every individual button. ButtonGroup is built on top of Joy UI's ButtonGroup and inherits all of its capabilities.
|
|
5
|
+
ButtonGroup 컴포넌트는 관련된 버튼들을 그룹화하여 하나의 통합된 인터페이스로 표시합니다. 버튼들을 논리적으로 묶어서 시각적 일관성을 제공하고, 공간을 효율적으로 사용할 수 있게 해줍니다. 툴바, 액션 버튼 세트, 토글 그룹 등에 주로 사용됩니다.
|
|
8
6
|
|
|
9
7
|
```tsx
|
|
10
8
|
<ButtonGroup {...args}>
|
|
@@ -30,17 +28,37 @@ import { ButtonGroup, Button } from '@ceed/cds';
|
|
|
30
28
|
function MyComponent() {
|
|
31
29
|
return (
|
|
32
30
|
<ButtonGroup>
|
|
33
|
-
<Button
|
|
34
|
-
<Button
|
|
35
|
-
<Button
|
|
31
|
+
<Button>첫번째</Button>
|
|
32
|
+
<Button>두번째</Button>
|
|
33
|
+
<Button>세번째</Button>
|
|
36
34
|
</ButtonGroup>
|
|
37
35
|
);
|
|
38
36
|
}
|
|
39
37
|
```
|
|
40
38
|
|
|
41
|
-
##
|
|
39
|
+
## Examples
|
|
40
|
+
|
|
41
|
+
### Basic Usage
|
|
42
|
+
|
|
43
|
+
기본적인 ButtonGroup 사용법입니다.
|
|
44
|
+
|
|
45
|
+
```tsx
|
|
46
|
+
<div style={{
|
|
47
|
+
display: 'flex',
|
|
48
|
+
gap: '2rem',
|
|
49
|
+
flexDirection: 'column'
|
|
50
|
+
}}>
|
|
51
|
+
<ButtonGroup>
|
|
52
|
+
<Button>첫번째</Button>
|
|
53
|
+
<Button>두번째</Button>
|
|
54
|
+
<Button>세번째</Button>
|
|
55
|
+
</ButtonGroup>
|
|
56
|
+
</div>
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Colors
|
|
42
60
|
|
|
43
|
-
|
|
61
|
+
다양한 색상을 적용할 수 있습니다.
|
|
44
62
|
|
|
45
63
|
```tsx
|
|
46
64
|
<div style={{
|
|
@@ -80,9 +98,9 @@ Apply a unified color theme to all buttons in the group using the `color` prop.
|
|
|
80
98
|
</div>
|
|
81
99
|
```
|
|
82
100
|
|
|
83
|
-
|
|
101
|
+
### Variants
|
|
84
102
|
|
|
85
|
-
|
|
103
|
+
다양한 스타일 변형을 제공합니다.
|
|
86
104
|
|
|
87
105
|
```tsx
|
|
88
106
|
<div style={{
|
|
@@ -116,9 +134,9 @@ ButtonGroup supports four visual variants: `solid`, `soft`, `outlined`, and `pla
|
|
|
116
134
|
</div>
|
|
117
135
|
```
|
|
118
136
|
|
|
119
|
-
|
|
137
|
+
### Sizes
|
|
120
138
|
|
|
121
|
-
|
|
139
|
+
크기를 조절할 수 있습니다.
|
|
122
140
|
|
|
123
141
|
```tsx
|
|
124
142
|
<div style={{
|
|
@@ -147,9 +165,9 @@ Control the size of all buttons in the group with the `size` prop. Available siz
|
|
|
147
165
|
</div>
|
|
148
166
|
```
|
|
149
167
|
|
|
150
|
-
|
|
168
|
+
### Orientations
|
|
151
169
|
|
|
152
|
-
|
|
170
|
+
수평(horizontal) 또는 수직(vertical) 방향으로 배치할 수 있습니다.
|
|
153
171
|
|
|
154
172
|
```tsx
|
|
155
173
|
<div style={{
|
|
@@ -177,9 +195,9 @@ Buttons can be arranged horizontally (default) or vertically. Use `orientation="
|
|
|
177
195
|
</div>
|
|
178
196
|
```
|
|
179
197
|
|
|
180
|
-
|
|
198
|
+
### With Icons
|
|
181
199
|
|
|
182
|
-
|
|
200
|
+
아이콘과 함께 사용할 수 있습니다.
|
|
183
201
|
|
|
184
202
|
```tsx
|
|
185
203
|
<div style={{
|
|
@@ -201,9 +219,49 @@ Combine text labels with icons using the `startDecorator` prop on individual but
|
|
|
201
219
|
</div>
|
|
202
220
|
```
|
|
203
221
|
|
|
204
|
-
|
|
222
|
+
### Action Groups
|
|
205
223
|
|
|
206
|
-
|
|
224
|
+
실제 사용 사례별 액션 그룹들입니다.
|
|
225
|
+
|
|
226
|
+
```tsx
|
|
227
|
+
<div style={{
|
|
228
|
+
display: 'flex',
|
|
229
|
+
gap: '2rem',
|
|
230
|
+
flexDirection: 'column'
|
|
231
|
+
}}>
|
|
232
|
+
<div>
|
|
233
|
+
<h4>File Actions</h4>
|
|
234
|
+
<ButtonGroup variant="outlined">
|
|
235
|
+
<Button onClick={() => alert('Save')}>저장</Button>
|
|
236
|
+
<Button onClick={() => alert('Save As')}>다른 이름으로 저장</Button>
|
|
237
|
+
<Button onClick={() => alert('Export')}>내보내기</Button>
|
|
238
|
+
</ButtonGroup>
|
|
239
|
+
</div>
|
|
240
|
+
|
|
241
|
+
<div>
|
|
242
|
+
<h4>Text Formatting</h4>
|
|
243
|
+
<ButtonGroup size="sm" variant="soft">
|
|
244
|
+
<Button>B</Button>
|
|
245
|
+
<Button>I</Button>
|
|
246
|
+
<Button>U</Button>
|
|
247
|
+
<Button>S</Button>
|
|
248
|
+
</ButtonGroup>
|
|
249
|
+
</div>
|
|
250
|
+
|
|
251
|
+
<div>
|
|
252
|
+
<h4>View Options</h4>
|
|
253
|
+
<ButtonGroup color="neutral" variant="outlined">
|
|
254
|
+
<Button>목록</Button>
|
|
255
|
+
<Button>격자</Button>
|
|
256
|
+
<Button>타일</Button>
|
|
257
|
+
</ButtonGroup>
|
|
258
|
+
</div>
|
|
259
|
+
</div>
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
### States
|
|
263
|
+
|
|
264
|
+
다양한 상태를 표현할 수 있습니다.
|
|
207
265
|
|
|
208
266
|
```tsx
|
|
209
267
|
<div style={{
|
|
@@ -240,9 +298,9 @@ ButtonGroup supports disabled states at the group level (affecting all children)
|
|
|
240
298
|
</div>
|
|
241
299
|
```
|
|
242
300
|
|
|
243
|
-
|
|
301
|
+
### Toggle Group
|
|
244
302
|
|
|
245
|
-
|
|
303
|
+
선택 상태를 토글할 수 있는 버튼 그룹입니다.
|
|
246
304
|
|
|
247
305
|
```tsx
|
|
248
306
|
<div>
|
|
@@ -267,125 +325,56 @@ By dynamically switching the `variant` prop on individual buttons based on selec
|
|
|
267
325
|
### Toolbar Actions
|
|
268
326
|
|
|
269
327
|
```tsx
|
|
270
|
-
import { ButtonGroup, Button } from '@ceed/cds';
|
|
271
|
-
import SaveIcon from '@mui/icons-material/Save';
|
|
272
|
-
import UndoIcon from '@mui/icons-material/Undo';
|
|
273
|
-
import RedoIcon from '@mui/icons-material/Redo';
|
|
274
|
-
|
|
275
328
|
<ButtonGroup variant="outlined">
|
|
276
|
-
<Button startDecorator={<SaveIcon />}
|
|
277
|
-
<Button startDecorator={<UndoIcon />}
|
|
278
|
-
<Button startDecorator={<RedoIcon />}
|
|
329
|
+
<Button startDecorator={<SaveIcon />}>저장</Button>
|
|
330
|
+
<Button startDecorator={<UndoIcon />}>실행 취소</Button>
|
|
331
|
+
<Button startDecorator={<RedoIcon />}>다시 실행</Button>
|
|
279
332
|
</ButtonGroup>
|
|
280
333
|
```
|
|
281
334
|
|
|
282
|
-
###
|
|
335
|
+
### Text Formatting
|
|
283
336
|
|
|
284
337
|
```tsx
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
<
|
|
288
|
-
<Button
|
|
289
|
-
variant={view === 'list' ? 'solid' : 'outlined'}
|
|
290
|
-
onClick={() => setView('list')}
|
|
291
|
-
>
|
|
292
|
-
List
|
|
293
|
-
</Button>
|
|
294
|
-
<Button
|
|
295
|
-
variant={view === 'grid' ? 'solid' : 'outlined'}
|
|
296
|
-
onClick={() => setView('grid')}
|
|
297
|
-
>
|
|
298
|
-
Grid
|
|
299
|
-
</Button>
|
|
300
|
-
<Button
|
|
301
|
-
variant={view === 'card' ? 'solid' : 'outlined'}
|
|
302
|
-
onClick={() => setView('card')}
|
|
303
|
-
>
|
|
304
|
-
Card
|
|
305
|
-
</Button>
|
|
338
|
+
<ButtonGroup size="sm" variant="soft">
|
|
339
|
+
<Button onClick={() => format('bold')}>B</Button>
|
|
340
|
+
<Button onClick={() => format('italic')}>I</Button>
|
|
341
|
+
<Button onClick={() => format('underline')}>U</Button>
|
|
306
342
|
</ButtonGroup>
|
|
307
343
|
```
|
|
308
344
|
|
|
309
|
-
###
|
|
345
|
+
### View Controls
|
|
310
346
|
|
|
311
347
|
```tsx
|
|
312
|
-
<ButtonGroup
|
|
313
|
-
<Button
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
<Button disabled>{page}</Button>
|
|
317
|
-
<Button onClick={() => setPage(page + 1)}>
|
|
318
|
-
Next
|
|
319
|
-
</Button>
|
|
348
|
+
<ButtonGroup color="neutral">
|
|
349
|
+
<Button onClick={() => setView('list')}>목록</Button>
|
|
350
|
+
<Button onClick={() => setView('grid')}>격자</Button>
|
|
351
|
+
<Button onClick={() => setView('card')}>카드</Button>
|
|
320
352
|
</ButtonGroup>
|
|
321
353
|
```
|
|
322
354
|
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
1. **Group only related actions together.** Each ButtonGroup should represent a logically connected set of operations.
|
|
355
|
+
### Pagination
|
|
326
356
|
|
|
327
357
|
```tsx
|
|
328
|
-
// ✅ Related file operations grouped together
|
|
329
358
|
<ButtonGroup variant="outlined">
|
|
330
|
-
<Button>
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
// ❌ Unrelated actions mixed in one group
|
|
336
|
-
<ButtonGroup>
|
|
337
|
-
<Button>Save</Button>
|
|
338
|
-
<Button>Delete Account</Button>
|
|
339
|
-
<Button>Help</Button>
|
|
359
|
+
<Button disabled={page === 1} onClick={() => setPage(page - 1)}>
|
|
360
|
+
이전
|
|
361
|
+
</Button>
|
|
362
|
+
<Button onClick={() => setPage(page + 1)}>다음</Button>
|
|
340
363
|
</ButtonGroup>
|
|
341
364
|
```
|
|
342
365
|
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
```tsx
|
|
346
|
-
// ✅ Concise group
|
|
347
|
-
<ButtonGroup>
|
|
348
|
-
<Button>Bold</Button>
|
|
349
|
-
<Button>Italic</Button>
|
|
350
|
-
<Button>Underline</Button>
|
|
351
|
-
</ButtonGroup>
|
|
352
|
-
|
|
353
|
-
// ❌ Too many options in a single group
|
|
354
|
-
<ButtonGroup>
|
|
355
|
-
<Button>Bold</Button>
|
|
356
|
-
<Button>Italic</Button>
|
|
357
|
-
<Button>Underline</Button>
|
|
358
|
-
<Button>Strikethrough</Button>
|
|
359
|
-
<Button>Superscript</Button>
|
|
360
|
-
<Button>Subscript</Button>
|
|
361
|
-
<Button>Code</Button>
|
|
362
|
-
</ButtonGroup>
|
|
363
|
-
```
|
|
366
|
+
## Best Practices
|
|
364
367
|
|
|
365
|
-
|
|
368
|
+
1. **관련성**: 논리적으로 관련된 버튼들만 그룹화하세요.
|
|
366
369
|
|
|
367
|
-
|
|
368
|
-
// ✅ Consistent styling via group props
|
|
369
|
-
<ButtonGroup variant="outlined" color="neutral">
|
|
370
|
-
<Button>A</Button>
|
|
371
|
-
<Button>B</Button>
|
|
372
|
-
</ButtonGroup>
|
|
370
|
+
2. **일관성**: 그룹 내의 모든 버튼은 동일한 variant, size, color를 사용하는 것이 좋습니다.
|
|
373
371
|
|
|
374
|
-
|
|
375
|
-
<ButtonGroup>
|
|
376
|
-
<Button variant="solid">A</Button>
|
|
377
|
-
<Button variant="outlined">B</Button>
|
|
378
|
-
<Button variant="plain">C</Button>
|
|
379
|
-
</ButtonGroup>
|
|
380
|
-
```
|
|
372
|
+
3. **적절한 개수**: 너무 많은 버튼을 한 그룹에 포함하지 마세요. 일반적으로 2-5개가 적당합니다.
|
|
381
373
|
|
|
382
|
-
4.
|
|
374
|
+
4. **명확한 레이블**: 각 버튼의 기능을 명확하게 알 수 있는 레이블을 사용하세요.
|
|
383
375
|
|
|
384
|
-
5.
|
|
376
|
+
5. **접근성**: 키보드 탐색이 가능하도록 하고, 스크린 리더를 위한 적절한 레이블을 제공하세요.
|
|
385
377
|
|
|
386
|
-
|
|
378
|
+
6. **상태 관리**: 토글 그룹으로 사용할 때는 현재 선택된 상태를 시각적으로 명확히 표시하세요.
|
|
387
379
|
|
|
388
|
-
|
|
389
|
-
- **ARIA grouping**: Wrap the ButtonGroup in a container with `role="group"` and an `aria-label` when the group represents a distinct set of controls (e.g., text formatting toolbar).
|
|
390
|
-
- **Disabled state**: When the entire group is disabled, all child buttons receive `aria-disabled="true"` automatically, preventing interaction and communicating the state to assistive technologies.
|
|
391
|
-
- **Toggle groups**: When using ButtonGroup as a toggle, consider adding `aria-pressed` to each button to communicate the selection state to screen readers.
|
|
380
|
+
7. **반응형 디자인**: 작은 화면에서는 vertical orientation을 고려하거나 적절한 줄바꿈을 제공하세요.
|
|
@@ -2,12 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
## Introduction
|
|
4
4
|
|
|
5
|
-
CurrencyInput is a specialized numeric input for entering monetary values. It automatically formats numbers with the appropriate currency symbol, thousand separators, and decimal places based on the selected currency (USD or KRW). It supports features like maximum value validation, minor unit conversion, and controlled/uncontrolled modes.
|
|
6
|
-
|
|
7
|
-
> **Tip: Use built-in form props**
|
|
8
|
-
>
|
|
9
|
-
> This component supports `label` and `helperText` props directly. Use these instead of wrapping with FormControl + FormLabel + FormHelperText for simpler forms.
|
|
10
|
-
|
|
11
5
|
```tsx
|
|
12
6
|
<CurrencyInput
|
|
13
7
|
name="currency-input"
|
|
@@ -31,42 +25,8 @@ CurrencyInput is a specialized numeric input for entering monetary values. It au
|
|
|
31
25
|
| useMinorUnit | — | — |
|
|
32
26
|
| onChange | — | — |
|
|
33
27
|
|
|
34
|
-
## Usage
|
|
35
|
-
|
|
36
|
-
```tsx
|
|
37
|
-
import { CurrencyInput } from '@ceed/cds';
|
|
38
|
-
|
|
39
|
-
function MyComponent() {
|
|
40
|
-
const [amount, setAmount] = React.useState(0);
|
|
41
|
-
|
|
42
|
-
return (
|
|
43
|
-
<CurrencyInput
|
|
44
|
-
label="Price"
|
|
45
|
-
currency="USD"
|
|
46
|
-
value={amount}
|
|
47
|
-
onChange={(e) => setAmount(e.target.value)}
|
|
48
|
-
/>
|
|
49
|
-
);
|
|
50
|
-
}
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
## Currency Formats
|
|
54
|
-
|
|
55
|
-
### USD (Default)
|
|
56
|
-
|
|
57
|
-
US Dollar format with `$` symbol, comma thousand separators, and 2 decimal places.
|
|
58
|
-
|
|
59
|
-
```tsx
|
|
60
|
-
<CurrencyInput
|
|
61
|
-
name="currency-input"
|
|
62
|
-
defaultValue={1000}
|
|
63
|
-
/>
|
|
64
|
-
```
|
|
65
|
-
|
|
66
28
|
### KRW
|
|
67
29
|
|
|
68
|
-
Korean Won format with `₩` symbol, comma thousand separators, and no decimal places.
|
|
69
|
-
|
|
70
30
|
```tsx
|
|
71
31
|
<CurrencyInput
|
|
72
32
|
name="currency-input"
|
|
@@ -75,13 +35,7 @@ Korean Won format with `₩` symbol, comma thousand separators, and no decimal p
|
|
|
75
35
|
/>
|
|
76
36
|
```
|
|
77
37
|
|
|
78
|
-
|
|
79
|
-
<CurrencyInput currency="KRW" value={50000} />
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
## Sizes
|
|
83
|
-
|
|
84
|
-
CurrencyInput supports three sizes: `sm`, `md` (default), and `lg`.
|
|
38
|
+
### Sizes
|
|
85
39
|
|
|
86
40
|
```tsx
|
|
87
41
|
<Stack gap={2}>
|
|
@@ -91,9 +45,7 @@ CurrencyInput supports three sizes: `sm`, `md` (default), and `lg`.
|
|
|
91
45
|
</Stack>
|
|
92
46
|
```
|
|
93
47
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
### With Label
|
|
48
|
+
### WithLabel
|
|
97
49
|
|
|
98
50
|
```tsx
|
|
99
51
|
<CurrencyInput
|
|
@@ -103,11 +55,7 @@ CurrencyInput supports three sizes: `sm`, `md` (default), and `lg`.
|
|
|
103
55
|
/>
|
|
104
56
|
```
|
|
105
57
|
|
|
106
|
-
|
|
107
|
-
<CurrencyInput label="Total Amount" />
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
### With Helper Text
|
|
58
|
+
### WithHelperText
|
|
111
59
|
|
|
112
60
|
```tsx
|
|
113
61
|
<CurrencyInput
|
|
@@ -118,11 +66,7 @@ CurrencyInput supports three sizes: `sm`, `md` (default), and `lg`.
|
|
|
118
66
|
/>
|
|
119
67
|
```
|
|
120
68
|
|
|
121
|
-
|
|
122
|
-
<CurrencyInput label="Price" helperText="Enter the item price in USD." />
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
### Error State
|
|
69
|
+
### Error
|
|
126
70
|
|
|
127
71
|
```tsx
|
|
128
72
|
<CurrencyInput
|
|
@@ -134,13 +78,7 @@ CurrencyInput supports three sizes: `sm`, `md` (default), and `lg`.
|
|
|
134
78
|
/>
|
|
135
79
|
```
|
|
136
80
|
|
|
137
|
-
|
|
138
|
-
<CurrencyInput label="Amount" error helperText="Amount is required." />
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
## Price Limit
|
|
142
|
-
|
|
143
|
-
Set the `max` prop to enforce a maximum value. When the entered value exceeds the limit, the input automatically displays an error state with a formatted limit message.
|
|
81
|
+
### PriceLimitError
|
|
144
82
|
|
|
145
83
|
```tsx
|
|
146
84
|
<CurrencyInput
|
|
@@ -151,119 +89,3 @@ Set the `max` prop to enforce a maximum value. When the entered value exceeds th
|
|
|
151
89
|
max={1000000}
|
|
152
90
|
/>
|
|
153
91
|
```
|
|
154
|
-
|
|
155
|
-
```tsx
|
|
156
|
-
<CurrencyInput
|
|
157
|
-
currency="USD"
|
|
158
|
-
max={1000000}
|
|
159
|
-
value={10000000}
|
|
160
|
-
/>
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-
## Minor Unit Mode
|
|
164
|
-
|
|
165
|
-
When `useMinorUnit` is true, the component converts between display values and minor units (e.g., cents for USD). This is useful when your API stores amounts in the smallest currency unit.
|
|
166
|
-
|
|
167
|
-
```tsx
|
|
168
|
-
// Display shows "$10.00", but onChange returns 1000 (cents)
|
|
169
|
-
<CurrencyInput currency="USD" useMinorUnit value={1000} />
|
|
170
|
-
|
|
171
|
-
// Display shows "₩10,000", onChange returns 10000 (no conversion for KRW)
|
|
172
|
-
<CurrencyInput currency="KRW" useMinorUnit value={10000} />
|
|
173
|
-
```
|
|
174
|
-
|
|
175
|
-
## Common Use Cases
|
|
176
|
-
|
|
177
|
-
### Product Price Editor
|
|
178
|
-
|
|
179
|
-
```tsx
|
|
180
|
-
function ProductPriceEditor() {
|
|
181
|
-
const [priceUSD, setPriceUSD] = React.useState(0);
|
|
182
|
-
const [priceKRW, setPriceKRW] = React.useState(0);
|
|
183
|
-
|
|
184
|
-
return (
|
|
185
|
-
<Stack gap={2}>
|
|
186
|
-
<CurrencyInput
|
|
187
|
-
label="USD Price"
|
|
188
|
-
currency="USD"
|
|
189
|
-
value={priceUSD}
|
|
190
|
-
onChange={(e) => setPriceUSD(e.target.value)}
|
|
191
|
-
max={99999.99}
|
|
192
|
-
/>
|
|
193
|
-
<CurrencyInput
|
|
194
|
-
label="KRW Price"
|
|
195
|
-
currency="KRW"
|
|
196
|
-
value={priceKRW}
|
|
197
|
-
onChange={(e) => setPriceKRW(e.target.value)}
|
|
198
|
-
max={99999999}
|
|
199
|
-
/>
|
|
200
|
-
</Stack>
|
|
201
|
-
);
|
|
202
|
-
}
|
|
203
|
-
```
|
|
204
|
-
|
|
205
|
-
### Invoice Line Item
|
|
206
|
-
|
|
207
|
-
```tsx
|
|
208
|
-
function InvoiceLineItem({ item, onChange }) {
|
|
209
|
-
return (
|
|
210
|
-
<Stack direction="row" gap={2} alignItems="flex-end">
|
|
211
|
-
<Input label="Description" value={item.description} />
|
|
212
|
-
<CurrencyInput
|
|
213
|
-
label="Unit Price"
|
|
214
|
-
currency="USD"
|
|
215
|
-
value={item.unitPrice}
|
|
216
|
-
onChange={(e) => onChange({ ...item, unitPrice: e.target.value })}
|
|
217
|
-
/>
|
|
218
|
-
<Input label="Qty" type="number" value={item.quantity} sx={{ width: 80 }} />
|
|
219
|
-
</Stack>
|
|
220
|
-
);
|
|
221
|
-
}
|
|
222
|
-
```
|
|
223
|
-
|
|
224
|
-
### Budget Limit Input
|
|
225
|
-
|
|
226
|
-
```tsx
|
|
227
|
-
function BudgetSetting() {
|
|
228
|
-
const [budget, setBudget] = React.useState(50000);
|
|
229
|
-
|
|
230
|
-
return (
|
|
231
|
-
<CurrencyInput
|
|
232
|
-
label="Monthly Budget"
|
|
233
|
-
helperText="Set the maximum monthly spending limit."
|
|
234
|
-
currency="USD"
|
|
235
|
-
value={budget}
|
|
236
|
-
onChange={(e) => setBudget(e.target.value)}
|
|
237
|
-
max={1000000}
|
|
238
|
-
/>
|
|
239
|
-
);
|
|
240
|
-
}
|
|
241
|
-
```
|
|
242
|
-
|
|
243
|
-
## Best Practices
|
|
244
|
-
|
|
245
|
-
1. **Choose the right currency**: Always set the `currency` prop explicitly. USD uses 2 decimal places while KRW uses none.
|
|
246
|
-
|
|
247
|
-
```tsx
|
|
248
|
-
// ✅ Explicit currency
|
|
249
|
-
<CurrencyInput currency="USD" />
|
|
250
|
-
<CurrencyInput currency="KRW" />
|
|
251
|
-
|
|
252
|
-
// ❌ Relying on default — may confuse users expecting KRW
|
|
253
|
-
<CurrencyInput />
|
|
254
|
-
```
|
|
255
|
-
|
|
256
|
-
2. **Set max limits**: Use `max` to prevent unreasonable values. The component displays a helpful error message when the limit is exceeded.
|
|
257
|
-
|
|
258
|
-
3. **Use `useMinorUnit` for API integration**: When your backend stores amounts in minor units (cents, etc.), enable `useMinorUnit` to avoid manual conversion.
|
|
259
|
-
|
|
260
|
-
4. **Use built-in label and helperText**: Prefer the component's own `label` and `helperText` props over wrapping with FormControl.
|
|
261
|
-
|
|
262
|
-
5. **Handle negative values carefully**: CurrencyInput supports negative values. If negatives are not valid for your use case, validate in `onChange`.
|
|
263
|
-
|
|
264
|
-
## Accessibility
|
|
265
|
-
|
|
266
|
-
- The input has `role="textbox"` with proper labeling via the `label` prop.
|
|
267
|
-
- Error states are communicated via `aria-invalid` and associated error messages.
|
|
268
|
-
- The currency symbol serves as a visual indicator; ensure labels also mention the currency for screen readers.
|
|
269
|
-
- Keyboard input is fully supported — users can type numbers, and formatting is applied automatically.
|