Completely updated React, fixed #11, (hopefully)

This commit is contained in:
2018-03-04 19:11:49 -05:00
parent 6e0afd6e2a
commit 34e5f5139a
13674 changed files with 333464 additions and 473223 deletions

View File

@@ -17,9 +17,9 @@ var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _warning = require('warning');
var _propTypes = require('prop-types');
var _warning2 = _interopRequireDefault(_warning);
var _propTypes2 = _interopRequireDefault(_propTypes);
var _SelectInput = require('./SelectInput');
@@ -33,15 +33,9 @@ var _Input = require('../Input');
var _Input2 = _interopRequireDefault(_Input);
var _reactHelpers = require('../utils/reactHelpers');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var babelPluginFlowReactPropTypes_proptype_Element = require('react').babelPluginFlowReactPropTypes_proptype_Element || require('prop-types').any;
// @inheritedComponent Input
var babelPluginFlowReactPropTypes_proptype_ChildrenArray = require('react').babelPluginFlowReactPropTypes_proptype_ChildrenArray || require('prop-types').any; // Import to enforce the CSS injection order
// Import to enforce the CSS injection order
var styles = exports.styles = function styles(theme) {
return {
@@ -50,16 +44,14 @@ var styles = exports.styles = function styles(theme) {
width: '100%'
},
select: {
'-moz-appearance': 'none', // Remove Firefox custom style
'-webkit-appearance': 'none', // Fix SSR issue
appearance: 'none', // Reset
'-moz-appearance': 'none', // Reset
'-webkit-appearance': 'none', // Reset
// When interacting quickly, the text can end up selected.
// Native select can't be selected either.
userSelect: 'none',
padding: '0 ' + theme.spacing.unit * 4 + 'px 2px 0',
width: 'auto',
paddingRight: theme.spacing.unit * 4,
width: 'calc(100% - ' + theme.spacing.unit * 4 + 'px)',
minWidth: theme.spacing.unit * 2, // So it doesn't collapse.
height: 'calc(1em + ' + (theme.spacing.unit * 2 - 2) + 'px)',
cursor: 'pointer',
'&:focus': {
// Show that it's not an text input
@@ -77,86 +69,26 @@ var styles = exports.styles = function styles(theme) {
}
},
selectMenu: {
width: 'auto', // Fix Safari textOverflow
textOverflow: 'ellipsis',
whiteSpace: 'nowrap',
overflow: 'hidden',
lineHeight: 'calc(1em + ' + (theme.spacing.unit * 2 - 2) + 'px)'
minHeight: '1.1875em' // Reset (19px), match the native input line-height
},
disabled: {
cursor: 'default'
},
icon: {
// We use a position absolute over a flexbox in order to forward the pointer events
// to the input.
position: 'absolute',
right: 0,
top: 4,
color: theme.palette.text.secondary,
'pointer-events': 'none' // Don't block pinter events on the select under the icon.
top: 'calc(50% - 12px)', // Center vertically
color: theme.palette.action.active,
'pointer-events': 'none' // Don't block pointer events on the select under the icon.
}
};
};
var babelPluginFlowReactPropTypes_proptype_Props = {
/**
* If true, the width of the popover will automatically be set according to the items inside the
* menu, otherwise it will be at least the width of the select input.
*/
autoWidth: require('prop-types').bool,
/**
* The option elements to populate the select with.
* Can be some `MenuItem` when `native` is false and `option` when `native` is true.
*/
children: typeof $ReadOnlyArray === 'function' ? require('prop-types').instanceOf($ReadOnlyArray).isRequired : require('prop-types').any.isRequired,
/**
* Useful to extend the style applied to components.
*/
classes: require('prop-types').object,
/**
* If `true`, the selected item is displayed even if its value is empty.
* You can only use it when the `native` property is `false` (default).
*/
displayEmpty: require('prop-types').bool,
/**
* An `Input` element; does not have to be a material-ui specific `Input`.
*/
input: typeof babelPluginFlowReactPropTypes_proptype_Element === 'function' ? babelPluginFlowReactPropTypes_proptype_Element : require('prop-types').shape(babelPluginFlowReactPropTypes_proptype_Element),
/**
* `classes` property applied to the `Input` element.
*/
InputClasses: require('prop-types').object,
/**
* If `true`, the component will be using a native `select` element.
*/
native: require('prop-types').bool,
/**
* If true, `value` must be an array and the menu will support multiple selections.
* You can only use it when the `native` property is `false` (default).
*/
multiple: require('prop-types').bool,
/**
* Properties applied to the `Menu` element.
*/
MenuProps: require('prop-types').object,
/**
* Render the selected value.
* You can only use it when the `native` property is `false` (default).
*/
renderValue: require('prop-types').func,
/**
* The input value, required for a controlled component.
*/
value: require('prop-types').oneOfType([typeof $ReadOnlyArray === 'function' ? require('prop-types').instanceOf($ReadOnlyArray) : require('prop-types').any, require('prop-types').string, require('prop-types').number])
};
}; // @inheritedComponent Input
function Select(props) {
var autoWidth = props.autoWidth,
@@ -164,42 +96,128 @@ function Select(props) {
classes = props.classes,
displayEmpty = props.displayEmpty,
input = props.input,
InputClasses = props.InputClasses,
native = props.native,
multiple = props.multiple,
inputProps = props.inputProps,
MenuProps = props.MenuProps,
multiple = props.multiple,
native = props.native,
onClose = props.onClose,
onOpen = props.onOpen,
open = props.open,
renderValue = props.renderValue,
other = (0, _objectWithoutProperties3.default)(props, ['autoWidth', 'children', 'classes', 'displayEmpty', 'input', 'InputClasses', 'native', 'multiple', 'MenuProps', 'renderValue']);
SelectDisplayProps = props.SelectDisplayProps,
other = (0, _objectWithoutProperties3.default)(props, ['autoWidth', 'children', 'classes', 'displayEmpty', 'input', 'inputProps', 'MenuProps', 'multiple', 'native', 'onClose', 'onOpen', 'open', 'renderValue', 'SelectDisplayProps']);
// Instead of `Element<typeof Input>` to have more flexibility.
process.env.NODE_ENV !== "production" ? (0, _warning2.default)((0, _reactHelpers.isMuiElement)(input, ['Input']), ['Material-UI: you have provided an invalid value to the `input` property.', 'We expect an element instance of the `Input` component.'].join('\n')) : void 0;
return _react2.default.cloneElement(input, (0, _extends3.default)({
// Most of the logic is implemented in `SelectInput`.
// The `Select` component is a simple API wrapper to expose something better to play with.
inputComponent: _SelectInput2.default,
classes: InputClasses
}, other, {
inputProps: (0, _extends3.default)({}, input ? input.props.inputProps : {}, {
inputProps: (0, _extends3.default)({
autoWidth: autoWidth,
children: children,
classes: classes,
displayEmpty: displayEmpty,
native: native,
multiple: multiple,
MenuProps: MenuProps,
renderValue: renderValue
})
}));
multiple: multiple,
native: native,
onClose: onClose,
onOpen: onOpen,
open: open,
renderValue: renderValue,
SelectDisplayProps: SelectDisplayProps,
type: undefined }, inputProps, input ? input.props.inputProps : {})
}, other));
}
Select.propTypes = process.env.NODE_ENV !== "production" ? {
/**
* If true, the width of the popover will automatically be set according to the items inside the
* menu, otherwise it will be at least the width of the select input.
*/
autoWidth: _propTypes2.default.bool,
/**
* The option elements to populate the select with.
* Can be some `MenuItem` when `native` is false and `option` when `native` is true.
*/
children: _propTypes2.default.node,
/**
* Useful to extend the style applied to components.
*/
classes: _propTypes2.default.object.isRequired,
/**
* If `true`, the selected item is displayed even if its value is empty.
* You can only use it when the `native` property is `false` (default).
*/
displayEmpty: _propTypes2.default.bool,
/**
* An `Input` element; does not have to be a material-ui specific `Input`.
*/
input: _propTypes2.default.element,
/**
* Properties applied to the `input` element.
* When `native` is `true`, the properties are applied on the `select` element.
*/
inputProps: _propTypes2.default.object,
/**
* Properties applied to the `Menu` element.
*/
MenuProps: _propTypes2.default.object,
/**
* If true, `value` must be an array and the menu will support multiple selections.
* You can only use it when the `native` property is `false` (default).
*/
multiple: _propTypes2.default.bool,
/**
* If `true`, the component will be using a native `select` element.
*/
native: _propTypes2.default.bool,
/**
* Callback function fired when a menu item is selected.
*
* @param {object} event The event source of the callback
* @param {object} child The react element that was selected
*/
onChange: _propTypes2.default.func,
/**
* Callback fired when the component requests to be closed.
* Useful in controlled mode (see open).
*
* @param {object} event The event source of the callback
*/
onClose: _propTypes2.default.func,
/**
* Callback fired when the component requests to be opened.
* Useful in controlled mode (see open).
*
* @param {object} event The event source of the callback
*/
onOpen: _propTypes2.default.func,
/**
* Control `select` open state.
* You can only use it when the `native` property is `false` (default).
*/
open: _propTypes2.default.bool,
/**
* Render the selected value.
* You can only use it when the `native` property is `false` (default).
*/
renderValue: _propTypes2.default.func,
/**
* Properties applied to the clickable div element.
*/
SelectDisplayProps: _propTypes2.default.object,
/**
* The input value, required for a controlled component.
*/
value: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.number, _propTypes2.default.arrayOf(_propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.number]))])
} : {};
Select.defaultProps = {
autoWidth: false,
displayEmpty: false,
input: _react2.default.createElement(_Input2.default, null),
native: false,
multiple: false
multiple: false,
native: false
};
Select.muiName = 'Select';