monthpicker enableMonth string[] 파라미터 추가

(선택가능한 월 배열 추가하면됨 ex.['4월', '5월'])
This commit is contained in:
Your Name
2025-07-28 11:12:27 +09:00
parent 07c7947da1
commit dad8b9925e
2 changed files with 6 additions and 2 deletions
@@ -19,6 +19,7 @@ type MonthPickerProps = {
readOnly?: boolean;
startYear?: number; // 시작 연도 props 추가
yearReadOnly?: boolean;
enableMonth?: string[];
};
// yyyyMM → Date 객체
@@ -41,6 +42,7 @@ export const DateMonthPicker = ({
readOnly = false,
startYear,
yearReadOnly = false,
enableMonth,
}: MonthPickerProps) => {
const [open, setOpen] = useState(false);
@@ -81,6 +83,7 @@ export const DateMonthPicker = ({
onMonthChange={handleSelect}
startYear={startYear}
yearReadOnly={yearReadOnly}
enableMonth={enableMonth}
/>
</PopoverContent>
</Popover>
@@ -30,9 +30,10 @@ export type MonthPickerProps = {
) => void;
startYear?: number;
yearReadOnly?: boolean;
enableMonth?: string[];
};
export function MonthPicker({ currentMonth, onMonthChange, startYear, yearReadOnly }: MonthPickerProps) {
export function MonthPicker({ currentMonth, onMonthChange, startYear, yearReadOnly, enableMonth }: MonthPickerProps) {
const today = startOfToday();
const currentYear = today.getFullYear();
@@ -113,7 +114,7 @@ const selectedYear = parseInt(yearFromProp);
<button
name="month"
className={getMonthButtonClass(month)}
disabled={isFuture(month)}
disabled={isFuture(month) || (enableMonth && !enableMonth?.includes(format(month, 'MMM', { locale: ko })))}
role="gridcell"
tabIndex={-1}
type="button"