Skip to content

Commit

Permalink
[base-ui][Select] Use Popup instead of Popper (#40524)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaldudak authored Jan 17, 2024
1 parent 85b24e9 commit ac5a1e0
Show file tree
Hide file tree
Showing 68 changed files with 1,100 additions and 581 deletions.
8 changes: 1 addition & 7 deletions docs/data/base/components/popup/AnimatedPopup.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,7 @@ export default function AnimatedPopup() {

function Animated(props) {
const { children, className } = props;
const { requestedEnter, onEntering, onExited } = useTransitionStateManager();

React.useEffect(() => {
if (requestedEnter) {
onEntering();
}
}, [onEntering, requestedEnter]);
const { requestedEnter, onExited } = useTransitionStateManager();

const handleAnimationEnd = React.useCallback(() => {
if (!requestedEnter) {
Expand Down
8 changes: 1 addition & 7 deletions docs/data/base/components/popup/AnimatedPopup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,7 @@ function Animated(
}>,
) {
const { children, className } = props;
const { requestedEnter, onEntering, onExited } = useTransitionStateManager();

React.useEffect(() => {
if (requestedEnter) {
onEntering();
}
}, [onEntering, requestedEnter]);
const { requestedEnter, onExited } = useTransitionStateManager();

const handleAnimationEnd = React.useCallback(() => {
if (!requestedEnter) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default function UnstyledSelectBasic() {
}}
slotProps={{
listbox: { className: 'CustomSelect-listbox' },
popper: { className: 'CustomSelect-popper' },
popup: { className: 'CustomSelect-popup' },
}}
defaultValue={10}
>
Expand Down Expand Up @@ -143,7 +143,7 @@ function Styles() {
isDarkMode ? 'rgba(0,0,0, 0.50)' : 'rgba(0,0,0, 0.05)'
};
}
.CustomSelect-popper {
.CustomSelect-popup {
z-index: 1;
}
.CustomSelect-option {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default function UnstyledSelectBasic() {
}}
slotProps={{
listbox: { className: 'CustomSelect-listbox' },
popper: { className: 'CustomSelect-popper' },
popup: { className: 'CustomSelect-popup' },
}}
defaultValue={10}
>
Expand Down Expand Up @@ -143,7 +143,7 @@ function Styles() {
isDarkMode ? 'rgba(0,0,0, 0.50)' : 'rgba(0,0,0, 0.05)'
};
}
.CustomSelect-popper {
.CustomSelect-popup {
z-index: 1;
}
.CustomSelect-option {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ import * as React from 'react';
import PropTypes from 'prop-types';
import { Select as BaseSelect, selectClasses } from '@mui/base/Select';
import { Option as BaseOption, optionClasses } from '@mui/base/Option';
import { Popper as BasePopper } from '@mui/base/Popper';
import { styled } from '@mui/system';
import UnfoldMoreRoundedIcon from '@mui/icons-material/UnfoldMoreRounded';

const Select = React.forwardRef(function Select(props, ref) {
const slots = {
root: CustomButton,
listbox: Listbox,
popper: Popper,
popup: Popup,
...props.slots,
};

Expand Down Expand Up @@ -169,6 +168,6 @@ const Option = styled(BaseOption)(
`,
);

const Popper = styled(BasePopper)`
const Popup = styled('div')`
z-index: 1;
`;
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
SelectRootSlotProps,
} from '@mui/base/Select';
import { Option as BaseOption, optionClasses } from '@mui/base/Option';
import { Popper as BasePopper } from '@mui/base/Popper';
import { styled } from '@mui/system';
import UnfoldMoreRoundedIcon from '@mui/icons-material/UnfoldMoreRounded';

Expand All @@ -17,7 +16,7 @@ const Select = React.forwardRef(function Select<
const slots: SelectProps<TValue, Multiple>['slots'] = {
root: CustomButton,
listbox: Listbox,
popper: Popper,
popup: Popup,
...props.slots,
};

Expand Down Expand Up @@ -179,6 +178,6 @@ const Option = styled(BaseOption)(
`,
);

const Popper = styled(BasePopper)`
const Popup = styled('div')`
z-index: 1;
`;
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ const Select = React.forwardRef(function CustomSelect(props, ref) {
),
};
},
popper: (ownerState) => {
popup: (ownerState) => {
const resolvedSlotProps = resolveSlotProps(
props.slotProps?.popper,
props.slotProps?.popup,
ownerState,
);
return {
Expand All @@ -149,7 +149,7 @@ Select.propTypes = {
*/
slotProps: PropTypes.shape({
listbox: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
popper: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
popup: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
root: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
}),
};
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,9 @@ const Select = React.forwardRef(function CustomSelect<
),
};
},
popper: (ownerState) => {
popup: (ownerState) => {
const resolvedSlotProps = resolveSlotProps(
props.slotProps?.popper,
props.slotProps?.popup,
ownerState,
);
return {
Expand Down
7 changes: 3 additions & 4 deletions docs/data/base/components/select/UnstyledSelectControlled.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import * as React from 'react';
import PropTypes from 'prop-types';
import { Select as BaseSelect, selectClasses } from '@mui/base/Select';
import { Option as BaseOption, optionClasses } from '@mui/base/Option';
import { Popper as BasePopper } from '@mui/base/Popper';
import { styled } from '@mui/system';
import UnfoldMoreRoundedIcon from '@mui/icons-material/UnfoldMoreRounded';

Expand All @@ -26,7 +25,7 @@ function Select(props) {
const slots = {
root: StyledButton,
listbox: Listbox,
popper: Popper,
popup: Popup,
...props.slots,
};

Expand All @@ -41,7 +40,7 @@ Select.propTypes = {
*/
slots: PropTypes.shape({
listbox: PropTypes.elementType,
popper: PropTypes.func,
popup: PropTypes.elementType,
root: PropTypes.elementType,
}),
};
Expand Down Expand Up @@ -190,7 +189,7 @@ const Option = styled(BaseOption)(
`,
);

const Popper = styled(BasePopper)`
const Popup = styled('div')`
z-index: 1;
`;

Expand Down
5 changes: 2 additions & 3 deletions docs/data/base/components/select/UnstyledSelectControlled.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
SelectRootSlotProps,
} from '@mui/base/Select';
import { Option as BaseOption, optionClasses } from '@mui/base/Option';
import { Popper as BasePopper } from '@mui/base/Popper';
import { styled } from '@mui/system';
import UnfoldMoreRoundedIcon from '@mui/icons-material/UnfoldMoreRounded';

Expand All @@ -30,7 +29,7 @@ function Select(props: SelectProps<number, false>) {
const slots: SelectProps<number, false>['slots'] = {
root: StyledButton,
listbox: Listbox,
popper: Popper,
popup: Popup,
...props.slots,
};

Expand Down Expand Up @@ -179,7 +178,7 @@ const Option = styled(BaseOption)(
`,
);

const Popper = styled(BasePopper)`
const Popup = styled('div')`
z-index: 1;
`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import PropTypes from 'prop-types';
import { Select as BaseSelect, selectClasses } from '@mui/base/Select';

import { Option as BaseOption, optionClasses } from '@mui/base/Option';
import { Popper as BasePopper } from '@mui/base/Popper';
import { styled } from '@mui/system';
import UnfoldMoreRoundedIcon from '@mui/icons-material/UnfoldMoreRounded';

Expand All @@ -30,7 +29,7 @@ function Select(props) {
const slots = {
root: Button,
listbox: Listbox,
popper: Popper,
popup: Popup,
...props.slots,
};

Expand All @@ -45,7 +44,7 @@ Select.propTypes = {
*/
slots: PropTypes.shape({
listbox: PropTypes.elementType,
popper: PropTypes.func,
popup: PropTypes.elementType,
root: PropTypes.elementType,
}),
};
Expand Down Expand Up @@ -192,6 +191,6 @@ const Option = styled(BaseOption)(
`,
);

const Popper = styled(BasePopper)`
const Popup = styled('div')`
z-index: 1;
`;
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
} from '@mui/base/Select';
import { SelectOption } from '@mui/base/useOption';
import { Option as BaseOption, optionClasses } from '@mui/base/Option';
import { Popper as BasePopper } from '@mui/base/Popper';
import { styled } from '@mui/system';
import UnfoldMoreRoundedIcon from '@mui/icons-material/UnfoldMoreRounded';

Expand All @@ -34,7 +33,7 @@ function Select(props: SelectProps<number, false>) {
const slots: SelectProps<number, false>['slots'] = {
root: Button,
listbox: Listbox,
popper: Popper,
popup: Popup,
...props.slots,
};

Expand Down Expand Up @@ -184,6 +183,6 @@ const Option = styled(BaseOption)(
`,
);

const Popper = styled(BasePopper)`
const Popup = styled('div')`
z-index: 1;
`;
5 changes: 2 additions & 3 deletions docs/data/base/components/select/UnstyledSelectForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import * as React from 'react';
import PropTypes from 'prop-types';
import { Select as BaseSelect, selectClasses } from '@mui/base/Select';
import { Option as BaseOption, optionClasses } from '@mui/base/Option';
import { Popper as BasePopper } from '@mui/base/Popper';
import { styled } from '@mui/system';
import UnfoldMoreRoundedIcon from '@mui/icons-material/UnfoldMoreRounded';

Expand Down Expand Up @@ -34,7 +33,7 @@ const Select = React.forwardRef(function CustomSelect(props, ref) {
const slots = {
root: Button,
listbox: Listbox,
popper: Popper,
popup: Popup,
...props.slots,
};

Expand Down Expand Up @@ -184,7 +183,7 @@ const Option = styled(BaseOption)(
`,
);

const Popper = styled(BasePopper)`
const Popup = styled('div')`
z-index: 1;
`;

Expand Down
5 changes: 2 additions & 3 deletions docs/data/base/components/select/UnstyledSelectForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
SelectRootSlotProps,
} from '@mui/base/Select';
import { Option as BaseOption, optionClasses } from '@mui/base/Option';
import { Popper as BasePopper } from '@mui/base/Popper';
import { styled } from '@mui/system';
import UnfoldMoreRoundedIcon from '@mui/icons-material/UnfoldMoreRounded';

Expand Down Expand Up @@ -41,7 +40,7 @@ const Select = React.forwardRef(function CustomSelect<
const slots: SelectProps<TValue, Multiple>['slots'] = {
root: Button,
listbox: Listbox,
popper: Popper,
popup: Popup,
...props.slots,
};

Expand Down Expand Up @@ -194,7 +193,7 @@ const Option = styled(BaseOption)(
`,
);

const Popper = styled(BasePopper)`
const Popup = styled('div')`
z-index: 1;
`;

Expand Down
7 changes: 3 additions & 4 deletions docs/data/base/components/select/UnstyledSelectGrouping.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import PropTypes from 'prop-types';
import { Select as BaseSelect, selectClasses } from '@mui/base/Select';
import { Option as BaseOption, optionClasses } from '@mui/base/Option';
import { OptionGroup as BaseOptionGroup } from '@mui/base/OptionGroup';
import { Popper as BasePopper } from '@mui/base/Popper';
import { styled } from '@mui/system';
import UnfoldMoreRoundedIcon from '@mui/icons-material/UnfoldMoreRounded';

Expand All @@ -28,7 +27,7 @@ function Select(props) {
const slots = {
root: Button,
listbox: Listbox,
popper: Popper,
popup: Popup,
...props.slots,
};

Expand All @@ -43,7 +42,7 @@ Select.propTypes = {
*/
slots: PropTypes.shape({
listbox: PropTypes.elementType,
popper: PropTypes.func,
popup: PropTypes.elementType,
root: PropTypes.elementType,
}),
};
Expand Down Expand Up @@ -237,6 +236,6 @@ const GroupOptions = styled('ul')`
}
`;

const Popper = styled(BasePopper)`
const Popup = styled('div')`
z-index: 1;
`;
5 changes: 2 additions & 3 deletions docs/data/base/components/select/UnstyledSelectGrouping.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
OptionGroup as BaseOptionGroup,
OptionGroupProps,
} from '@mui/base/OptionGroup';
import { Popper as BasePopper } from '@mui/base/Popper';
import { styled } from '@mui/system';
import UnfoldMoreRoundedIcon from '@mui/icons-material/UnfoldMoreRounded';

Expand All @@ -35,7 +34,7 @@ function Select(props: SelectProps<string, false>) {
const slots: SelectProps<string, false>['slots'] = {
root: Button,
listbox: Listbox,
popper: Popper,
popup: Popup,
...props.slots,
};

Expand Down Expand Up @@ -222,6 +221,6 @@ const GroupOptions = styled('ul')`
}
`;

const Popper = styled(BasePopper)`
const Popup = styled('div')`
z-index: 1;
`;
Loading

0 comments on commit ac5a1e0

Please sign in to comment.