Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FilledInput][material-next] Add FilledInput component #39307

Merged
merged 38 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
5643028
Convert to TS
mj12albert Oct 3, 2023
9a733e8
Fix types
mj12albert Oct 9, 2023
a3c761a
Fix styles
mj12albert Oct 4, 2023
c0a4b96
Fix describeConformance
mj12albert Oct 4, 2023
30b9098
Fix tests
mj12albert Oct 4, 2023
8794164
Convert FormControl test to typescript
mj12albert Oct 4, 2023
de742ce
Update FormControl tests that rely on FilledInput
mj12albert Oct 4, 2023
9c8626d
Convert InputBase tests to typescript
mj12albert Oct 4, 2023
692ee5c
Update proptypes
mj12albert Oct 4, 2023
5a7559f
Prettier
mj12albert Oct 4, 2023
b8ac7f5
Minor CI fixes
mj12albert Oct 4, 2023
8690782
Fix internal imports
mj12albert Oct 5, 2023
b9027a5
Fully use useSlotProps
mj12albert Oct 5, 2023
9e91251
Fix slots in types and proptypes
mj12albert Oct 6, 2023
cc82a27
Drop componentsProps test
mj12albert Oct 6, 2023
02d7bf9
Tweak styles
mj12albert Oct 6, 2023
6f9473f
Support tertiary color
mj12albert Oct 9, 2023
873c75f
Set up experiments page
mj12albert Oct 6, 2023
2d249b5
Fix skipped FormControl test
mj12albert Oct 9, 2023
54b1945
Update docs
mj12albert Oct 9, 2023
e6908c1
Fix proptypes
mj12albert Oct 9, 2023
c60d7fe
Update InputBase test types
mj12albert Oct 13, 2023
7d98926
Misc fixes
mj12albert Oct 13, 2023
0adc161
Add default component type to custom interface
mj12albert Oct 13, 2023
53efd42
Update proptypes
mj12albert Oct 13, 2023
227a2b3
Do not separate SingleLine and MultiLine input props
mj12albert Oct 13, 2023
4a821f9
Update test
mj12albert Oct 13, 2023
6c233b2
Fix test and update comments
mj12albert Oct 13, 2023
cbf63bd
Pass multiline and type through useSlotProps
mj12albert Oct 13, 2023
f46a4c2
Merge remote-tracking branch 'upstream/master' into material-next/fil…
mj12albert Oct 13, 2023
b322096
Remove unrelated expect
mj12albert Oct 17, 2023
452fa87
Merge remote-tracking branch 'upstream/master' into material-next/fil…
mj12albert Oct 17, 2023
1797c40
Fix test
mj12albert Oct 20, 2023
073ae1b
Add a test
mj12albert Oct 20, 2023
2f6bc51
Add a runtime warning for multilne props on a single line input
mj12albert Oct 20, 2023
44e2a7d
Merge remote-tracking branch 'upstream/master' into material-next/fil…
mj12albert Oct 20, 2023
b253ded
Merge remote-tracking branch 'upstream/master' into material-next/fil…
mj12albert Oct 23, 2023
5d132de
Fix test
mj12albert Oct 23, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions docs/pages/experiments/md3/inputs.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as React from 'react';
import Stack from '@mui/material/Stack';
import Divider from '@mui/material/Divider';
import Md2FilledInput from '@mui/material/FilledInput';
import { ThemeProvider, createTheme } from '@mui/material/styles';
import FilledInput from '@mui/material-next/FilledInput';
Expand All @@ -14,16 +15,22 @@ export default function MaterialYouInputs() {
return (
<Stack spacing={4}>
<ThemeProvider theme={md2Theme}>
<pre>MD2</pre>
<Stack display="inline-flex" direction="row" gap={4}>
<Md2FilledInput defaultValue="Hello" color="primary" />
<Md2FilledInput defaultValue="Hello" color="secondary" />
<Md2FilledInput defaultValue="primary" color="primary" />
<Md2FilledInput defaultValue="secondary" color="secondary" />
</Stack>
<Divider />
</ThemeProvider>
<CssVarsProvider theme={md3Theme}>
<ModeSwitcher />
<Stack direction="row" gap={1}>
<pre>MD3</pre>
<ModeSwitcher />
</Stack>
<Stack display="inline-flex" direction="row" gap={4}>
<FilledInput defaultValue="Hello" color="primary" />
<FilledInput defaultValue="Hello" color="secondary" />
<FilledInput defaultValue="primary" color="primary" />
<FilledInput defaultValue="secondary" color="secondary" />
<FilledInput defaultValue="tertiary" color="tertiary" />
</Stack>
</CssVarsProvider>
</Stack>
Expand Down
13 changes: 13 additions & 0 deletions packages/mui-material-next/migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,19 @@ If you need to prevent default on a `key-up` and/or `key-down` event, then besid

This is to ensure that default is prevented when the `ButtonBase` root is not a native button, for example, when the root element used is a `span`.

## FilledInput

### Removed `inputProps`

`inputProps` are removed in favor of `slotProps.input`:

```diff
<FilledInput
- inputProps={{ className: 'my-input' }}
+ slotProps={{ input: { className: 'my-input' } }}
/>
```

## FormControl

### Renamed `FormControlState`
Expand Down
41 changes: 0 additions & 41 deletions packages/mui-material-next/src/FilledInput/FilledInput.d.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import * as React from 'react';
import { expect } from 'chai';
import { createRenderer, describeConformance } from '@mui-internal/test-utils';
import FilledInput, { filledInputClasses as classes } from '@mui/material/FilledInput';
import InputBase from '@mui/material/InputBase';
import { CssVarsProvider, extendTheme } from '@mui/material-next/styles';
import FilledInput, { filledInputClasses as classes } from '@mui/material-next/FilledInput';
import InputBase from '@mui/material-next/InputBase';

describe('<FilledInput />', () => {
const { render } = createRenderer();

describeConformance(<FilledInput open />, () => ({
ThemeProvider: CssVarsProvider,
createTheme: extendTheme,
classes,
inheritComponent: InputBase,
render,
Expand All @@ -16,11 +19,9 @@ describe('<FilledInput />', () => {
testDeepOverrides: { slotName: 'input', slotClassName: classes.input },
testVariantProps: { variant: 'contained', fullWidth: true },
testStateOverrides: { prop: 'size', value: 'small', styleKey: 'sizeSmall' },
testLegacyComponentsProp: true,
slots: {
// can't test with DOM element as Input places an ownerState prop on it unconditionally.
root: { expectedClassName: classes.root, testWithElement: null },
input: { expectedClassName: classes.input, testWithElement: null },
root: { expectedClassName: classes.root },
input: { expectedClassName: classes.input, testWithElement: 'input' },
},
skip: [
'componentProp',
Expand All @@ -30,9 +31,10 @@ describe('<FilledInput />', () => {
}));

it('should have the underline class', () => {
const { container } = render(<FilledInput />);
const root = container.firstChild;
const { getByTestId } = render(<FilledInput data-testid="test-input" />);
const root = getByTestId('test-input');
expect(root).not.to.equal(null);
expect(root).to.have.class(classes.underline);
});

it('color={undefined} should not result in crash', () => {
Expand All @@ -42,8 +44,8 @@ describe('<FilledInput />', () => {
});

it('can disable the underline', () => {
const { container } = render(<FilledInput disableUnderline />);
const root = container.firstChild;
const { getByTestId } = render(<FilledInput data-testid="test-input" disableUnderline />);
const root = getByTestId('test-input');
expect(root).not.to.have.class(classes.underline);
});

Expand All @@ -52,19 +54,15 @@ describe('<FilledInput />', () => {
expect(document.querySelector('.error')).not.to.equal(null);
});

it('should respects the componentsProps if passed', () => {
mj12albert marked this conversation as resolved.
Show resolved Hide resolved
render(<FilledInput componentsProps={{ root: { 'data-test': 'test' } }} />);
expect(document.querySelector('[data-test=test]')).not.to.equal(null);
});

it('should respect the classes coming from InputBase', () => {
render(
const { getByTestId } = render(
<FilledInput
data-test="test"
data-testid="test-input"
multiline
sx={{ [`&.${classes.multiline}`]: { mt: '10px' } }}
/>,
);
expect(document.querySelector('[data-test=test]')).toHaveComputedStyle({ marginTop: '10px' });
const root = getByTestId('test-input');
expect(root).toHaveComputedStyle({ marginTop: '10px' });
});
});
Loading