-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature Request] Mitigate need for users to keep @internationalized/date version in sync with NextUI #4567
Comments
I also have this issue going from 3.6.0 -> 3.7.0 on @internationalized/date package. |
will export those packages in next minor release |
After migration, I got the error:
Here is my code: import { type CalendarDate, parseDate } from "@internationalized/date";
export const dateRangeAtom = atom<[Date, Date]>([
new Date(new Date().setFullYear(new Date().getFullYear() - 2)),
new Date(),
]);
type DateRangePicker = {
start: CalendarDate;
end: CalendarDate;
};
function dateValueToDate(dateValue: CalendarDate): Date {
return new Date(dateValue.year, dateValue.month - 1, dateValue.day);
}
export const dateRangePickerAtom = atom<
DateRangePicker,
DateRangePicker[],
void
>(
(get) => {
const [startDate, endDate] = get(dateRangeAtom);
return {
start: parseDate(format(startDate, "yyyy-MM-dd")),
end: parseDate(format(endDate, "yyyy-MM-dd")),
};
},
(_get, set, newVal) => {
set(dateRangeAtom, [
dateValueToDate(newVal.start),
dateValueToDate(newVal.end),
]);
},
);
// in React
<DateRangePicker
label="Pick Date Range"
className="w-auto max-w-xs"
value={dateRangePicker}
onChange={setDateRangePicker}
/>
// type error from value={dateRangePicker} |
@mengxi-ream are you using |
I'm using |
fixed when I changed the version to |
@mengxi-ream Internally we are using 3.6.0. Please use the fixed version at this moment. In the future, we will export the package from our side so that users can use the exact same version to avoid incompatible issues. |
I also have the same type of issue with the "maxValue" parameter: Error: Type 'CalendarDate' is not assignable to type 'DateValue | null | undefined'. I am using the following versions: |
After fighting with this issue for the better part of a day I was only able to validate two solutions for this issue both have their downsides and hopefully the HeroUI team will have a permanent fix for this issue from their side sooner than later. I can confirm this Solution 1: Solution 2:
I don't love the bloated code in #2 but I like that the solution is isolated to to the problem area and not a sweeping global change. And guys, I love what your doing with NextUI/HeroUI but but as a paying Pro member this level of a bug should have never made it into a stable release branch. Hopefully we can add a bit more testing around this going forward. |
Is your feature request related to a problem? Please describe.
Today, in order to use
<DatePicker>
, users of NextUI also have to take on a dependency on the@internationalized/date
package.It's also necessary to keep your version of this library exactly in sync with NextUI. (for example, a version mismatch can cause an error like
Type 'ZonedDateTime' is not assignable to type 'CalendarDate | CalendarDateTime | ZonedDateTime | null | undefined'.
, seen in the screenshot below)(I'm guessing this isn't a surprise, as the docs provide instructions to install 3.6.0 specifically)
Describe the solution you'd like
What if NextUI re-exported symbols from their own version of
@internationlized/date
? So users could switch from this:To something like this:
Then, if I'm only using
@internationalized/date
for NextUI, then I won't need to add it to my package.json (and won't accidentally update it).Or, if I am using it elsewhere, I'll have a chance of being able to update it without breaking NextUI. (though I'd probably run into version conflicts elsewhere)
Describe alternatives you've considered
Another issue suggests not requiring
@internationalized/date
at all: #4401Screenshots or Videos
The text was updated successfully, but these errors were encountered: