Skip to content

Commit

Permalink
[Select] Accept boolean (#12429)
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari authored Aug 6, 2018
1 parent 63b23ee commit a9309bb
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/material-ui/src/NativeSelect/NativeSelect.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export interface NativeSelectProps
Pick<NativeSelectInputProps, 'onChange'> {
IconComponent?: React.ReactType;
input?: React.ReactNode;
value?: string | number;
value?: string | number | boolean;
}

export type NativeSelectClassKey = 'root' | 'select' | 'selectMenu' | 'disabled' | 'icon';
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/NativeSelect/NativeSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ NativeSelect.propTypes = {
/**
* The input value.
*/
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.bool]),
};

NativeSelect.defaultProps = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export interface NativeSelectInputProps {
) => void;
name?: string;
onChange?: (event: React.ChangeEvent<HTMLSelectElement>, child: React.ReactNode) => void;
value?: string | number;
value?: string | number | boolean;
}

declare const NativeSelectInput: React.ComponentType<NativeSelectInputProps>;
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/NativeSelect/NativeSelectInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ NativeSelectInput.propTypes = {
/**
* The input value.
*/
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.bool]),
};

export default NativeSelectInput;
2 changes: 1 addition & 1 deletion packages/material-ui/src/Select/Select.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export interface SelectProps
open?: boolean;
renderValue?: (value: SelectProps['value']) => React.ReactNode;
SelectDisplayProps?: React.HTMLAttributes<HTMLDivElement>;
value?: Array<string | number> | string | number;
value?: Array<string | number | boolean> | string | number | boolean;
}

export type SelectClassKey = 'root' | 'select' | 'selectMenu' | 'disabled' | 'icon';
Expand Down
3 changes: 2 additions & 1 deletion packages/material-ui/src/Select/Select.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ Select.propTypes = {
value: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number,
PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number])),
PropTypes.bool,
PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.bool])),
]),
};

Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/Select/SelectInput.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export interface SelectInputProps {
renderValue?: (value: SelectInputProps['value']) => React.ReactNode;
SelectDisplayProps?: React.HTMLAttributes<HTMLDivElement>;
tabIndex?: number;
value?: string | number | Array<string | number>;
value?: string | number | boolean | Array<string | number | boolean>;
}

declare const SelectInput: React.ComponentType<SelectInputProps>;
Expand Down
3 changes: 2 additions & 1 deletion packages/material-ui/src/Select/SelectInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,8 @@ SelectInput.propTypes = {
value: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number,
PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number])),
PropTypes.bool,
PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.bool])),
]).isRequired,
};

Expand Down
2 changes: 1 addition & 1 deletion pages/api/native-select.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ An alternative to `<Select native />` with a much smaller dependency graph.
| <span class="prop-name">input</span> | <span class="prop-type">element | <span class="prop-default">&lt;Input /></span> | An `Input` element; does not have to be a material-ui specific `Input`. |
| <span class="prop-name">inputProps</span> | <span class="prop-type">object |   | Attributes applied to the `select` element. |
| <span class="prop-name">onChange</span> | <span class="prop-type">func |   | Callback function fired when a menu item is selected.<br><br>**Signature:**<br>`function(event: object) => void`<br>*event:* The event source of the callback. You can pull out the new value by accessing `event.target.value`. |
| <span class="prop-name">value</span> | <span class="prop-type">union:&nbsp;string&nbsp;&#124;<br>&nbsp;number<br> |   | The input value. |
| <span class="prop-name">value</span> | <span class="prop-type">union:&nbsp;string&nbsp;&#124;<br>&nbsp;number&nbsp;&#124;<br>&nbsp;bool<br> |   | The input value. |

Any other properties supplied will be spread to the root element ([Input](/api/input)).

Expand Down
2 changes: 1 addition & 1 deletion pages/api/select.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ title: Select API
| <span class="prop-name">open</span> | <span class="prop-type">bool |   | Control `select` open state. You can only use it when the `native` property is `false` (default). |
| <span class="prop-name">renderValue</span> | <span class="prop-type">func |   | Render the selected value. You can only use it when the `native` property is `false` (default).<br><br>**Signature:**<br>`function(value: any) => ReactElement`<br>*value:* The `value` provided to the component. |
| <span class="prop-name">SelectDisplayProps</span> | <span class="prop-type">object |   | Properties applied to the clickable div element. |
| <span class="prop-name">value</span> | <span class="prop-type">union:&nbsp;string&nbsp;&#124;<br>&nbsp;number&nbsp;&#124;<br>&nbsp;arrayOf<br> |   | The input value. This property is required when the `native` property is `false` (default). |
| <span class="prop-name">value</span> | <span class="prop-type">union:&nbsp;string&nbsp;&#124;<br>&nbsp;number&nbsp;&#124;<br>&nbsp;bool&nbsp;&#124;<br>&nbsp;arrayOf<br> |   | The input value. This property is required when the `native` property is `false` (default). |

Any other properties supplied will be spread to the root element ([Input](/api/input)).

Expand Down

0 comments on commit a9309bb

Please sign in to comment.