@ceed/ads 1.29.1 → 1.30.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/dist/components/DatePicker/DatePicker.d.ts +10 -0
- package/dist/components/DateRangePicker/DateRangePicker.d.ts +10 -0
- package/dist/components/inputs/DatePicker.md +48 -0
- package/dist/components/inputs/DateRangePicker.md +62 -0
- package/dist/index.browser.js +2 -2
- package/dist/index.browser.js.map +3 -3
- package/dist/index.cjs +173 -6
- package/dist/index.js +173 -6
- package/framer/index.js +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import Input from '../Input';
|
|
3
|
+
export interface DatePickerPreset {
|
|
4
|
+
/** 프리셋 버튼에 표시할 라벨 */
|
|
5
|
+
label: string;
|
|
6
|
+
/** 컴포넌트의 format에 맞는 날짜 문자열 (예: "2026/04/03") */
|
|
7
|
+
value: string;
|
|
8
|
+
}
|
|
3
9
|
interface BaseDatePickerProps {
|
|
4
10
|
/**
|
|
5
11
|
* props.format 의 형식을 따라야 한다.
|
|
@@ -39,6 +45,10 @@ interface BaseDatePickerProps {
|
|
|
39
45
|
* @returns If `true` the date will be disabled
|
|
40
46
|
*/
|
|
41
47
|
shouldDisableDate?: (date: string) => boolean;
|
|
48
|
+
/**
|
|
49
|
+
* 달력 옆에 표시할 프리셋 목록. 각 항목의 value는 format prop의 형식을 따라야 한다.
|
|
50
|
+
*/
|
|
51
|
+
presets?: DatePickerPreset[];
|
|
42
52
|
}
|
|
43
53
|
export type DatePickerProps = BaseDatePickerProps & Omit<React.ComponentProps<typeof Input>, 'onChange' | 'value' | 'defaultValue'>;
|
|
44
54
|
declare const DatePicker: React.ForwardRefExoticComponent<Omit<DatePickerProps, "ref"> & React.RefAttributes<HTMLInputElement>>;
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import Input from '../Input';
|
|
3
|
+
export interface DateRangePickerPreset {
|
|
4
|
+
/** 프리셋 버튼에 표시할 라벨 */
|
|
5
|
+
label: string;
|
|
6
|
+
/** 컴포넌트의 format에 맞는 날짜 범위 문자열 (예: "2026/03/31 - 2026/04/03") */
|
|
7
|
+
value: string;
|
|
8
|
+
}
|
|
3
9
|
interface BaseDateRangePickerProps {
|
|
4
10
|
/**
|
|
5
11
|
* props.format 의 형식을 따라야 한다.
|
|
@@ -32,6 +38,10 @@ interface BaseDateRangePickerProps {
|
|
|
32
38
|
displayFormat?: string;
|
|
33
39
|
inputReadOnly?: boolean;
|
|
34
40
|
hideClearButton?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* 달력 옆에 표시할 프리셋 목록. 각 항목의 value는 format prop의 형식을 따라야 한다.
|
|
43
|
+
*/
|
|
44
|
+
presets?: DateRangePickerPreset[];
|
|
35
45
|
}
|
|
36
46
|
export type DateRangePickerProps = BaseDateRangePickerProps & Omit<React.ComponentProps<typeof Input>, 'onChange' | 'value' | 'defaultValue'>;
|
|
37
47
|
declare const DateRangePicker: React.ForwardRefExoticComponent<Omit<DateRangePickerProps, "ref"> & React.RefAttributes<HTMLInputElement>>;
|
|
@@ -256,6 +256,54 @@ Common patterns: `YYYY/MM/DD` (default), `YYYY-MM-DD` (ISO 8601), `MM/DD/YYYY` (
|
|
|
256
256
|
|
|
257
257
|
## Additional Features
|
|
258
258
|
|
|
259
|
+
### Presets
|
|
260
|
+
|
|
261
|
+
Use the `presets` prop to display a list of quick-select options alongside the calendar. This is useful when users frequently select common dates like "Today" or a specific day offset. The preset panel appears to the right of the calendar inside the popup.
|
|
262
|
+
|
|
263
|
+
Each preset's `value` must match the component's `format` prop. When the current value matches a preset, that preset is automatically highlighted -- regardless of whether the value was set via the preset button or by selecting the same date on the calendar.
|
|
264
|
+
|
|
265
|
+
```tsx
|
|
266
|
+
<DatePicker {...args} value={value} onChange={e => {
|
|
267
|
+
setValue(e.target.value);
|
|
268
|
+
args.onChange?.(e);
|
|
269
|
+
}} presets={[{
|
|
270
|
+
label: 'Today',
|
|
271
|
+
value: fmt(today)
|
|
272
|
+
}, {
|
|
273
|
+
label: 'Yesterday',
|
|
274
|
+
value: daysAgo(1)
|
|
275
|
+
}, {
|
|
276
|
+
label: '3 days ago',
|
|
277
|
+
value: daysAgo(3)
|
|
278
|
+
}, {
|
|
279
|
+
label: '1 week ago',
|
|
280
|
+
value: daysAgo(7)
|
|
281
|
+
}]} />
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
```tsx
|
|
285
|
+
import { DatePicker } from '@ceed/ads';
|
|
286
|
+
|
|
287
|
+
function QuickDateSelect() {
|
|
288
|
+
const [date, setDate] = useState('');
|
|
289
|
+
const today = new Date();
|
|
290
|
+
const fmt = (d: Date) =>
|
|
291
|
+
`${d.getFullYear()}/${String(d.getMonth() + 1).padStart(2, '0')}/${String(d.getDate()).padStart(2, '0')}`;
|
|
292
|
+
|
|
293
|
+
return (
|
|
294
|
+
<DatePicker
|
|
295
|
+
label="Select Date"
|
|
296
|
+
value={date}
|
|
297
|
+
onChange={(e) => setDate(e.target.value)}
|
|
298
|
+
presets={[
|
|
299
|
+
{ label: 'Today', value: fmt(today) },
|
|
300
|
+
{ label: 'Yesterday', value: fmt(new Date(today.getTime() - 86400000)) },
|
|
301
|
+
]}
|
|
302
|
+
/>
|
|
303
|
+
);
|
|
304
|
+
}
|
|
305
|
+
```
|
|
306
|
+
|
|
259
307
|
### Reset Button
|
|
260
308
|
|
|
261
309
|
Pair DatePicker with an external reset button to programmatically clear the value.
|
|
@@ -339,6 +339,68 @@ Fully read-only state where neither typing nor calendar selection is available.
|
|
|
339
339
|
|
|
340
340
|
## Additional Options
|
|
341
341
|
|
|
342
|
+
### Presets
|
|
343
|
+
|
|
344
|
+
Use the `presets` prop to display quick-select options alongside the calendar, such as "Last 7 days" or "Last 1 month". The preset panel appears to the right of the calendar inside the popup, providing one-click access to commonly used date ranges.
|
|
345
|
+
|
|
346
|
+
Each preset's `value` must match the component's `format` prop and use the `-` separator (e.g., `"2026/03/01 - 2026/04/03"`). When the current value matches a preset, that preset is automatically highlighted -- regardless of whether the value was set via the preset button or by selecting the same range on the calendar.
|
|
347
|
+
|
|
348
|
+
```tsx
|
|
349
|
+
<DateRangePicker {...args} value={value} onChange={e => {
|
|
350
|
+
setValue(e.target.value);
|
|
351
|
+
args.onChange?.(e);
|
|
352
|
+
}} presets={[{
|
|
353
|
+
label: 'Today',
|
|
354
|
+
value: `${fmt(today)} - ${fmt(today)}`
|
|
355
|
+
}, {
|
|
356
|
+
label: 'Last 3 days',
|
|
357
|
+
value: range(3)
|
|
358
|
+
}, {
|
|
359
|
+
label: 'Last 7 days',
|
|
360
|
+
value: range(7)
|
|
361
|
+
}, {
|
|
362
|
+
label: 'Last 1 month',
|
|
363
|
+
value: range(1, 'months')
|
|
364
|
+
}, {
|
|
365
|
+
label: 'Last 3 months',
|
|
366
|
+
value: range(3, 'months')
|
|
367
|
+
}, {
|
|
368
|
+
label: 'Last 6 months',
|
|
369
|
+
value: range(6, 'months')
|
|
370
|
+
}]} />
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
```tsx
|
|
374
|
+
import { DateRangePicker } from '@ceed/ads';
|
|
375
|
+
|
|
376
|
+
function ReportFilter() {
|
|
377
|
+
const [dateRange, setDateRange] = useState('');
|
|
378
|
+
const today = new Date();
|
|
379
|
+
const fmt = (d: Date) =>
|
|
380
|
+
`${d.getFullYear()}/${String(d.getMonth() + 1).padStart(2, '0')}/${String(d.getDate()).padStart(2, '0')}`;
|
|
381
|
+
const monthsAgo = (n: number) => {
|
|
382
|
+
const d = new Date(today);
|
|
383
|
+
d.setMonth(d.getMonth() - n);
|
|
384
|
+
return `${fmt(d)} - ${fmt(today)}`;
|
|
385
|
+
};
|
|
386
|
+
|
|
387
|
+
return (
|
|
388
|
+
<DateRangePicker
|
|
389
|
+
label="Report Period"
|
|
390
|
+
value={dateRange}
|
|
391
|
+
onChange={(e) => setDateRange(e.target.value)}
|
|
392
|
+
disableFuture
|
|
393
|
+
presets={[
|
|
394
|
+
{ label: 'Last 7 days', value: `${fmt(new Date(today.getTime() - 7 * 86400000))} - ${fmt(today)}` },
|
|
395
|
+
{ label: 'Last 1 month', value: monthsAgo(1) },
|
|
396
|
+
{ label: 'Last 3 months', value: monthsAgo(3) },
|
|
397
|
+
{ label: 'Last 6 months', value: monthsAgo(6) },
|
|
398
|
+
]}
|
|
399
|
+
/>
|
|
400
|
+
);
|
|
401
|
+
}
|
|
402
|
+
```
|
|
403
|
+
|
|
342
404
|
### Hide Clear Button
|
|
343
405
|
|
|
344
406
|
Remove the clear button from the calendar popup using `hideClearButton`.
|