Skip to content

Commit

Permalink
[Switch] Simplify source (mui#38910)
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari authored and xcode-it committed Sep 11, 2023
1 parent 88918c9 commit 925a3b0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 21 deletions.
13 changes: 1 addition & 12 deletions packages/mui-base/src/Switch/Switch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,7 @@ const Switch = React.forwardRef(function Switch<RootComponentType extends React.
...other
} = props;

const useSwitchProps = {
checked: checkedProp,
defaultChecked,
disabled: disabledProp,
onBlur,
onChange,
onFocus,
onFocusVisible,
readOnly: readOnlyProp,
};

const { getInputProps, checked, disabled, focusVisible, readOnly } = useSwitch(useSwitchProps);
const { getInputProps, checked, disabled, focusVisible, readOnly } = useSwitch(props);

const ownerState: SwitchOwnerState = {
...props,
Expand Down
11 changes: 2 additions & 9 deletions packages/mui-joy/src/Switch/Switch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,6 @@ const Switch = React.forwardRef(function Switch(inProps, ref) {
}, [registerEffect]);
}

const disabledProp = inProps.disabled ?? formControl?.disabled ?? disabledExternalProp;
const size = inProps.size ?? formControl?.size ?? sizeProp;
const { getColor } = useColorInversion(variant);
const color = getColor(
Expand All @@ -275,14 +274,8 @@ const Switch = React.forwardRef(function Switch(inProps, ref) {
);

const useSwitchProps = {
checked: checkedProp,
defaultChecked,
disabled: disabledProp,
onBlur,
onChange,
onFocus,
onFocusVisible,
readOnly: readOnlyProp,
disabled: inProps.disabled ?? formControl?.disabled ?? disabledExternalProp,
...props,
};

const { getInputProps, checked, disabled, focusVisible, readOnly } = useSwitch(useSwitchProps);
Expand Down

0 comments on commit 925a3b0

Please sign in to comment.