UNPKG

react-web-native-sketch

Version:

[TODO: We need an overview of how this can be used via npm vs as a local package]

62 lines 3.28 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); var React = require("react"); var Select_1 = require("@material-ui/core/Select"); var __1 = require("../../"); var __2 = require("../.."); var selectUtils_1 = require("./selectUtils"); var core_1 = require("@material-ui/core"); var styles = function () { return ({ input: { color: __2.appTheme.textColor, }, icon: { color: __2.appTheme.textColor, }, label: { color: __2.appTheme.textColor, }, focusedLabel: { color: __2.appTheme.primaryColor, }, }); }; var CSelect = /** @class */ (function (_super) { __extends(CSelect, _super); function CSelect() { return _super !== null && _super.apply(this, arguments) || this; } CSelect.prototype.render = function () { var _a = this.props, classes = _a.classes, disabled = _a.disabled, disableUnderline = _a.disableUnderline, error = _a.error, nullName = _a.nullName, onChange = _a.onChange, options = _a.options, title = _a.title, value = _a.value, multiple = _a.multiple, nullable = _a.nullable, selectStyles = _a.selectStyles, _b = selectUtils_1.getSelectData(options, value, multiple, nullName, nullable), selectedIndex = _b.selectedIndex, selectedIndexMultiple = _b.selectedIndexMultiple, optionsList = _b.optionsList; return (React.createElement(core_1.FormControl, { error: !!error, fullWidth: true }, title && React.createElement(core_1.InputLabel, { classes: { root: classes.label, } }, title), React.createElement(Select_1.default, { native: __1.isXs(), value: multiple ? selectedIndexMultiple : selectedIndex === -1 ? 0 : selectedIndex, onChange: function (event) { if (multiple) { onChange && onChange((event.target.value || []).map(function (i) { return optionsList[i].value; })); } else { onChange && onChange(optionsList[event.target.value].value); } }, error: !!error, fullWidth: true, disabled: disabled, disableUnderline: disableUnderline, multiple: multiple || false, classes: selectStyles }, optionsList.map(function (option, index) { return (__1.isXs() ? React.createElement("option", { key: index, value: index }, option.text) : React.createElement(core_1.MenuItem, { key: index, value: index }, option.text)); })), error && React.createElement(core_1.FormHelperText, null, error))); }; return CSelect; }(React.PureComponent)); exports.Select = __1.createStyles(styles, 'Select')(CSelect); //# sourceMappingURL=Select.js.map