Skip to content

Commit

Permalink
fix: typecheck errors
Browse files Browse the repository at this point in the history
  • Loading branch information
wingkwong committed Dec 8, 2024
1 parent e7f269d commit 84006f2
Show file tree
Hide file tree
Showing 32 changed files with 59 additions and 59 deletions.
6 changes: 3 additions & 3 deletions apps/docs/app/examples/table/custom-styles/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -360,9 +360,9 @@ export default function Page() {
</Button>
</DropdownTrigger>
<DropdownMenu>
<DropdownItem>View</DropdownItem>
<DropdownItem>Edit</DropdownItem>
<DropdownItem>Delete</DropdownItem>
<DropdownItem key="view">View</DropdownItem>
<DropdownItem key="edit">Edit</DropdownItem>
<DropdownItem key="delete">Delete</DropdownItem>
</DropdownMenu>
</Dropdown>
</div>
Expand Down
6 changes: 3 additions & 3 deletions apps/docs/app/examples/table/use-case/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -352,9 +352,9 @@ export default function Page() {
</Button>
</DropdownTrigger>
<DropdownMenu>
<DropdownItem>View</DropdownItem>
<DropdownItem>Edit</DropdownItem>
<DropdownItem>Delete</DropdownItem>
<DropdownItem key="view">View</DropdownItem>
<DropdownItem key="edit">Edit</DropdownItem>
<DropdownItem key="delete">Delete</DropdownItem>
</DropdownMenu>
</Dropdown>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {today, getLocalTimeZone} from "@internationalized/date";

export default function App() {
let defaultDate = today(getLocalTimeZone());
let [focusedDate, setFocusedDate] = React.useState<DateValue>(defaultDate);
let [focusedDate, setFocusedDate] = React.useState<DateValue | null>(defaultDate);

return (
<Calendar
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/content/components/calendar/controlled.raw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {Calendar} from "@nextui-org/react";
import {parseDate} from "@internationalized/date";

export default function App() {
let [value, setValue] = React.useState<DateValue>(parseDate("2024-03-07"));
let [value, setValue] = React.useState<DateValue | null>(parseDate("2024-03-07"));

return <Calendar aria-label="Date (Controlled)" value={value} onChange={setValue} />;
}
4 changes: 2 additions & 2 deletions apps/docs/content/components/calendar/invalid-date.raw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import {today, getLocalTimeZone, isWeekend} from "@internationalized/date";
import {useLocale} from "@react-aria/i18n";

export default function App() {
let [date, setDate] = React.useState<DateValue>(today(getLocalTimeZone()));
let [date, setDate] = React.useState<DateValue | null>(today(getLocalTimeZone()));
let {locale} = useLocale();
let isInvalid = isWeekend(date, locale);
let isInvalid = isWeekend(date!, locale);

return (
<Calendar
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/content/components/calendar/presets.raw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {useLocale} from "@react-aria/i18n";

export default function App() {
let defaultDate = today(getLocalTimeZone());
let [value, setValue] = React.useState<DateValue>(defaultDate);
let [value, setValue] = React.useState<DateValue | null>(defaultDate);
let {locale} = useLocale();

let now = today(getLocalTimeZone());
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/content/components/date-input/controlled.raw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {DateValue, parseDate, getLocalTimeZone} from "@internationalized/date";
import {useDateFormatter} from "@react-aria/i18n";

export default function App() {
const [value, setValue] = React.useState<DateValue>(parseDate("2024-04-04"));
const [value, setValue] = React.useState<DateValue | null>(parseDate("2024-04-04"));

let formatter = useDateFormatter({dateStyle: "full"});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {DateInput} from "@nextui-org/react";
import {DateValue, now, parseAbsoluteToLocal} from "@internationalized/date";

export default function App() {
let [date, setDate] = React.useState<DateValue>(parseAbsoluteToLocal("2021-04-07T18:45:22Z"));
let [date, setDate] = React.useState<DateValue | null>(parseAbsoluteToLocal("2021-04-07T18:45:22Z"));

return (
<div className="w-full max-w-xl flex flex-col items-start gap-4">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {DateValue, parseAbsoluteToLocal} from "@internationalized/date";
import {I18nProvider} from "@react-aria/i18n";

export default function App() {
const [date, setDate] = React.useState<DateValue>(parseAbsoluteToLocal("2021-04-07T18:45:22Z"));
const [date, setDate] = React.useState<DateValue | null>(parseAbsoluteToLocal("2021-04-07T18:45:22Z"));

return (
<div className="flex flex-col gap-4">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {DateValue, parseDate, getLocalTimeZone} from "@internationalized/date";
import {useDateFormatter} from "@react-aria/i18n";

export default function App() {
const [value, setValue] = React.useState<DateValue>(parseDate("2024-04-04"));
const [value, setValue] = React.useState<DateValue | null>(parseDate("2024-04-04"));

let formatter = useDateFormatter({dateStyle: "full"});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {DatePicker} from "@nextui-org/react";
import {DateValue, now, parseAbsoluteToLocal} from "@internationalized/date";

export default function App() {
let [date, setDate] = React.useState<DateValue>(parseAbsoluteToLocal("2021-04-07T18:45:22Z"));
let [date, setDate] = React.useState<DateValue | null>(parseAbsoluteToLocal("2021-04-07T18:45:22Z"));

return (
<div className="w-full max-w-xl flex flex-col items-start gap-4">
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/content/components/date-picker/granularity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const AppTs = `import {DatePicker} from "@nextui-org/react";
import {DateValue, now, parseAbsoluteToLocal} from "@internationalized/date";
export default function App() {
let [date, setDate] = React.useState<DateValue>(parseAbsoluteToLocal("2021-04-07T18:45:22Z"));
let [date, setDate] = React.useState<DateValue | null>(parseAbsoluteToLocal("2021-04-07T18:45:22Z"));
return (
<div className="w-full max-w-xl flex flex-col items-start gap-4">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {DateValue, parseAbsoluteToLocal} from "@internationalized/date";
import {I18nProvider} from "@react-aria/i18n";

export default function App() {
let [date, setDate] = React.useState<DateValue>(parseAbsoluteToLocal("2021-04-07T18:45:22Z"));
let [date, setDate] = React.useState<DateValue | null>(parseAbsoluteToLocal("2021-04-07T18:45:22Z"));

return (
<div className="flex flex-col gap-4">
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/content/components/date-picker/preset.raw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {useLocale, useDateFormatter} from "@react-aria/i18n";
export default function App() {
let defaultDate = today(getLocalTimeZone());

const [value, setValue] = React.useState<DateValue>(defaultDate);
const [value, setValue] = React.useState<DateValue | null>(defaultDate);

let {locale} = useLocale();
let formatter = useDateFormatter({dateStyle: "full"});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {parseDate, getLocalTimeZone} from "@internationalized/date";
import {useDateFormatter} from "@react-aria/i18n";

export default function App() {
const [value, setValue] = React.useState<RangeValue<DateValue>>({
const [value, setValue] = React.useState<RangeValue<DateValue> | null>({
start: parseDate("2024-04-01"),
end: parseDate("2024-04-08"),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {DateRangePicker} from "@nextui-org/react";
import {parseAbsoluteToLocal} from "@internationalized/date";

export default function App() {
let [date, setDate] = React.useState<RangeValue<DateValue>>({
let [date, setDate] = React.useState<RangeValue<DateValue> | null>({
start: parseAbsoluteToLocal("2024-04-01T18:45:22Z"),
end: parseAbsoluteToLocal("2024-04-08T19:15:22Z"),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {parseAbsoluteToLocal} from "@internationalized/date";
import {I18nProvider} from "@react-aria/i18n";

export default function App() {
let [date, setDate] = React.useState<RangeValue<DateValue>>({
let [date, setDate] = React.useState<RangeValue<DateValue> | null>({
start: parseAbsoluteToLocal("2021-04-01T18:45:22Z"),
end: parseAbsoluteToLocal("2021-04-14T19:15:22Z"),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default function App() {
end: today(getLocalTimeZone()).add({weeks: 1, days: 3}),
});

let [focusedValue, setFocusedValue] = React.useState<DateValue>(today(getLocalTimeZone()));
let [focusedValue, setFocusedValue] = React.useState<DateValue | null>(today(getLocalTimeZone()));

let {locale} = useLocale();

Expand Down
6 changes: 3 additions & 3 deletions apps/docs/content/components/table/custom-styles.raw.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -449,9 +449,9 @@ export default function App() {
</Button>
</DropdownTrigger>
<DropdownMenu>
<DropdownItem>View</DropdownItem>
<DropdownItem>Edit</DropdownItem>
<DropdownItem>Delete</DropdownItem>
<DropdownItem key="view">View</DropdownItem>
<DropdownItem key="edit">Edit</DropdownItem>
<DropdownItem key="delete">Delete</DropdownItem>
</DropdownMenu>
</Dropdown>
</div>
Expand Down
6 changes: 3 additions & 3 deletions apps/docs/content/components/table/custom-styles.raw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -461,9 +461,9 @@ export default function App() {
</Button>
</DropdownTrigger>
<DropdownMenu>
<DropdownItem>View</DropdownItem>
<DropdownItem>Edit</DropdownItem>
<DropdownItem>Delete</DropdownItem>
<DropdownItem key="view">View</DropdownItem>
<DropdownItem key="edit">Edit</DropdownItem>
<DropdownItem key="delete">Delete</DropdownItem>
</DropdownMenu>
</Dropdown>
</div>
Expand Down
6 changes: 3 additions & 3 deletions apps/docs/content/components/table/use-case.raw.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -441,9 +441,9 @@ export default function App() {
</Button>
</DropdownTrigger>
<DropdownMenu>
<DropdownItem>View</DropdownItem>
<DropdownItem>Edit</DropdownItem>
<DropdownItem>Delete</DropdownItem>
<DropdownItem key="view">View</DropdownItem>
<DropdownItem key="edit">Edit</DropdownItem>
<DropdownItem key="delete">Delete</DropdownItem>
</DropdownMenu>
</Dropdown>
</div>
Expand Down
6 changes: 3 additions & 3 deletions apps/docs/content/components/table/use-case.raw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -454,9 +454,9 @@ export default function App() {
</Button>
</DropdownTrigger>
<DropdownMenu>
<DropdownItem>View</DropdownItem>
<DropdownItem>Edit</DropdownItem>
<DropdownItem>Delete</DropdownItem>
<DropdownItem key="view">View</DropdownItem>
<DropdownItem key="edit">Edit</DropdownItem>
<DropdownItem key="delete">Delete</DropdownItem>
</DropdownMenu>
</Dropdown>
</div>
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/content/components/time-input/controlled.raw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {parseAbsoluteToLocal, Time, ZonedDateTime} from "@internationalized/date
import {useDateFormatter} from "@react-aria/i18n";

export default function App() {
let [value, setValue] = React.useState<TimeInputValue>(
let [value, setValue] = React.useState<TimeInputValue | null>(
parseAbsoluteToLocal("2024-04-08T18:45:22Z"),
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {TimeInput} from "@nextui-org/react";
import {parseAbsoluteToLocal} from "@internationalized/date";

export default function App() {
let [date, setDate] = React.useState<TimeInputValue>(
let [date, setDate] = React.useState<TimeInputValue | null>(
parseAbsoluteToLocal("2021-04-07T18:45:22Z"),
);

Expand Down
8 changes: 4 additions & 4 deletions packages/components/calendar/stories/calendar.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const defaultProps = {
const Template = (args: CalendarProps) => <Calendar {...args} />;

const ControlledTemplate = (args: CalendarProps) => {
let [value, setValue] = React.useState<DateValue>(parseDate("2024-03-07"));
let [value, setValue] = React.useState<DateValue | null>(parseDate("2024-03-07"));

return (
<div className="flex flex-wrap gap-4">
Expand Down Expand Up @@ -110,7 +110,7 @@ const UnavailableDatesTemplate = (args: CalendarProps) => {

const ControlledFocusedValueTemplate = (args: CalendarProps) => {
let defaultDate = today(getLocalTimeZone());
let [focusedDate, setFocusedDate] = React.useState<DateValue>(defaultDate);
let [focusedDate, setFocusedDate] = React.useState<DateValue | null>(defaultDate);

return (
<div className="flex flex-col gap-4">
Expand All @@ -133,7 +133,7 @@ const ControlledFocusedValueTemplate = (args: CalendarProps) => {
};

const InvalidDateTemplate = (args: CalendarProps) => {
let [date, setDate] = React.useState<DateValue>(today(getLocalTimeZone()));
let [date, setDate] = React.useState<DateValue | null>(today(getLocalTimeZone()));
let {locale} = useLocale();
let isInvalid = isWeekend(date, locale);

Expand Down Expand Up @@ -161,7 +161,7 @@ const InternationalCalendarsTemplate = (args: CalendarProps) => {

const PresetsTemplate = (args: CalendarProps) => {
let defaultDate = today(getLocalTimeZone());
let [value, setValue] = React.useState<DateValue>(defaultDate);
let [value, setValue] = React.useState<DateValue | null>(defaultDate);
let {locale} = useLocale();

let now = today(getLocalTimeZone());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ const ControlledFocusedValueTemplate = (args: RangeCalendarProps) => {
};

const InvalidDatesTemplate = (args: RangeCalendarProps) => {
let [date, setDate] = React.useState<RangeValue<DateValue>>({
let [date, setDate] = React.useState<RangeValue<DateValue> | null>({
start: today(getLocalTimeZone()),
end: today(getLocalTimeZone()).add({weeks: 1}),
});
Expand Down Expand Up @@ -172,12 +172,12 @@ const InternationalCalendarsTemplate = (args: RangeCalendarProps) => {
};

const PresetsTemplate = (args: RangeCalendarProps) => {
let [value, setValue] = React.useState<RangeValue<DateValue>>({
let [value, setValue] = React.useState<RangeValue<DateValue> | null>({
start: today(getLocalTimeZone()),
end: today(getLocalTimeZone()).add({weeks: 1, days: 3}),
});

let [focusedValue, setFocusedValue] = React.useState<DateValue>(today(getLocalTimeZone()));
let [focusedValue, setFocusedValue] = React.useState<DateValue | null>(today(getLocalTimeZone()));

let {locale} = useLocale();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ describe("DateInput", () => {

it("supports form reset", async () => {
function Test() {
let [value, setValue] = React.useState<DateValue>(new CalendarDate(2020, 2, 3));
let [value, setValue] = React.useState<DateValue | null>(new CalendarDate(2020, 2, 3));

return (
<form>
Expand Down
6 changes: 3 additions & 3 deletions packages/components/date-input/stories/date-input.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ const LabelPlacementTemplate = (args: DateInputProps) => (
);

const ControlledTemplate = (args: DateInputProps) => {
const [value, setValue] = React.useState<DateValue>(parseDate("2024-04-04"));
const [value, setValue] = React.useState<DateValue | null>(parseDate("2024-04-04"));

let formatter = useDateFormatter({dateStyle: "full"});

Expand Down Expand Up @@ -131,7 +131,7 @@ const TimeZonesTemplate = (args: DateInputProps) => (
);

const GranularityTemplate = (args: DateInputProps) => {
let [date, setDate] = React.useState<DateValue>(parseAbsoluteToLocal("2021-04-07T18:45:22Z"));
let [date, setDate] = React.useState<DateValue | null>(parseAbsoluteToLocal("2021-04-07T18:45:22Z"));

return (
<div className="w-full max-w-xl flex flex-col items-start gap-4">
Expand All @@ -155,7 +155,7 @@ const GranularityTemplate = (args: DateInputProps) => {
};

const InternationalCalendarsTemplate = (args: DateInputProps) => {
let [date, setDate] = React.useState<DateValue>(parseAbsoluteToLocal("2021-04-07T18:45:22Z"));
let [date, setDate] = React.useState<DateValue | null>(parseAbsoluteToLocal("2021-04-07T18:45:22Z"));

return (
<div className="flex flex-col gap-4">
Expand Down
4 changes: 2 additions & 2 deletions packages/components/date-picker/src/use-date-picker.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type {DateValue} from "@internationalized/date";
import type {DateInputProps, TimeInputProps} from "@nextui-org/date-input";
import type {DateInputProps} from "@nextui-org/date-input";
import type {DatePickerState} from "@react-stately/datepicker";
import type {ButtonProps} from "@nextui-org/button";
import type {CalendarProps} from "@nextui-org/calendar";
Expand Down Expand Up @@ -163,7 +163,7 @@ export function useDatePicker<T extends DateValue>({
} as DateInputProps;
};

const getTimeInputProps = (): TimeInputProps => {
const getTimeInputProps = () => {
if (!showTimeField) return {};

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ const LabelPlacementTemplate = (args: DatePickerProps) => (
);

const ControlledTemplate = (args: DatePickerProps) => {
const [value, setValue] = React.useState<DateValue>(parseDate("2024-04-04"));
const [value, setValue] = React.useState<DateValue | null>(parseDate("2024-04-04"));

let formatter = useDateFormatter({dateStyle: "full"});

Expand Down Expand Up @@ -149,7 +149,7 @@ const TimeZonesTemplate = (args: DatePickerProps) => (
);

const GranularityTemplate = (args: DatePickerProps) => {
let [date, setDate] = React.useState<DateValue>(parseAbsoluteToLocal("2021-04-07T18:45:22Z"));
let [date, setDate] = React.useState<DateValue | null>(parseAbsoluteToLocal("2021-04-07T18:45:22Z"));

return (
<div className="w-full max-w-xl flex flex-col items-start gap-4">
Expand Down Expand Up @@ -182,7 +182,7 @@ const GranularityTemplate = (args: DatePickerProps) => {
};

const InternationalCalendarsTemplate = (args: DatePickerProps) => {
let [date, setDate] = React.useState<DateValue>(parseAbsoluteToLocal("2021-04-07T18:45:22Z"));
let [date, setDate] = React.useState<DateValue | null>(parseAbsoluteToLocal("2021-04-07T18:45:22Z"));

return (
<div className="flex flex-col gap-4">
Expand All @@ -202,7 +202,7 @@ const InternationalCalendarsTemplate = (args: DatePickerProps) => {
const PresetsTemplate = (args: DatePickerProps) => {
let defaultDate = today(getLocalTimeZone());

const [value, setValue] = React.useState<DateValue>(defaultDate);
const [value, setValue] = React.useState<DateValue | null>(defaultDate);

let {locale} = useLocale();
let formatter = useDateFormatter({dateStyle: "full"});
Expand Down
Loading

0 comments on commit 84006f2

Please sign in to comment.