Skip to content

Commit

Permalink
Merge branch 'master' into renovate/babel
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeeshanTamboli committed Jul 12, 2023
2 parents e8e064a + 1a71391 commit 0203678
Show file tree
Hide file tree
Showing 32 changed files with 1,397 additions and 122 deletions.
10 changes: 0 additions & 10 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -269,15 +269,6 @@ jobs:
yarn workspace @mui/material typescript:module-augmentation
yarn workspace @mui/base typescript:module-augmentation
yarn workspace @mui/joy typescript:module-augmentation
- restore_cache:
name: Restore generated declaration files
keys:
# #default-branch-switch
# We assume that the target branch is `master` and that declaration files are persisted in commit order.
# "If there are multiple matches, the most recently generated cache will be used."
- typescript-declaration-files-master

- run:
name: Diff declaration files
command: |
Expand All @@ -286,7 +277,6 @@ jobs:
git add -f packages/mui-utils/build || echo '/utils declarations do not exist'
yarn lerna run build:types
git --no-pager diff
- run:
name: Any defect declaration files?
command: node scripts/testBuiltTypes.mjs
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/5.priority-support.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 'Priority support: SLA ⏰'
description: I'm a Premium plan user and I have the priority support add-on, I can't find a solution to my problem with MUI X.
description: I'm an MUI X Premium user and we have purchased the Priority Support add-on. I can't find a solution to my problem with MUI Core (Material UI, Base UI, MUI System, and Joy UI).
title: '[question] '
labels: ['status: needs triage', 'support: unknown']
body:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/priority-support-validation-prompt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
with:
issue-number: ${{ github.event.issue.number }}
body: |
You have created a priority support request ⏰. Please validate your support key using the link below:
You have created a support request under the ["Priority Support"](https://mui.com/legal/technical-support-sla/#priority-support) terms, which is a paid add-on to MUI X Premium ⏰. Please validate your support key using the link below:
https://tools-public.mui.com/prod/pages/jyhs86t?repo=mui-x&issueId=${{ github.event.issue.number }}
Expand Down
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ A big thanks to the 15 contributors who made this release possible. Here are som

### Docs

- [docs] Polish ukraine banner (#37905) @oliviertassinari
- [docs] Reduce ukraine banner size (#34795) @oliviertassinari
- [docs] Polish Ukraine banner (#37905) @oliviertassinari
- [docs] Reduce Ukraine banner size (#34795) @oliviertassinari
- [docs] Add callouts about controlled vs uncontrolled components in Core docs (#37849) @samuelsycamore
- [docs] Add missing Portal elements to Tailwind CSS interoperability guide (#37807) @enrique-ramirez
- [docs] Small pickers migration improvement (#37815) @alexfauquette
Expand Down
142 changes: 142 additions & 0 deletions docs/data/base/components/form-control/BasicFormControl/css/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
import * as React from 'react';
import PropTypes from 'prop-types';
import FormControl, { useFormControlContext } from '@mui/base/FormControl';
import Input, { inputClasses } from '@mui/base/Input';
import { useTheme } from '@mui/system';
import clsx from 'clsx';

export default function BasicFormControl() {
return (
<React.Fragment>
<FormControl defaultValue="" required>
<Label>Name</Label>
<Input placeholder="Write your name here" className="CustomInput" />
<HelperText />
</FormControl>
<Styles />
</React.Fragment>
);
}

const Label = React.forwardRef(({ className: classNameProp, children }, ref) => {
const formControlContext = useFormControlContext();
const [dirty, setDirty] = React.useState(false);

React.useEffect(() => {
if (formControlContext?.filled) {
setDirty(true);
}
}, [formControlContext]);

if (formControlContext === undefined) {
return <p className={clsx('text-sm mb-1', classNameProp)}>{children}</p>;
}

const { error, required, filled } = formControlContext;
const showRequiredError = dirty && required && !filled;

return (
<p
ref={ref}
className={clsx(
'text-sm mb-1',
classNameProp,
error || showRequiredError ? 'invalid text-red-500' : '',
)}
>
{children}
{required ? ' *' : ''}
</p>
);
});

const HelperText = React.forwardRef((props, ref) => {
const { className, ...other } = props;
const formControlContext = useFormControlContext();
const [dirty, setDirty] = React.useState(false);

React.useEffect(() => {
if (formControlContext?.filled) {
setDirty(true);
}
}, [formControlContext]);

if (formControlContext === undefined) {
return null;
}

const { required, filled } = formControlContext;
const showRequiredError = dirty && required && !filled;

return showRequiredError ? (
<p ref={ref} className={clsx('text-sm', className)} {...other}>
This field is required.
</p>
) : null;
});

HelperText.propTypes = {
className: PropTypes.string,
};

const cyan = {
50: '#E9F8FC',
100: '#BDEBF4',
200: '#99D8E5',
300: '#66BACC',
400: '#1F94AD',
500: '#0D5463',
600: '#094855',
700: '#063C47',
800: '#043039',
900: '#022127',
};

const grey = {
50: '#F3F6F9',
100: '#E7EBF0',
200: '#E0E3E7',
300: '#CDD2D7',
400: '#B2BAC2',
500: '#A0AAB4',
600: '#6F7E8C',
700: '#3E5060',
800: '#2D3843',
900: '#1A2027',
};

function useIsDarkMode() {
const theme = useTheme();
return theme.palette.mode === 'dark';
}

function Styles() {
// Replace this with your app logic for determining dark mode
const isDarkMode = useIsDarkMode();

return (
<style>
{`
.CustomInput .${inputClasses.input} {
width: 320px;
font-size: 0.875rem;
font-family: IBM Plex Sans, sans-serif;
font-weight: 400;
line-height: 1.5;
padding: 8px 12px;
border-radius: 8px;
color: ${isDarkMode ? grey[300] : grey[900]};
background: ${isDarkMode ? grey[900] : '#fff'};
border: 1px solid ${isDarkMode ? grey[800] : grey[300]};
}
.CustomInput .${inputClasses.input}:hover {
background: ${isDarkMode ? '' : grey[100]};
border-color: ${isDarkMode ? grey[700] : grey[400]};
}
.CustomInput .${inputClasses.input}:focus {
outline: 3px solid ${isDarkMode ? cyan[600] : cyan[100]};
}
`}
</style>
);
}
142 changes: 142 additions & 0 deletions docs/data/base/components/form-control/BasicFormControl/css/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
import * as React from 'react';
import FormControl, { useFormControlContext } from '@mui/base/FormControl';
import Input, { inputClasses } from '@mui/base/Input';
import { useTheme } from '@mui/system';
import clsx from 'clsx';

export default function BasicFormControl() {
return (
<React.Fragment>
<FormControl defaultValue="" required>
<Label>Name</Label>
<Input placeholder="Write your name here" className="CustomInput" />
<HelperText />
</FormControl>
<Styles />
</React.Fragment>
);
}

const Label = React.forwardRef<
HTMLParagraphElement,
{ className?: string; children?: React.ReactNode }
>(({ className: classNameProp, children }, ref) => {
const formControlContext = useFormControlContext();
const [dirty, setDirty] = React.useState(false);

React.useEffect(() => {
if (formControlContext?.filled) {
setDirty(true);
}
}, [formControlContext]);

if (formControlContext === undefined) {
return <p className={clsx('text-sm mb-1', classNameProp)}>{children}</p>;
}

const { error, required, filled } = formControlContext;
const showRequiredError = dirty && required && !filled;

return (
<p
ref={ref}
className={clsx(
'text-sm mb-1',
classNameProp,
error || showRequiredError ? 'invalid text-red-500' : '',
)}
>
{children}
{required ? ' *' : ''}
</p>
);
});

const HelperText = React.forwardRef<HTMLParagraphElement, { className?: string }>(
(props, ref) => {
const { className, ...other } = props;
const formControlContext = useFormControlContext();
const [dirty, setDirty] = React.useState(false);

React.useEffect(() => {
if (formControlContext?.filled) {
setDirty(true);
}
}, [formControlContext]);

if (formControlContext === undefined) {
return null;
}

const { required, filled } = formControlContext;
const showRequiredError = dirty && required && !filled;

return showRequiredError ? (
<p ref={ref} className={clsx('text-sm', className)} {...other}>
This field is required.
</p>
) : null;
},
);

const cyan = {
50: '#E9F8FC',
100: '#BDEBF4',
200: '#99D8E5',
300: '#66BACC',
400: '#1F94AD',
500: '#0D5463',
600: '#094855',
700: '#063C47',
800: '#043039',
900: '#022127',
};

const grey = {
50: '#F3F6F9',
100: '#E7EBF0',
200: '#E0E3E7',
300: '#CDD2D7',
400: '#B2BAC2',
500: '#A0AAB4',
600: '#6F7E8C',
700: '#3E5060',
800: '#2D3843',
900: '#1A2027',
};

function useIsDarkMode() {
const theme = useTheme();
return theme.palette.mode === 'dark';
}

function Styles() {
// Replace this with your app logic for determining dark mode
const isDarkMode = useIsDarkMode();

return (
<style>
{`
.CustomInput .${inputClasses.input} {
width: 320px;
font-size: 0.875rem;
font-family: IBM Plex Sans, sans-serif;
font-weight: 400;
line-height: 1.5;
padding: 8px 12px;
border-radius: 8px;
color: ${isDarkMode ? grey[300] : grey[900]};
background: ${isDarkMode ? grey[900] : '#fff'};
border: 1px solid ${isDarkMode ? grey[800] : grey[300]};
}
.CustomInput .${inputClasses.input}:hover {
background: ${isDarkMode ? '' : grey[100]};
border-color: ${isDarkMode ? grey[700] : grey[400]};
}
.CustomInput .${inputClasses.input}:focus {
outline: 3px solid ${isDarkMode ? cyan[600] : cyan[100]};
}
`}
</style>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<React.Fragment>
<FormControl defaultValue="" required>
<Label>Name</Label>
<Input placeholder="Write your name here" className="CustomInput" />
<HelperText />
</FormControl>
<Styles />
</React.Fragment>
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default function BasicFormControl() {
return (
<FormControl defaultValue="" required>
<Label>Name</Label>
<StyledInput />
<StyledInput placeholder="Write your name here" />
<HelperText />
</FormControl>
);
Expand All @@ -24,10 +24,10 @@ const StyledInput = styled(Input)(
font-weight: 400;
line-height: 1.5;
color: ${theme.palette.mode === 'dark' ? grey[300] : grey[900]};
background: ${theme.palette.mode === 'dark' ? grey[900] : grey[50]};
background: ${theme.palette.mode === 'dark' ? grey[900] : '#fff'};
border: 1px solid ${theme.palette.mode === 'dark' ? grey[800] : grey[300]};
padding: 8px 12px;
border-radius: 8px;
padding: 12px 12px;
&:hover {
background: ${theme.palette.mode === 'dark' ? '' : grey[100]};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default function BasicFormControl() {
return (
<FormControl defaultValue="" required>
<Label>Name</Label>
<StyledInput />
<StyledInput placeholder="Write your name here" />
<HelperText />
</FormControl>
);
Expand All @@ -24,10 +24,10 @@ const StyledInput = styled(Input)(
font-weight: 400;
line-height: 1.5;
color: ${theme.palette.mode === 'dark' ? grey[300] : grey[900]};
background: ${theme.palette.mode === 'dark' ? grey[900] : grey[50]};
background: ${theme.palette.mode === 'dark' ? grey[900] : '#fff'};
border: 1px solid ${theme.palette.mode === 'dark' ? grey[800] : grey[300]};
padding: 8px 12px;
border-radius: 8px;
padding: 12px 12px;
&:hover {
background: ${theme.palette.mode === 'dark' ? '' : grey[100]};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<FormControl defaultValue="" required>
<Label>Name</Label>
<StyledInput />
<StyledInput placeholder="Write your name here" />
<HelperText />
</FormControl>

0 comments on commit 0203678

Please sign in to comment.