@ceed/ads 1.35.1 → 1.37.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/README.md +85 -95
- package/dist/components/Accordions/Accordions.d.ts +1 -0
- package/dist/components/Alert/Alert.d.ts +5 -5
- package/dist/components/Autocomplete/Autocomplete.d.ts +2 -2
- package/dist/components/Avatar/Avatar.d.ts +7 -17
- package/dist/components/Box/Box.d.ts +1 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +6 -5
- package/dist/components/Button/Button.d.ts +3 -2
- package/dist/components/Calendar/Calendar.d.ts +1 -0
- package/dist/components/Card/Card.d.ts +1 -0
- package/dist/components/Checkbox/Checkbox.d.ts +1 -0
- package/dist/components/Chip/Chip.d.ts +1 -0
- package/dist/components/Container/Container.d.ts +6 -1
- package/dist/components/DialogActions/DialogActions.d.ts +1 -0
- package/dist/components/DialogContent/DialogContent.d.ts +1 -0
- package/dist/components/DialogFrame/DialogFrame.d.ts +1 -1
- package/dist/components/DialogTitle/DialogTitle.d.ts +1 -0
- package/dist/components/Divider/Divider.d.ts +1 -0
- package/dist/components/Dropdown/Dropdown.d.ts +28 -1
- package/dist/components/FilterMenu/components/MonthRange.d.ts +11 -0
- package/dist/components/FilterMenu/types.d.ts +5 -1
- package/dist/components/FilterableCheckboxGroup/FilterableCheckboxGroup.d.ts +1 -1
- package/dist/components/FormControl/FormControl.d.ts +1 -0
- package/dist/components/FormHelperText/FormHelperText.d.ts +1 -0
- package/dist/components/FormLabel/FormLabel.d.ts +1 -0
- package/dist/components/Grid/Grid.d.ts +1 -0
- package/dist/components/IconButton/IconButton.d.ts +3 -2
- package/dist/components/IconMenuButton/IconMenuButton.d.ts +7 -6
- package/dist/components/InfoSign/InfoSign.d.ts +3 -2
- package/dist/components/Input/Input.d.ts +8 -22
- package/dist/components/InsetDrawer/InsetDrawer.d.ts +1 -0
- package/dist/components/Markdown/Markdown.d.ts +9 -24
- package/dist/components/Menu/Menu.d.ts +2 -1
- package/dist/components/MenuButton/MenuButton.d.ts +10 -8
- package/dist/components/Modal/Modal.d.ts +4 -2
- package/dist/components/NavigationGroup/NavigationGroup.d.ts +3 -2
- package/dist/components/NavigationItem/NavigationItem.d.ts +3 -2
- package/dist/components/Navigator/Navigator.d.ts +5 -4
- package/dist/components/Pagination/Pagination.d.ts +2 -2
- package/dist/components/ProfileMenu/ProfileMenu.d.ts +3 -3
- package/dist/components/Radio/Radio.d.ts +1 -0
- package/dist/components/RadioList/RadioList.d.ts +3 -2
- package/dist/components/Select/Select.d.ts +12 -10
- package/dist/components/Sheet/Sheet.d.ts +1 -0
- package/dist/components/Stack/Stack.d.ts +1 -0
- package/dist/components/Stepper/Stepper.d.ts +2 -1
- package/dist/components/Switch/Switch.d.ts +1 -0
- package/dist/components/Table/Table.d.ts +7 -5
- package/dist/components/Tabs/Tabs.d.ts +1 -0
- package/dist/components/Textarea/Textarea.d.ts +8 -20
- package/dist/components/ThemeProvider/ThemeProvider.d.ts +24 -2
- package/dist/components/Tooltip/Tooltip.d.ts +1 -0
- package/dist/components/Typography/Typography.d.ts +1 -0
- package/dist/components/Uploader/Uploader.d.ts +18 -17
- package/dist/components/data-display/Avatar.md +61 -73
- package/dist/components/data-display/Badge.md +198 -182
- package/dist/components/data-display/Chip.md +165 -143
- package/dist/components/data-display/DataTable.md +843 -338
- package/dist/components/data-display/InfoSign.md +1 -3
- package/dist/components/data-display/Markdown.md +93 -125
- package/dist/components/data-display/Table.md +1454 -1008
- package/dist/components/data-display/Tooltip.md +1 -1
- package/dist/components/data-display/Typography.md +101 -104
- package/dist/components/feedback/Alert.md +81 -87
- package/dist/components/feedback/CircularProgress.md +34 -38
- package/dist/components/feedback/Dialog.md +25 -17
- package/dist/components/feedback/Modal.md +297 -266
- package/dist/components/feedback/Skeleton.md +125 -89
- package/dist/components/index.d.ts +60 -1
- package/dist/components/inputs/Autocomplete.md +192 -96
- package/dist/components/inputs/Button.md +85 -85
- package/dist/components/inputs/ButtonGroup.md +197 -187
- package/dist/components/inputs/Calendar.md +25 -28
- package/dist/components/inputs/Checkbox.md +13 -31
- package/dist/components/inputs/CurrencyInput.md +6 -6
- package/dist/components/inputs/DatePicker.md +229 -110
- package/dist/components/inputs/DateRangePicker.md +248 -137
- package/dist/components/inputs/FilterMenu.md +138 -8
- package/dist/components/inputs/FilterableCheckboxGroup.md +116 -56
- package/dist/components/inputs/FormControl.md +76 -70
- package/dist/components/inputs/IconButton.md +231 -207
- package/dist/components/inputs/Input.md +133 -100
- package/dist/components/inputs/MonthPicker.md +186 -84
- package/dist/components/inputs/MonthRangePicker.md +73 -49
- package/dist/components/inputs/PercentageInput.md +17 -33
- package/dist/components/inputs/RadioButton.md +322 -258
- package/dist/components/inputs/RadioList.md +68 -52
- package/dist/components/inputs/RadioTileGroup.md +287 -170
- package/dist/components/inputs/SearchBar.md +82 -60
- package/dist/components/inputs/Select.md +108 -97
- package/dist/components/inputs/Slider.md +155 -104
- package/dist/components/inputs/Switch.md +194 -139
- package/dist/components/inputs/Textarea.md +17 -22
- package/dist/components/inputs/Uploader/Uploader.md +69 -40
- package/dist/components/layout/Box.md +841 -662
- package/dist/components/layout/Container.md +3 -11
- package/dist/components/layout/Grid.md +480 -394
- package/dist/components/layout/Stack.md +739 -566
- package/dist/components/navigation/Breadcrumbs.md +182 -116
- package/dist/components/navigation/Dropdown.md +732 -391
- package/dist/components/navigation/IconMenuButton.md +15 -7
- package/dist/components/navigation/InsetDrawer.md +550 -378
- package/dist/components/navigation/Link.md +104 -94
- package/dist/components/navigation/Menu.md +624 -503
- package/dist/components/navigation/MenuButton.md +19 -11
- package/dist/components/navigation/NavigationGroup.md +19 -50
- package/dist/components/navigation/NavigationItem.md +6 -6
- package/dist/components/navigation/Navigator.md +26 -28
- package/dist/components/navigation/Pagination.md +87 -76
- package/dist/components/navigation/ProfileMenu.md +67 -45
- package/dist/components/navigation/Stepper.md +2 -12
- package/dist/components/navigation/Tabs.md +210 -184
- package/dist/components/surfaces/Accordions.md +90 -173
- package/dist/components/surfaces/Card.md +1096 -711
- package/dist/components/surfaces/Divider.md +562 -412
- package/dist/components/surfaces/Sheet.md +700 -518
- package/dist/guides/ThemeProvider.md +65 -40
- package/dist/index.browser.js +5 -5
- package/dist/index.browser.js.map +4 -4
- package/dist/index.cjs +1906 -1690
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1404 -1180
- package/framer/index.js +1 -1
- package/package.json +34 -36
|
@@ -44,14 +44,7 @@ import { Input } from '@ceed/ads';
|
|
|
44
44
|
function MyComponent() {
|
|
45
45
|
const [value, setValue] = useState('');
|
|
46
46
|
|
|
47
|
-
return (
|
|
48
|
-
<Input
|
|
49
|
-
label="Name"
|
|
50
|
-
placeholder="Enter your name"
|
|
51
|
-
value={value}
|
|
52
|
-
onChange={(e) => setValue(e.target.value)}
|
|
53
|
-
/>
|
|
54
|
-
);
|
|
47
|
+
return <Input label="Name" placeholder="Enter your name" value={value} onChange={(e) => setValue(e.target.value)} />;
|
|
55
48
|
}
|
|
56
49
|
```
|
|
57
50
|
|
|
@@ -61,23 +54,23 @@ Input supports four visual styles: `outlined` (default), `solid`, `soft`, and `p
|
|
|
61
54
|
|
|
62
55
|
```tsx
|
|
63
56
|
<>
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
</>
|
|
57
|
+
<Input placeholder="Type in here…" variant="solid" />
|
|
58
|
+
<Input placeholder="Type in here…" variant="soft" />
|
|
59
|
+
<Input placeholder="Type in here…" variant="outlined" />
|
|
60
|
+
<Input placeholder="Type in here…" variant="plain" />
|
|
61
|
+
</>
|
|
69
62
|
```
|
|
70
63
|
|
|
71
64
|
## Sizes
|
|
72
65
|
|
|
73
|
-
Three sizes are available: `sm
|
|
66
|
+
Three sizes are available: `sm` (default), `md`, and `lg`.
|
|
74
67
|
|
|
75
68
|
```tsx
|
|
76
69
|
<>
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
</>
|
|
70
|
+
<Input {...args} size="lg" />
|
|
71
|
+
<Input {...args} size="md" />
|
|
72
|
+
<Input {...args} size="sm" />
|
|
73
|
+
</>
|
|
81
74
|
```
|
|
82
75
|
|
|
83
76
|
## Label and Helper Text
|
|
@@ -88,8 +81,8 @@ The `label` prop renders a form label above the input.
|
|
|
88
81
|
|
|
89
82
|
```tsx
|
|
90
83
|
<>
|
|
91
|
-
|
|
92
|
-
</>
|
|
84
|
+
<Input placeholder="Type in here…" label="Label" />
|
|
85
|
+
</>
|
|
93
86
|
```
|
|
94
87
|
|
|
95
88
|
### Helper Text
|
|
@@ -98,8 +91,8 @@ The `helperText` prop renders descriptive text below the input.
|
|
|
98
91
|
|
|
99
92
|
```tsx
|
|
100
93
|
<>
|
|
101
|
-
|
|
102
|
-
</>
|
|
94
|
+
<Input placeholder="Type in here…" helperText="I'm helper text" />
|
|
95
|
+
</>
|
|
103
96
|
```
|
|
104
97
|
|
|
105
98
|
## States
|
|
@@ -118,8 +111,8 @@ Set `error` to visually indicate a validation failure. Combine with `helperText`
|
|
|
118
111
|
|
|
119
112
|
```tsx
|
|
120
113
|
<>
|
|
121
|
-
|
|
122
|
-
</>
|
|
114
|
+
<Input placeholder="Invalid input" label="label" error />
|
|
115
|
+
</>
|
|
123
116
|
```
|
|
124
117
|
|
|
125
118
|
### Required
|
|
@@ -141,40 +134,66 @@ Use `startDecorator` and `endDecorator` to add icons, buttons, or other elements
|
|
|
141
134
|
|
|
142
135
|
```tsx
|
|
143
136
|
<Stack spacing={3}>
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
137
|
+
<Input
|
|
138
|
+
placeholder="Amount"
|
|
139
|
+
startDecorator={
|
|
140
|
+
{
|
|
141
|
+
dollar: "$",
|
|
142
|
+
baht: "฿",
|
|
143
|
+
yen: "¥"
|
|
144
|
+
}[currency]
|
|
145
|
+
}
|
|
146
|
+
endDecorator={
|
|
147
|
+
<React.Fragment>
|
|
148
|
+
<Divider orientation="vertical" />
|
|
149
|
+
<Select
|
|
150
|
+
variant="plain"
|
|
151
|
+
value={currency}
|
|
152
|
+
options={[
|
|
153
|
+
{
|
|
154
|
+
value: "dollar",
|
|
155
|
+
label: "US dollar"
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
value: "baht",
|
|
159
|
+
label: "Thai baht"
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
value: "yen",
|
|
163
|
+
label: "Japanese yen"
|
|
164
|
+
}
|
|
165
|
+
]}
|
|
166
|
+
onChange={(e) => setCurrency(e.target.value!)}
|
|
167
|
+
slotProps={{
|
|
168
|
+
listbox: {
|
|
169
|
+
variant: "outlined"
|
|
170
|
+
}
|
|
171
|
+
}}
|
|
172
|
+
sx={{
|
|
173
|
+
mr: -1.5,
|
|
174
|
+
"&:hover": {
|
|
175
|
+
bgcolor: "transparent"
|
|
176
|
+
}
|
|
177
|
+
}}
|
|
178
|
+
/>
|
|
179
|
+
</React.Fragment>
|
|
180
|
+
}
|
|
181
|
+
sx={{
|
|
182
|
+
width: 300
|
|
183
|
+
}}
|
|
184
|
+
/>
|
|
185
|
+
<Input
|
|
186
|
+
placeholder="Your location"
|
|
187
|
+
startDecorator={
|
|
188
|
+
<Button variant="soft" color="neutral" startDecorator={<LocationOn />}>
|
|
189
|
+
Locate
|
|
190
|
+
</Button>
|
|
191
|
+
}
|
|
192
|
+
sx={{
|
|
193
|
+
width: 300
|
|
194
|
+
}}
|
|
195
|
+
/>
|
|
196
|
+
</Stack>
|
|
178
197
|
```
|
|
179
198
|
|
|
180
199
|
When using `endDecorator` together with `enableClearable`, both elements are displayed side by side:
|
|
@@ -194,15 +213,12 @@ Set `enableClearable` to show a clear button when the input has a value. Clickin
|
|
|
194
213
|
|
|
195
214
|
```tsx
|
|
196
215
|
<>
|
|
197
|
-
|
|
198
|
-
</>
|
|
216
|
+
<Input placeholder="Type in here…" label="Label" enableClearable />
|
|
217
|
+
</>
|
|
199
218
|
```
|
|
200
219
|
|
|
201
220
|
```tsx
|
|
202
|
-
<Input
|
|
203
|
-
enableClearable
|
|
204
|
-
placeholder="Type something and clear it"
|
|
205
|
-
/>
|
|
221
|
+
<Input enableClearable placeholder="Type something and clear it" />
|
|
206
222
|
```
|
|
207
223
|
|
|
208
224
|
## Password Input
|
|
@@ -211,15 +227,27 @@ Setting `type="password"` creates a password field with an automatic visibility
|
|
|
211
227
|
|
|
212
228
|
```tsx
|
|
213
229
|
<Stack spacing={3}>
|
|
214
|
-
|
|
215
|
-
|
|
230
|
+
<Typography level="body-md">Default password input with toggle button:</Typography>
|
|
231
|
+
<Input {...args} placeholder="Enter password" type="password" label="Password" />
|
|
216
232
|
|
|
217
|
-
|
|
218
|
-
|
|
233
|
+
<Typography level="body-md">Disabled password input:</Typography>
|
|
234
|
+
<Input
|
|
235
|
+
{...args}
|
|
236
|
+
placeholder="Enter password"
|
|
237
|
+
type="password"
|
|
238
|
+
label="Disabled Password"
|
|
239
|
+
disabled
|
|
240
|
+
/>
|
|
219
241
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
242
|
+
<Typography level="body-md">Password input with toggle button disabled:</Typography>
|
|
243
|
+
<Input
|
|
244
|
+
{...args}
|
|
245
|
+
placeholder="Enter password"
|
|
246
|
+
type="password"
|
|
247
|
+
label="No Toggle"
|
|
248
|
+
disableTogglePasswordButton
|
|
249
|
+
/>
|
|
250
|
+
</Stack>
|
|
223
251
|
```
|
|
224
252
|
|
|
225
253
|
### Disabling the Password Toggle
|
|
@@ -236,12 +264,20 @@ Password inputs (`type="password"`) do not support custom `endDecorator` because
|
|
|
236
264
|
|
|
237
265
|
```tsx
|
|
238
266
|
<Stack spacing={3}>
|
|
239
|
-
|
|
240
|
-
|
|
267
|
+
<Typography level="body-md">
|
|
268
|
+
When type="password", the endDecorator is not supported:
|
|
269
|
+
</Typography>
|
|
270
|
+
<Input
|
|
271
|
+
{...args}
|
|
272
|
+
placeholder="Enter password"
|
|
273
|
+
type="password"
|
|
274
|
+
label="Password with endDecorator (will show warning)"
|
|
275
|
+
endDecorator={<Chip color="primary">Hi</Chip>}
|
|
276
|
+
/>
|
|
241
277
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
</Stack>
|
|
278
|
+
<Typography level="body-md">The password toggle button takes precedence:</Typography>
|
|
279
|
+
<Input {...args} placeholder="Enter password" type="password" label="Password" />
|
|
280
|
+
</Stack>
|
|
245
281
|
```
|
|
246
282
|
|
|
247
283
|
## Form Control
|
|
@@ -250,9 +286,9 @@ Combining `label`, `helperText`, and `error` produces a complete form field.
|
|
|
250
286
|
|
|
251
287
|
```tsx
|
|
252
288
|
<>
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
</>
|
|
289
|
+
<Input placeholder="Type in here..." helperText="I'm helper text" label="Label" />
|
|
290
|
+
<Input placeholder="Invalid input" helperText="I'm helper text" label="Label" error />
|
|
291
|
+
</>
|
|
256
292
|
```
|
|
257
293
|
|
|
258
294
|
```tsx
|
|
@@ -277,18 +313,20 @@ Use `value` and `onChange` for controlled behavior.
|
|
|
277
313
|
|
|
278
314
|
```tsx
|
|
279
315
|
<>
|
|
280
|
-
|
|
281
|
-
|
|
316
|
+
<Input
|
|
317
|
+
placeholder="Type in here…"
|
|
318
|
+
label="Label"
|
|
319
|
+
enableClearable
|
|
320
|
+
value={value}
|
|
321
|
+
onChange={handleChange}
|
|
322
|
+
/>
|
|
323
|
+
</>
|
|
282
324
|
```
|
|
283
325
|
|
|
284
326
|
```tsx
|
|
285
327
|
const [value, setValue] = useState('');
|
|
286
328
|
|
|
287
|
-
<Input
|
|
288
|
-
value={value}
|
|
289
|
-
onChange={(e) => setValue(e.target.value)}
|
|
290
|
-
placeholder="Controlled input"
|
|
291
|
-
/>
|
|
329
|
+
<Input value={value} onChange={(e) => setValue(e.target.value)} placeholder="Controlled input" />;
|
|
292
330
|
```
|
|
293
331
|
|
|
294
332
|
### Uncontrolled
|
|
@@ -332,18 +370,8 @@ function LoginForm({ onSubmit }) {
|
|
|
332
370
|
return (
|
|
333
371
|
<form onSubmit={onSubmit}>
|
|
334
372
|
<Stack spacing={2}>
|
|
335
|
-
<Input
|
|
336
|
-
|
|
337
|
-
type="email"
|
|
338
|
-
required
|
|
339
|
-
placeholder="Enter your email"
|
|
340
|
-
/>
|
|
341
|
-
<Input
|
|
342
|
-
label="Password"
|
|
343
|
-
type="password"
|
|
344
|
-
required
|
|
345
|
-
placeholder="Enter your password"
|
|
346
|
-
/>
|
|
373
|
+
<Input label="Email" type="email" required placeholder="Enter your email" />
|
|
374
|
+
<Input label="Password" type="password" required placeholder="Enter your password" />
|
|
347
375
|
<Button type="submit">Sign In</Button>
|
|
348
376
|
</Stack>
|
|
349
377
|
</form>
|
|
@@ -363,7 +391,12 @@ function ValidatedForm() {
|
|
|
363
391
|
const isValid = /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email);
|
|
364
392
|
|
|
365
393
|
return (
|
|
366
|
-
<form
|
|
394
|
+
<form
|
|
395
|
+
onSubmit={(e) => {
|
|
396
|
+
e.preventDefault();
|
|
397
|
+
setSubmitted(true);
|
|
398
|
+
}}
|
|
399
|
+
>
|
|
367
400
|
<Stack spacing={2}>
|
|
368
401
|
<Input
|
|
369
402
|
label="Email"
|
|
@@ -401,7 +434,7 @@ function ValidatedForm() {
|
|
|
401
434
|
| `readOnly` | `boolean` | `false` | Makes the input read-only (focusable but not editable) |
|
|
402
435
|
| `required` | `boolean` | `false` | Marks the field as required (adds asterisk to label) |
|
|
403
436
|
| `name` | `string` | - | HTML name attribute for form submission |
|
|
404
|
-
| `size` | `'sm' \| 'md' \| 'lg'` | `'
|
|
437
|
+
| `size` | `'sm' \| 'md' \| 'lg'` | `'sm'` | Input size |
|
|
405
438
|
| `variant` | `'outlined' \| 'solid' \| 'soft' \| 'plain'` | `'outlined'` | Visual style variant |
|
|
406
439
|
| `color` | `'primary' \| 'neutral' \| 'danger' \| 'success' \| 'warning'` | `'neutral'` | Color scheme |
|
|
407
440
|
| `startDecorator` | `ReactNode` | - | Content rendered at the start of the input |
|
|
@@ -35,13 +35,7 @@ import { MonthPicker } from '@ceed/ads';
|
|
|
35
35
|
function MonthForm() {
|
|
36
36
|
const [month, setMonth] = useState('');
|
|
37
37
|
|
|
38
|
-
return (
|
|
39
|
-
<MonthPicker
|
|
40
|
-
label="Select Month"
|
|
41
|
-
value={month}
|
|
42
|
-
onChange={(e) => setMonth(e.target.value)}
|
|
43
|
-
/>
|
|
44
|
-
);
|
|
38
|
+
return <MonthPicker label="Select Month" value={month} onChange={(e) => setMonth(e.target.value)} />;
|
|
45
39
|
}
|
|
46
40
|
```
|
|
47
41
|
|
|
@@ -56,10 +50,10 @@ MonthPicker supports three sizes (`sm`, `md`, `lg`) for different layouts and co
|
|
|
56
50
|
|
|
57
51
|
```tsx
|
|
58
52
|
<Stack gap={2}>
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
</Stack>
|
|
53
|
+
<MonthPicker size="sm" />
|
|
54
|
+
<MonthPicker size="md" />
|
|
55
|
+
<MonthPicker size="lg" />
|
|
56
|
+
</Stack>
|
|
63
57
|
```
|
|
64
58
|
|
|
65
59
|
## Form Field Features
|
|
@@ -157,17 +151,19 @@ The parent component manages the month state via the `value` and `onChange` prop
|
|
|
157
151
|
|
|
158
152
|
```tsx
|
|
159
153
|
<Stack gap={2}>
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
154
|
+
<MonthPicker {...args} value={value} onChange={(e) => setValue(e.target.value)} />
|
|
155
|
+
<Button
|
|
156
|
+
onClick={() => {
|
|
157
|
+
const currentValue = new Date(value);
|
|
158
|
+
currentValue.setMonth(currentValue.getMonth() + 1);
|
|
159
|
+
const year = currentValue.getFullYear();
|
|
160
|
+
const month = String(currentValue.getMonth() + 1).padStart(2, "0");
|
|
161
|
+
setValue(`${year}/${month}/01`);
|
|
162
|
+
}}
|
|
163
|
+
>
|
|
164
|
+
Next Month
|
|
165
|
+
</Button>
|
|
166
|
+
</Stack>
|
|
171
167
|
```
|
|
172
168
|
|
|
173
169
|
### Uncontrolled
|
|
@@ -190,13 +186,55 @@ The `format` prop determines the shape of the value emitted by `onChange`. Each
|
|
|
190
186
|
|
|
191
187
|
```tsx
|
|
192
188
|
<Stack gap={2}>
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
189
|
+
<MonthPicker
|
|
190
|
+
{...args}
|
|
191
|
+
value={value["YYYY.MM.DD"]}
|
|
192
|
+
label="YYYY.MM.DD"
|
|
193
|
+
name="YYYY.MM.DD"
|
|
194
|
+
format="YYYY.MM.DD"
|
|
195
|
+
onChange={handleChange}
|
|
196
|
+
/>
|
|
197
|
+
<MonthPicker
|
|
198
|
+
{...args}
|
|
199
|
+
value={value["YYYY/MM/DD"]}
|
|
200
|
+
label="YYYY/MM/DD"
|
|
201
|
+
name="YYYY/MM/DD"
|
|
202
|
+
format="YYYY/MM/DD"
|
|
203
|
+
onChange={handleChange}
|
|
204
|
+
/>
|
|
205
|
+
<MonthPicker
|
|
206
|
+
{...args}
|
|
207
|
+
value={value["MM/DD/YYYY"]}
|
|
208
|
+
label="MM/DD/YYYY"
|
|
209
|
+
name="MM/DD/YYYY"
|
|
210
|
+
format="MM/DD/YYYY"
|
|
211
|
+
onChange={handleChange}
|
|
212
|
+
/>
|
|
213
|
+
<MonthPicker
|
|
214
|
+
{...args}
|
|
215
|
+
value={value["YYYY-MM-DD"]}
|
|
216
|
+
label="YYYY-MM-DD"
|
|
217
|
+
name="YYYY-MM-DD"
|
|
218
|
+
format="YYYY-MM-DD"
|
|
219
|
+
onChange={handleChange}
|
|
220
|
+
/>
|
|
221
|
+
<MonthPicker
|
|
222
|
+
{...args}
|
|
223
|
+
value={value["DD/MM/YYYY"]}
|
|
224
|
+
label="DD/MM/YYYY"
|
|
225
|
+
name="DD/MM/YYYY"
|
|
226
|
+
format="DD/MM/YYYY"
|
|
227
|
+
onChange={handleChange}
|
|
228
|
+
/>
|
|
229
|
+
<MonthPicker
|
|
230
|
+
{...args}
|
|
231
|
+
value={value["DD.MM.YYYY"]}
|
|
232
|
+
label="DD.MM.YYYY"
|
|
233
|
+
name="DD.MM.YYYY"
|
|
234
|
+
format="DD.MM.YYYY"
|
|
235
|
+
onChange={handleChange}
|
|
236
|
+
/>
|
|
237
|
+
</Stack>
|
|
200
238
|
```
|
|
201
239
|
|
|
202
240
|
### Display Formats
|
|
@@ -205,43 +243,108 @@ The `displayFormat` prop controls what users see in the input field, independent
|
|
|
205
243
|
|
|
206
244
|
```tsx
|
|
207
245
|
<Stack gap={2}>
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
246
|
+
<MonthPicker
|
|
247
|
+
{...args}
|
|
248
|
+
value={value1}
|
|
249
|
+
label="YYYY.MM"
|
|
250
|
+
name="YYYY.MM"
|
|
251
|
+
displayFormat="YYYY.MM"
|
|
252
|
+
onChange={(e) => {
|
|
253
|
+
setValue1(e.target.value);
|
|
254
|
+
args.onChange?.(e);
|
|
255
|
+
}}
|
|
256
|
+
/>
|
|
257
|
+
<MonthPicker
|
|
258
|
+
{...args}
|
|
259
|
+
value={value2}
|
|
260
|
+
label="YYYY/MM"
|
|
261
|
+
name="YYYY/MM"
|
|
262
|
+
displayFormat="YYYY/MM"
|
|
263
|
+
onChange={(e) => {
|
|
264
|
+
setValue2(e.target.value);
|
|
265
|
+
args.onChange?.(e);
|
|
266
|
+
}}
|
|
267
|
+
/>
|
|
268
|
+
<MonthPicker
|
|
269
|
+
{...args}
|
|
270
|
+
value={value3}
|
|
271
|
+
label="MM/YYYY"
|
|
272
|
+
name="MM/YYYY"
|
|
273
|
+
displayFormat="MM/YYYY"
|
|
274
|
+
onChange={(e) => {
|
|
275
|
+
setValue3(e.target.value);
|
|
276
|
+
args.onChange?.(e);
|
|
277
|
+
}}
|
|
278
|
+
/>
|
|
279
|
+
<MonthPicker
|
|
280
|
+
{...args}
|
|
281
|
+
value={value4}
|
|
282
|
+
label="YYYY-MM"
|
|
283
|
+
name="YYYY-MM"
|
|
284
|
+
displayFormat="YYYY-MM"
|
|
285
|
+
onChange={(e) => {
|
|
286
|
+
setValue4(e.target.value);
|
|
287
|
+
args.onChange?.(e);
|
|
288
|
+
}}
|
|
289
|
+
/>
|
|
290
|
+
<MonthPicker
|
|
291
|
+
{...args}
|
|
292
|
+
value={value5}
|
|
293
|
+
label="YYYY-MM-DD"
|
|
294
|
+
name="YYYY-MM-DD"
|
|
295
|
+
displayFormat="YYYY-MM-DD"
|
|
296
|
+
onChange={(e) => {
|
|
297
|
+
setValue5(e.target.value);
|
|
298
|
+
args.onChange?.(e);
|
|
299
|
+
}}
|
|
300
|
+
/>
|
|
301
|
+
<MonthPicker
|
|
302
|
+
{...args}
|
|
303
|
+
value={value6}
|
|
304
|
+
label="MMMM YYYY"
|
|
305
|
+
name="MMMM YYYY"
|
|
306
|
+
displayFormat="MMMM YYYY"
|
|
307
|
+
onChange={(e) => {
|
|
308
|
+
setValue6(e.target.value);
|
|
309
|
+
args.onChange?.(e);
|
|
310
|
+
}}
|
|
311
|
+
/>
|
|
312
|
+
<MonthPicker
|
|
313
|
+
{...args}
|
|
314
|
+
value={value6}
|
|
315
|
+
label="MMM YYYY"
|
|
316
|
+
name="MMM YYYY"
|
|
317
|
+
displayFormat="MMM YYYY"
|
|
318
|
+
onChange={(e) => {
|
|
319
|
+
setValue6(e.target.value);
|
|
320
|
+
args.onChange?.(e);
|
|
321
|
+
}}
|
|
322
|
+
/>
|
|
323
|
+
<MonthPicker
|
|
324
|
+
{...args}
|
|
325
|
+
value={value6}
|
|
326
|
+
label="MMM YYYY (en-US)"
|
|
327
|
+
name="MMM YYYY (en-US)"
|
|
328
|
+
displayFormat="MMM YYYY"
|
|
329
|
+
locale="en-US"
|
|
330
|
+
onChange={(e) => {
|
|
331
|
+
setValue6(e.target.value);
|
|
332
|
+
args.onChange?.(e);
|
|
333
|
+
}}
|
|
334
|
+
/>
|
|
335
|
+
<MonthPicker
|
|
336
|
+
{...args}
|
|
337
|
+
value={value6}
|
|
338
|
+
label="MMM YYYY (ko-KR)"
|
|
339
|
+
name="MMM YYYY (ko-KR)"
|
|
340
|
+
displayFormat="MMM YYYY"
|
|
341
|
+
locale="ko-KR"
|
|
342
|
+
onChange={(e) => {
|
|
343
|
+
setValue6(e.target.value);
|
|
344
|
+
args.onChange?.(e);
|
|
345
|
+
}}
|
|
346
|
+
/>
|
|
347
|
+
</Stack>
|
|
245
348
|
```
|
|
246
349
|
|
|
247
350
|
### With Reset Button
|
|
@@ -249,15 +352,21 @@ The `displayFormat` prop controls what users see in the input field, independent
|
|
|
249
352
|
A controlled example with an external reset button to clear the selected value.
|
|
250
353
|
|
|
251
354
|
```tsx
|
|
252
|
-
<div
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
355
|
+
<div
|
|
356
|
+
style={{
|
|
357
|
+
display: "flex",
|
|
358
|
+
gap: "10px"
|
|
359
|
+
}}
|
|
360
|
+
>
|
|
361
|
+
<MonthPicker
|
|
362
|
+
{...props}
|
|
363
|
+
value={value}
|
|
364
|
+
onChange={(event) => {
|
|
365
|
+
setValue(event.target.value);
|
|
366
|
+
}}
|
|
367
|
+
/>
|
|
368
|
+
<Button onClick={() => setValue("")}>Reset</Button>
|
|
369
|
+
</div>
|
|
261
370
|
```
|
|
262
371
|
|
|
263
372
|
## Billing Period Selection
|
|
@@ -335,21 +444,14 @@ function CreditCardExpiry() {
|
|
|
335
444
|
|
|
336
445
|
```tsx
|
|
337
446
|
// ✅ Good: Separate concerns
|
|
338
|
-
<MonthPicker
|
|
339
|
-
format="YYYY/MM/DD"
|
|
340
|
-
displayFormat="MMMM YYYY"
|
|
341
|
-
/>
|
|
447
|
+
<MonthPicker format="YYYY/MM/DD" displayFormat="MMMM YYYY" />
|
|
342
448
|
```
|
|
343
449
|
|
|
344
450
|
3. **Provide context with `helperText`**: Guide users on what they are selecting, especially when constraints are applied.
|
|
345
451
|
|
|
346
452
|
```tsx
|
|
347
453
|
// ✅ Good: Clear guidance
|
|
348
|
-
<MonthPicker
|
|
349
|
-
label="Statement Month"
|
|
350
|
-
helperText="Select the month for your account statement"
|
|
351
|
-
disableFuture
|
|
352
|
-
/>
|
|
454
|
+
<MonthPicker label="Statement Month" helperText="Select the month for your account statement" disableFuture />
|
|
353
455
|
```
|
|
354
456
|
|
|
355
457
|
4. **Set reasonable date constraints**: Use `minDate`, `maxDate`, `disableFuture`, or `disablePast` to prevent invalid selections at the UI level.
|