Skip to content

feat(components): add DatePicker composite component#9958

Merged
originalix merged 20 commits intoOneKeyHQ:xfrom
yikZero:feature/datepicker
Feb 3, 2026
Merged

feat(components): add DatePicker composite component#9958
originalix merged 20 commits intoOneKeyHQ:xfrom
yikZero:feature/datepicker

Conversation

@yikZero
Copy link
Copy Markdown
Contributor

@yikZero yikZero commented Feb 2, 2026

Summary

Add a new cross-platform DatePicker composite component to @onekeyhq/components with 5 selection modes: single date, date range, year, month, and multi-select.

Changes

  • New component: packages/components/src/composite/DatePicker/ (11 files)
    • DatePicker.Basic — single date selection
    • DatePicker.Range — date range selection with dual-panel on desktop
    • DatePicker.Year — year grid selection
    • DatePicker.Month — month grid selection
    • DatePicker.MultiSelect — multiple date selection
  • New dependency: @rehookify/datepicker for headless date picker state management
  • i18n: 6 new translation keys (global_select_date, global_select_date_range, global_select_year, global_select_month, global_select_dates, global_number_dates_selected)
  • Gallery demo: Added DatePicker story page with all 5 modes demonstrated
  • Route registration: Added gallery route for DatePicker

Design Decisions

  • Follows existing composite component patterns (Dialog, Tabs) for file structure and withStaticProperties usage
  • Uses Popover for trigger/calendar popup, consistent with existing components
  • Responsive: dual-panel range picker on desktop (md breakpoint), single panel on mobile
  • Uses useMedia for responsive sizing, useIntl for i18n — same as other components
  • Day/month/year view switching within a single calendar panel

Open with Devin

Add DatePicker composite component with single date, date range, year,
month, and multi-select modes. Built on @rehookify/datepicker with
OneKey Popover integration for web/desktop floating panels.
- Refactor Calendar to support dual panel layout for range mode
- Update DayCell with proper range highlight styling
- Replace custom trigger with Input component
- Make CalendarHeader nav buttons optional for dual panel
- Compact layout: smaller day cells (32px), tighter spacing
- Inline view switching (day/month/year) with slide animations
- Range picker: dual calendar on desktop, single on mobile
- Fix: non-current-month dates use $textDisabled, no range highlight
- Fix: year/month picker now fills value on click
- Fix: disabled state blocks popover open
- Fix: range picker reopens with end date on right panel
- Add clear button with stopPropagation, calendar icon hover state
- Rename useDateAnimation.tsx to .ts (no JSX)
- Use relative import path in type.ts
- Replace requestAnimationFrame with useRef+useEffect for RN compat
- Replace hardcoded height 36 with $9 token
- Remove empty onPress handler in DatePickerTrigger
- Pass onYearSelect/onMonthSelect through CalendarPanel
…entions

- Add optional `title` prop to all picker variants (was hardcoded)
- Add `renderTrigger` support for custom trigger UI
- Change `floatingPanelProps` type to `IPopoverProps['floatingPanelProps']`
- Use `export * from './type'` instead of explicit type re-exports
- Move `onOpenChange` to base props, add nav boundary constraints
- Add today dot indicator, same-day range styling, disabled date band
- Disable month/year drill-down in range dual-panel mode
- Replace locale-dependent Date string parsing with numeric month/year from $date
- Increase day cell height ($8→$10), month/year grid height ($9→$11), weekday row height ($6→$8) for better mobile touch targets
- Set week start to Monday via calendar.startDay across all picker variants
- Fix CalendarPanel height collapse in single-panel mode by conditionally
  applying flex={1}/flexBasis={0} only for dual-panel range layout
- Remove internal slide animations (useDateAnimation deleted)
- Simplify conditional logic across Calendar, DayCell, CalendarHeader
- Extract common picker config into createPickerConfig helper
- Add fullWidth/hideOutOfMonth props for range mode improvements
- Make CalendarHeader responsive with useMedia
- Unify date format to yyyy-MM-dd, month to yyyy-MM
- Hide Sheet header on all picker types (showHeader={false})
Extract DayGrid, MonthGrid, YearGrid, and CalendarPanel into
individual files for better maintainability and easier modification.
Calendar.tsx now serves as the assembler component only.
Replace all hardcoded English strings in DatePicker with ETranslations
keys (global_select_date, global_select_date_range, global_select_year,
global_select_month, global_select_dates, global_number_dates_selected).
Also fetch latest locale translations.
- Extract usePickerState hook for common open/close state management
- Extract usePickerI18n hook for i18n fallback pattern
- Extract PickerPopover wrapper to eliminate repeated Popover setup
- Extract renderPickerTrigger helper for trigger rendering logic
- Extract SINGLE_PANEL_PROPS constant for shared panel dimensions
- Reduces ~100 lines of duplicated code across 5 picker variants
… code

- Extract shared callOnClick helper into utils.ts (same pattern as Tabs)
- Simplify conditional logic in CalendarHeader and CalendarPanel
- Extract named variables to reduce nested ternaries
- Wrap hasValue in useMemo in DatePickerTrigger
- Reorder variable declarations for better logical grouping in DayCell
@revan-zhang
Copy link
Copy Markdown
Contributor

revan-zhang commented Feb 2, 2026

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@socket-security
Copy link
Copy Markdown

socket-security bot commented Feb 2, 2026

All alerts resolved. Learn more about Socket for GitHub.

This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored.

View full report

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

View issue and 7 additional flags in Devin Review.

Open in Devin Review

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 new potential issue.

View issue and 10 additional flags in Devin Review.

Open in Devin Review

@originalix originalix enabled auto-merge (squash) February 2, 2026 16:34
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 new potential issue.

View issue and 13 additional flags in Devin Review.

Open in Devin Review

@originalix originalix merged commit c38c1ce into OneKeyHQ:x Feb 3, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants