Skip to content

Commit

Permalink
restore-few-classes
Browse files Browse the repository at this point in the history
  • Loading branch information
sai6855 committed May 9, 2024
1 parent 1fba791 commit 5e28613
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 7 deletions.
24 changes: 24 additions & 0 deletions docs/pages/material-ui/api/filled-input.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,18 @@
"import { FilledInput } from '@mui/material';"
],
"classes": [
{
"key": "adornedEnd",
"className": "MuiFilledInput-adornedEnd",
"description": "Styles applied to the root element if `endAdornment` is provided.",
"isGlobal": false
},
{
"key": "adornedStart",
"className": "MuiFilledInput-adornedStart",
"description": "Styles applied to the root element if `startAdornment` is provided.",
"isGlobal": false
},
{
"key": "colorSecondary",
"className": "MuiFilledInput-colorSecondary",
Expand Down Expand Up @@ -105,12 +117,24 @@
"description": "Styles applied to the input element.",
"isGlobal": false
},
{
"key": "multiline",
"className": "MuiFilledInput-multiline",
"description": "Styles applied to the root element if `multiline={true}`.",
"isGlobal": false
},
{
"key": "root",
"className": "MuiFilledInput-root",
"description": "Styles applied to the root element.",
"isGlobal": false
},
{
"key": "sizeSmall",
"className": "MuiFilledInput-sizeSmall",
"description": "Styles applied to the root element if `size=\"small\"`.",
"isGlobal": false
},
{
"key": "underline",
"className": "MuiFilledInput-underline",
Expand Down
20 changes: 20 additions & 0 deletions docs/translations/api-docs/filled-input/filled-input.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,16 @@
}
},
"classDescriptions": {
"adornedEnd": {
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
"nodeName": "the root element",
"conditions": "<code>endAdornment</code> is provided"
},
"adornedStart": {
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
"nodeName": "the root element",
"conditions": "<code>startAdornment</code> is provided"
},
"colorSecondary": {
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
"nodeName": "the root element",
Expand All @@ -117,7 +127,17 @@
"conditions": "<code>hiddenLabel={true}</code>"
},
"input": { "description": "Styles applied to {{nodeName}}.", "nodeName": "the input element" },
"multiline": {
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
"nodeName": "the root element",
"conditions": "<code>multiline={true}</code>"
},
"root": { "description": "Styles applied to the root element." },
"sizeSmall": {
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
"nodeName": "the root element",
"conditions": "<code>size=\"small\"</code>"
},
"underline": {
"description": "Styles applied to {{nodeName}} unless {{conditions}}.",
"nodeName": "the root element",
Expand Down
14 changes: 12 additions & 2 deletions packages/mui-material/src/FilledInput/FilledInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,22 @@ import {
InputBaseRoot,
InputBaseComponent as InputBaseInput,
} from '../InputBase/InputBase';
import { capitalize } from '../utils';

const useUtilityClasses = (ownerState) => {
const { classes, disableUnderline } = ownerState;
const { classes, disableUnderline, startAdornment, endAdornment, size, hiddenLabel, multiline } =
ownerState;

const slots = {
root: ['root', !disableUnderline && 'underline'],
root: [
'root',
!disableUnderline && 'underline',
startAdornment && 'adornedStart',
endAdornment && 'adornedEnd',
size === 'small' && `size${capitalize(size)}`,
hiddenLabel && 'hiddenLabel',
multiline && 'multiline',
],
input: ['input'],
};

Expand Down
16 changes: 12 additions & 4 deletions packages/mui-material/src/FilledInput/FilledInput.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,22 @@ describe('<FilledInput />', () => {
/>,
);

expect(document.querySelector('.MuiFilledInput-sizeSmall')).to.equal(null);
expect(document.querySelector('.MuiFilledInput-multiline')).to.equal(null);
expect(document.querySelector('.MuiFilledInput-adornedEnd')).to.equal(null);
expect(document.querySelector('.MuiFilledInput-adornedStart')).to.equal(null);
expect(document.querySelector('.MuiFilledInput-inputSizeSmall')).to.equal(null);
expect(document.querySelector('.MuiFilledInput-inputMultiline')).to.equal(null);
expect(document.querySelector('.MuiFilledInput-inputAdornedStart')).to.equal(null);
expect(document.querySelector('.MuiFilledInput-inputAdornedEnd')).to.equal(null);
expect(document.querySelector('.MuiFilledInput-inputTypeSearch')).to.equal(null);
});

it('should have following classes', () => {
const { container } = render(
<FilledInput hiddenLabel multiline size="small" startAdornment="start" endAdornment="end" />,
);
const root = container.firstChild;
expect(root).to.have.class(classes.hiddenLabel);
expect(root).to.have.class(classes.multiline);
expect(root).to.have.class(classes.sizeSmall);
expect(root).to.have.class(classes.adornedEnd);
expect(root).to.have.class(classes.adornedStart);
});
});
19 changes: 18 additions & 1 deletion packages/mui-material/src/FilledInput/filledInputClasses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,16 @@ export interface FilledInputClasses {
focused: string;
/** State class applied to the root element if `disabled={true}`. */
disabled: string;
/** Styles applied to the root element if `startAdornment` is provided. */
adornedStart: string;
/** Styles applied to the root element if `endAdornment` is provided. */
adornedEnd: string;
/** State class applied to the root element if `error={true}`. */
error: string;
/** Styles applied to the root element if `size="small"`. */
sizeSmall: string;
/** Styles applied to the root element if `multiline={true}`. */
multiline: string;
/** Styles applied to the root element if `hiddenLabel={true}`. */
hiddenLabel: string;
/** Styles applied to the input element. */
Expand All @@ -29,7 +37,16 @@ export function getFilledInputUtilityClass(slot: string): string {

const filledInputClasses: FilledInputClasses = {
...inputBaseClasses,
...generateUtilityClasses('MuiFilledInput', ['root', 'underline', 'input']),
...generateUtilityClasses('MuiFilledInput', [
'root',
'underline',
'input',
'adornedStart',
'adornedEnd',
'sizeSmall',
'multiline',
'hiddenLabel',
]),
};

export default filledInputClasses;

0 comments on commit 5e28613

Please sign in to comment.