UNPKG

tuya-panel-kit

Version:

a functional component library for developing tuya device panels!

189 lines (163 loc) 7.09 kB
Object.defineProperty(exports, "__esModule", { value: true }); var _jsxFileName = 'src/components/dialog/password.js'; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _propTypes = require('prop-types'); var _propTypes2 = _interopRequireDefault(_propTypes); var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _reactNative = require('react-native'); var _TYText = require('../TYText'); var _TYText2 = _interopRequireDefault(_TYText); var _footer = require('./footer'); var _footer2 = _interopRequireDefault(_footer); var _styled = require('./styled'); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var Password = function (_Component) { _inherits(Password, _Component); function Password() { var _ref; var _temp, _this, _ret; _classCallCheck(this, Password); for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Password.__proto__ || Object.getPrototypeOf(Password)).call.apply(_ref, [this].concat(args))), _this), _this._handleConfirm = function () { var onConfirm = _this.props.onConfirm; onConfirm && onConfirm(); }, _temp), _possibleConstructorReturn(_this, _ret); } _createClass(Password, [{ key: 'renderPassword', value: function renderPassword() { return _react2.default.createElement( _styled.StyledInputContainer, { __source: { fileName: _jsxFileName, lineNumber: 58 } }, _react2.default.createElement(_styled.StyledInput, { maxLength: 6, secureTextEntry: true, value: typeof value !== 'undefined' ? this.state.value : undefined, onChangeText: this._handleChangeText, __source: { fileName: _jsxFileName, lineNumber: 59 } }) ); } }, { key: 'render', value: function render() { var _props = this.props, style = _props.style, contentStyle = _props.contentStyle, titleNumberOfLines = _props.titleNumberOfLines, title = _props.title, titleStyle = _props.titleStyle, subTitle = _props.subTitle, subTitleStyle = _props.subTitleStyle, confirmText = _props.confirmText, confirmTextStyle = _props.confirmTextStyle, confirmAccessibilityLabel = _props.confirmAccessibilityLabel, footerWrapperStyle = _props.footerWrapperStyle, cancelText = _props.cancelText, cancelTextStyle = _props.cancelTextStyle, cancelAccessibilityLabel = _props.cancelAccessibilityLabel, onCancel = _props.onCancel; return _react2.default.createElement( _styled.StyledContainer, { style: style, __source: { fileName: _jsxFileName, lineNumber: 90 } }, _react2.default.createElement( _styled.StyledContent, { style: contentStyle, __source: { fileName: _jsxFileName, lineNumber: 91 } }, _react2.default.createElement( _styled.StyledTitle, { style: titleStyle, numberOfLines: titleNumberOfLines, __source: { fileName: _jsxFileName, lineNumber: 92 } }, title ), !!subTitle && _react2.default.createElement( _styled.StyledSubTitle, { style: subTitleStyle, __source: { fileName: _jsxFileName, lineNumber: 95 } }, subTitle ), this.renderPassword() ), _react2.default.createElement(_footer2.default, { style: footerWrapperStyle, cancelTextStyle: cancelTextStyle, confirmTextStyle: confirmTextStyle, cancelText: cancelText, confirmText: confirmText, cancelAccessibilityLabel: cancelAccessibilityLabel, confirmAccessibilityLabel: confirmAccessibilityLabel, onCancel: onCancel, onConfirm: this._handleConfirm, __source: { fileName: _jsxFileName, lineNumber: 98 } }) ); } }]); return Password; }(_react.Component); Password.propTypes = { style: _reactNative.ViewPropTypes.style, contentStyle: _reactNative.ViewPropTypes.style, titleNumberOfLines: _propTypes2.default.number, title: _propTypes2.default.string.isRequired, titleStyle: _TYText2.default.propTypes.style, subTitle: _propTypes2.default.string, subTitleStyle: _TYText2.default.propTypes.style, footerWrapperStyle: _reactNative.ViewPropTypes.style, cancelText: _propTypes2.default.string.isRequired, cancelTextStyle: _TYText2.default.propTypes.style, cancelAccessibilityLabel: _propTypes2.default.string, confirmText: _propTypes2.default.string.isRequired, confirmTextStyle: _TYText2.default.propTypes.style, confirmAccessibilityLabel: _propTypes2.default.string, onCancel: _propTypes2.default.func, onConfirm: _propTypes2.default.func }; Password.defaultProps = { style: null, contentStyle: null, titleNumberOfLines: 2, titleStyle: null, subTitle: '', subTitleStyle: null, footerWrapperStyle: null, cancelTextStyle: null, cancelAccessibilityLabel: 'Dialog.Cancel', confirmTextStyle: null, confirmAccessibilityLabel: 'Dialog.Confirm', onCancel: null, onConfirm: null }; exports.default = Password;