Skip to content

Commit 81d471f

Browse files
committed
chore: cleanup
1 parent 4ad4cf9 commit 81d471f

File tree

2 files changed

+7
-15
lines changed

2 files changed

+7
-15
lines changed

src/components/experimental/DatePicker/docs/DatePicker.stories.tsx

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,7 @@ import type { DateRange as RdpRange } from 'react-day-picker';
33
import { getLocalTimeZone, today } from '@internationalized/date';
44
import type { Meta, StoryObj } from '@storybook/react';
55
import { DatePicker } from '../DatePicker';
6-
import type {
7-
DatePickerProps,
8-
SingleProps,
9-
MultipleProps,
10-
RangeProps,
11-
LegacyCompatProps // <-- import
12-
} from '../DatePicker';
6+
import type { DatePickerProps, SingleProps, MultipleProps, RangeProps, LegacyCompatProps } from '../DatePicker';
137

148
const meta = {
159
title: 'Experimental/Components/DatePicker',
@@ -27,7 +21,6 @@ type RangeStory = StoryObj<RangeProps & LegacyCompatProps>;
2721
const TZ = getLocalTimeZone();
2822
const TODAY = today(TZ);
2923

30-
// Single mode
3124
export const Default: SingleStory = { args: { mode: 'single' } };
3225

3326
export const WithDefaultValue: SingleStory = {

src/components/experimental/DatePicker/util/index.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1-
// util/index.ts
21
import { format as dfFormat, isValid as dfIsValid, parse as dfParse } from 'date-fns';
32
import { CalendarDate, fromDate, getLocalTimeZone, type DateValue } from '@internationalized/date';
43

54
export type Mode = 'single' | 'multiple' | 'range';
65

6+
type CalendarLike = { year: number; month: number; day: number };
7+
8+
function isCalendarLike(v: unknown): v is CalendarLike {
9+
return !!v && typeof v === 'object' && 'year' in v && 'month' in v && 'day' in v;
10+
}
11+
712
export function tryParse(raw: string, fmt: string, locale?: Locale): Date | null {
813
if (!raw?.trim()) return null;
914
const p = dfParse(raw, fmt, new Date(), { locale });
@@ -41,11 +46,6 @@ export function getSeparator(mode?: Mode, separator?: string): string {
4146
return (mode === 'range' ? separator : undefined) ?? ' – ';
4247
}
4348

44-
type CalendarLike = { year: number; month: number; day: number };
45-
function isCalendarLike(v: unknown): v is CalendarLike {
46-
return !!v && typeof v === 'object' && 'year' in v && 'month' in v && 'day' in v;
47-
}
48-
4949
export function toJSDate(d: unknown): Date | undefined {
5050
if (!d) return undefined;
5151
if (d instanceof Date) return d;
@@ -61,6 +61,5 @@ export function dateToCalendarDate(d: Date): CalendarDate {
6161
}
6262

6363
export function calendarDateToDate(dv: DateValue): Date {
64-
// DateValue has year/month/day; create a local JS Date at midnight.
6564
return new Date(dv.year, dv.month - 1, dv.day);
6665
}

0 commit comments

Comments
 (0)