UNPKG

react-web-native-sketch

Version:

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

50 lines 2.67 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 __1 = require("../../"); var platform_1 = require("../../primitives/platform/platform"); var CustomPicker_1 = require("../TextInputContainer/CustomPicker"); var TextInputContainer_native_1 = require("../TextInputContainer/TextInputContainer.native"); var selectUtils_1 = require("./selectUtils"); var Select = /** @class */ (function (_super) { __extends(Select, _super); function Select() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.state = { isModalVisible: false, minuteInterval: 1, }; _this._hideModal = function () { _this.setState({ isModalVisible: false }); }; _this._showModal = function () { _this.setState({ isModalVisible: true }); }; _this._onConfirm = function (value) { var onChange = _this.props.onChange; onChange(value); _this.setState({ isModalVisible: false }); }; return _this; } Select.prototype.render = function () { var _a = this.props, nullName = _a.nullName, nullable = _a.nullable, options = _a.options, title = _a.title, value = _a.value, multiple = _a.multiple; var _b = selectUtils_1.getSelectData(options, value, multiple, nullName, nullable), selectedIndex = _b.selectedIndex, optionsList = _b.optionsList, displayedValue = (optionsList[selectedIndex] && optionsList[selectedIndex].text) || nullName || ''; return (React.createElement(__1.View, { style: { flex: 1 } }, React.createElement(TextInputContainer_native_1.TextInputContainer, { title: title, labelPositionLeft: platform_1.isIOS, onPress: this._showModal, value: displayedValue }), React.createElement(CustomPicker_1.CustomPicker, { isVisible: this.state.isModalVisible, onConfirm: this._onConfirm, onCancel: this._hideModal, title: title, value: value, isSelect: true, options: options }))); }; return Select; }(React.PureComponent)); exports.Select = Select; //# sourceMappingURL=Select.ios.js.map