-
Notifications
You must be signed in to change notification settings - Fork 4
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
fix(useDatePicker): fix onDateSelect type, export types #79
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## alpha #79 +/- ##
=======================================
Coverage 91.31% 91.31%
=======================================
Files 56 56
Lines 1197 1197
Branches 328 330 +2
=======================================
Hits 1093 1093
Misses 102 102
Partials 2 2 ☔ View full report in Codecov by Sentry. |
c424f6f
to
5374d3f
Compare
# [2.0.0-alpha.4](v2.0.0-alpha.3...v2.0.0-alpha.4) (2024-10-09) ### Bug Fixes * **useDatePicker:** fix onDateSelect type, export types ([#79](#79)) ([94358d2](94358d2))
🎉 This PR is included in version 2.0.0-alpha.4 🎉 The release is available on: Your semantic-release bot 📦🚀 |
# [2.0.0](v1.3.2...v2.0.0) (2024-11-21) ### Bug Fixes * use export type ([#81](#81)) ([eaa8cdb](eaa8cdb)) * **useDatePicker:** fix onDateSelect type, export types ([#79](#79)) ([94358d2](94358d2)) * add 'valid' property to validation result ([894e181](894e181)) * remove Temporal references from hook public API and clean up use date picker ([#75](#75)) ([fb31512](fb31512)) * update validation logic to expose error code and mirror RFF format ([001d236](001d236)) * use NepaliCalendar instance to validate dates ([9fb353a](9fb353a)) ### BREAKING CHANGES * Remove Temporal references from hook public API * feat: remove validation details from result of useDatePicker as they are available in exposed validate date string function * feat: remove calendar date from use date picker * refactor: remove calendarDate from onDateSelect callback * refactor: remove zonedDateTime from week days array * refactor: fix linting issues
🎉 This PR is included in version 2.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Trying to destructure the object in
onDateSelect
causes a runtime error, because it can be null (and isnull
when usingclear
-button in UI, that consumes this hook. I've updated the parameter type ofonDateSelect
to include null. However I also noticed that the hooks actually just calls it with, excluding the
calendarDate
. Should we update the type for the calendar to be optional, or the runtime code here?I've also exported the types, as it's convenient for consumers to be able to import types callback and options. Previously you would need to do something like
type UseDatePickerOptions = Parameters<typeof useDatePicker>[0]
Note that the UI needs to update to the new version to get this propagated to UI-types, but it shouldn't require code changes in UI.