-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e3a37cb
commit df004fe
Showing
26 changed files
with
906 additions
and
0 deletions.
There are no files selected for viewing
70 changes: 70 additions & 0 deletions
70
docs/data/base/components/number-input/UnstyledNumberInputIntroduction.js
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,70 @@ | ||
import * as React from 'react'; | ||
import NumberInputUnstyled from '@mui/base/NumberInputUnstyled'; | ||
import { styled } from '@mui/system'; | ||
|
||
const blue = { | ||
100: '#DAECFF', | ||
200: '#b6daff', | ||
400: '#3399FF', | ||
500: '#007FFF', | ||
600: '#0072E5', | ||
}; | ||
|
||
const grey = { | ||
50: '#f6f8fa', | ||
100: '#eaeef2', | ||
200: '#d0d7de', | ||
300: '#afb8c1', | ||
400: '#8c959f', | ||
500: '#6e7781', | ||
600: '#57606a', | ||
700: '#424a53', | ||
800: '#32383f', | ||
900: '#24292f', | ||
}; | ||
|
||
const StyledInputElement = styled('input')( | ||
({ theme }) => ` | ||
width: 320px; | ||
font-family: IBM Plex Sans, sans-serif; | ||
font-size: 0.875rem; | ||
font-weight: 400; | ||
line-height: 1.5; | ||
padding: 12px; | ||
border-radius: 12px; | ||
color: ${theme.palette.mode === 'dark' ? grey[300] : grey[900]}; | ||
background: ${theme.palette.mode === 'dark' ? grey[900] : '#fff'}; | ||
border: 1px solid ${theme.palette.mode === 'dark' ? grey[700] : grey[200]}; | ||
box-shadow: 0px 4px 30px ${theme.palette.mode === 'dark' ? grey[900] : grey[200]}; | ||
&:hover { | ||
border-color: ${blue[400]}; | ||
} | ||
&:focus { | ||
border-color: ${blue[400]}; | ||
box-shadow: 0 0 0 3px ${theme.palette.mode === 'dark' ? blue[500] : blue[200]}; | ||
} | ||
// firefox | ||
&:focus-visible { | ||
outline: 0; | ||
} | ||
`, | ||
); | ||
|
||
const CustomNumberInput = React.forwardRef(function CustomNumberInput(props, ref) { | ||
return ( | ||
<NumberInputUnstyled | ||
slots={{ input: StyledInputElement }} | ||
{...props} | ||
ref={ref} | ||
/> | ||
); | ||
}); | ||
|
||
export default function UnstyledNumberInputIntroduction() { | ||
return ( | ||
<CustomNumberInput aria-label="Demo number input" placeholder="Type a number…" /> | ||
); | ||
} |
75 changes: 75 additions & 0 deletions
75
docs/data/base/components/number-input/UnstyledNumberInputIntroduction.tsx
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,75 @@ | ||
import * as React from 'react'; | ||
import NumberInputUnstyled, { | ||
NumberInputUnstyledProps, | ||
} from '@mui/base/NumberInputUnstyled'; | ||
import { styled } from '@mui/system'; | ||
|
||
const blue = { | ||
100: '#DAECFF', | ||
200: '#b6daff', | ||
400: '#3399FF', | ||
500: '#007FFF', | ||
600: '#0072E5', | ||
}; | ||
|
||
const grey = { | ||
50: '#f6f8fa', | ||
100: '#eaeef2', | ||
200: '#d0d7de', | ||
300: '#afb8c1', | ||
400: '#8c959f', | ||
500: '#6e7781', | ||
600: '#57606a', | ||
700: '#424a53', | ||
800: '#32383f', | ||
900: '#24292f', | ||
}; | ||
|
||
const StyledInputElement = styled('input')( | ||
({ theme }) => ` | ||
width: 320px; | ||
font-family: IBM Plex Sans, sans-serif; | ||
font-size: 0.875rem; | ||
font-weight: 400; | ||
line-height: 1.5; | ||
padding: 12px; | ||
border-radius: 12px; | ||
color: ${theme.palette.mode === 'dark' ? grey[300] : grey[900]}; | ||
background: ${theme.palette.mode === 'dark' ? grey[900] : '#fff'}; | ||
border: 1px solid ${theme.palette.mode === 'dark' ? grey[700] : grey[200]}; | ||
box-shadow: 0px 4px 30px ${theme.palette.mode === 'dark' ? grey[900] : grey[200]}; | ||
&:hover { | ||
border-color: ${blue[400]}; | ||
} | ||
&:focus { | ||
border-color: ${blue[400]}; | ||
box-shadow: 0 0 0 3px ${theme.palette.mode === 'dark' ? blue[500] : blue[200]}; | ||
} | ||
// firefox | ||
&:focus-visible { | ||
outline: 0; | ||
} | ||
`, | ||
); | ||
|
||
const CustomNumberInput = React.forwardRef(function CustomNumberInput( | ||
props: NumberInputUnstyledProps, | ||
ref: React.ForwardedRef<HTMLDivElement>, | ||
) { | ||
return ( | ||
<NumberInputUnstyled | ||
slots={{ input: StyledInputElement }} | ||
{...props} | ||
ref={ref} | ||
/> | ||
); | ||
}); | ||
|
||
export default function UnstyledNumberInputIntroduction() { | ||
return ( | ||
<CustomNumberInput aria-label="Demo number input" placeholder="Type a number…" /> | ||
); | ||
} |
1 change: 1 addition & 0 deletions
1
docs/data/base/components/number-input/UnstyledNumberInputIntroduction.tsx.preview
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 @@ | ||
<CustomNumberInput aria-label="Demo number input" placeholder="Type a number…" /> |
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,33 @@ | ||
--- | ||
product: base | ||
title: Unstyled React Number Input component and hook | ||
components: NumberInputUnstyled | ||
# hooks: useNumberInput | ||
githubLabel: 'component: NumberInput' | ||
--- | ||
|
||
# Unstyled Number Input | ||
|
||
<p class="description">The Unstyled Number Input component provides users with a field for integer values, and buttons to increment or decrement the value.</p> | ||
|
||
## Introduction | ||
|
||
🚧 | ||
|
||
{{"demo": "UnstyledNumberInputIntroduction.js", "defaultCodeOpen": false, "bg": "gradient"}} | ||
|
||
{{"component": "modules/components/ComponentLinkHeader.js", "design": false}} | ||
|
||
## Component | ||
|
||
### Usage | ||
|
||
After [installation](/base/getting-started/installation/), you can start building with this component using the following basic elements: | ||
|
||
```jsx | ||
import NumberInputUnstyled from '@mui/base/NumberInputUnstyled'; | ||
|
||
export default function MyApp() { | ||
return <NumberInputUnstyled />; | ||
} | ||
``` |
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import * as React from 'react'; | ||
import ApiPage from 'docs/src/modules/components/ApiPage'; | ||
import mapApiPageTranslations from 'docs/src/modules/utils/mapApiPageTranslations'; | ||
import jsonPageContent from './number-input-unstyled.json'; | ||
|
||
export default function Page(props) { | ||
const { descriptions, pageContent } = props; | ||
return <ApiPage descriptions={descriptions} pageContent={pageContent} />; | ||
} | ||
|
||
Page.getInitialProps = () => { | ||
const req = require.context( | ||
'docs/translations/api-docs/number-input-unstyled', | ||
false, | ||
/number-input-unstyled.*.json$/, | ||
); | ||
const descriptions = mapApiPageTranslations(req); | ||
|
||
return { | ||
descriptions, | ||
pageContent: jsonPageContent, | ||
}; | ||
}; |
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,20 @@ | ||
{ | ||
"props": { | ||
"id": { "type": { "name": "string" } }, | ||
"slotProps": { | ||
"type": { "name": "shape", "description": "{ input?: func<br>| object }" }, | ||
"default": "{}" | ||
}, | ||
"slots": { | ||
"type": { "name": "shape", "description": "{ input?: elementType }" }, | ||
"default": "{}" | ||
} | ||
}, | ||
"name": "NumberInputUnstyled", | ||
"styles": { "classes": [], "globalClasses": {}, "name": null }, | ||
"spread": true, | ||
"filename": "/packages/mui-base/src/NumberInputUnstyled/NumberInputUnstyled.tsx", | ||
"inheritance": null, | ||
"demos": "<ul><li><a href=\"/base/react-number-input/\">hooks: useNumberInput</a></li></ul>", | ||
"cssComponent": false | ||
} |
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,23 @@ | ||
import * as React from 'react'; | ||
import HookApiPage from 'docs/src/modules/components/HookApiPage'; | ||
import mapApiPageTranslations from 'docs/src/modules/utils/mapApiPageTranslations'; | ||
import jsonPageContent from './use-number-input.json'; | ||
|
||
export default function Page(props) { | ||
const { descriptions, pageContent } = props; | ||
return <HookApiPage descriptions={descriptions} pageContent={pageContent} />; | ||
} | ||
|
||
Page.getInitialProps = () => { | ||
const req = require.context( | ||
'docs/translations/api-docs/use-number-input', | ||
false, | ||
/use-number-input.*.json$/, | ||
); | ||
const descriptions = mapApiPageTranslations(req); | ||
|
||
return { | ||
descriptions, | ||
pageContent: jsonPageContent, | ||
}; | ||
}; |
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,37 @@ | ||
{ | ||
"parameters": { | ||
"defaultValue": { "type": { "name": "unknown", "description": "unknown" } }, | ||
"disabled": { "type": { "name": "boolean", "description": "boolean" } }, | ||
"error": { "type": { "name": "boolean", "description": "boolean" } }, | ||
"inputRef": { | ||
"type": { | ||
"name": "React.Ref<HTMLInputElement>", | ||
"description": "React.Ref<HTMLInputElement>" | ||
} | ||
}, | ||
"max": { "type": { "name": "number", "description": "number" } }, | ||
"min": { "type": { "name": "number", "description": "number" } }, | ||
"onBlur": { | ||
"type": { "name": "React.FocusEventHandler", "description": "React.FocusEventHandler" } | ||
}, | ||
"onChange": { | ||
"type": { | ||
"name": "UseNumberInputChangeHandler", | ||
"description": "UseNumberInputChangeHandler" | ||
} | ||
}, | ||
"onClick": { | ||
"type": { "name": "React.MouseEventHandler", "description": "React.MouseEventHandler" } | ||
}, | ||
"onFocus": { | ||
"type": { "name": "React.FocusEventHandler", "description": "React.FocusEventHandler" } | ||
}, | ||
"required": { "type": { "name": "boolean", "description": "boolean" } }, | ||
"step": { "type": { "name": "number", "description": "number" } }, | ||
"value": { "type": { "name": "unknown", "description": "unknown" } } | ||
}, | ||
"returnValue": {}, | ||
"name": "useNumberInput", | ||
"filename": "/packages/mui-base/src/NumberInputUnstyled/useNumberInput.ts", | ||
"demos": "<ul></ul>" | ||
} |
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,7 @@ | ||
import * as React from 'react'; | ||
import MarkdownDocs from 'docs/src/modules/components/MarkdownDocs'; | ||
import * as pageProps from 'docs/data/base/components/number-input/number-input.md?@mui/markdown'; | ||
|
||
export default function Page() { | ||
return <MarkdownDocs {...pageProps} />; | ||
} |
9 changes: 9 additions & 0 deletions
9
docs/translations/api-docs/number-input-unstyled/number-input-unstyled.json
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,9 @@ | ||
{ | ||
"componentDescription": "", | ||
"propDescriptions": { | ||
"id": "The id of the <code>input</code> element.", | ||
"slotProps": "The props used for each slot inside the Input.", | ||
"slots": "The components used for each slot inside the InputBase. Either a string to use a HTML element or a component. See <a href=\"#slots\">Slots API</a> below for more details." | ||
}, | ||
"classDescriptions": {} | ||
} |
10 changes: 10 additions & 0 deletions
10
docs/translations/api-docs/use-number-input/use-number-input.json
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,10 @@ | ||
{ | ||
"hookDescription": "", | ||
"parametersDescriptions": { | ||
"defaultValue": "The default value. Use when the component is not controlled.", | ||
"disabled": "If <code>true</code>, the component is disabled.\nThe prop defaults to the value (<code>false</code>) inherited from the parent FormControl component.", | ||
"error": "If <code>true</code>, the <code>input</code> will indicate an error by setting the <code>aria-invalid</code> attribute.\nThe prop defaults to the value (<code>false</code>) inherited from the parent FormControl component.", | ||
"required": "If <code>true</code>, the <code>input</code> element is required.\nThe prop defaults to the value (<code>false</code>) inherited from the parent FormControl component." | ||
}, | ||
"returnValueDescriptions": {} | ||
} |
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
Oops, something went wrong.