-
-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into fix-default-value-menu
- Loading branch information
Showing
163 changed files
with
5,435 additions
and
417 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
contact_links: | ||
- name: Support ❔ | ||
url: https://mui.com/getting-started/support/ | ||
url: https://mui.com/base-ui/getting-started/support/ | ||
about: I need support with Base UI. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,2 @@ | ||
Broken links found by `pnpm docs:link-check` that exist: | ||
|
||
- https://mui.com/material-ui/customization/css-theme-variables/configuration/#advanced-configuration | ||
- https://mui.com/material-ui/customization/css-theme-variables/configuration/#changing-variable-prefixes | ||
- https://mui.com/material-ui/customization/theme-components/#creating-new-component-variants | ||
- https://mui.com/material-ui/customization/theme-components/#overrides-based-on-props | ||
- https://mui.com/material-ui/migrating-to-v6/ | ||
- https://mui.com/material-ui/react-grid2/#whats-changed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
import * as React from 'react'; | ||
import * as Field from '@base_ui/react/Field'; | ||
import { styled } from '@mui/system'; | ||
|
||
const cache = new Map(); | ||
|
||
function checkAvailability(name) { | ||
const takenNames = ['admin', 'root', 'superuser']; | ||
return new Promise((resolve) => { | ||
setTimeout(() => { | ||
const result = takenNames.includes(name) ? 'Name taken' : null; | ||
cache.set(name, result); | ||
resolve(result); | ||
}, 500); | ||
}); | ||
} | ||
|
||
export default function UnstyledFieldAsync() { | ||
const [loading, setLoading] = React.useState(false); | ||
|
||
async function handleValidate(value) { | ||
const name = value; | ||
|
||
if (name === '') { | ||
return null; | ||
} | ||
|
||
const isCached = cache.has(name); | ||
if (isCached) { | ||
return cache.get(name); | ||
} | ||
|
||
setLoading(true); | ||
|
||
try { | ||
const error = await checkAvailability(name); | ||
setLoading(false); | ||
return error; | ||
} catch (e) { | ||
setLoading(false); | ||
return 'Failed to fetch name availability'; | ||
} | ||
} | ||
|
||
return ( | ||
<div> | ||
<h3>Handle availability checker</h3> | ||
<FieldRoot | ||
validate={handleValidate} | ||
validateOnChange | ||
validateDebounceTime={500} | ||
> | ||
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}> | ||
<Field.Label>@</Field.Label> | ||
<Field.Validity> | ||
{(state) => ( | ||
<FieldControl | ||
data-pending={state.value === '' || loading || undefined} | ||
/> | ||
)} | ||
</Field.Validity> | ||
</div> | ||
<Field.Validity> | ||
{(state) => { | ||
if (loading) { | ||
return <FieldDescription>Checking availability...</FieldDescription>; | ||
} | ||
|
||
if (state.value === '') { | ||
return <FieldDescription>Enter a name</FieldDescription>; | ||
} | ||
|
||
if (!state.validity.customError) { | ||
return ( | ||
<FieldDescription | ||
data-type="success" | ||
role="alert" | ||
aria-live="polite" | ||
> | ||
<strong>@{state.value}</strong> is available | ||
</FieldDescription> | ||
); | ||
} | ||
|
||
return <FieldError show="customError" />; | ||
}} | ||
</Field.Validity> | ||
</FieldRoot> | ||
</div> | ||
); | ||
} | ||
|
||
const FieldRoot = styled(Field.Root)` | ||
width: 275px; | ||
`; | ||
|
||
const FieldControl = styled(Field.Control)` | ||
border: 1px solid #ccc; | ||
border-radius: 4px; | ||
width: 100%; | ||
padding: 6px; | ||
font-size: 100%; | ||
&[data-field='invalid']:not([data-pending]) { | ||
border-color: red; | ||
background-color: rgb(255 0 0 / 0.1); | ||
} | ||
&[data-field='valid']:not([data-pending]) { | ||
border-color: green; | ||
background-color: rgb(0 255 0 / 0.1); | ||
} | ||
&:focus { | ||
outline: 0; | ||
border-color: #0078d4; | ||
box-shadow: 0 0 0 3px rgba(0 100 255 / 0.3); | ||
&[data-field='invalid']:not([data-pending]) { | ||
border-color: red; | ||
box-shadow: 0 0 0 3px rgba(255 0 0 / 0.3); | ||
} | ||
&[data-field='valid']:not([data-pending]) { | ||
box-shadow: 0 0 0 3px rgba(100 200 100 / 0.3); | ||
} | ||
} | ||
`; | ||
|
||
const FieldDescription = styled(Field.Description)` | ||
font-size: 90%; | ||
margin: 0; | ||
margin-top: 4px; | ||
line-height: 1.1; | ||
color: grey; | ||
&[data-type='success'] { | ||
color: green; | ||
} | ||
`; | ||
|
||
const FieldError = styled(Field.Error)` | ||
display: block; | ||
font-size: 90%; | ||
margin: 0; | ||
margin-top: 4px; | ||
line-height: 1.1; | ||
color: red; | ||
`; |
Oops, something went wrong.