DataViews: Vendor DateCalendar and DateRangeCalendar from components - #81324
DataViews: Vendor DateCalendar and DateRangeCalendar from components#81324oandregal wants to merge 1 commit into
DateCalendar and DateRangeCalendar from components#81324Conversation
Move the private DateCalendar / DateRangeCalendar components (and their TZDate re-export) from @wordpress/components into @wordpress/dataviews as internal components, and delete them from the components package. DataViews was their only consumer, and unlocking them via cross-package private APIs breaks npm-bundled copies of the package (see #81230). - Move packages/components/src/calendar to packages/dataviews/src/components/calendar, including tests; drop the Storybook stories, READMEs, and their docs manifest entries. - Copy the internal useControlledValue hook, the only dependency on components internals. - Rename the CSS class prefix from components-calendar to dataviews-calendar so stale wp-components stylesheets cannot double-style the calendar. - Replace the components-internal theme variables with the design-system tokens they resolve to, per the stylelint policy banning --wp-components-color-* outside the components package. - Move the react-day-picker dependency from components to dataviews. - Import the calendar directly in the date and datetime dataform controls; date.tsx no longer needs the private APIs unlock at all. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
I'm not fully convinced vendoring components in DataViews is the way forward, but DateCalendar/DateRangeCalendar have a more compact API surface and less usage than the Validated* components (#81306 (comment)), so it's a better place for experimenting and understanding the boundaries. If we go this route, a hard rule is that DataViews should never export these components. If a second consumer wants to use them in the future, it should vendor them itself (until there's a canonical version from wp/ui or wp/components). This is unfortunate, but I don't see any other way forward. |
|
Warning: Type of PR label mismatch To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.
Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task. |
1 similar comment
|
Warning: Type of PR label mismatch To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.
Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task. |
There was a problem hiding this comment.
Pull request overview
Moves private calendar components into DataViews, eliminating their cross-package private API usage.
Changes:
- Vendors calendar implementation, styles, and tests into DataViews.
- Updates DataForm consumers and CSS class prefixes.
- Moves
react-day-pickerand removes Components exports/docs.
Reviewed changes
Copilot reviewed 21 out of 29 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
docs/manifest.json |
Removes obsolete calendar docs. |
package-lock.json |
Moves dependency ownership. |
packages/components/CHANGELOG.md |
Records calendar removal. |
packages/components/package.json |
Removes react-day-picker. |
packages/components/src/calendar/date-calendar/README.md |
Removes private API docs. |
packages/components/src/calendar/date-range-calendar/README.md |
Removes range API docs. |
packages/components/src/calendar/stories/date-calendar.story.tsx |
Removes obsolete story. |
packages/components/src/calendar/stories/date-range-calendar.story.tsx |
Removes obsolete range story. |
packages/components/src/calendar/utils/constants.ts |
Removes old class constants. |
packages/components/src/private-apis.ts |
Removes calendar private exports. |
packages/components/src/style.scss |
Removes calendar styles. |
packages/dataviews/CHANGELOG.md |
Records vendored calendars. |
packages/dataviews/package.json |
Adds react-day-picker. |
packages/dataviews/src/components/calendar/date-calendar/index.tsx |
Moves single-date calendar. |
packages/dataviews/src/components/calendar/date-range-calendar/index.tsx |
Moves range calendar. |
packages/dataviews/src/components/calendar/index.tsx |
Provides internal exports. |
packages/dataviews/src/components/calendar/style.scss |
Renames and retokens styles. |
packages/dataviews/src/components/calendar/test/__utils__/index.ts |
Moves test helpers. |
packages/dataviews/src/components/calendar/test/date-calendar.tsx |
Moves single-date tests. |
packages/dataviews/src/components/calendar/test/date-range-calendar.tsx |
Moves range tests. |
packages/dataviews/src/components/calendar/types.ts |
Moves and updates types. |
packages/dataviews/src/components/calendar/utils/constants.ts |
Defines DataViews class names. |
packages/dataviews/src/components/calendar/utils/day-cell.tsx |
Moves custom day cells. |
packages/dataviews/src/components/calendar/utils/misc.ts |
Moves month clamping utility. |
packages/dataviews/src/components/calendar/utils/use-controlled-value.ts |
Vendors controlled-state utility. |
packages/dataviews/src/components/calendar/utils/use-localization-props.ts |
Moves localization behavior. |
packages/dataviews/src/components/dataform-controls/date.tsx |
Uses internal calendars directly. |
packages/dataviews/src/components/dataform-controls/datetime.tsx |
Uses internal date calendar. |
packages/dataviews/src/style.scss |
Includes calendar styles. |
|
Closing in favor of #81337 |
Part of #81230
What?
Moves the private
DateCalendarandDateRangeCalendarcomponents out of@wordpress/componentsand into@wordpress/dataviewsas internal components, removing them from the components package entirely. ThedateanddatetimeDataForm controls now import them directly instead of unlocking them through@wordpress/private-apis.Why?
DataViews is a bundled package: plugins may import it from npm rather than using the WordPress script. When two copies of
@wordpress/private-apisexist in one runtime, one copy cannot unlock objects locked by the other, which crashes at module initialization ("Cannot unlock an object that was not locked before"). #81230 tracks removing every private cross-package API usage from DataViews.The calendar components were blocked on "still stabilizing in
@wordpress/components" — but they are consumed nowhere else: the two DataViews controls were their only usage sites in Gutenberg. I also checked some typical external repositories and there's no import either. Vendoring them into DataViews as internal components unblocks the private-APIs removal without forcing a public-API stabilization decision, and the components package can always reintroduce a public calendar later.How?
packages/components/src/calendar/topackages/dataviews/src/components/calendar/.components-calendartodataviews-calendar, so a bundled newer DataViews can never be double-styled by an olderwp-componentsstylesheet that still ships the calendar rules.--wpds-*, andvar(--wp-admin-theme-color, #3858e9)for the accent), following the stylelint policy that disallows--wp-components-color-*outside the components package. Computed values are unchanged.react-day-pickerdependency from@wordpress/components(no remaining usage there) to@wordpress/dataviews.date.tsxneeds no private-API unlock at all anymore;datetime.tsxkeeps a single unlock forValidatedInputControl(a separate DataViews: remove all private API usage #81230 item).private-apis.tsentries and the stylesheet registration.Testing Instructions
npm run test:unit packages/dataviews/src/components/calendar(115 tests) and the full suitenpm run test:unit packages/dataviews(556 tests).npm run buildand confirm it passes, including type generation.betweenoperator): the calendar and range calendar should render and behave exactly as on trunk — presets, month navigation, range hover preview, timezone handling.DataFormvalidation story) and verify the single-date calendar works, including selected-day and today indicators.dataviews-calendarprefix, and the styles come from the DataViews stylesheet.wp-componentsCSS no longer containscomponents-calendarrules.packages/componentsno longer references the calendar:grep -r "DateCalendar" packages/components/srcreturns nothing.Use of AI Tools
This PR, including this description, was written by Claude Code (Claude Fable 5), based on issue #81230's analysis, and human-reviewed before submission.