Skip to content

Commit

Permalink
[pickers] Remove WrapperVariantContext (#8088)
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasTy authored Mar 1, 2023
1 parent 389a853 commit 67ab509
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 120 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
executeInTheNextEventLoopTick,
getActiveElement,
usePicker,
WrapperVariantContext,
PickersPopper,
InferError,
ExportedBaseToolbarProps,
Expand Down Expand Up @@ -169,29 +168,27 @@ export const useDesktopRangePicker = <

const renderPicker = () => (
<LocalizationProvider localeText={localeText}>
<WrapperVariantContext.Provider value="desktop">
<Field {...fieldProps} slots={slotsForField} slotProps={slotPropsForField} />
<PickersPopper
role="tooltip"
containerRef={popperRef}
anchorEl={fieldRef.current}
onBlur={handleBlur}
{...actions}
open={open}
<Field {...fieldProps} slots={slotsForField} slotProps={slotPropsForField} />
<PickersPopper
role="tooltip"
containerRef={popperRef}
anchorEl={fieldRef.current}
onBlur={handleBlur}
{...actions}
open={open}
slots={slots}
slotProps={slotProps}
shouldRestoreFocus={shouldRestoreFocus}
>
<Layout
{...layoutProps}
{...slotProps?.layout}
slots={slots}
slotProps={slotProps}
shouldRestoreFocus={shouldRestoreFocus}
slotProps={slotPropsForLayout}
>
<Layout
{...layoutProps}
{...slotProps?.layout}
slots={slots}
slotProps={slotPropsForLayout}
>
{renderCurrentView()}
</Layout>
</PickersPopper>
</WrapperVariantContext.Provider>
{renderCurrentView()}
</Layout>
</PickersPopper>
</LocalizationProvider>
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
import {
DateOrTimeView,
usePicker,
WrapperVariantContext,
PickersModalDialog,
InferError,
ExportedBaseToolbarProps,
Expand Down Expand Up @@ -176,19 +175,17 @@ export const useMobileRangePicker = <

const renderPicker = () => (
<LocalizationProvider localeText={localeText}>
<WrapperVariantContext.Provider value="mobile">
<Field {...fieldProps} slots={slotsForField} slotProps={slotPropsForField} />
<PickersModalDialog {...actions} open={open} slots={slots} slotProps={slotProps}>
<Layout
{...layoutProps}
{...slotProps?.layout}
slots={slots}
slotProps={slotPropsForLayout}
>
{renderCurrentView()}
</Layout>
</PickersModalDialog>
</WrapperVariantContext.Provider>
<Field {...fieldProps} slots={slotsForField} slotProps={slotPropsForField} />
<PickersModalDialog {...actions} open={open} slots={slots} slotProps={slotProps}>
<Layout
{...layoutProps}
{...slotProps?.layout}
slots={slots}
slotProps={slotPropsForLayout}
>
{renderCurrentView()}
</Layout>
</PickersModalDialog>
</LocalizationProvider>
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
import {
DateOrTimeView,
usePicker,
WrapperVariantContext,
DIALOG_WIDTH,
ExportedBaseToolbarProps,
} from '@mui/x-date-pickers/internals';
Expand Down Expand Up @@ -74,24 +73,22 @@ export const useStaticRangePicker = <

const renderPicker = () => (
<LocalizationProvider localeText={localeText}>
<WrapperVariantContext.Provider value={displayStaticWrapperAs}>
<Layout
{...layoutProps}
{...slotProps?.layout}
slots={slots}
slotProps={slotPropsForLayout}
sx={[
...(Array.isArray(sx) ? sx : [sx]),
...(Array.isArray(slotProps?.layout?.sx)
? slotProps!.layout!.sx
: [slotProps?.layout?.sx]),
]}
className={clsx(className, slotProps?.layout?.className)}
ref={ref}
>
{renderCurrentView()}
</Layout>
</WrapperVariantContext.Provider>
<Layout
{...layoutProps}
{...slotProps?.layout}
slots={slots}
slotProps={slotPropsForLayout}
sx={[
...(Array.isArray(sx) ? sx : [sx]),
...(Array.isArray(slotProps?.layout?.sx)
? slotProps!.layout!.sx
: [slotProps?.layout?.sx]),
]}
className={clsx(className, slotProps?.layout?.className)}
ref={ref}
>
{renderCurrentView()}
</Layout>
</LocalizationProvider>
);

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { UseDesktopPickerParams, UseDesktopPickerProps } from './useDesktopPicke
import { useUtils } from '../useUtils';
import { usePicker } from '../usePicker';
import { LocalizationProvider } from '../../../LocalizationProvider';
import { WrapperVariantContext } from '../../components/wrappers/WrapperVariantContext';
import { BaseSingleInputFieldProps } from '../../models/fields';
import { PickersLayout } from '../../../PickersLayout';
import { InferError } from '../validation/useValidation';
Expand Down Expand Up @@ -161,28 +160,26 @@ export const useDesktopPicker = <

const renderPicker = () => (
<LocalizationProvider localeText={localeText}>
<WrapperVariantContext.Provider value="desktop">
<Field
{...fieldProps}
slots={slotsForField}
slotProps={slotProps}
inputRef={handleInputRef}
/>
<PickersPopper
role="dialog"
placement="bottom-start"
anchorEl={containerRef.current}
{...actions}
open={open}
slots={slots}
slotProps={slotProps}
shouldRestoreFocus={shouldRestoreFocus}
>
<Layout {...layoutProps} {...slotProps?.layout} slots={slots} slotProps={slotProps}>
{renderCurrentView()}
</Layout>
</PickersPopper>
</WrapperVariantContext.Provider>
<Field
{...fieldProps}
slots={slotsForField}
slotProps={slotProps}
inputRef={handleInputRef}
/>
<PickersPopper
role="dialog"
placement="bottom-start"
anchorEl={containerRef.current}
{...actions}
open={open}
slots={slots}
slotProps={slotProps}
shouldRestoreFocus={shouldRestoreFocus}
>
<Layout {...layoutProps} {...slotProps?.layout} slots={slots} slotProps={slotProps}>
{renderCurrentView()}
</Layout>
</PickersPopper>
</LocalizationProvider>
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { usePicker } from '../usePicker';
import { onSpaceOrEnter } from '../../utils/utils';
import { useUtils } from '../useUtils';
import { LocalizationProvider } from '../../../LocalizationProvider';
import { WrapperVariantContext } from '../../components/wrappers/WrapperVariantContext';
import { BaseSingleInputFieldProps } from '../../models/fields';
import { PickersLayout } from '../../../PickersLayout';
import { InferError } from '../validation/useValidation';
Expand Down Expand Up @@ -125,19 +124,17 @@ export const useMobilePicker = <

const renderPicker = () => (
<LocalizationProvider localeText={localeText}>
<WrapperVariantContext.Provider value="mobile">
<Field
{...fieldProps}
slots={slotsForField}
slotProps={slotProps}
inputRef={handleInputRef}
/>
<PickersModalDialog {...actions} open={open} slots={slots} slotProps={slotProps}>
<Layout {...layoutProps} {...slotProps?.layout} slots={slots} slotProps={slotProps}>
{renderCurrentView()}
</Layout>
</PickersModalDialog>
</WrapperVariantContext.Provider>
<Field
{...fieldProps}
slots={slotsForField}
slotProps={slotProps}
inputRef={handleInputRef}
/>
<PickersModalDialog {...actions} open={open} slots={slots} slotProps={slotProps}>
<Layout {...layoutProps} {...slotProps?.layout} slots={slots} slotProps={slotProps}>
{renderCurrentView()}
</Layout>
</PickersModalDialog>
</LocalizationProvider>
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { DateOrTimeView } from '../../models/views';
import { UseStaticPickerParams, UseStaticPickerProps } from './useStaticPicker.types';
import { usePicker } from '../usePicker';
import { LocalizationProvider } from '../../../LocalizationProvider';
import { WrapperVariantContext } from '../../components/wrappers/WrapperVariantContext';
import { PickersLayout } from '../../../PickersLayout';
import { DIALOG_WIDTH } from '../../constants/dimensions';

Expand Down Expand Up @@ -52,24 +51,22 @@ export const useStaticPicker = <

const renderPicker = () => (
<LocalizationProvider localeText={localeText}>
<WrapperVariantContext.Provider value={displayStaticWrapperAs}>
<Layout
{...layoutProps}
{...slotProps?.layout}
slots={slots}
slotProps={slotProps}
sx={[
...(Array.isArray(sx) ? sx : [sx]),
...(Array.isArray(slotProps?.layout?.sx)
? slotProps!.layout!.sx
: [slotProps?.layout?.sx]),
]}
className={clsx(className, slotProps?.layout?.className)}
ref={ref}
>
{renderCurrentView()}
</Layout>
</WrapperVariantContext.Provider>
<Layout
{...layoutProps}
{...slotProps?.layout}
slots={slots}
slotProps={slotProps}
sx={[
...(Array.isArray(sx) ? sx : [sx]),
...(Array.isArray(slotProps?.layout?.sx)
? slotProps!.layout!.sx
: [slotProps?.layout?.sx]),
]}
className={clsx(className, slotProps?.layout?.className)}
ref={ref}
>
{renderCurrentView()}
</Layout>
</LocalizationProvider>
);

Expand Down
1 change: 0 additions & 1 deletion packages/x-date-pickers/src/internals/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ export type {
PickersPopperClasses,
} from './components/pickersPopperClasses';
export { PickersToolbarButton } from './components/PickersToolbarButton';
export { WrapperVariantContext } from './components/wrappers/WrapperVariantContext';

export { DAY_MARGIN, DIALOG_WIDTH } from './constants/dimensions';

Expand Down

0 comments on commit 67ab509

Please sign in to comment.