-
-
Notifications
You must be signed in to change notification settings - Fork 2
feat(useDate): add new composable #57
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Member
johnleider
commented
Dec 15, 2025
|
commit: |
8a30546 to
83a6010
Compare
- Replace export * with explicit exports in bridge (fixes Volar) - Add T extends Temporal.PlainDateTime generic constraint - Cache Intl.DateTimeFormat/NumberFormat instances for performance - Optimize formatByString with pre-compiled regex - Document parse() limitation (format param ignored) - Add tests for createDateFallback and locale synchronization
- Add comprehensive useDate docs with API reference - Cover installation, usage, format presets/tokens - Document locale integration and Vuetify 3 bridge - Add to composables index
Vuetify will adapt to use v0's date system directly.
Remove string handling from parseDayOfWeek - Vuetify will adapt.
- Add function overloads for proper type inference with custom adapters
- Fix memory leak: watchEffect now uses onScopeDispose for cleanup
- Fix SSR safety: Temporal.Now guarded with IN_BROWSER check
- Extract createDateInternal and resolveLocale helpers
- Simplify createDateFallback to non-generic (always PlainDateTime)
Custom adapters now infer types correctly:
createDate({ adapter: new DateFnsAdapter() }) → DateContext<Date>
- Add YY token to FORMAT_TOKEN_REGEX for 2-digit year formatting - Add firstDayOfWeek parameter to endOfWeek() for consistency - Add MAX_CACHE_SIZE limit to format caches to prevent memory leaks - Add useDate() composable tests for fallback behavior - Document SSR-safe date() behavior (returns epoch on server) - Remove stale Vuetify 3 Bridge documentation - Fix parameter types in docs (number only, not number | string)
- Add 7 missing comparison methods to documentation - Fix locale type in docs (required → optional) - Add SSR behavior tests for date() edge cases - Add cache management tests for formatter reuse
- Fix getDiff to gracefully handle invalid string input (return 0 instead of throwing)
- Fix createDateContext to preserve custom adapter when provided
- Fix createDatePlugin to preserve custom adapter when provided
- Fix typo in comment ("disrectly" -> "directly")
Add missing test coverage identified by inspection: - getWeek() with firstDayOfWeek and minimalDays parameters - createDateContext() trinity tuple structure and options - Document timezone-dependent formatting SSR limitation
- Add SSR test file with IN_BROWSER=false mock to validate epoch fallback - Add getDiff tests for all unit types: hours, minutes, seconds, weeks, months, years - Test string comparing parameter and invalid date handling
- Add JSDoc warning to useDate<T> generic overload about unchecked type parameter - Add inline comments explaining cast safety in overload implementations - Export DateOptionsBase for custom adapter authors - Clear Intl caches on locale change to prevent stale formatters in SSR - Add section comments to adapters barrel file
Add prominent TYPE SAFETY WARNING header to useDate<T>() JSDoc. Clarify that incorrect usage causes silent runtime failures and recommend using the type-safe first overload when possible.
Align adapter naming with framework convention (Vuetify0<Feature>Adapter).
Add tests for medium/low severity findings from code inspection: - Cache eviction logic at MAX_CACHE_SIZE limit - Component lifecycle cleanup (watchEffect disposal) - useLocale integration with localeMap - Cache clearing on locale change - ZonedDateTime input handling - formatByString midnight/noon edge cases (12:00 AM/PM)
Replace raw typeof/null checks with isString and isNull utilities for consistency with codebase patterns.
- Update all references to renamed Vuetify0DateAdapter class - Replace == null with isNullOrUndefined() utility - Add type-level regression tests for overload protection - Fix createDateContext type signature in docs
- Add custom adapter type inference test - Add SSR tests for useDate/createDateFallback outside component - Add dynamic locale sync test with useLocale integration - Add leap year and invalid locale edge case tests - Add locale switching benchmarks (cache eviction, toggle)
- Enhance SSR/hydration docs with warning callout and code examples - Add type-level tests verifying overload safety - Replace getCurrentInstance() with instanceExists() utility - Minor import ordering cleanup
73d81f2 to
1f8943e
Compare
- Remove overloaded signatures from createDate, createDateContext, createDatePlugin, and useDate - Consolidate 6 option interfaces into 2 (DateOptions, DateContextOptions) - Change generic pattern to E extends DateContext (matches useBreakpoints) - Rename localeMap option to locales for clarity - Inline single-use helper functions (resolveLocale, isIntlLocale) - Tighten internal variable names (selectedId, initialLocale)
- Fix docs: localeMap → locales (stale API name) - DateAdapter<T> now defaults to Temporal.PlainDateTime - isValid/isNull are now type predicates for narrowing - Generic pattern: Z, E extends DateContext<Z> (matches v0 conventions) - Add @module JSDoc to adapters barrel file - Fix onScopeDispose call (remove undocumented parameter)
- Add polyfill installation instructions to use-date.md - Install @js-temporal/polyfill in apps/docs - Add createDatePlugin to docs zero.ts plugin - Update DocsReleases.vue to use useDate for date formatting - Fix parseISO to handle timezone-aware strings (e.g., "2024-06-15T10:30:00Z")
- Add interactive example with DocsExample component - Use code groups for package manager installation options - Link TC39 proposal in description and installation tip - Update DateAdapter interface with type predicate signatures - Expand Custom Adapters section with isValid/isNull examples - Add useDate to shiki-api-transformer for hover popovers - Ignore @js-temporal/polyfill in knip (peer dependency)
- Rename localeMap to locales in test assertions - Add DateAdapter type assertion for custom adapter tests - Update auto-generated type declarations
- Add calendar.vue demonstrating getWeekArray, getWeekdays, navigation - Handle Feb 2025 edge case (4 weeks) by padding with next month - Add Examples section to documentation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.