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

Pass labelProps to DateField and SelectField #485

Merged
merged 5 commits into from
Nov 13, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
11 changes: 11 additions & 0 deletions API.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Table of Contents

- [Table of Contents](#table-of-contents)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a good addition. Leave it as it is now, but it's better not to mix purposes of PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, vscode did this automatically, didn't mean to do that.

- [Fields](#fields)
- [`AutoField`](#autofield)
- [`AutoFields`](#autofields)
Expand Down Expand Up @@ -326,6 +327,11 @@ import DateField from 'uniforms-unstyled/DateField'; // Choose your theme packag
// use this prop instead.
inputRef={ref => {}}

// Props for the InputLabel
// Available in:
// material-ui
labelProps={{ shrink: true, disableAnimation: true }}

// Maximum value.
// Date object.
max={new Date(2100, 1, 1)}
Expand Down Expand Up @@ -859,6 +865,11 @@ import SelectField from 'uniforms-unstyled/SelectField'; // Choose your theme pa
// use this prop instead.
inputRef={ref => {}}

// Props for the InputLabel
// Available in:
// material-ui
labelProps={{ shrink: true, disableAnimation: true }}

// Field inline error.
// *Some description would be great, huh?*
// Available in:
Expand Down
5 changes: 3 additions & 2 deletions packages/uniforms-material/src/DateField.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import FormControl from '@material-ui/core/FormControl';
import FormHelperText from '@material-ui/core/FormHelperText';
import FormLabel from '@material-ui/core/FormLabel';
import InputLabel from '@material-ui/core/InputLabel';
import Input from '@material-ui/core/Input';
radekmie marked this conversation as resolved.
Show resolved Hide resolved
import React from 'react';
import connectField from 'uniforms/connectField';
Expand Down Expand Up @@ -32,6 +32,7 @@ const Date = ({
required,
showInlineError,
value,
labelProps,
...props
}) => (
<FormControl
Expand All @@ -41,7 +42,7 @@ const Date = ({
margin={margin}
required={required}
>
{label && <FormLabel component="legend" htmlFor={name}>{label}</FormLabel>}
{label && <InputLabel htmlFor={name} {...labelProps}>{label}</InputLabel>}
<Input
name={name}
onChange={event => dateParse(event.target.valueAsNumber, onChange)}
Expand Down
3 changes: 2 additions & 1 deletion packages/uniforms-material/src/SelectField.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const renderSelect = ({
showInlineError,
transform,
value,
labelProps,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep these ordered.

...props
}) => {
const Item = native ? 'option' : MenuItem;
Expand All @@ -55,7 +56,7 @@ const renderSelect = ({
margin={margin}
required={required}
>
{label && <InputLabel htmlFor={name}>{label}</InputLabel>}
{label && <InputLabel htmlFor={name} {...labelProps}>{label}</InputLabel>}
<SelectMaterial
inputProps={{name, id, ...inputProps}}
multiple={fieldType === Array || undefined}
Expand Down