Skip to content

Commit

Permalink
Merge branch 'master' into patch-2
Browse files Browse the repository at this point in the history
  • Loading branch information
mj12albert authored Dec 15, 2024
2 parents 5f893a7 + 68e3b40 commit 6e42d61
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 105 deletions.
44 changes: 6 additions & 38 deletions docs/data/material/components/text-fields/FormattedInputs.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,35 +29,6 @@ TextMaskCustom.propTypes = {
onChange: PropTypes.func.isRequired,
};

const NumericFormatCustom = React.forwardRef(
function NumericFormatCustom(props, ref) {
const { onChange, ...other } = props;

return (
<NumericFormat
{...other}
getInputRef={ref}
onValueChange={(values) => {
onChange({
target: {
name: props.name,
value: values.value,
},
});
}}
thousandSeparator
valueIsNumericString
prefix="$"
/>
);
},
);

NumericFormatCustom.propTypes = {
name: PropTypes.string.isRequired,
onChange: PropTypes.func.isRequired,
};

export default function FormattedInputs() {
const [values, setValues] = React.useState({
textmask: '(100) 000-0000',
Expand All @@ -83,18 +54,15 @@ export default function FormattedInputs() {
inputComponent={TextMaskCustom}
/>
</FormControl>
<TextField
label="react-number-format"
<NumericFormat
value={values.numberformat}
onChange={handleChange}
name="numberformat"
id="formatted-numberformat-input"
slotProps={{
input: {
inputComponent: NumericFormatCustom,
},
}}
customInput={TextField}
thousandSeparator
valueIsNumericString
prefix="$"
variant="standard"
label="react-number-format"
/>
</Stack>
);
Expand Down
41 changes: 7 additions & 34 deletions docs/data/material/components/text-fields/FormattedInputs.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import { IMaskInput } from 'react-imask';
import { NumericFormat, NumericFormatProps } from 'react-number-format';
import { NumericFormat } from 'react-number-format';
import Stack from '@mui/material/Stack';
import Input from '@mui/material/Input';
import InputLabel from '@mui/material/InputLabel';
Expand Down Expand Up @@ -30,30 +30,6 @@ const TextMaskCustom = React.forwardRef<HTMLInputElement, CustomProps>(
},
);

const NumericFormatCustom = React.forwardRef<NumericFormatProps, CustomProps>(
function NumericFormatCustom(props, ref) {
const { onChange, ...other } = props;

return (
<NumericFormat
{...other}
getInputRef={ref}
onValueChange={(values) => {
onChange({
target: {
name: props.name,
value: values.value,
},
});
}}
thousandSeparator
valueIsNumericString
prefix="$"
/>
);
},
);

export default function FormattedInputs() {
const [values, setValues] = React.useState({
textmask: '(100) 000-0000',
Expand All @@ -79,18 +55,15 @@ export default function FormattedInputs() {
inputComponent={TextMaskCustom as any}
/>
</FormControl>
<TextField
label="react-number-format"
<NumericFormat
value={values.numberformat}
onChange={handleChange}
name="numberformat"
id="formatted-numberformat-input"
slotProps={{
input: {
inputComponent: NumericFormatCustom as any,
},
}}
customInput={TextField}
thousandSeparator
valueIsNumericString
prefix="$"
variant="standard"
label="react-number-format"
/>
</Stack>
);
Expand Down
9 changes: 5 additions & 4 deletions packages/mui-material/src/Autocomplete/Autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,11 @@ const AutocompleteClearIndicator = styled(IconButton, {
const AutocompletePopupIndicator = styled(IconButton, {
name: 'MuiAutocomplete',
slot: 'PopupIndicator',
overridesResolver: ({ ownerState }, styles) => ({
...styles.popupIndicator,
...(ownerState.popupOpen && styles.popupIndicatorOpen),
}),
overridesResolver: (props, styles) => {
const { ownerState } = props;

return [styles.popupIndicator, ownerState.popupOpen && styles.popupIndicatorOpen];
},
})({
padding: 2,
marginRight: -2,
Expand Down
7 changes: 3 additions & 4 deletions packages/mui-material/src/AvatarGroup/AvatarGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@ const useUtilityClasses = (ownerState) => {
const AvatarGroupRoot = styled('div', {
name: 'MuiAvatarGroup',
slot: 'Root',
overridesResolver: (props, styles) => ({
[`& .${avatarGroupClasses.avatar}`]: styles.avatar,
...styles.root,
}),
overridesResolver: (props, styles) => {
return [{ [`& .${avatarGroupClasses.avatar}`]: styles.avatar }, styles.root];
},
})(
memoTheme(({ theme }) => ({
display: 'flex',
Expand Down
12 changes: 7 additions & 5 deletions packages/mui-material/src/CardHeader/CardHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ const useUtilityClasses = (ownerState) => {
const CardHeaderRoot = styled('div', {
name: 'MuiCardHeader',
slot: 'Root',
overridesResolver: (props, styles) => ({
[`& .${cardHeaderClasses.title}`]: styles.title,
[`& .${cardHeaderClasses.subheader}`]: styles.subheader,
...styles.root,
}),
overridesResolver: (props, styles) => {
return [
{ [`& .${cardHeaderClasses.title}`]: styles.title },
{ [`& .${cardHeaderClasses.subheader}`]: styles.subheader },
styles.root,
];
},
})({
display: 'flex',
alignItems: 'center',
Expand Down
14 changes: 8 additions & 6 deletions packages/mui-material/src/FormControl/FormControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@ const useUtilityClasses = (ownerState) => {
const FormControlRoot = styled('div', {
name: 'MuiFormControl',
slot: 'Root',
overridesResolver: ({ ownerState }, styles) => {
return {
...styles.root,
...styles[`margin${capitalize(ownerState.margin)}`],
...(ownerState.fullWidth && styles.fullWidth),
};
overridesResolver: (props, styles) => {
const { ownerState } = props;

return [
styles.root,
styles[`margin${capitalize(ownerState.margin)}`],
ownerState.fullWidth && styles.fullWidth,
];
},
})({
display: 'inline-flex',
Expand Down
13 changes: 7 additions & 6 deletions packages/mui-material/src/FormLabel/FormLabel.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,13 @@ const useUtilityClasses = (ownerState) => {
export const FormLabelRoot = styled('label', {
name: 'MuiFormLabel',
slot: 'Root',
overridesResolver: ({ ownerState }, styles) => {
return {
...styles.root,
...(ownerState.color === 'secondary' && styles.colorSecondary),
...(ownerState.filled && styles.filled),
};
overridesResolver: (props, styles) => {
const { ownerState } = props;
return [
styles.root,
ownerState.color === 'secondary' && styles.colorSecondary,
ownerState.filled && styles.filled,
];
},
})(
memoTheme(({ theme }) => ({
Expand Down
16 changes: 8 additions & 8 deletions packages/mui-material/src/styles/styled.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,10 @@ describe('styled', () => {
},
});

const testOverridesResolver = (props, styles) => ({
...styles.root,
...(props.variant && styles[props.variant]),
});
const testOverridesResolver = (props, styles) => [
styles.root,
props.variant && styles[props.variant],
];

Test = styled('div', {
shouldForwardProp: (prop) => prop !== 'variant' && prop !== 'size' && prop !== 'sx',
Expand Down Expand Up @@ -429,10 +429,10 @@ describe('styled', () => {
});

it('should respect the skipSx option', () => {
const testOverridesResolver = (props, styles) => ({
...styles.root,
...(props.variant && styles[props.variant]),
});
const testOverridesResolver = (props, styles) => [
styles.root,
props.variant && styles[props.variant],
];

const TestNoSx = styled('div', {
shouldForwardProp: (prop) => prop !== 'variant' && prop !== 'size' && prop !== 'sx',
Expand Down

0 comments on commit 6e42d61

Please sign in to comment.