From c3596923c6ace8e8bf99a3a945cb0340aadff539 Mon Sep 17 00:00:00 2001 From: delangle Date: Fri, 3 Apr 2026 07:56:53 +0200 Subject: [PATCH 01/11] [scheduler] Replace copied Base UI internals with @base-ui/react/internals imports MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Update @base-ui/react to a build from PR https://github.com/mui/base-ui/pull/4505 which exposes internal utilities under @base-ui/react/internals/*. Replace ~46 files' imports from base-ui-copy/ with proper imports: - useRenderElement → @base-ui/react/internals/useRenderElement - BaseUIComponentProps, NonNativeButtonProps → @base-ui/react/internals/types - useButton → @base-ui/react/internals/use-button - createChangeEventDetails → @base-ui/react/internals/createBaseUIEventDetails - TemporalAdapter, TemporalSupportedObject, TemporalTimezone → @base-ui/react/internals/temporal Delete 11 now-redundant copy files (utils/ and types/ directories). Remaining in base-ui-copy/ (not yet available in internals): - composite/ (CompositeList, CompositeRootContext, useCompositeListItem) - temporal-adapter-date-fns/ (UnstableTemporalAdapterDateFns) Co-Authored-By: Claude Opus 4.6 --- .../x-scheduler-headless-premium/package.json | 4 +- .../eventTimelinePremiumViewSelectors.ts | 2 +- .../src/models/index.ts | 2 +- .../timeline-grid/cell/TimelineGridCell.tsx | 3 +- .../TimelineGridCurrentTimeIndicator.tsx | 3 +- .../TimelineGridEventPlaceholder.tsx | 3 +- .../TimelineGridEventResizeHandler.tsx | 3 +- .../event-row/TimelineGridEventRow.tsx | 3 +- .../timeline-grid/event/TimelineGridEvent.tsx | 9 +- .../timeline-grid/root/TimelineGridRoot.tsx | 3 +- .../src/timeline-grid/row/TimelineGridRow.tsx | 3 +- .../sub-grid/TimelineGridSubGrid.tsx | 3 +- .../EventTimelinePremiumStore.ts | 4 +- packages/x-scheduler-headless/package.json | 2 +- .../src/base-ui-copy/index.ts | 10 +- .../TemporalAdapterDateFns.ts | 4 +- .../src/base-ui-copy/types/index.ts | 29 -- .../base-ui-copy/types/temporal-adapter.ts | 382 ------------------ .../src/base-ui-copy/types/temporal.ts | 49 --- .../src/base-ui-copy/utils/constants.ts | 40 -- .../utils/createBaseUIEventDetails.ts | 164 -------- .../utils/getStateAttributesProps.ts | 32 -- .../src/base-ui-copy/utils/reason-parts.ts | 44 -- .../src/base-ui-copy/utils/reasons.ts | 5 - .../base-ui-copy/utils/resolveClassName.ts | 13 - .../src/base-ui-copy/utils/resolveStyle.ts | 13 - .../src/base-ui-copy/utils/types.ts | 94 ----- .../src/base-ui-copy/utils/useButton.ts | 291 ------------- .../utils/useFocusableWhenDisabled.ts | 99 ----- .../base-ui-copy/utils/useRenderElement.tsx | 283 ------------- .../CalendarGridCurrentTimeIndicator.tsx | 4 +- .../day-cell/CalendarGridDayCell.tsx | 4 +- .../CalendarGridDayEventPlaceholder.tsx | 4 +- .../CalendarGridDayEventResizeHandler.tsx | 4 +- .../day-event/CalendarGridDayEvent.tsx | 6 +- .../day-row/CalendarGridDayRow.tsx | 4 +- .../header-cell/CalendarGridHeaderCell.tsx | 4 +- .../header-row/CalendarGridHeaderRow.tsx | 4 +- .../calendar-grid/root/CalendarGridRoot.tsx | 4 +- .../time-column/CalendarGridTimeColumn.tsx | 4 +- .../CalendarGridTimeEventPlaceholder.tsx | 4 +- .../CalendarGridTimeEventResizeHandler.tsx | 4 +- .../time-event/CalendarGridTimeEvent.tsx | 6 +- .../CalendarGridTimeScrollableContent.tsx | 4 +- .../src/get-day-list/getDayList.ts | 2 +- .../utils/SchedulerStore/SchedulerStore.ts | 2 +- .../SchedulerStore/SchedulerStore.types.ts | 2 +- .../SchedulerStore/SchedulerStore.utils.ts | 2 +- .../src/internals/utils/date-utils.ts | 2 +- .../src/internals/utils/event-utils.ts | 2 +- ...RecurringEventOccurrencesForVisibleDays.ts | 2 +- .../projectRRuleToTimezone.ts | 2 +- .../utils/recurring-events/rRuleString.ts | 2 +- .../x-scheduler-headless/src/models/event.ts | 4 +- .../x-scheduler-headless/src/models/index.ts | 2 +- .../src/models/recurringEvent.ts | 2 +- .../x-scheduler-headless/src/models/view.ts | 2 +- .../src/process-event/processEvent.ts | 2 +- .../src/process-event/resolveEventDate.ts | 2 +- .../src/standalone-event/StandaloneEvent.tsx | 6 +- .../src/use-adapter/useAdapter.ts | 2 +- .../src/use-adapter/useAdapter.types.ts | 2 +- .../use-event-calendar/EventCalendarStore.ts | 2 +- packages/x-scheduler-premium/package.json | 6 +- packages/x-scheduler/package.json | 4 +- pnpm-lock.yaml | 342 +++++++++++----- test/utils/scheduler/event-builder.ts | 2 +- 67 files changed, 339 insertions(+), 1718 deletions(-) delete mode 100644 packages/x-scheduler-headless/src/base-ui-copy/types/index.ts delete mode 100644 packages/x-scheduler-headless/src/base-ui-copy/types/temporal-adapter.ts delete mode 100644 packages/x-scheduler-headless/src/base-ui-copy/types/temporal.ts delete mode 100644 packages/x-scheduler-headless/src/base-ui-copy/utils/constants.ts delete mode 100644 packages/x-scheduler-headless/src/base-ui-copy/utils/createBaseUIEventDetails.ts delete mode 100644 packages/x-scheduler-headless/src/base-ui-copy/utils/getStateAttributesProps.ts delete mode 100644 packages/x-scheduler-headless/src/base-ui-copy/utils/reason-parts.ts delete mode 100644 packages/x-scheduler-headless/src/base-ui-copy/utils/reasons.ts delete mode 100644 packages/x-scheduler-headless/src/base-ui-copy/utils/resolveClassName.ts delete mode 100644 packages/x-scheduler-headless/src/base-ui-copy/utils/resolveStyle.ts delete mode 100644 packages/x-scheduler-headless/src/base-ui-copy/utils/types.ts delete mode 100644 packages/x-scheduler-headless/src/base-ui-copy/utils/useButton.ts delete mode 100644 packages/x-scheduler-headless/src/base-ui-copy/utils/useFocusableWhenDisabled.ts delete mode 100644 packages/x-scheduler-headless/src/base-ui-copy/utils/useRenderElement.tsx diff --git a/packages/x-scheduler-headless-premium/package.json b/packages/x-scheduler-headless-premium/package.json index 34d4c3618af93..cafd8a2d97eec 100644 --- a/packages/x-scheduler-headless-premium/package.json +++ b/packages/x-scheduler-headless-premium/package.json @@ -49,10 +49,10 @@ }, "dependencies": { "@babel/runtime": "catalog:", - "@base-ui/react": "^1.3.0", + "@base-ui/react": "https://pkg.pr.new/mui/base-ui/@base-ui/react@4505", "@base-ui/utils": "catalog:", - "@mui/x-scheduler-headless": "workspace:*", "@mui/x-internals": "workspace:*", + "@mui/x-scheduler-headless": "workspace:*", "prop-types": "catalog:" }, "peerDependencies": { diff --git a/packages/x-scheduler-headless-premium/src/event-timeline-premium-selectors/eventTimelinePremiumViewSelectors.ts b/packages/x-scheduler-headless-premium/src/event-timeline-premium-selectors/eventTimelinePremiumViewSelectors.ts index 9c2f61abff04b..a0a84619ab4e0 100644 --- a/packages/x-scheduler-headless-premium/src/event-timeline-premium-selectors/eventTimelinePremiumViewSelectors.ts +++ b/packages/x-scheduler-headless-premium/src/event-timeline-premium-selectors/eventTimelinePremiumViewSelectors.ts @@ -1,5 +1,5 @@ import { createSelector, createSelectorMemoized } from '@base-ui/utils/store'; -import { TemporalAdapter } from '@mui/x-scheduler-headless/base-ui-copy'; +import { TemporalAdapter } from '@base-ui/react/internals/temporal'; import type { EventTimelinePremiumState as State } from '../use-event-timeline-premium'; import { TemporalSupportedObject, EventTimelinePremiumView } from '../models'; diff --git a/packages/x-scheduler-headless-premium/src/models/index.ts b/packages/x-scheduler-headless-premium/src/models/index.ts index 4ed6ea9d56b99..01c869290a7b0 100644 --- a/packages/x-scheduler-headless-premium/src/models/index.ts +++ b/packages/x-scheduler-headless-premium/src/models/index.ts @@ -1,4 +1,4 @@ -export type { TemporalSupportedObject } from '@mui/x-scheduler-headless/base-ui-copy'; +export type { TemporalSupportedObject } from '@base-ui/react/internals/temporal'; export * from './preferences'; export * from './view'; diff --git a/packages/x-scheduler-headless-premium/src/timeline-grid/cell/TimelineGridCell.tsx b/packages/x-scheduler-headless-premium/src/timeline-grid/cell/TimelineGridCell.tsx index c4e1f5b503fd9..b4f338dcf83d2 100644 --- a/packages/x-scheduler-headless-premium/src/timeline-grid/cell/TimelineGridCell.tsx +++ b/packages/x-scheduler-headless-premium/src/timeline-grid/cell/TimelineGridCell.tsx @@ -1,6 +1,7 @@ 'use client'; import * as React from 'react'; -import { useRenderElement, BaseUIComponentProps } from '@mui/x-scheduler-headless/base-ui-copy'; +import { useRenderElement } from '@base-ui/react/internals/useRenderElement'; +import { BaseUIComponentProps } from '@base-ui/react/internals/types'; export const TimelineGridCell = React.forwardRef(function TimelineGridCell( componentProps: TimelineGridCell.Props, diff --git a/packages/x-scheduler-headless-premium/src/timeline-grid/current-time-indicator/TimelineGridCurrentTimeIndicator.tsx b/packages/x-scheduler-headless-premium/src/timeline-grid/current-time-indicator/TimelineGridCurrentTimeIndicator.tsx index dbd1373874b70..a68cc8aac1cc0 100644 --- a/packages/x-scheduler-headless-premium/src/timeline-grid/current-time-indicator/TimelineGridCurrentTimeIndicator.tsx +++ b/packages/x-scheduler-headless-premium/src/timeline-grid/current-time-indicator/TimelineGridCurrentTimeIndicator.tsx @@ -1,7 +1,8 @@ 'use client'; import * as React from 'react'; import { useStore } from '@base-ui/utils/store'; -import { useRenderElement, BaseUIComponentProps } from '@mui/x-scheduler-headless/base-ui-copy'; +import { useRenderElement } from '@base-ui/react/internals/useRenderElement'; +import { BaseUIComponentProps } from '@base-ui/react/internals/types'; import { useAdapterContext } from '@mui/x-scheduler-headless/use-adapter-context'; import { useElementPositionInCollection } from '@mui/x-scheduler-headless/internals'; import { schedulerNowSelectors } from '@mui/x-scheduler-headless/scheduler-selectors'; diff --git a/packages/x-scheduler-headless-premium/src/timeline-grid/event-placeholder/TimelineGridEventPlaceholder.tsx b/packages/x-scheduler-headless-premium/src/timeline-grid/event-placeholder/TimelineGridEventPlaceholder.tsx index 2c4788b381d13..26335f3091e26 100644 --- a/packages/x-scheduler-headless-premium/src/timeline-grid/event-placeholder/TimelineGridEventPlaceholder.tsx +++ b/packages/x-scheduler-headless-premium/src/timeline-grid/event-placeholder/TimelineGridEventPlaceholder.tsx @@ -2,7 +2,8 @@ import * as React from 'react'; import { useStore } from '@base-ui/utils/store'; import { useElementPositionInCollection, useEvent } from '@mui/x-scheduler-headless/internals'; -import { useRenderElement, BaseUIComponentProps } from '@mui/x-scheduler-headless/base-ui-copy'; +import { useRenderElement } from '@base-ui/react/internals/useRenderElement'; +import { BaseUIComponentProps } from '@base-ui/react/internals/types'; import { useEventTimelinePremiumStoreContext } from '../../use-event-timeline-premium-store-context'; import { TimelineGridEventPlaceholderCssVars } from './TimelineGridEventPlaceholderCssVars'; import { eventTimelinePremiumViewSelectors } from '../../event-timeline-premium-selectors'; diff --git a/packages/x-scheduler-headless-premium/src/timeline-grid/event-resize-handler/TimelineGridEventResizeHandler.tsx b/packages/x-scheduler-headless-premium/src/timeline-grid/event-resize-handler/TimelineGridEventResizeHandler.tsx index 70a7b9ae70ddd..bfa50726f07f1 100644 --- a/packages/x-scheduler-headless-premium/src/timeline-grid/event-resize-handler/TimelineGridEventResizeHandler.tsx +++ b/packages/x-scheduler-headless-premium/src/timeline-grid/event-resize-handler/TimelineGridEventResizeHandler.tsx @@ -1,7 +1,8 @@ 'use client'; import * as React from 'react'; import { useStableCallback } from '@base-ui/utils/useStableCallback'; -import { useRenderElement, BaseUIComponentProps } from '@mui/x-scheduler-headless/base-ui-copy'; +import { useRenderElement } from '@base-ui/react/internals/useRenderElement'; +import { BaseUIComponentProps } from '@base-ui/react/internals/types'; import { useEventResizeHandler } from '@mui/x-scheduler-headless/internals'; import { SchedulerEventSide } from '@mui/x-scheduler-headless/models'; import { useTimelineGridEventContext } from '../event/TimelineGridEventContext'; diff --git a/packages/x-scheduler-headless-premium/src/timeline-grid/event-row/TimelineGridEventRow.tsx b/packages/x-scheduler-headless-premium/src/timeline-grid/event-row/TimelineGridEventRow.tsx index ed87ed144581d..7a8be49ec1137 100644 --- a/packages/x-scheduler-headless-premium/src/timeline-grid/event-row/TimelineGridEventRow.tsx +++ b/packages/x-scheduler-headless-premium/src/timeline-grid/event-row/TimelineGridEventRow.tsx @@ -1,7 +1,8 @@ 'use client'; import * as React from 'react'; import { useStore } from '@base-ui/utils/store'; -import { useRenderElement, BaseUIComponentProps } from '@mui/x-scheduler-headless/base-ui-copy'; +import { useRenderElement } from '@base-ui/react/internals/useRenderElement'; +import { BaseUIComponentProps } from '@base-ui/react/internals/types'; import { schedulerOccurrenceSelectors } from '@mui/x-scheduler-headless/scheduler-selectors'; import { useEventOccurrencesWithTimelinePosition } from '@mui/x-scheduler-headless/use-event-occurrences-with-timeline-position'; import { useAdapterContext } from '@mui/x-scheduler-headless/use-adapter-context'; diff --git a/packages/x-scheduler-headless-premium/src/timeline-grid/event/TimelineGridEvent.tsx b/packages/x-scheduler-headless-premium/src/timeline-grid/event/TimelineGridEvent.tsx index c0a45f8f41e1c..e0a7f594144e5 100644 --- a/packages/x-scheduler-headless-premium/src/timeline-grid/event/TimelineGridEvent.tsx +++ b/packages/x-scheduler-headless-premium/src/timeline-grid/event/TimelineGridEvent.tsx @@ -2,12 +2,9 @@ import * as React from 'react'; import { useStableCallback } from '@base-ui/utils/useStableCallback'; import { useStore } from '@base-ui/utils/store'; -import { - useButton, - useRenderElement, - BaseUIComponentProps, - NonNativeButtonProps, -} from '@mui/x-scheduler-headless/base-ui-copy'; +import { useButton } from '@base-ui/react/internals/use-button'; +import { useRenderElement } from '@base-ui/react/internals/useRenderElement'; +import { BaseUIComponentProps, NonNativeButtonProps } from '@base-ui/react/internals/types'; import { SchedulerEventId, SchedulerEventOccurrence, diff --git a/packages/x-scheduler-headless-premium/src/timeline-grid/root/TimelineGridRoot.tsx b/packages/x-scheduler-headless-premium/src/timeline-grid/root/TimelineGridRoot.tsx index 48361942ff0ce..2241344ef52f7 100644 --- a/packages/x-scheduler-headless-premium/src/timeline-grid/root/TimelineGridRoot.tsx +++ b/packages/x-scheduler-headless-premium/src/timeline-grid/root/TimelineGridRoot.tsx @@ -1,7 +1,8 @@ 'use client'; import * as React from 'react'; import { useStore } from '@base-ui/utils/store'; -import { useRenderElement, BaseUIComponentProps } from '@mui/x-scheduler-headless/base-ui-copy'; +import { useRenderElement } from '@base-ui/react/internals/useRenderElement'; +import { BaseUIComponentProps } from '@base-ui/react/internals/types'; import { schedulerOccurrenceSelectors } from '@mui/x-scheduler-headless/scheduler-selectors'; import { useEventTimelinePremiumStoreContext } from '../../use-event-timeline-premium-store-context'; import { eventTimelinePremiumViewSelectors } from '../../event-timeline-premium-selectors'; diff --git a/packages/x-scheduler-headless-premium/src/timeline-grid/row/TimelineGridRow.tsx b/packages/x-scheduler-headless-premium/src/timeline-grid/row/TimelineGridRow.tsx index 4ee329d8a67c8..e1871f9db985c 100644 --- a/packages/x-scheduler-headless-premium/src/timeline-grid/row/TimelineGridRow.tsx +++ b/packages/x-scheduler-headless-premium/src/timeline-grid/row/TimelineGridRow.tsx @@ -1,6 +1,7 @@ 'use client'; import * as React from 'react'; -import { useRenderElement, BaseUIComponentProps } from '@mui/x-scheduler-headless/base-ui-copy'; +import { useRenderElement } from '@base-ui/react/internals/useRenderElement'; +import { BaseUIComponentProps } from '@base-ui/react/internals/types'; export const TimelineGridRow = React.forwardRef(function TimelineGridRow( componentProps: TimelineGridRow.Props, diff --git a/packages/x-scheduler-headless-premium/src/timeline-grid/sub-grid/TimelineGridSubGrid.tsx b/packages/x-scheduler-headless-premium/src/timeline-grid/sub-grid/TimelineGridSubGrid.tsx index 34f181062fe4f..7b1fa805590d6 100644 --- a/packages/x-scheduler-headless-premium/src/timeline-grid/sub-grid/TimelineGridSubGrid.tsx +++ b/packages/x-scheduler-headless-premium/src/timeline-grid/sub-grid/TimelineGridSubGrid.tsx @@ -1,7 +1,8 @@ 'use client'; import * as React from 'react'; import { useStore } from '@base-ui/utils/store'; -import { useRenderElement, BaseUIComponentProps } from '@mui/x-scheduler-headless/base-ui-copy'; +import { useRenderElement } from '@base-ui/react/internals/useRenderElement'; +import { BaseUIComponentProps } from '@base-ui/react/internals/types'; import { schedulerOccurrenceSelectors } from '@mui/x-scheduler-headless/scheduler-selectors'; import { SchedulerResourceId } from '@mui/x-scheduler-headless/models'; import { useEventTimelinePremiumStoreContext } from '../../use-event-timeline-premium-store-context'; diff --git a/packages/x-scheduler-headless-premium/src/use-event-timeline-premium/EventTimelinePremiumStore.ts b/packages/x-scheduler-headless-premium/src/use-event-timeline-premium/EventTimelinePremiumStore.ts index 603ad0f295bd0..996b2ee4742be 100644 --- a/packages/x-scheduler-headless-premium/src/use-event-timeline-premium/EventTimelinePremiumStore.ts +++ b/packages/x-scheduler-headless-premium/src/use-event-timeline-premium/EventTimelinePremiumStore.ts @@ -6,11 +6,11 @@ import { SchedulerParametersToStateMapper, SchedulerStore, } from '@mui/x-scheduler-headless/internals'; -import { createChangeEventDetails } from '@mui/x-scheduler-headless/base-ui-copy'; +import { createChangeEventDetails } from '@base-ui/react/internals/createBaseUIEventDetails'; import type { TemporalAdapter, TemporalSupportedObject, -} from '@mui/x-scheduler-headless/base-ui-copy'; +} from '@base-ui/react/internals/temporal'; import { EventTimelinePremiumPreferences, EventTimelinePremiumView } from '../models'; import { EventTimelinePremiumState, diff --git a/packages/x-scheduler-headless/package.json b/packages/x-scheduler-headless/package.json index f0deb7f2cf79a..4781dc9696df8 100644 --- a/packages/x-scheduler-headless/package.json +++ b/packages/x-scheduler-headless/package.json @@ -70,7 +70,7 @@ "@atlaskit/pragmatic-drag-and-drop": "^1.7.7", "@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^2.1.2", "@babel/runtime": "catalog:", - "@base-ui/react": "^1.3.0", + "@base-ui/react": "https://pkg.pr.new/mui/base-ui/@base-ui/react@4505", "@base-ui/utils": "catalog:", "@floating-ui/react": "^0.27.16", "@floating-ui/react-dom": "^2.1.6", diff --git a/packages/x-scheduler-headless/src/base-ui-copy/index.ts b/packages/x-scheduler-headless/src/base-ui-copy/index.ts index 978406e945a58..6b35149117bd1 100644 --- a/packages/x-scheduler-headless/src/base-ui-copy/index.ts +++ b/packages/x-scheduler-headless/src/base-ui-copy/index.ts @@ -1,5 +1,5 @@ -export * from './types'; -export * from './utils/useRenderElement'; -export * from './utils/types'; -export * from './utils/useButton'; -export * from './utils/createBaseUIEventDetails'; +export * from './composite/list/CompositeList'; +export * from './composite/list/CompositeListContext'; +export * from './composite/list/useCompositeListItem'; +export * from './composite/root/CompositeRootContext'; +export * from './temporal-adapter-date-fns'; diff --git a/packages/x-scheduler-headless/src/base-ui-copy/temporal-adapter-date-fns/TemporalAdapterDateFns.ts b/packages/x-scheduler-headless/src/base-ui-copy/temporal-adapter-date-fns/TemporalAdapterDateFns.ts index 22ac48f170607..04b636fd35a7b 100644 --- a/packages/x-scheduler-headless/src/base-ui-copy/temporal-adapter-date-fns/TemporalAdapterDateFns.ts +++ b/packages/x-scheduler-headless/src/base-ui-copy/temporal-adapter-date-fns/TemporalAdapterDateFns.ts @@ -63,7 +63,7 @@ import { DateBuilderReturnType, TemporalTimezone, TemporalAdapter, -} from '../types'; +} from '@base-ui/react/internals/temporal'; const FORMATS: TemporalAdapterFormats = { // Digit formats with leading zeroes @@ -93,7 +93,7 @@ const FORMATS: TemporalAdapterFormats = { localizedNumericDate: 'P', // Note: Day and month are padded on enUS unlike Luxon }; -declare module '@mui/x-scheduler-headless/base-ui-copy/types' { +declare module '@base-ui/react/internals/temporal' { interface TemporalSupportedObjectLookup { 'date-fns': Date; } diff --git a/packages/x-scheduler-headless/src/base-ui-copy/types/index.ts b/packages/x-scheduler-headless/src/base-ui-copy/types/index.ts deleted file mode 100644 index 27cb7d42046c5..0000000000000 --- a/packages/x-scheduler-headless/src/base-ui-copy/types/index.ts +++ /dev/null @@ -1,29 +0,0 @@ -import type * as React from 'react'; - -export * from './temporal'; -export * from './temporal-adapter'; - -export type { - BaseUIChangeEventDetails, - BaseUIGenericEventDetails, -} from '../utils/createBaseUIEventDetails'; - -export type HTMLProps = React.HTMLAttributes & { - ref?: React.Ref | undefined; -}; - -/** - * Shape of the render prop: a function that takes props to be spread on the element and component's state and returns a React element. - * - * @template Props Props to be spread on the rendered element. - * @template State Component's internal state. - */ -export type ComponentRenderFn = ( - props: Props, - state: State, -) => React.ReactElement; - -export type BaseUIEvent> = E & { - preventBaseUIHandler: () => void; - readonly baseUIHandlerPrevented?: boolean | undefined; -}; diff --git a/packages/x-scheduler-headless/src/base-ui-copy/types/temporal-adapter.ts b/packages/x-scheduler-headless/src/base-ui-copy/types/temporal-adapter.ts deleted file mode 100644 index b1c0057d1e160..0000000000000 --- a/packages/x-scheduler-headless/src/base-ui-copy/types/temporal-adapter.ts +++ /dev/null @@ -1,382 +0,0 @@ -import { TemporalTimezone, TemporalSupportedObject, TemporalSupportedValue } from './temporal'; - -export interface TemporalAdapterFormats { - /** - * The 4-digit year. - * @example "2019" - */ - yearPadded: string; - /** - * The month with leading zeros. - * @example "08" - */ - monthPadded: string; - /** - * The day of the month with leading zeros. - * @example "01" - */ - dayOfMonthPadded: string; - /** - * The hours with leading zeros, 24-hour clock. - * @example "01", "23" - */ - hours24hPadded: string; - /** - * The hours with leading zeros, 12-hour clock. - * @example "01", "11" - */ - hours12hPadded: string; - /** - * The minutes with leading zeros. - * @example "01", "59" - */ - minutesPadded: string; - /** - * The seconds with leading zeros. - * @example "01", "59" - */ - secondsPadded: string; - /** - * The day of the month without leading zeros. - * @example "1" - */ - dayOfMonth: string; - /** - * The hours without leading zeros, 24-hour clock. - * @example "1", "23" - */ - hours24h: string; - /** - * The hours without leading zeros, 12-hour clock. - * @example "1", "11" - */ - hours12h: string; - /** - * The abbreviated month name. - * @example "Aug" - */ - month3Letters: string; - /** - * The full month name. - * @example "August" - */ - monthFullLetter: string; - /** - * The week day name. - * @example "Wednesday" - */ - weekday: string; - /** - * The abbreviated week day name. - * @example "Wed" - * */ - weekday3Letters: string; - /** - * The initial of the week day name. - * @example "W" - * */ - weekday1Letter: string; - /** - * The meridiem. - * @example "AM" - */ - meridiem: string; - /** - * The localized date format including year, month, day and weekday. - * @example "Wednesday, August 6, 2014" - */ - localizedDateWithFullMonthAndWeekDay: string; - /** - * The localized numeric date format including year, month and day. - * @example "8/6/2014" - */ - localizedNumericDate: string; -} - -export type DateBuilderReturnType = [T] extends [null] - ? null - : TemporalSupportedObject; - -export interface TemporalAdapter { - isTimezoneCompatible: boolean; - formats: TemporalAdapterFormats; - /** - * Name of the library that is used right now. - */ - lib: string; - /** - * Characters used to escape a string inside a format. - */ - escapedCharacters: { start: string; end: string }; - /** - * Creates a date in the date library format. - */ - date(value: T, timezone: TemporalTimezone): DateBuilderReturnType; - /** - * Parses a date from a string in the given format. - */ - parse(value: string, format: string, timezone: TemporalTimezone): TemporalSupportedObject; - /** - * Creates a date in the date library format for the current time. - */ - now(timezone: TemporalTimezone): TemporalSupportedObject; - /** - * Extracts the timezone from a date. - */ - getTimezone(value: TemporalSupportedValue | null): TemporalTimezone; - /** - * Converts a date to another timezone. - */ - setTimezone(value: TemporalSupportedObject, timezone: TemporalTimezone): TemporalSupportedObject; - /** - * Converts a date in the library format into a JavaScript `Date` object. - */ - toJsDate(value: TemporalSupportedObject): Date; - /** - * Gets the code of the locale currently used by the adapter. - */ - getCurrentLocaleCode(): string; - /** - * Checks if the date is valid. - */ - isValid(value: TemporalSupportedValue): value is TemporalSupportedObject; - /** - * Formats a date using an adapter format string (see the `AdapterFormats` interface). - */ - format(value: TemporalSupportedObject, formatKey: keyof TemporalAdapterFormats): string; - /** - * Formats a date using a format of the date library. - */ - formatByString(value: TemporalSupportedObject, formatString: string): string; - /** - * Checks if the two dates are equal (which means they represent the same timestamp). - */ - isEqual(value: TemporalSupportedValue, comparing: TemporalSupportedValue): boolean; - /** - * Checks if the two dates are in the same year. - * Uses the timezone of the `value`. - */ - isSameYear(value: TemporalSupportedObject, comparing: TemporalSupportedObject): boolean; - /** - * Checks if the two dates are in the same month. - * Uses the timezone of the `value`. - */ - isSameMonth(value: TemporalSupportedObject, comparing: TemporalSupportedObject): boolean; - /** - * Checks if the two dates are in the same day. - * Uses the timezone of the `value`. - */ - isSameDay(value: TemporalSupportedObject, comparing: TemporalSupportedObject): boolean; - /** - * Checks if the two dates are at the same hour. - * Uses the timezone of the `value`. - */ - isSameHour(value: TemporalSupportedObject, comparing: TemporalSupportedObject): boolean; - /** - * Checks if the `value` date is after the `comparing` date. - */ - isAfter(value: TemporalSupportedObject, comparing: TemporalSupportedObject): boolean; - /** - * Checks if the `value` date is before the `comparing` date. - */ - isBefore(value: TemporalSupportedObject, comparing: TemporalSupportedObject): boolean; - /** - * Checks if the value is within the provided range. - */ - isWithinRange( - value: TemporalSupportedObject, - range: [TemporalSupportedObject, TemporalSupportedObject], - ): boolean; - /** - * Returns the start of the year for the given date. - */ - startOfYear(value: TemporalSupportedObject): TemporalSupportedObject; - /** - * Returns the start of the month for the given date. - */ - startOfMonth(value: TemporalSupportedObject): TemporalSupportedObject; - /** - * Returns the start of the week for the given date. - */ - startOfWeek(value: TemporalSupportedObject): TemporalSupportedObject; - /** - * Returns the start of the day for the given date. - */ - startOfDay(value: TemporalSupportedObject): TemporalSupportedObject; - /** - * Returns the start of the hour for the given date. - */ - startOfHour(value: TemporalSupportedObject): TemporalSupportedObject; - /** - * Returns the start of the minute for the given date. - */ - startOfMinute(value: TemporalSupportedObject): TemporalSupportedObject; - /** - * Returns the start of the second for the given date. - */ - startOfSecond(value: TemporalSupportedObject): TemporalSupportedObject; - /** - * Returns the end of the year for the given date. - */ - endOfYear(value: TemporalSupportedObject): TemporalSupportedObject; - /** - * Returns the end of the month for the given date. - */ - endOfMonth(value: TemporalSupportedObject): TemporalSupportedObject; - /** - * Returns the end of the week for the given date. - */ - endOfWeek(value: TemporalSupportedObject): TemporalSupportedObject; - /** - * Returns the end of the day for the given date. - */ - endOfDay(value: TemporalSupportedObject): TemporalSupportedObject; - /** - * Returns the end of the hour for the given date. - */ - endOfHour(value: TemporalSupportedObject): TemporalSupportedObject; - /** - * Returns the end of the minute for the given date. - */ - endOfMinute(value: TemporalSupportedObject): TemporalSupportedObject; - /** - * Returns the end of the second for the given date. - */ - endOfSecond(value: TemporalSupportedObject): TemporalSupportedObject; - /** - * Adds the specified number of years to the given date. - */ - addYears(value: TemporalSupportedObject, amount: number): TemporalSupportedObject; - /** - * Adds the specified number of months to the given date. - */ - addMonths(value: TemporalSupportedObject, amount: number): TemporalSupportedObject; - /** - * Adds the specified number of weeks to the given date. - */ - addWeeks(value: TemporalSupportedObject, amount: number): TemporalSupportedObject; - /** - * Adds the specified number of days to the given date. - */ - addDays(value: TemporalSupportedObject, amount: number): TemporalSupportedObject; - /** - * Adds the specified number of hours to the given date. - */ - addHours(value: TemporalSupportedObject, amount: number): TemporalSupportedObject; - /** - * Adds the specified number of minutes to the given date. - */ - addMinutes(value: TemporalSupportedObject, amount: number): TemporalSupportedObject; - /** - * Adds the specified number of seconds to the given date. - */ - addSeconds(value: TemporalSupportedObject, amount: number): TemporalSupportedObject; - /** - * Adds the specified number of milliseconds to the given date. - */ - addMilliseconds(value: TemporalSupportedObject, amount: number): TemporalSupportedObject; - /** - * Gets the year of the given date. - */ - getYear(value: TemporalSupportedObject): number; - /** - * Gets the month of the given date. - * The value is 0-based, in the Gregorian calendar January = 0, February = 1, ... - */ - getMonth(value: TemporalSupportedObject): number; - /** - * Gets the date (day in the month) of the given date. - */ - getDate(value: TemporalSupportedObject): number; - /** - * Gets the hours of the given date. - */ - getHours(value: TemporalSupportedObject): number; - /** - * Gets the minutes of the given date. - */ - getMinutes(value: TemporalSupportedObject): number; - /** - * Gets the seconds of the given date. - */ - getSeconds(value: TemporalSupportedObject): number; - /** - * Gets the milliseconds of the given date. - */ - getMilliseconds(value: TemporalSupportedObject): number; - /** - * Gets the time since epoch of the given date. - */ - getTime(value: TemporalSupportedObject): number; - /** - * Sets the year to the given date. - */ - setYear(value: TemporalSupportedObject, year: number): TemporalSupportedObject; - /** - * Sets the month to the given date. - */ - setMonth(value: TemporalSupportedObject, month: number): TemporalSupportedObject; - /** - * Sets the date (day in the month) to the given date. - */ - setDate(value: TemporalSupportedObject, date: number): TemporalSupportedObject; - /** - * Sets the hours to the given date. - */ - setHours(value: TemporalSupportedObject, hours: number): TemporalSupportedObject; - /** - * Sets the minutes to the given date. - */ - setMinutes(value: TemporalSupportedObject, minutes: number): TemporalSupportedObject; - /** - * Sets the seconds to the given date. - */ - setSeconds(value: TemporalSupportedObject, seconds: number): TemporalSupportedObject; - /** - * Sets the milliseconds to the given date. - */ - setMilliseconds(value: TemporalSupportedObject, milliseconds: number): TemporalSupportedObject; - /** - * Gets the number of full years between the given dates. - */ - differenceInYears: (value: TemporalSupportedObject, comparing: TemporalSupportedObject) => number; - /** - * Gets the number of full months between the given dates. - */ - differenceInMonths: ( - value: TemporalSupportedObject, - comparing: TemporalSupportedObject, - ) => number; - /** - * Gets the number of full weeks between the given dates. - */ - differenceInWeeks: (value: TemporalSupportedObject, comparing: TemporalSupportedObject) => number; - /** - * Gets the number of full days between the given dates. - */ - differenceInDays: (value: TemporalSupportedObject, comparing: TemporalSupportedObject) => number; - /** - * Gets the number of full hours between the given dates. - */ - differenceInHours: (value: TemporalSupportedObject, comparing: TemporalSupportedObject) => number; - /** - * Gets the number of full minutes between the given dates. - */ - differenceInMinutes: ( - value: TemporalSupportedObject, - comparing: TemporalSupportedObject, - ) => number; - /** - * Gets the number of days in a month of the given date. - */ - getDaysInMonth(value: TemporalSupportedObject): number; - /** - * Gets the number of the week of the given date. - */ - getWeekNumber(value: TemporalSupportedObject): number; - /** - * Gets the number of the day of the week of the given date. - * The value is 1-based, 1 - first day of the week, 7 - last day of the week. - */ - getDayOfWeek(value: TemporalSupportedObject): number; -} diff --git a/packages/x-scheduler-headless/src/base-ui-copy/types/temporal.ts b/packages/x-scheduler-headless/src/base-ui-copy/types/temporal.ts deleted file mode 100644 index 496494ebc4815..0000000000000 --- a/packages/x-scheduler-headless/src/base-ui-copy/types/temporal.ts +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Lookup in which each date library can register its supported date object type. - * - * ``` - * // Example taken from the TemporalAdapterDateFns.ts file. - * declare module '@base-ui/react/types' { - * interface TemporalSupportedObjectLookup { - * 'date-fns': Date; - * } - * } - * ``` - */ -export interface TemporalSupportedObjectLookup {} - -/** - * The valid shape date objects can take in the components and utilities that deal with dates and times. - */ -export type TemporalSupportedObject = keyof TemporalSupportedObjectLookup extends never - ? any - : TemporalSupportedObjectLookup[keyof TemporalSupportedObjectLookup]; - -/** - * The valid value for the timezone argument in components and utilities that deal with dates and times. - */ -export type TemporalTimezone = 'default' | 'system' | 'UTC' | string; - -/** - * The type that the `value` and `defaultValue` props can receive on non-range date and time components (date, time and date-time). - */ -export type TemporalValue = TemporalSupportedObject | null; - -/** - * The type that the `value` and `defaultValue` props can receive on range components (date-range, time-range and date-time-range). - */ -export type TemporalRangeValue = [TemporalValue, TemporalValue]; - -/** - * The type that the `value` and `defaultValue` props can receive on all temporal components. - */ -export type TemporalSupportedValue = TemporalValue | TemporalRangeValue; - -export type TemporalNonNullableRangeValue = [TemporalSupportedObject, TemporalSupportedObject]; - -export type TemporalNonNullableValue = - TValue extends TemporalRangeValue - ? TValue extends TemporalValue - ? TemporalSupportedObject | TemporalNonNullableRangeValue - : TemporalNonNullableRangeValue - : TemporalSupportedObject; diff --git a/packages/x-scheduler-headless/src/base-ui-copy/utils/constants.ts b/packages/x-scheduler-headless/src/base-ui-copy/utils/constants.ts deleted file mode 100644 index e6941e50a079a..0000000000000 --- a/packages/x-scheduler-headless/src/base-ui-copy/utils/constants.ts +++ /dev/null @@ -1,40 +0,0 @@ -export const TYPEAHEAD_RESET_MS = 500; -export const PATIENT_CLICK_THRESHOLD = 500; -export const DISABLED_TRANSITIONS_STYLE = { style: { transition: 'none' } }; - -export { EMPTY_OBJECT, EMPTY_ARRAY } from '@base-ui/utils/empty'; -export const CLICK_TRIGGER_IDENTIFIER = 'data-base-ui-click-trigger'; -export const BASE_UI_SWIPE_IGNORE_ATTRIBUTE = 'data-base-ui-swipe-ignore'; -export const LEGACY_SWIPE_IGNORE_ATTRIBUTE = 'data-swipe-ignore'; - -export const BASE_UI_SWIPE_IGNORE_SELECTOR = `[${BASE_UI_SWIPE_IGNORE_ATTRIBUTE}]`; -export const LEGACY_SWIPE_IGNORE_SELECTOR = `[${LEGACY_SWIPE_IGNORE_ATTRIBUTE}]`; - -/** - * Used for dropdowns that usually strictly prefer top/bottom placements and - * use `var(--available-height)` to limit their height. - */ -export const DROPDOWN_COLLISION_AVOIDANCE = { - fallbackAxisSide: 'none', -} as const; - -/** - * Used by regular popups that usually aren't scrollable and are allowed to - * freely flip to any axis of placement. - */ -export const POPUP_COLLISION_AVOIDANCE = { - fallbackAxisSide: 'end', -} as const; - -/** - * Special visually hidden styles for the aria-owns owner element to ensure owned element - * accessibility in iOS/Safari/VoiceControl. - * The owner element is an empty span, so most of the common visually hidden styles are not needed. - * @see https://github.com/floating-ui/floating-ui/issues/3403 - */ -export const ownerVisuallyHidden: React.CSSProperties = { - clipPath: 'inset(50%)', - position: 'fixed', - top: 0, - left: 0, -}; diff --git a/packages/x-scheduler-headless/src/base-ui-copy/utils/createBaseUIEventDetails.ts b/packages/x-scheduler-headless/src/base-ui-copy/utils/createBaseUIEventDetails.ts deleted file mode 100644 index c8c138661bf35..0000000000000 --- a/packages/x-scheduler-headless/src/base-ui-copy/utils/createBaseUIEventDetails.ts +++ /dev/null @@ -1,164 +0,0 @@ -import { EMPTY_OBJECT } from './constants'; -import { REASONS } from './reasons'; - -interface ReasonToEventMap { - [REASONS.none]: Event; - - [REASONS.triggerPress]: MouseEvent | PointerEvent | TouchEvent | KeyboardEvent; - [REASONS.triggerHover]: MouseEvent; - [REASONS.triggerFocus]: FocusEvent; - - [REASONS.outsidePress]: MouseEvent | PointerEvent | TouchEvent; - [REASONS.itemPress]: MouseEvent | KeyboardEvent | PointerEvent; - [REASONS.closePress]: MouseEvent | KeyboardEvent | PointerEvent; - [REASONS.linkPress]: MouseEvent | PointerEvent; - [REASONS.clearPress]: PointerEvent | MouseEvent | KeyboardEvent; - [REASONS.chipRemovePress]: PointerEvent | MouseEvent | KeyboardEvent; - [REASONS.trackPress]: PointerEvent | MouseEvent | TouchEvent; - [REASONS.incrementPress]: PointerEvent | MouseEvent | TouchEvent; - [REASONS.decrementPress]: PointerEvent | MouseEvent | TouchEvent; - - [REASONS.inputChange]: InputEvent | Event; - [REASONS.inputClear]: InputEvent | FocusEvent | Event; - [REASONS.inputBlur]: FocusEvent; - [REASONS.inputPaste]: ClipboardEvent; - [REASONS.inputPress]: MouseEvent | PointerEvent | TouchEvent | KeyboardEvent; - - [REASONS.focusOut]: FocusEvent | KeyboardEvent; - [REASONS.escapeKey]: KeyboardEvent; - [REASONS.closeWatcher]: Event; - [REASONS.listNavigation]: KeyboardEvent; - [REASONS.keyboard]: KeyboardEvent; - - [REASONS.pointer]: PointerEvent; - [REASONS.drag]: PointerEvent | TouchEvent; - [REASONS.swipe]: PointerEvent | TouchEvent; - [REASONS.wheel]: WheelEvent; - [REASONS.scrub]: PointerEvent; - - [REASONS.cancelOpen]: MouseEvent; - [REASONS.siblingOpen]: Event; - [REASONS.disabled]: Event; - [REASONS.imperativeAction]: Event; - - [REASONS.windowResize]: UIEvent; -} - -/** - * Maps a change `reason` string to the corresponding native event type. - */ -export type ReasonToEvent = Reason extends keyof ReasonToEventMap - ? ReasonToEventMap[Reason] - : Event; - -type BaseUIChangeEventDetail = { - /** - * The reason for the event. - */ - reason: Reason; - /** - * The native event associated with the custom event. - */ - event: ReasonToEvent; - /** - * Cancels Base UI from handling the event. - */ - cancel: () => void; - /** - * Allows the event to propagate in cases where Base UI will stop the propagation. - */ - allowPropagation: () => void; - /** - * Indicates whether the event has been canceled. - */ - isCanceled: boolean; - /** - * Indicates whether the event is allowed to propagate. - */ - isPropagationAllowed: boolean; - /** - * The element that triggered the event, if applicable. - */ - trigger: Element | undefined; -} & CustomProperties; - -/** - * Details of custom change events emitted by Base UI components. - */ -export type BaseUIChangeEventDetails< - Reason extends string, - CustomProperties extends object = {}, -> = Reason extends string ? BaseUIChangeEventDetail & {} : never; - -/** - * Details of custom generic events emitted by Base UI components. - */ -type BaseUIGenericEventDetail = { - /** - * The reason for the event. - */ - reason: Reason; - /** - * The native event associated with the custom event. - */ - event: ReasonToEvent; -} & CustomProperties; - -export type BaseUIGenericEventDetails< - Reason extends string, - CustomProperties extends object = {}, -> = Reason extends string ? BaseUIGenericEventDetail & {} : never; - -/** - * Creates a Base UI event details object with the given reason and utilities - * for preventing Base UI's internal event handling. - */ -export function createChangeEventDetails< - Reason extends string, - CustomProperties extends object = {}, ->( - reason: Reason, - event?: ReasonToEvent, - trigger?: HTMLElement, - customProperties?: CustomProperties, -): BaseUIChangeEventDetails { - let canceled = false; - let allowPropagation = false; - const custom = customProperties ?? (EMPTY_OBJECT as CustomProperties); - const details: BaseUIChangeEventDetail = { - reason, - event: (event ?? new Event('base-ui')) as ReasonToEvent, - cancel() { - canceled = true; - }, - allowPropagation() { - allowPropagation = true; - }, - get isCanceled() { - return canceled; - }, - get isPropagationAllowed() { - return allowPropagation; - }, - trigger, - ...custom, - }; - return details as BaseUIChangeEventDetails; -} - -export function createGenericEventDetails< - Reason extends keyof ReasonToEventMap, - CustomProperties extends object = {}, ->( - reason: Reason, - event?: ReasonToEvent, - customProperties?: CustomProperties, -): BaseUIGenericEventDetails { - const custom = customProperties ?? (EMPTY_OBJECT as CustomProperties); - const details: BaseUIGenericEventDetail = { - reason, - event: (event ?? new Event('base-ui')) as ReasonToEvent, - ...custom, - }; - return details as BaseUIGenericEventDetails; -} diff --git a/packages/x-scheduler-headless/src/base-ui-copy/utils/getStateAttributesProps.ts b/packages/x-scheduler-headless/src/base-ui-copy/utils/getStateAttributesProps.ts deleted file mode 100644 index 58c0c0d0aca15..0000000000000 --- a/packages/x-scheduler-headless/src/base-ui-copy/utils/getStateAttributesProps.ts +++ /dev/null @@ -1,32 +0,0 @@ -export type StateAttributesMapping = { - [Property in keyof State]?: (state: State[Property]) => Record | null; -}; - -export function getStateAttributesProps>( - state: State, - customMapping?: StateAttributesMapping, -) { - const props: Record = {}; - - /* eslint-disable-next-line guard-for-in */ - for (const key in state) { - const value = state[key]; - - if (customMapping?.hasOwnProperty(key)) { - const customProps = customMapping[key]!(value); - if (customProps != null) { - Object.assign(props, customProps); - } - - continue; - } - - if (value === true) { - props[`data-${key.toLowerCase()}`] = ''; - } else if (value) { - props[`data-${key.toLowerCase()}`] = value.toString(); - } - } - - return props; -} diff --git a/packages/x-scheduler-headless/src/base-ui-copy/utils/reason-parts.ts b/packages/x-scheduler-headless/src/base-ui-copy/utils/reason-parts.ts deleted file mode 100644 index 43ebd7ff36f10..0000000000000 --- a/packages/x-scheduler-headless/src/base-ui-copy/utils/reason-parts.ts +++ /dev/null @@ -1,44 +0,0 @@ -export const none = 'none' as const; - -export const triggerPress = 'trigger-press' as const; -export const triggerHover = 'trigger-hover' as const; -export const triggerFocus = 'trigger-focus' as const; - -export const outsidePress = 'outside-press' as const; -export const itemPress = 'item-press' as const; -export const closePress = 'close-press' as const; -export const linkPress = 'link-press' as const; -export const clearPress = 'clear-press' as const; -export const chipRemovePress = 'chip-remove-press' as const; -export const trackPress = 'track-press' as const; -export const incrementPress = 'increment-press' as const; -export const decrementPress = 'decrement-press' as const; - -export const inputChange = 'input-change' as const; -export const inputClear = 'input-clear' as const; -export const inputBlur = 'input-blur' as const; -export const inputPaste = 'input-paste' as const; -export const inputPress = 'input-press' as const; - -export const focusOut = 'focus-out' as const; -export const escapeKey = 'escape-key' as const; -export const closeWatcher = 'close-watcher' as const; -export const listNavigation = 'list-navigation' as const; -export const keyboard = 'keyboard' as const; - -export const pointer = 'pointer' as const; -export const drag = 'drag' as const; -export const wheel = 'wheel' as const; -export const scrub = 'scrub' as const; - -export const cancelOpen = 'cancel-open' as const; -export const siblingOpen = 'sibling-open' as const; -export const disabled = 'disabled' as const; -export const imperativeAction = 'imperative-action' as const; -export const swipe = 'swipe' as const; - -export const windowResize = 'window-resize' as const; - -export const dayPress = 'day-press' as const; -export const monthChange = 'month-change' as const; -export const valuePropChange = 'value-prop-change' as const; diff --git a/packages/x-scheduler-headless/src/base-ui-copy/utils/reasons.ts b/packages/x-scheduler-headless/src/base-ui-copy/utils/reasons.ts deleted file mode 100644 index 70f9631f4cb99..0000000000000 --- a/packages/x-scheduler-headless/src/base-ui-copy/utils/reasons.ts +++ /dev/null @@ -1,5 +0,0 @@ -import * as REASONS from './reason-parts'; - -export { REASONS }; -export type BaseUIEventReasons = typeof REASONS; -export type BaseUIEventReason = BaseUIEventReasons[keyof BaseUIEventReasons]; diff --git a/packages/x-scheduler-headless/src/base-ui-copy/utils/resolveClassName.ts b/packages/x-scheduler-headless/src/base-ui-copy/utils/resolveClassName.ts deleted file mode 100644 index 486d39cb38116..0000000000000 --- a/packages/x-scheduler-headless/src/base-ui-copy/utils/resolveClassName.ts +++ /dev/null @@ -1,13 +0,0 @@ -/** - * If the provided className is a string, it will be returned as is. - * Otherwise, the function will call the className function with the state as the first argument. - * - * @param className - * @param state - */ -export function resolveClassName( - className: string | ((state: State) => string | undefined) | undefined, - state: State, -) { - return typeof className === 'function' ? className(state) : className; -} diff --git a/packages/x-scheduler-headless/src/base-ui-copy/utils/resolveStyle.ts b/packages/x-scheduler-headless/src/base-ui-copy/utils/resolveStyle.ts deleted file mode 100644 index 39a7284d88642..0000000000000 --- a/packages/x-scheduler-headless/src/base-ui-copy/utils/resolveStyle.ts +++ /dev/null @@ -1,13 +0,0 @@ -/** - * If the provided style is an object, it will be returned as is. - * Otherwise, the function will call the style function with the state as the first argument. - * - * @param style - * @param state - */ -export function resolveStyle( - style: React.CSSProperties | ((state: State) => React.CSSProperties | undefined) | undefined, - state: State, -) { - return typeof style === 'function' ? style(state) : style; -} diff --git a/packages/x-scheduler-headless/src/base-ui-copy/utils/types.ts b/packages/x-scheduler-headless/src/base-ui-copy/utils/types.ts deleted file mode 100644 index 23c712a31c4b3..0000000000000 --- a/packages/x-scheduler-headless/src/base-ui-copy/utils/types.ts +++ /dev/null @@ -1,94 +0,0 @@ -import type * as React from 'react'; -import type { BaseUIEvent, ComponentRenderFn, HTMLProps } from '../types'; - -export type { HTMLProps, BaseUIEvent, ComponentRenderFn }; - -export interface FloatingUIOpenChangeDetails { - open: boolean; - reason: string; - nativeEvent: Event; - nested: boolean; - triggerElement?: Element | undefined; -} - -type WithPreventBaseUIHandler = T extends (event: infer E) => any - ? E extends React.SyntheticEvent - ? (event: BaseUIEvent) => ReturnType - : T - : T extends undefined - ? undefined - : T; - -/** - * Adds a `preventBaseUIHandler` method to all event handlers. - */ -export type WithBaseUIEvent = { - [K in keyof T]: WithPreventBaseUIHandler; -}; - -/** - * Props shared by all Base UI components. - * Contains `className` (string or callback taking the component's state as an argument) and `render` (function to customize rendering). - */ -export type BaseUIComponentProps< - ElementType extends React.ElementType, - State, - RenderFunctionProps = HTMLProps, -> = Omit< - WithBaseUIEvent>, - 'className' | 'color' | 'defaultValue' | 'defaultChecked' | 'style' -> & { - /** - * CSS class applied to the element, or a function that - * returns a class based on the component's state. - */ - className?: string | ((state: State) => string | undefined) | undefined; - /** - * Allows you to replace the component's HTML element - * with a different tag, or compose it with another component. - * - * Accepts a `ReactElement` or a function that returns the element to render. - */ - render?: React.ReactElement | ComponentRenderFn | undefined; - /** - * Style applied to the element, or a function that - * returns a style object based on the component's state. - */ - style?: React.CSSProperties | ((state: State) => React.CSSProperties | undefined) | undefined; -}; - -export interface NativeButtonProps { - /** - * Whether the component renders a native `