UNPKG

react-web-native-sketch

Version:

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

73 lines 3.49 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 react_native_1 = require("react-native"); var __1 = require("../../"); var selectUtils_1 = require("../../nativeComponents/Select/selectUtils"); var styles = function () { return ({ container: { paddingTop: 2, }, label: { fontSize: 12, color: __1.appTheme.primaryColor, }, picker: { marginTop: -9, marginBottom: -15, marginLeft: -8, marginRight: -8, }, emptyPicker: { marginTop: 8, }, bottomBorder: { height: 1, width: '100%', }, }); }; var CSelect = /** @class */ (function (_super) { __extends(CSelect, _super); function CSelect(props) { var _this = _super.call(this, props) || this; var options = props.options, value = props.value, nullName = props.nullName, nullable = props.nullable, multiple = props.multiple; var _a = selectUtils_1.getSelectData(options, value, multiple, nullName, nullable), selectedIndex = _a.selectedIndex, optionsList = _a.optionsList; _this.state = { itemValue: optionsList[selectedIndex].value }; return _this; } CSelect.prototype.render = function () { var _this = this; var _a = this.props, title = _a.title, onChange = _a.onChange, classes = _a.classes, error = _a.error, options = _a.options, value = _a.value, nullName = _a.nullName, nullable = _a.nullable, multiple = _a.multiple; var _b = selectUtils_1.getSelectData(options, value, multiple, nullName, nullable), selectedIndex = _b.selectedIndex, optionsList = _b.optionsList; return (React.createElement(__1.View, { style: classes.container }, React.createElement(__1.Text, { style: classes.label }, title || ' '), React.createElement(react_native_1.Picker, { style: [classes.picker, selectedIndex === -1 && classes.emptyPicker], selectedValue: this.state.itemValue, onValueChange: function (value, index) { if (value === selectUtils_1.NOT_AVAILABLE_FIELD_VALUE && index === 0) { value = null; } _this.setState({ itemValue: value }); onChange && onChange(value); } }, optionsList.map(function (option, index) { return React.createElement(react_native_1.Picker.Item, { key: index, value: option.value, label: option.text }); })), React.createElement(__1.View, { style: [classes.bottomBorder, { backgroundColor: error ? '#fff' : __1.appTheme.primaryColor, }] }), !!error ? React.createElement(__1.Text, { style: classes.baseErrorText }, error) : null)); }; return CSelect; }(React.PureComponent)); ; var componentName = 'Select'; exports.Select = __1.createStyles(styles, componentName)(CSelect); //# sourceMappingURL=Select.android.js.map