Socket
Socket
Sign inDemoInstall

nuke-input

Package Overview
Dependencies
8
Maintainers
4
Versions
185
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.1.10 to 2.2.2

35

CHANGELOG.md

@@ -6,2 +6,37 @@ # Change Log

<a name="2.2.2"></a>
## [2.2.2](https://gitlab.alibaba-inc.com/nuke/input/compare/v2.2.1...v2.2.2) (2018-08-23)
**Note:** Version bump only for package nuke-input
<a name="2.2.1"></a>
## [2.2.1](https://gitlab.alibaba-inc.com/nuke/input/compare/v2.2.0...v2.2.1) (2018-08-23)
**Note:** Version bump only for package nuke-input
<a name="2.2.0"></a>
# [2.2.0](https://gitlab.alibaba-inc.com/nuke/input/compare/v2.1.10...v2.2.0) (2018-08-23)
### Bug Fixes
* merge conflict ([7a4e427](https://gitlab.alibaba-inc.com/nuke/input/commit/7a4e427))
### Features
* add jest test suite ([ebe6aba](https://gitlab.alibaba-inc.com/nuke/input/commit/ebe6aba))
<a name="2.1.10"></a>

@@ -8,0 +43,0 @@ ## [2.1.10](https://gitlab.alibaba-inc.com/nuke/input/compare/v2.1.9...v2.1.10) (2018-08-20)

25

lib/index.js

@@ -1,1 +0,24 @@

'use strict';Object.defineProperty(exports,'__esModule',{value:!0});var _nukeEnv=require('nuke-env'),_native=require('./native'),_native2=_interopRequireDefault(_native),_web=require('./web'),_web2=_interopRequireDefault(_web);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}var InputEntry=_web2.default;_nukeEnv.isWeex&&(InputEntry=_native2.default),exports.default=InputEntry,module.exports=exports['default'];
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _nukeEnv = require('nuke-env');
var _native = require('./native');
var _native2 = _interopRequireDefault(_native);
var _web = require('./web');
var _web2 = _interopRequireDefault(_web);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var InputEntry = _web2.default;
if (_nukeEnv.isWeex) {
InputEntry = _native2.default;
}
exports.default = InputEntry;
module.exports = exports['default'];

@@ -1,1 +0,7 @@

'use strict';Object.defineProperty(exports,'__esModule',{value:!0}),exports.default='accept acceptCharset accessKey action preventEnterKey returnKeyType allowFullScreen allowTransparency\nalt async autoComplete autoPlay capture cellPadding cellSpacing challenge\ncharSet checked classID className colSpan cols content contentEditable contextMenu\ncontrols coords crossOrigin data dateTime default defer dir disabled download draggable\nencType form formAction formEncType formMethod formNoValidate formTarget frameBorder\nheaders height hidden high href hrefLang encrypt htmlFor httpEquiv windowSoftInputMode icon id inputMode integrity\nis keyParams keyType kind label lang list loop low manifest marginHeight marginWidth max maxLength media\nmediaGroup method min minLength multiple muted name noValidate nonce open\noptimum pattern placeholder poster preload radioGroup readOnly rel required\nreversed role rowSpan rows sandbox scope scoped scrolling seamless selected\nshape size sizes span spellCheck src srcDoc srcLang srcSet start step style\nsummary tabIndex target title type useMap value width wmode wrap encryptFormat searchEncryptFormat encryptSeckeyType'.replace(/\s+/g,' ').replace(/\t|\n|\r/g,'').split(' '),module.exports=exports['default'];
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = 'accept acceptCharset accessKey action preventEnterKey returnKeyType allowFullScreen allowTransparency\nalt async autoComplete autoPlay capture cellPadding cellSpacing challenge\ncharSet checked classID className colSpan cols content contentEditable contextMenu\ncontrols coords crossOrigin data dateTime default defer dir disabled download draggable\nencType form formAction formEncType formMethod formNoValidate formTarget frameBorder\nheaders height hidden high href hrefLang encrypt htmlFor httpEquiv windowSoftInputMode icon id inputMode integrity\nis keyParams keyType kind label lang list loop low manifest marginHeight marginWidth max maxLength media\nmediaGroup method min minLength multiple muted name noValidate nonce open\noptimum pattern placeholder poster preload radioGroup readOnly rel required\nreversed role rowSpan rows sandbox scope scoped scrolling seamless selected\nshape size sizes span spellCheck src srcDoc srcLang srcSet start step style\nsummary tabIndex target title type useMap value width wmode wrap encryptFormat searchEncryptFormat encryptSeckeyType'.replace(/\s+/g, ' ').replace(/\t|\n|\r/g, '').split(' ');
module.exports = exports['default'];

@@ -1,1 +0,18 @@

'use strict';Object.defineProperty(exports,'__esModule',{value:!0});var _nukeEnv=require('nuke-env'),_nukeEnv2=_interopRequireDefault(_nukeEnv);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}exports.default=function(num){return 6<num?num:''+Math.floor(num/2).toString()+(_nukeEnv2.default.isWeb?'px':'wx')},module.exports=exports['default'];
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _nukeEnv = require('nuke-env');
var _nukeEnv2 = _interopRequireDefault(_nukeEnv);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.default = function (num) {
if (num > 6) return num;
return '' + Math.floor(num / 2).toString() + (_nukeEnv2.default.isWeb ? 'px' : 'wx');
};
module.exports = exports['default'];

@@ -1,1 +0,83 @@

'use strict';Object.defineProperty(exports,'__esModule',{value:!0});var _createClass=function(){function defineProperties(target,props){for(var descriptor,i=0;i<props.length;i++)descriptor=props[i],descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,'value'in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}(),_rax=require('rax'),_nukeView=require('nuke-view'),_nukeView2=_interopRequireDefault(_nukeView),_nukeText=require('nuke-text'),_nukeText2=_interopRequireDefault(_nukeText);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&&('object'==typeof call||'function'==typeof call)?call:self}function _inherits(subClass,superClass){if('function'!=typeof superClass&&null!==superClass)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:!1,writable:!0,configurable:!0}}),superClass&&(Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass)}var Count=function(_PureComponent){function Count(props,context){_classCallCheck(this,Count);var _this=_possibleConstructorReturn(this,(Count.__proto__||Object.getPrototypeOf(Count)).call(this,props));return _this.fixedFont=context.commonConfigs&&context.commonConfigs.fixedFont,'fixedFont'in props&&(_this.fixedFont=props.fixedFont),_this}return _inherits(Count,_PureComponent),_createClass(Count,[{key:'render',value:function render(){var _props=this.props,maxLength=_props.maxLength,multiple=_props.multiple,renderCount=_props.renderCount,styles=_props.themeStyle,count=_props.count;return maxLength&&renderCount?(0,_rax.createElement)(_nukeView2.default,{style:styles[''+(multiple?'md-multiple-count-wrap':'md-single-count-wrap')]},(0,_rax.createElement)(_nukeText2.default,{fixedFont:this.fixedFont,style:[styles[''+(multiple?'multiple-count-text':'single-count-text')],count>maxLength?styles['count-error']:{}]},count,' / ',maxLength)):null}}]),Count}(_rax.PureComponent);Count.contextTypes={},exports.default=Count,module.exports=exports['default'];
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
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 _rax = require('rax');
var _nukeView = require('nuke-view');
var _nukeView2 = _interopRequireDefault(_nukeView);
var _nukeText = require('nuke-text');
var _nukeText2 = _interopRequireDefault(_nukeText);
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; } /** @jsx createElement */
var Count = function (_PureComponent) {
_inherits(Count, _PureComponent);
function Count(props, context) {
_classCallCheck(this, Count);
var _this = _possibleConstructorReturn(this, (Count.__proto__ || Object.getPrototypeOf(Count)).call(this, props));
_this.fixedFont = context.commonConfigs && context.commonConfigs.fixedFont;
if ('fixedFont' in props) {
_this.fixedFont = props.fixedFont;
}
return _this;
}
_createClass(Count, [{
key: 'render',
value: function render() {
var _props = this.props,
maxLength = _props.maxLength,
multiple = _props.multiple,
renderCount = _props.renderCount,
styles = _props.themeStyle,
count = _props.count;
if (!maxLength || !renderCount) return null;
// const { count } = this.state;
return (0, _rax.createElement)(
_nukeView2.default,
{
style: styles['' + (multiple ? 'md-multiple-count-wrap' : 'md-single-count-wrap')]
},
(0, _rax.createElement)(
_nukeText2.default,
{
fixedFont: this.fixedFont,
style: [styles['' + (multiple ? 'multiple-count-text' : 'single-count-text')], count > maxLength ? styles['count-error'] : {}]
},
count,
' / ',
maxLength
)
);
}
}]);
return Count;
}(_rax.PureComponent);
Count.contextTypes = {
// androidConfigs: PropTypes.any,
};
exports.default = Count;
module.exports = exports['default'];

@@ -1,1 +0,7 @@

'use strict';Object.defineProperty(exports,'__esModule',{value:!0}),exports.default='onCopy onCut onPaste onCompositionEnd onCompositionStart onCompositionUpdate onKeyDown\n onKeyPress onKeyUp onFocus onBlur onChange onInput onSubmit onClick onContextMenu onDoubleClick\n onDrag onDragEnd onDragEnter onDragExit onDragLeave onDragOver onDragStart onDrop onMouseDown\n onMouseEnter onMouseLeave onMouseMove onMouseOut onMouseOver onMouseUp onSelect onTouchCancel\n onTouchEnd onTouchMove onTouchStart onScroll onWheel onAbort onCanPlay onCanPlayThrough\n onDurationChange onEmptied onEncrypted onEnded onError onLoadedData onLoadedMetadata\n onLoadStart onPause onPlay onPlaying onProgress onScanGunScanned onRateChange onSeeked onSeeking onStalled onSuspend onTimeUpdate onVolumeChange onWaiting onLoad onError'.replace(/\s+/g,' ').replace(/\t|\n|\r/g,'').split(' '),module.exports=exports['default'];
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = 'onCopy onCut onPaste onCompositionEnd onCompositionStart onCompositionUpdate onKeyDown\n onKeyPress onKeyUp onFocus onBlur onChange onInput onSubmit onClick onContextMenu onDoubleClick\n onDrag onDragEnd onDragEnter onDragExit onDragLeave onDragOver onDragStart onDrop onMouseDown\n onMouseEnter onMouseLeave onMouseMove onMouseOut onMouseOver onMouseUp onSelect onTouchCancel\n onTouchEnd onTouchMove onTouchStart onScroll onWheel onAbort onCanPlay onCanPlayThrough\n onDurationChange onEmptied onEncrypted onEnded onError onLoadedData onLoadedMetadata\n onLoadStart onPause onPlay onPlaying onProgress onScanGunScanned onRateChange onSeeked onSeeking onStalled onSuspend onTimeUpdate onVolumeChange onWaiting onLoad onError'.replace(/\s+/g, ' ').replace(/\t|\n|\r/g, '').split(' ');
module.exports = exports['default'];

@@ -1,1 +0,10 @@

'use strict';Object.defineProperty(exports,'__esModule',{value:!0}),exports.default={clear:'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAMAAAC7IEhfAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAABIUExURUxpcdvb2+rq6tvb29vb2////9vb29vb29ra2t3d3dzc3Nvb29vb29vb29vb29vb29zc3OPj49ra2tra2tra2v///+3t7evr66GrXawAAAAUdFJOUwDoDNn+Aap/81IWcr+l0yOCCfKD2tG2sAAAAONJREFUOMuVlVkSgyAQRMctoIKitnr/m0arYgKC2uk/i8dQs7UigfrWmkLrwti2l0s1roOnzjVJLFcaJ2mVx1ydIaGsPmGVKpFUqSqfG1641Gvw4t1wG/mLqXAr9c2jvAfLT0Z5hgdlefjwuoTnyxo83hx1Xuc5IJd5Pki992jyDnwy+HQb2KWPwmvdNi9IBjmFRy8tUuSZQysWCTLiYMUgJmMORgrEZMyhkGhalxQHLSMHjvzTdDJ0eeiC0y2kh0IcO2b04NKrwC8Xva68AfCWQpsUb3u8kf5hzXuPJsrsH34fb8y0YVOqBARgAAAAAElFTkSuQmCC',warning:'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAA/UExURUxpcdIKFtEJF9IJF9EKFtEKFtcIENMIFNIJF88AENIKFtIIFdEJF9EJF9EKFtUFFdIIFNEKFtIKFtEJF9IKF+mWP4kAAAAUdFJOUwCg37/vgCBAwBDQYHDg8DA/z1CQP2gf+wAAAJ9JREFUOMvNk9sSgyAMRJE7ar3U/f9vlamVFAj01X2BIYcNkx2EeJ5C+AO8ZL8+A3O3gQZ0r4lBlOkbdC0GfHS06hZf2bbB6NwIDHx9jXe9ED4uKwt4AhRXdyAArmGQAMZiwi+Ad51SDkjegABMxZDldayV0tdOhjqlXKZOCfckUWWWDOgNmUVKCfu27fde2zLmUpTZwgMLtXCs7FP+4gkrxRPG+kr+5gAAAABJRU5ErkJggg=='},module.exports=exports['default'];
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = {
clear: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAMAAAC7IEhfAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAABIUExURUxpcdvb2+rq6tvb29vb2////9vb29vb29ra2t3d3dzc3Nvb29vb29vb29vb29vb29zc3OPj49ra2tra2tra2v///+3t7evr66GrXawAAAAUdFJOUwDoDNn+Aap/81IWcr+l0yOCCfKD2tG2sAAAAONJREFUOMuVlVkSgyAQRMctoIKitnr/m0arYgKC2uk/i8dQs7UigfrWmkLrwti2l0s1roOnzjVJLFcaJ2mVx1ydIaGsPmGVKpFUqSqfG1641Gvw4t1wG/mLqXAr9c2jvAfLT0Z5hgdlefjwuoTnyxo83hx1Xuc5IJd5Pki992jyDnwy+HQb2KWPwmvdNi9IBjmFRy8tUuSZQysWCTLiYMUgJmMORgrEZMyhkGhalxQHLSMHjvzTdDJ0eeiC0y2kh0IcO2b04NKrwC8Xva68AfCWQpsUb3u8kf5hzXuPJsrsH34fb8y0YVOqBARgAAAAAElFTkSuQmCC',
warning: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAA/UExURUxpcdIKFtEJF9IJF9EKFtEKFtcIENMIFNIJF88AENIKFtIIFdEJF9EJF9EKFtUFFdIIFNEKFtIKFtEJF9IKF+mWP4kAAAAUdFJOUwCg37/vgCBAwBDQYHDg8DA/z1CQP2gf+wAAAJ9JREFUOMvNk9sSgyAMRJE7ar3U/f9vlamVFAj01X2BIYcNkx2EeJ5C+AO8ZL8+A3O3gQZ0r4lBlOkbdC0GfHS06hZf2bbB6NwIDHx9jXe9ED4uKwt4AhRXdyAArmGQAMZiwi+Ad51SDkjegABMxZDldayV0tdOhjqlXKZOCfckUWWWDOgNmUVKCfu27fde2zLmUpTZwgMLtXCs7FP+4gkrxRPG+kr+5gAAAABJRU5ErkJggg=='
};
module.exports = exports['default'];

@@ -1,1 +0,7 @@

'use strict';Object.defineProperty(exports,'__esModule',{value:!0}),exports.default=['color','fontSize','fontStyle','fontWeight','lineHeight','textAlign','textDecoration'],module.exports=exports['default'];
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = ['color', 'fontSize', 'fontStyle', 'fontWeight', 'lineHeight', 'textAlign', 'textDecoration'];
module.exports = exports['default'];

@@ -1,1 +0,120 @@

'use strict';Object.defineProperty(exports,'__esModule',{value:!0}),exports.default=void 0;var _createClass=function(){function defineProperties(target,props){for(var descriptor,i=0;i<props.length;i++)descriptor=props[i],descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,'value'in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}(),_rax=require('rax'),_util=require('./util');function _defineProperty(obj,key,value){return key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,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&&('object'==typeof call||'function'==typeof call)?call:self}function _inherits(subClass,superClass){if('function'!=typeof superClass&&null!==superClass)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:!1,writable:!0,configurable:!0}}),superClass&&(Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass)}var InputComponent=function(_Component){function InputComponent(props){_classCallCheck(this,InputComponent);var _this=_possibleConstructorReturn(this,(InputComponent.__proto__||Object.getPrototypeOf(InputComponent)).call(this,props));return _this.changeHandler=_this.changeHandler.bind(_this),_this.focusHandler=_this.focusHandler.bind(_this),_this.blurHandler=_this.blurHandler.bind(_this),_this.focus=_this.focus.bind(_this),_this.blur=_this.blur.bind(_this),_this}return _inherits(InputComponent,_Component),_createClass(InputComponent,[{key:'changeHandler',value:function changeHandler(e){var value=(0,_util.getText)(e),maxLength=this.props.maxLength;maxLength&&value&&value.length>maxLength||('value'in this.props&&this.setState({value:value}),this.trigger('onChange',value,(0,_util.genEventObject)(e)))}},{key:'trigger',value:function trigger(fn){if('string'==typeof fn&&(fn=this.props[fn]),'function'==typeof fn){for(var _len=arguments.length,attrs=Array(1<_len?_len-1:0),_key=1;_key<_len;_key++)attrs[_key-1]=arguments[_key];return fn.apply(this,attrs)}}},{key:'calcBorder',value:function calcBorder(style){return['Color','Style','Width'].map(function(attr){if(style['border'+attr]){var _attrObj,attrObj=(_attrObj={},_defineProperty(_attrObj,'borderTop'+attr,style['border'+attr]),_defineProperty(_attrObj,'borderLeft'+attr,style['border'+attr]),_defineProperty(_attrObj,'borderRight'+attr,style['border'+attr]),_defineProperty(_attrObj,'borderBottom'+attr,style['border'+attr]),_attrObj);delete style['border'+attr],style=Object.assign({},attrObj,style)}}),style}},{key:'focusHandler',value:function focusHandler(e){this.trigger('onFocus',e)}},{key:'focus',value:function focus(){this.focusInput()}},{key:'focusInput',value:function focusInput(){this.refs.input.focus&&this.refs.input.focus()}},{key:'blur',value:function blur(){this.blurInput()}},{key:'blurInput',value:function blurInput(){this.refs.input.blur&&this.refs.input.blur()}},{key:'blurHandler',value:function blurHandler(e){this.setState({focus:!1}),this.trigger('onBlur',e)}}]),InputComponent}(_rax.Component);exports.default=InputComponent,module.exports=exports['default'];
'use strict';
/** @jsx createElement */
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = undefined;
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 _rax = require('rax');
var _util = require('./util');
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return 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 InputComponent = function (_Component) {
_inherits(InputComponent, _Component);
function InputComponent(props) {
_classCallCheck(this, InputComponent);
var _this = _possibleConstructorReturn(this, (InputComponent.__proto__ || Object.getPrototypeOf(InputComponent)).call(this, props));
_this.changeHandler = _this.changeHandler.bind(_this);
_this.focusHandler = _this.focusHandler.bind(_this);
_this.blurHandler = _this.blurHandler.bind(_this);
_this.focus = _this.focus.bind(_this);
_this.blur = _this.blur.bind(_this);
return _this;
}
_createClass(InputComponent, [{
key: 'changeHandler',
value: function changeHandler(e) {
var value = (0, _util.getText)(e);
var maxLength = this.props.maxLength;
if (maxLength && value && value.length > maxLength) return;
if ('value' in this.props) {
this.setState({ value: value });
}
this.trigger('onChange', value, (0, _util.genEventObject)(e));
}
}, {
key: 'trigger',
value: function trigger(fn) {
if (typeof fn === 'string') fn = this.props[fn];
if (!(typeof fn === 'function')) return;
for (var _len = arguments.length, attrs = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
attrs[_key - 1] = arguments[_key];
}
return fn.apply(this, attrs);
}
}, {
key: 'calcBorder',
value: function calcBorder(style) {
['Color', 'Style', 'Width'].map(function (attr) {
if (style['border' + attr]) {
var _attrObj;
var attrObj = (_attrObj = {}, _defineProperty(_attrObj, 'borderTop' + attr, style['border' + attr]), _defineProperty(_attrObj, 'borderLeft' + attr, style['border' + attr]), _defineProperty(_attrObj, 'borderRight' + attr, style['border' + attr]), _defineProperty(_attrObj, 'borderBottom' + attr, style['border' + attr]), _attrObj);
delete style['border' + attr];
style = Object.assign({}, attrObj, style);
}
});
return style;
}
}, {
key: 'focusHandler',
value: function focusHandler(e) {
this.trigger('onFocus', e);
}
}, {
key: 'focus',
value: function focus() {
this.focusInput();
}
}, {
key: 'focusInput',
value: function focusInput() {
this.refs.input.focus && this.refs.input.focus();
}
}, {
key: 'blur',
value: function blur() {
this.blurInput();
}
}, {
key: 'blurInput',
value: function blurInput() {
this.refs.input.blur && this.refs.input.blur();
}
}, {
key: 'blurHandler',
value: function blurHandler(e) {
this.setState({
focus: false
});
this.trigger('onBlur', e);
}
}]);
return InputComponent;
}(_rax.Component);
exports.default = InputComponent;
module.exports = exports['default'];

@@ -1,1 +0,104 @@

'use strict';Object.defineProperty(exports,'__esModule',{value:!0});var _createClass=function(){function defineProperties(target,props){for(var descriptor,i=0;i<props.length;i++)descriptor=props[i],descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,'value'in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}(),_rax=require('rax'),_nukeView=require('nuke-view'),_nukeView2=_interopRequireDefault(_nukeView),_nukeText=require('nuke-text'),_nukeText2=_interopRequireDefault(_nukeText);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&&('object'==typeof call||'function'==typeof call)?call:self}function _inherits(subClass,superClass){if('function'!=typeof superClass&&null!==superClass)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:!1,writable:!0,configurable:!0}}),superClass&&(Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass)}var PlaceHolder=function(_PureComponent){function PlaceHolder(props,context){_classCallCheck(this,PlaceHolder);var _this=_possibleConstructorReturn(this,(PlaceHolder.__proto__||Object.getPrototypeOf(PlaceHolder)).call(this,props));return _this.fixedFont=context.commonConfigs&&context.commonConfigs.fixedFont,'fixedFont'in props&&(_this.fixedFont=props.fixedFont),_this}return _inherits(PlaceHolder,_PureComponent),_createClass(PlaceHolder,[{key:'render',value:function render(){var _props=this.props,placeholder=_props.placeholder,placeholderColor=_props.placeholderColor,themeStyle=_props.themeStyle,status=_props.status,disabled=_props.disabled,errorMessage=_props.errorMessage,floatPlaceholder=_props.floatPlaceholder,hideErrorWhenFocus=_props.hideErrorWhenFocus,focus=_props.focus,inputValue=_props.inputValue,maxLengthError=_props.maxLengthError,validInput=_props.validInput;if(!placeholder)return null;if((focus||inputValue)&&!floatPlaceholder)return null;var phStyle=Object.assign({},themeStyle.placeholder,themeStyle['md-placeholder-small'],focus||inputValue||!validInput?{}:themeStyle['md-placeholder'],floatPlaceholder?{}:themeStyle['md-placeholder-static']),phTextStyle=Object.assign({},themeStyle['placeholder-text'],themeStyle['md-placeholder-small-text'],placeholderColor?{color:placeholderColor}:{},focus||inputValue?{}:themeStyle['md-placeholder-text'],'error'===status&&errorMessage?themeStyle['md-placeholder-small-text-has-error']:{},inputValue?{}:themeStyle['md-empty-placeholder-text'],focus?themeStyle['md-focus-placeholder-text']:{},disabled?themeStyle['md-disabled-placeholder-text']:{});return'error'===status&&(maxLengthError||!hideErrorWhenFocus)&&(phTextStyle=Object.assign(phTextStyle,themeStyle['md-placeholder-small-text-has-error']),disabled&&(phTextStyle=Object.assign(phTextStyle,themeStyle['md-disabled-placeholder-text']))),(0,_rax.createElement)(_nukeView2.default,{style:phStyle},(0,_rax.createElement)(_nukeText2.default,{fixedFont:this.fixedFont,style:phTextStyle},placeholder))}}]),PlaceHolder}(_rax.PureComponent);PlaceHolder.contextTypes={},exports.default=PlaceHolder,module.exports=exports['default'];
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
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 _rax = require('rax');
var _nukeView = require('nuke-view');
var _nukeView2 = _interopRequireDefault(_nukeView);
var _nukeText = require('nuke-text');
var _nukeText2 = _interopRequireDefault(_nukeText);
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; } /** @jsx createElement */
var PlaceHolder = function (_PureComponent) {
_inherits(PlaceHolder, _PureComponent);
function PlaceHolder(props, context) {
_classCallCheck(this, PlaceHolder);
var _this = _possibleConstructorReturn(this, (PlaceHolder.__proto__ || Object.getPrototypeOf(PlaceHolder)).call(this, props));
_this.fixedFont = context.commonConfigs && context.commonConfigs.fixedFont;
if ('fixedFont' in props) {
_this.fixedFont = props.fixedFont;
}
return _this;
}
// shouldComponentUpdate(nextProps) {
// return (
// nextProps.status !== this.props.status ||
// nextProps.focus !== this.props.focus ||
// nextProps.disabled !== this.props.disabled ||
// nextProps.inputValue !== this.props.inputValue ||
// nextProps.maxLengthError !== this.props.maxLengthError ||
// nextProps.placeholder !== this.props.placeholder
// // nextState.error !== this.state.error
// );
// }
_createClass(PlaceHolder, [{
key: 'render',
value: function render() {
// const { focus, inputValue, maxLengthError } = this.state;
var _props = this.props,
placeholder = _props.placeholder,
placeholderColor = _props.placeholderColor,
themeStyle = _props.themeStyle,
status = _props.status,
disabled = _props.disabled,
errorMessage = _props.errorMessage,
floatPlaceholder = _props.floatPlaceholder,
hideErrorWhenFocus = _props.hideErrorWhenFocus,
focus = _props.focus,
inputValue = _props.inputValue,
maxLengthError = _props.maxLengthError,
validInput = _props.validInput;
var hasError = status === 'error' && errorMessage;
if (!placeholder) return null;
if ((focus || inputValue) && !floatPlaceholder) return null;
var phStyle = Object.assign({}, themeStyle.placeholder, themeStyle['md-placeholder-small'], !focus && !inputValue && validInput ? themeStyle['md-placeholder'] : {}, floatPlaceholder ? {} : themeStyle['md-placeholder-static']);
var phTextStyle = Object.assign({}, themeStyle['placeholder-text'], themeStyle['md-placeholder-small-text'], placeholderColor ? { color: placeholderColor } : {}, !focus && !inputValue ? themeStyle['md-placeholder-text'] : {}, hasError ? themeStyle['md-placeholder-small-text-has-error'] : {}, !inputValue ? themeStyle['md-empty-placeholder-text'] : {}, focus ? themeStyle['md-focus-placeholder-text'] : {}, disabled ? themeStyle['md-disabled-placeholder-text'] : {});
if (status === 'error' && (maxLengthError || !hideErrorWhenFocus)) {
phTextStyle = Object.assign(phTextStyle, themeStyle['md-placeholder-small-text-has-error']);
if (disabled) {
phTextStyle = Object.assign(phTextStyle, themeStyle['md-disabled-placeholder-text']);
}
}
return (0, _rax.createElement)(
_nukeView2.default,
{ style: phStyle },
(0, _rax.createElement)(
_nukeText2.default,
{ fixedFont: this.fixedFont, style: phTextStyle },
placeholder
)
);
}
}]);
return PlaceHolder;
}(_rax.PureComponent);
PlaceHolder.contextTypes = {
// androidConfigs: PropTypes.any,
};
exports.default = PlaceHolder;
module.exports = exports['default'];

@@ -1,1 +0,32 @@

'use strict';Object.defineProperty(exports,'__esModule',{value:!0}),exports.genEventObject=exports.getText=void 0;var _nukeEnv=require('nuke-env');function getText(event){var text;return text=_nukeEnv.isWeex?event.value:event.target.value,text}function genEventObject(originalEvent){var text=getText(originalEvent);return{nativeEvent:{text:text},value:text,target:originalEvent.target,originalEvent:originalEvent}}exports.getText=getText,exports.genEventObject=genEventObject;
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.genEventObject = exports.getText = undefined;
var _nukeEnv = require('nuke-env');
function getText(event) {
var text = void 0;
if (_nukeEnv.isWeex) {
text = event.value;
} else {
text = event.target.value;
}
return text;
}
function genEventObject(originalEvent) {
var text = getText(originalEvent);
return {
nativeEvent: {
text: text
},
value: text,
target: originalEvent.target,
originalEvent: originalEvent
};
}
exports.getText = getText;
exports.genEventObject = genEventObject;

@@ -1,1 +0,107 @@

'use strict';Object.defineProperty(exports,'__esModule',{value:!0});var _extends=Object.assign||function(target){for(var source,i=1;i<arguments.length;i++)for(var key in source=arguments[i],source)Object.prototype.hasOwnProperty.call(source,key)&&(target[key]=source[key]);return target},_createClass=function(){function defineProperties(target,props){for(var descriptor,i=0;i<props.length;i++)descriptor=props[i],descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,'value'in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}(),_rax=require('rax'),_nukeThemeProvider=require('nuke-theme-provider'),_styles=require('./styles'),_styles2=_interopRequireDefault(_styles),_material=require('./view/material'),_material2=_interopRequireDefault(_material),_normal=require('./view/normal'),_normal2=_interopRequireDefault(_normal);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&&('object'==typeof call||'function'==typeof call)?call:self}function _inherits(subClass,superClass){if('function'!=typeof superClass&&null!==superClass)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:!1,writable:!0,configurable:!0}}),superClass&&(Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass)}var Input=function(_Component){function Input(props,context){_classCallCheck(this,Input);var _this=_possibleConstructorReturn(this,(Input.__proto__||Object.getPrototypeOf(Input)).call(this,props));return _this.focus=_this.focus.bind(_this),_this.blur=_this.blur.bind(_this),_this.clear=_this.clear.bind(_this),_this.getRef=_this.getRef.bind(_this),_this.getValue=_this.getValue.bind(_this),_this.setNativeFormatRule=_this.setNativeFormatRule.bind(_this),_this.materialDesign=context.androidConfigs&&context.androidConfigs.materialDesign,'materialDesign'in props&&(_this.materialDesign=props.materialDesign),_this}return _inherits(Input,_Component),_createClass(Input,[{key:'focus',value:function focus(){this.refs.baseinput.focus()}},{key:'clear',value:function clear(){this.refs.baseinput.clear()}},{key:'getRef',value:function getRef(){return this.refs.baseinput.getRef()}},{key:'blur',value:function blur(){this.refs.baseinput.blur()}},{key:'getValue',value:function getValue(){return this.refs.baseinput.getValue()}},{key:'setNativeFormatRule',value:function setNativeFormatRule(rules){return this.refs.baseinput.setNativeFormatRule(rules)}},{key:'render',value:function render(){return this.materialDesign?(0,_rax.createElement)(_material2.default,_extends({ref:'baseinput'},this.props)):(0,_rax.createElement)(_normal2.default,_extends({ref:'baseinput'},this.props))}}]),Input}(_rax.Component);Input.contextTypes={androidConfigs:_rax.PropTypes.any,commonConfigs:_rax.PropTypes.any},Input.displayName='Input';var StyledInput=(0,_nukeThemeProvider.connectStyle)(_styles2.default,{withRef:!0})(Input);exports.default=StyledInput,module.exports=exports['default'];
'use strict';
/** @jsx createElement */
Object.defineProperty(exports, "__esModule", {
value: true
});
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
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 _rax = require('rax');
var _nukeThemeProvider = require('nuke-theme-provider');
var _styles = require('./styles');
var _styles2 = _interopRequireDefault(_styles);
var _material = require('./view/material');
var _material2 = _interopRequireDefault(_material);
var _normal = require('./view/normal');
var _normal2 = _interopRequireDefault(_normal);
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 Input = function (_Component) {
_inherits(Input, _Component);
function Input(props, context) {
_classCallCheck(this, Input);
var _this = _possibleConstructorReturn(this, (Input.__proto__ || Object.getPrototypeOf(Input)).call(this, props));
_this.focus = _this.focus.bind(_this);
_this.blur = _this.blur.bind(_this);
_this.clear = _this.clear.bind(_this);
_this.getRef = _this.getRef.bind(_this);
_this.getValue = _this.getValue.bind(_this);
_this.setNativeFormatRule = _this.setNativeFormatRule.bind(_this);
_this.materialDesign = context.androidConfigs && context.androidConfigs.materialDesign;
if ('materialDesign' in props) {
_this.materialDesign = props.materialDesign;
}
return _this;
}
_createClass(Input, [{
key: 'focus',
value: function focus() {
this.refs.baseinput.focus();
}
}, {
key: 'clear',
value: function clear() {
this.refs.baseinput.clear();
}
}, {
key: 'getRef',
value: function getRef() {
return this.refs.baseinput.getRef();
}
}, {
key: 'blur',
value: function blur() {
this.refs.baseinput.blur();
}
}, {
key: 'getValue',
value: function getValue() {
return this.refs.baseinput.getValue();
}
}, {
key: 'setNativeFormatRule',
value: function setNativeFormatRule(rules) {
return this.refs.baseinput.setNativeFormatRule(rules);
}
}, {
key: 'render',
value: function render() {
return this.materialDesign ? (0, _rax.createElement)(_material2.default, _extends({ ref: 'baseinput' }, this.props)) : (0, _rax.createElement)(_normal2.default, _extends({ ref: 'baseinput' }, this.props));
}
}]);
return Input;
}(_rax.Component);
Input.contextTypes = {
androidConfigs: _rax.PropTypes.any,
commonConfigs: _rax.PropTypes.any
};
Input.displayName = 'Input';
var StyledInput = (0, _nukeThemeProvider.connectStyle)(_styles2.default, { withRef: true })(Input);
exports.default = StyledInput;
module.exports = exports['default'];

@@ -1,1 +0,430 @@

'use strict';var _extends=Object.assign||function(target){for(var source,i=1;i<arguments.length;i++)for(var key in source=arguments[i],source)Object.prototype.hasOwnProperty.call(source,key)&&(target[key]=source[key]);return target},_variable=require('./variable'),_variable2=_interopRequireDefault(_variable),_nukeHelper=require('nuke-helper');function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function styleProvider(){var theme=0<arguments.length&&arguments[0]!==void 0?arguments[0]:{},Variables=(0,_variable2.default)(theme),core=theme.Core;return{Input:{"input-wrap":{},"input-inner":{flex:1},"single-wrap":{borderRadius:Variables['single-radius'],borderColor:Variables['single-line-color'],borderWidth:Variables['line-width'],borderStyle:Variables['border-style'],backgroundColor:Variables['bg-color'],height:Variables['single-height'],paddingLeft:Variables['single-padding-left-right'],paddingRight:Variables['single-padding-left-right']},"single-disabled":{borderColor:Variables['disabled-line-color'],backgroundColor:Variables['disabled-bg-color']},"md-single-disabled":{borderColor:Variables['disabled-line-color'],backgroundColor:'transparent'},"single-disabled-input":{color:Variables['disabled-color']},"multiple-wrap":_extends({},core.border(Variables['line-width'],Variables.borderStyle,Variables['multiple-borderColor']),{borderRadius:Variables['multiple-radius'],backgroundColor:Variables['bg-color'],height:Variables['multiple-height'],padding:Variables['multiple-padding']}),"multiple-disabled":{backgroundColor:Variables['disabled-bg-color']},"md-multiple-disabled":{backgroundColor:'transparent'},"multiple-disabled-input":{backgroundColor:Variables['disabled-bg-color'],color:Variables['disabled-color']},"single-input":{backgroundColor:'transparent',color:Variables['single-color'],height:Variables['single-height'],fontSize:Variables['single-font-size']},readonly:{color:Variables['readonly-color']},"multiple-input":{fontSize:Variables['multiple-font-size']},"single-md-wrap":{flexDirection:'column',paddingTop:Variables['md-placeholder-small-height'],paddingLeft:0,paddingRight:0,borderRadius:Variables['md-border-radius'],borderColor:'transparent',borderBottomWidth:Variables['md-border-top-width'],borderTopWidth:Variables['md-border-top-width'],borderLeftWidth:Variables['md-border-left-width'],borderRightWidth:Variables['md-border-right-width']},"static-placeholder":{paddingTop:0},"md-line":{height:(0,_nukeHelper.fixSmallUnit)(Variables['md-line-height']),marginTop:Variables['md-line-margin-tb'],marginBottom:Variables['md-line-margin-tb'],backgroundColor:Variables['md-border-color']},"md-line-focus":{height:(0,_nukeHelper.fixSmallUnit)(Variables['md-line-focus-height']),marginTop:0,marginBottom:0,backgroundColor:Variables['md-focus-border-color']},"md-line-error":{height:(0,_nukeHelper.fixSmallUnit)(Variables['md-line-error-height']),marginTop:0,marginBottom:0,backgroundColor:Variables['md-error-border-color']},"md-line-disabled":{height:(0,_nukeHelper.fixSmallUnit)(Variables['md-line-height']),backgroundColor:'transparent',borderBottomWidth:Variables['md-line-height'],borderBottomStyle:'dotted',borderBottomColor:Variables['disabled-line-color']},input:{borderTopWidth:0,borderBottomWidth:0,borderLeftWidth:0,borderRightWidth:0,paddingLeft:0,paddingRight:0},"input-has-clear":{paddingRight:36},"md-input":{borderTopWidth:0,borderBottomWidth:0,borderLeftWidth:0,borderRightWidth:0,paddingLeft:0,paddingRight:0,zIndex:3,backgroundColor:'transparent',marginTop:Variables['md-input-margin-top'],marginBottom:Variables['md-input-margin-bottom'],height:Variables['md-input-height']},"multiple-md-input":{borderTopWidth:0,borderBottomWidth:0,borderLeftWidth:0,borderRightWidth:0,paddingLeft:0,paddingRight:0,marginTop:Variables['md-input-margin-top'],marginBottom:Variables['md-input-margin-top'],zIndex:3,backgroundColor:'transparent',lineHeight:Variables['md-input-height']},"md-error":{height:Variables['md-error-height'],justifyContent:'center'},"md-help":{height:Variables['md-help-height'],justifyContent:'flex-end',flexDirection:'row',marginTop:Variables['md-help-margin-top']},"md-error-text":{color:Variables['md-error-text-color'],fontSize:Variables['md-error-text-font-size'],flex:1,display:'flex'},"web-normalize":{webkitAppearance:'none',outline:'none',boxSizing:'border-box',width:'100%',border:'none',resize:'none',zIndex:1},"single-count-wrap":{alignSelf:'flex-end',maxWidth:Variables['single-count-min-width']},"single-count-text":{flex:1,textAlign:'right',fontSize:Variables['count-font-size'],color:Variables['count-color']},"count-error":{color:Variables['count-error-color']},"multiple-count-wrap":{alignSelf:'flex-end',maxWidth:Variables['multiple-count-min-width']},"multiple-count-text":{flex:1,textAlign:'right',fontSize:Variables['count-font-size'],color:Variables['count-color']},"md-single-count-wrap":{alignSelf:'flex-end',maxWidth:Variables['single-count-min-width']},"md-multiple-count-wrap":{alignSelf:'flex-end',maxWidth:Variables['multiple-count-min-width']},"md-multiple-count-text":{flex:1,textAlign:'right',fontSize:Variables['count-font-size'],color:Variables['count-color']},"md-clear":{width:Variables['md-clear-width'],height:Variables['md-clear-height'],position:'absolute',top:Variables['md-clear-top'],right:Variables['md-clear-right'],zIndex:4},"md-icon":{width:Variables['md-icon-width'],height:Variables['md-icon-height'],position:'absolute',top:Variables['md-icon-top'],right:Variables['md-icon-right'],zIndex:4},"clear-image":{width:Variables['clear-width'],height:Variables['clear-height']},"md-warning":{width:Variables['md-warning-width'],height:Variables['md-warning-height'],position:'absolute',bottom:Variables['md-warning-bottom'],right:Variables['md-warning-right']},"single-outter":{},"multiple-outter":{},help:{minHeight:Variables['error-height'],justifyContent:'center'},clear:{width:Variables['clear-width'],height:Variables['clear-height']},clearWrap:{width:Variables['icon-width'],height:Variables['icon-height'],position:'absolute',top:0,right:Variables['icon-right'],zIndex:2,justifyContent:'center'},icon:{width:Variables['icon-width'],height:Variables['icon-height'],position:'absolute',justifyContent:'center',right:Variables['icon-right'],top:0,zIndex:2},"icon-image":{width:Variables['icon-width'],height:Variables['icon-height']},"error-text":{color:Variables['error-text-color'],lineHeight:Variables['error-text-line-height'],fontSize:Variables['error-text-font-size'],paddingTop:Variables['error-text-padding-top']},"error-input-wrap":{borderColor:Variables['error-border-color']},"focus-input-wrap":{borderColor:Variables['focus-border-color']},warning:{width:Variables['warning-width'],height:Variables['warning-height'],position:'absolute',bottom:Variables['warning-bottom'],right:Variables['warning-right']},"multiple-md-wrap":{position:'relative',flexDirection:'column',justifyContent:'flex-end',padding:Variables['multiple-padding'],paddingTop:Variables['md-placeholder-height'],paddingLeft:0,paddingRight:0,borderRadius:Variables['md-border-radius'],borderColor:'transparent',borderBottomWidth:Variables['md-border-top-width'],borderTopWidth:Variables['md-border-top-width'],borderLeftWidth:Variables['md-border-left-width'],borderRightWidth:Variables['md-border-right-width'],backgroundColor:Variables['bg-color']},"text-for-height":{position:'absolute',top:10,left:10,fontSize:Variables['multiple-font-size'],lineHeight:36,visibility:'hidden'},"multiple-md-placeholder":{top:Variables['multiple-md-placeholder-top']},placeholder:_extends({position:'absolute',flexDirection:'row',left:0,top:Variables['placeholder-top'],justifyContent:'flex-start',alignItems:'center',minWidth:Variables['placeholder-min-width'],height:Variables['placeholder-height']},core.padding(0,0)),"placeholder-text":{color:Variables['placeholder-color'],fontSize:Variables['placeholder-font-size']},"md-placeholder":{alignItems:'center',height:Variables['md-placeholder-height'],top:Variables['md-placeholder-small-height']+Variables['md-input-margin-top']},"md-placeholder-static":{top:Variables['md-input-margin-top']},"md-placeholder-text":{color:Variables['md-placeholder-color'],fontSize:Variables['md-placeholder-font-size']},"md-focus-placeholder-text":{color:Variables['md-focus-placeholder-color']},"md-empty-placeholder-text":{color:Variables['md-empty-placeholder-color']},"md-disabled-placeholder-text":{color:Variables['md-disabled-placeholder-color']},"md-placeholder-small":{height:Variables['md-placeholder-small-height'],top:Variables['md-placeholder-small-top']},"md-placeholder-small-text":{paddingTop:Variables['md-placeholder-small-padding-top'],fontSize:Variables['md-placeholder-small-font-size']},"md-placeholder-small-text-has-error":{color:Variables['md-error-placeholder-color']}}}}module.exports=styleProvider;
'use strict';
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _variable = require('./variable');
var _variable2 = _interopRequireDefault(_variable);
var _nukeHelper = require('nuke-helper');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function styleProvider() {
var theme = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var Variables = (0, _variable2.default)(theme);
var core = theme.Core;
return {
Input: {
'input-wrap': {},
'input-inner': {
flex: 1
},
'single-wrap': {
borderRadius: Variables['single-radius'],
borderColor: Variables['single-line-color'],
borderWidth: Variables['line-width'],
borderStyle: Variables['border-style'],
backgroundColor: Variables['bg-color'],
height: Variables['single-height'],
paddingLeft: Variables['single-padding-left-right'],
paddingRight: Variables['single-padding-left-right']
},
'single-disabled': {
borderColor: Variables['disabled-line-color'],
backgroundColor: Variables['disabled-bg-color']
},
'md-single-disabled': {
borderColor: Variables['disabled-line-color'],
backgroundColor: 'transparent'
},
'single-disabled-input': {
color: Variables['disabled-color']
},
'multiple-wrap': _extends({}, core.border(Variables['line-width'], Variables.borderStyle, Variables['multiple-borderColor']), {
borderRadius: Variables['multiple-radius'],
backgroundColor: Variables['bg-color'],
height: Variables['multiple-height'],
padding: Variables['multiple-padding']
}),
'multiple-disabled': {
backgroundColor: Variables['disabled-bg-color']
},
'md-multiple-disabled': {
backgroundColor: 'transparent'
},
'multiple-disabled-input': {
backgroundColor: Variables['disabled-bg-color'],
color: Variables['disabled-color']
},
'single-input': {
backgroundColor: 'transparent',
color: Variables['single-color'],
height: Variables['single-height'],
fontSize: Variables['single-font-size']
},
readonly: {
color: Variables['readonly-color']
},
'multiple-input': {
fontSize: Variables['multiple-font-size']
},
'single-md-wrap': {
// position: 'relative',
flexDirection: 'column',
// justifyContent: 'flex-end',
// height:
// Variables['md-input-height'] + Variables['md-placeholder-height'],
paddingTop: Variables['md-placeholder-small-height'],
paddingLeft: 0,
paddingRight: 0,
borderRadius: Variables['md-border-radius'],
borderColor: 'transparent',
borderBottomWidth: Variables['md-border-top-width'],
borderTopWidth: Variables['md-border-top-width'],
borderLeftWidth: Variables['md-border-left-width'],
borderRightWidth: Variables['md-border-right-width']
},
'static-placeholder': {
paddingTop: 0
},
'md-line': {
height: (0, _nukeHelper.fixSmallUnit)(Variables['md-line-height']),
marginTop: Variables['md-line-margin-tb'],
marginBottom: Variables['md-line-margin-tb'],
backgroundColor: Variables['md-border-color']
},
'md-line-focus': {
height: (0, _nukeHelper.fixSmallUnit)(Variables['md-line-focus-height']),
marginTop: 0,
marginBottom: 0,
backgroundColor: Variables['md-focus-border-color']
},
'md-line-error': {
height: (0, _nukeHelper.fixSmallUnit)(Variables['md-line-error-height']),
marginTop: 0,
marginBottom: 0,
backgroundColor: Variables['md-error-border-color']
},
'md-line-disabled': {
height: (0, _nukeHelper.fixSmallUnit)(Variables['md-line-height']),
backgroundColor: 'transparent',
borderBottomWidth: Variables['md-line-height'],
borderBottomStyle: 'dotted',
borderBottomColor: Variables['disabled-line-color']
},
input: {
borderTopWidth: 0,
borderBottomWidth: 0,
borderLeftWidth: 0,
borderRightWidth: 0,
paddingLeft: 0,
paddingRight: 0
},
'input-has-clear': {
paddingRight: 36
},
'md-input': {
borderTopWidth: 0,
borderBottomWidth: 0,
borderLeftWidth: 0,
borderRightWidth: 0,
paddingLeft: 0,
paddingRight: 0,
zIndex: 3,
backgroundColor: 'transparent',
marginTop: Variables['md-input-margin-top'],
marginBottom: Variables['md-input-margin-bottom'],
height: Variables['md-input-height']
},
'multiple-md-input': {
borderTopWidth: 0,
borderBottomWidth: 0,
borderLeftWidth: 0,
borderRightWidth: 0,
paddingLeft: 0,
paddingRight: 0,
marginTop: Variables['md-input-margin-top'],
marginBottom: Variables['md-input-margin-top'],
zIndex: 3,
backgroundColor: 'transparent',
// bottom: Variables['md-border-bottom-width'],
lineHeight: Variables['md-input-height']
},
'md-error': {
height: Variables['md-error-height'],
justifyContent: 'center'
},
'md-help': {
height: Variables['md-help-height'],
justifyContent: 'flex-end',
flexDirection: 'row',
marginTop: Variables['md-help-margin-top']
},
'md-error-text': {
color: Variables['md-error-text-color'],
fontSize: Variables['md-error-text-font-size'],
flex: 1,
display: 'flex'
},
'web-normalize': {
webkitAppearance: 'none',
outline: 'none',
boxSizing: 'border-box',
width: '100%',
border: 'none',
resize: 'none',
zIndex: 1
},
'single-count-wrap': {
// position: 'absolute',
alignSelf: 'flex-end',
// bottom: Variables['single-count-bottom'],
// right: Variables['single-count-right'],
maxWidth: Variables['single-count-min-width']
// flexDirection: 'row',
// justifyContent: 'flex-end',
// backgroundColor: 'red'
},
'single-count-text': {
flex: 1,
textAlign: 'right',
fontSize: Variables['count-font-size'],
color: Variables['count-color']
},
'count-error': {
color: Variables['count-error-color']
},
'multiple-count-wrap': {
alignSelf: 'flex-end',
// position: 'absolute',
// bottom: Variables['multiple-count-bottom'],
// right: Variables['multiple-count-right'],
maxWidth: Variables['multiple-count-min-width']
// flexDirection: 'row',
// justifyContent: 'flex-end',
// backgroundColor: 'red'
},
'multiple-count-text': {
flex: 1,
textAlign: 'right',
fontSize: Variables['count-font-size'],
color: Variables['count-color']
},
'md-single-count-wrap': {
alignSelf: 'flex-end',
// position: 'absolute',
// bottom: Variables['md-single-count-bottom'],
// right: Variables['md-single-count-right'],
maxWidth: Variables['single-count-min-width']
},
'md-multiple-count-wrap': {
alignSelf: 'flex-end',
maxWidth: Variables['multiple-count-min-width']
},
'md-multiple-count-text': {
flex: 1,
textAlign: 'right',
fontSize: Variables['count-font-size'],
color: Variables['count-color']
},
'md-clear': {
width: Variables['md-clear-width'],
height: Variables['md-clear-height'],
position: 'absolute',
top: Variables['md-clear-top'],
right: Variables['md-clear-right'],
zIndex: 4 // for web
},
'md-icon': {
width: Variables['md-icon-width'],
height: Variables['md-icon-height'],
position: 'absolute',
top: Variables['md-icon-top'],
right: Variables['md-icon-right'],
zIndex: 4 // for web
},
'clear-image': {
width: Variables['clear-width'],
height: Variables['clear-height']
},
'md-warning': {
width: Variables['md-warning-width'],
height: Variables['md-warning-height'],
position: 'absolute',
bottom: Variables['md-warning-bottom'],
right: Variables['md-warning-right']
},
'single-outter': {
// height: Variables['single-height'] + Variables['error-height'],
},
'multiple-outter': {
// height: Variables['single-height'] + Variables['error-height'],
},
help: {
minHeight: Variables['error-height'],
justifyContent: 'center'
},
clear: {
width: Variables['clear-width'],
height: Variables['clear-height']
// position: 'absolute',
// top: Variables['clear-top'],
// right: Variables['clear-right'],
// zIndex: 2, // for web
},
clearWrap: {
width: Variables['icon-width'],
height: Variables['icon-height'],
position: 'absolute',
top: 0,
right: Variables['icon-right'],
zIndex: 2, // for web
justifyContent: 'center'
},
icon: {
width: Variables['icon-width'],
height: Variables['icon-height'],
position: 'absolute',
justifyContent: 'center',
// top: Variables['icon-top'],
right: Variables['icon-right'],
top: 0,
// right: 0,
zIndex: 2 // for web
},
'icon-image': {
width: Variables['icon-width'],
height: Variables['icon-height']
},
'error-text': {
color: Variables['error-text-color'],
lineHeight: Variables['error-text-line-height'],
// justifyContent: 'center',
fontSize: Variables['error-text-font-size'],
paddingTop: Variables['error-text-padding-top']
},
'error-input-wrap': {
borderColor: Variables['error-border-color']
},
'focus-input-wrap': {
borderColor: Variables['focus-border-color']
},
warning: {
width: Variables['warning-width'],
height: Variables['warning-height'],
position: 'absolute',
bottom: Variables['warning-bottom'],
right: Variables['warning-right']
},
'multiple-md-wrap': {
position: 'relative',
flexDirection: 'column',
justifyContent: 'flex-end',
padding: Variables['multiple-padding'],
// height:
// Variables['md-input-height'] + Variables['md-placeholder-height'],
paddingTop: Variables['md-placeholder-height'],
// lineHeight: Variables['md-input-height'],
paddingLeft: 0,
paddingRight: 0,
borderRadius: Variables['md-border-radius'],
borderColor: 'transparent',
borderBottomWidth: Variables['md-border-top-width'],
borderTopWidth: Variables['md-border-top-width'],
borderLeftWidth: Variables['md-border-left-width'],
borderRightWidth: Variables['md-border-right-width'],
backgroundColor: Variables['bg-color']
},
'text-for-height': {
position: 'absolute',
top: 10,
left: 10,
fontSize: Variables['multiple-font-size'],
lineHeight: 36,
// color: 'red',
visibility: 'hidden'
},
'multiple-md-placeholder': {
top: Variables['multiple-md-placeholder-top']
},
placeholder: _extends({
position: 'absolute',
// width: '90%',
flexDirection: 'row',
left: 0,
top: Variables['placeholder-top'],
justifyContent: 'flex-start',
alignItems: 'center',
minWidth: Variables['placeholder-min-width'],
height: Variables['placeholder-height']
}, core.padding(0, 0)),
'placeholder-text': {
color: Variables['placeholder-color'],
fontSize: Variables['placeholder-font-size']
},
'md-placeholder': {
alignItems: 'center',
// lineHeight: Variables['md-placeholder-height'],
height: Variables['md-placeholder-height'],
top: Variables['md-placeholder-small-height'] + Variables['md-input-margin-top']
// ## todo (weex 0.17)
// transitionProperty: 'top',
// transitionDuration: '0.1s',
// transitionDelay: '0s',
// // transitionTimingFunction: 'cubic-bezier(0.25, 0.1, 0.25, 1.0)',
// transitionTimingFunction: 'linear',
},
'md-placeholder-static': {
top: Variables['md-input-margin-top']
},
'md-placeholder-text': {
color: Variables['md-placeholder-color'],
fontSize: Variables['md-placeholder-font-size']
},
'md-focus-placeholder-text': {
color: Variables['md-focus-placeholder-color']
},
'md-empty-placeholder-text': {
color: Variables['md-empty-placeholder-color']
},
'md-disabled-placeholder-text': {
color: Variables['md-disabled-placeholder-color']
},
'md-placeholder-small': {
// lineHeight: Variables['md-placeholder-small-height'],
height: Variables['md-placeholder-small-height'],
// to avoid cut when placeholder language is thai
top: Variables['md-placeholder-small-top'] // ## todo (weex 0.17)
// transitionProperty: 'top',
// transitionDuration: '0.1s',
// transitionDelay: '0s',
// transitionTimingFunction: 'linear',
// transitionTimingFunction: 'cubic-bezier(0.25, 0.1, 0.25, 1.0)',
},
'md-placeholder-small-text': {
paddingTop: Variables['md-placeholder-small-padding-top'],
fontSize: Variables['md-placeholder-small-font-size']
},
'md-placeholder-small-text-has-error': {
color: Variables['md-error-placeholder-color']
}
}
};
}
module.exports = styleProvider;

@@ -1,1 +0,530 @@

'use strict';function VariableMix(theme){var core=theme.Core,ComponentCustomStyle=theme.Input||{},inputVariables={"bg-color":core['color-white'],"disabled-bg-color":core['color-fill1-3'],"disabled-line-color":core['color-line1-1'],"disabled-color":core['color-text1-1'],"border-color":core['color-line1-2'],"border-style":core['line-solid'],"line-width":core['line-1'],"single-height":core['s-10'],"single-font-size":core['font-size-body-3'],"single-readonly-color":core['color-text1-2'],"placeholder-color":core['color-text1-2'],"placeholder-font-size":core['font-size-subhead'],"placeholder-height":core['s-6'],"placeholder-min-width":200,"placeholder-top":10,"single-padding-left-right":20,"single-radius":core['corner-1'],"single-color":core['color-text1-4'],"single-line-color":core['color-line1-2'],"multiple-height":core['s-20'],"multiple-font-size":core['font-size-body-3'],"multiple-inset-padding":core['s-1'],"multiple-inset-color":core['color-text1-4'],"multiple-padding":core['s-1'],"multiple-radius":core['corner-0'],"multiple-color":core['color-text1-4'],"multiple-border-color":core['color-line1-2'],"single-count-bottom":14,"single-count-right":10,"single-count-min-width":200,"count-color":core['color-text1-1'],"count-font-size":core['font-size-caption'],"count-error-color":core['color-error-3'],"multiple-count-bottom":16,"multiple-count-right":10,"multiple-count-min-width":200,"error-height":core['s-6'],"error-text-color":core['color-error-3'],"error-text-line-height":core['s-6'],"error-text-font-size":core['font-size-caption'],"error-text-padding-top":6,"error-border-color":core['color-error-3'],"focus-border-color":core['color-brand1-6'],"clear-width":34,"clear-height":34,"clear-top":26,"clear-right":20,"icon-width":34,"icon-height":34,"icon-top":26,"icon-right":20,"warning-width":38,"warning-height":38,"warning-bottom":6,"warning-right":4,"md-focus-placeholder-color":core['color-brand1-6'],"md-empty-placeholder-color":core['color-text1-2'],"md-error-placeholder-color":core['color-error-3'],"md-disabled-placeholder-color":core['color-text1-1'],"md-border-color":core['color-line1-2'],"md-border-radius":core['corner-0'],"md-focus-border-color":core['color-brand1-6'],"md-error-border-color":core['color-error-3'],"md-border-top-width":0,"md-line-height":core['line-2'],"md-line-margin-tb":core['line-1'],"md-line-focus-height":core['line-3'],"md-line-error-height":core['line-3'],"md-border-left-width":0,"md-border-right-width":0,"md-placeholder-height":40,"md-placeholder-small-height":36,"md-placeholder-small-padding-top":6,"md-placeholder-font-size":core['font-size-body-3'],"md-placeholder-color":core['color-text1-1'],"md-placeholder-small-font-size":core['font-size-caption'],"md-input-height":40,"md-input-margin-top":6,"md-input-margin-bottom":6,"md-help-height":28,"md-help-margin-top":core['s-1'],"md-error-height":28,"md-error-text-color":core['color-error-3'],"md-error-text-font-size":core['font-size-caption'],"md-single-count-bottom":10,"md-single-count-right":10,"md-clear-width":32,"md-clear-height":32,"md-clear-top":40,"md-clear-right":10,"md-icon-width":32,"md-icon-height":32,"md-icon-top":40,"md-icon-right":10,"md-warning-width":36,"md-warning-height":36,"md-warning-bottom":6,"md-warning-right":10,"md-multiple-height":160,"md-placeholder-top":50,"md-placeholder-small-top":0,"multiple-md-placeholder-top":10},variable=Object.assign(inputVariables,ComponentCustomStyle);return variable}module.exports=VariableMix;
'use strict';
function VariableMix(theme) {
var core = theme.Core;
var ComponentCustomStyle = theme.Input || {};
/**
* 输入框
* @namespace component
* @property module input
* @property tag Input
* @property category component
*/
var inputVariables = {
/**
* background
* @property namespace statement
*/
'bg-color': core['color-white'],
/**
* background
* @property namespace statement/disabled
*/
'disabled-bg-color': core['color-fill1-3'],
/**
* border
* @property namespace statement/disabled
*/
'disabled-line-color': core['color-line1-1'],
/**
* text
* @property namespace statement/disabled
*/
'disabled-color': core['color-text1-1'],
/**
* border
* @property namespace statement
*/
'border-color': core['color-line1-2'],
/**
* border-style
* @property namespace statement
*/
'border-style': core['line-solid'],
/**
* border
* @property namespace size/border
*/
'line-width': core['line-1'],
/**
* height
* @property namespace size/bouncing
*/
'single-height': core['s-10'],
/**
* text
* @property namespace size/text
*/
'single-font-size': core['font-size-body-3'],
/**
* text
* @property namespace statement
*/
'single-readonly-color': core['color-text1-2'],
/**
* text
* @property namespace statement/placeholder
*/
'placeholder-color': core['color-text1-2'],
/**
* text
* @property namespace size/placeholder
*/
'placeholder-font-size': core['font-size-subhead'],
/**
* height
* @property namespace size/placeholder
*/
'placeholder-height': core['s-6'],
/**
* min-width
* @property namespace size/placeholder
*/
'placeholder-min-width': 200,
/**
* top
* @property namespace size/placeholder
*/
'placeholder-top': 10,
/**
* padding(l, r)
* @property namespace size/bouncing
*/
'single-padding-left-right': 20,
/**
* corner
* @property namespace statement
*/
'single-radius': core['corner-1'],
/**
* text
* @property namespace statement
*/
'single-color': core['color-text1-4'],
/**
* border
* @property namespace statement
*/
'single-line-color': core['color-line1-2'],
/**
* height
* @property namespace size/bounding
*/
'multiple-height': core['s-20'],
/**
* text
* @property namespace size/text
*/
'multiple-font-size': core['font-size-body-3'],
/**
* padding
* @property namespace size/bounding
*/
'multiple-inset-padding': core['s-1'],
/**
* text
* @property namespace statement
*/
'multiple-inset-color': core['color-text1-4'],
/**
* padding(l, r)
* @property namespace size/bouncing
*/
'multiple-padding': core['s-1'],
/**
* corner
* @property namespace statement
*/
'multiple-radius': core['corner-0'],
/**
* text
* @property namespace statement
*/
'multiple-color': core['color-text1-4'],
/**
* border
* @property namespace statement
*/
'multiple-border-color': core['color-line1-2'],
/**
* bottom
* @property namespace size/count
*/
'single-count-bottom': 14,
/**
* right
* @property namespace size/count
*/
'single-count-right': 10,
/**
* min-width
* @property namespace size/count
*/
'single-count-min-width': 200,
/**
* text
* @property namespace statement/count
*/
'count-color': core['color-text1-1'],
/**
* text
* @property namespace statement/count
*/
'count-font-size': core['font-size-caption'],
/**
* text
* @property namespace statement/count
*/
'count-error-color': core['color-error-3'],
/**
* bottom
* @property namespace size/count
*/
'multiple-count-bottom': 16,
/**
* right
* @property namespace size/count
*/
'multiple-count-right': 10,
/**
* min-width
* @property namespace size/count
*/
'multiple-count-min-width': 200,
/**
* height
* @property namespace size/error
*/
'error-height': core['s-6'],
/**
* text
* @property namespace statement/error
*/
'error-text-color': core['color-error-3'],
/**
* lineHeight
* @property namespace size/error
*/
'error-text-line-height': core['s-6'],
/**
* text
* @property namespace size/error
*/
'error-text-font-size': core['font-size-caption'],
/**
* padding(t)
* @property namespace size/error
*/
'error-text-padding-top': 6,
/**
* border
* @property namespace statement/error
*/
'error-border-color': core['color-error-3'],
/**
* border
* @property namespace statement/focus
*/
'focus-border-color': core['color-brand1-6'],
/**
* width
* @property namespace size/clear
*/
'clear-width': 34,
/**
* height
* @property namespace size/clear
*/
'clear-height': 34,
/**
* top
* @property namespace size/clear
*/
'clear-top': 26,
/**
* right
* @property namespace size/clear
*/
'clear-right': 20,
/**
* width
* @property namespace size/icon
*/
'icon-width': 34,
/**
* height
* @property namespace size/icon
*/
'icon-height': 34,
/**
* top
* @property namespace size/icon
*/
'icon-top': 26,
/**
* right
* @property namespace size/icon
*/
'icon-right': 20,
/**
* width
* @property namespace size/warning
*/
'warning-width': 38,
/**
* height
* @property namespace size/warning
*/
'warning-height': 38,
/**
* bottom
* @property namespace size/warning
*/
'warning-bottom': 6,
/**
* right
* @property namespace size/warning
*/
'warning-right': 4,
/**
* text
* @property namespace statement/placeholder
*/
'md-focus-placeholder-color': core['color-brand1-6'],
/**
* text
* @property namespace statement/placeholder
*/
'md-empty-placeholder-color': core['color-text1-2'],
/**
* text
* @property namespace statement/placeholder
*/
'md-error-placeholder-color': core['color-error-3'],
/**
* text
* @property namespace statement/placeholder/disabled
*/
'md-disabled-placeholder-color': core['color-text1-1'],
/**
* border
* @property namespace statement/placeholder
*/
'md-border-color': core['color-line1-2'],
/**
* corner
* @property namespace statement
*/
'md-border-radius': core['corner-0'],
/**
* border
* @property namespace statement/focus
*/
'md-focus-border-color': core['color-brand1-6'],
/**
* border
* @property namespace statement/error
*/
'md-error-border-color': core['color-error-3'],
/**
* border-top
* @property namespace statement
*/
'md-border-top-width': 0,
/**
* height
* @property namespace size/line
*/
'md-line-height': core['line-2'],
/**
* margin(t,b)
* @property namespace size/line
*/
'md-line-margin-tb': core['line-1'],
/**
* height
* @property namespace size/line/focus
*/
'md-line-focus-height': core['line-3'],
/**
* height
* @property namespace size/line/error
*/
'md-line-error-height': core['line-3'],
/**
* border-left
* @property namespace size/bounding
*/
'md-border-left-width': 0,
/**
* border-right
* @property namespace size/bounding
*/
'md-border-right-width': 0,
/**
* height
* @property namespace size/placeholder
*/
'md-placeholder-height': 40,
/**
* height
* @property namespace size/placeholder/small
*/
'md-placeholder-small-height': 36,
/**
* padding(t)
* @property namespace size/placeholder/small
*/
'md-placeholder-small-padding-top': 6,
/**
* text
* @property namespace size/placeholder
*/
'md-placeholder-font-size': core['font-size-body-3'],
/**
* text
* @property namespace statement/placeholder
*/
'md-placeholder-color': core['color-text1-1'],
/**
* text
* @property namespace size/placeholder/small
*/
'md-placeholder-small-font-size': core['font-size-caption'],
/**
* height
* @property namespace size/bounding
*/
'md-input-height': 40,
/**
* margin(t)
* @property namespace size/bounding
*/
'md-input-margin-top': 6,
/**
* margin(b)
* @property namespace size/bounding
*/
'md-input-margin-bottom': 6,
/**
* height
* @property namespace size/help
*/
'md-help-height': 28,
/**
* margin(t)
* @property namespace size/help
*/
'md-help-margin-top': core['s-1'],
/**
* height
* @property namespace size/error
*/
'md-error-height': 28,
/**
* text
* @property namespace statement/error
*/
'md-error-text-color': core['color-error-3'],
/**
* text
* @property namespace size/error
*/
'md-error-text-font-size': core['font-size-caption'],
/**
* bottom
* @property namespace size/count
*/
'md-single-count-bottom': 10,
/**
* right
* @property namespace size/count
*/
'md-single-count-right': 10,
/**
* width
* @property namespace size/clear
*/
'md-clear-width': 32,
/**
* height
* @property namespace size/clear
*/
'md-clear-height': 32,
/**
* top
* @property namespace size/clear
*/
'md-clear-top': 40,
/**
* right
* @property namespace size/clear
*/
'md-clear-right': 10,
/**
* width
* @property namespace size/icon
*/
'md-icon-width': 32,
/**
* height
* @property namespace size/icon
*/
'md-icon-height': 32,
/**
* top
* @property namespace size/icon
*/
'md-icon-top': 40,
/**
* right
* @property namespace size/icon
*/
'md-icon-right': 10,
/**
* width
* @property namespace size/warning
*/
'md-warning-width': 36,
/**
* height
* @property namespace size/warning
*/
'md-warning-height': 36,
/**
* bottom
* @property namespace size/warning
*/
'md-warning-bottom': 6,
/**
* right
* @property namespace size/warning
*/
'md-warning-right': 10,
/**
* height
* @property namespace size/bouding
*/
'md-multiple-height': 160,
/**
* top
* @property namespace size/placeholder
*/
'md-placeholder-top': 50,
/**
* top
* @property namespace size/placeholder/small
*/
'md-placeholder-small-top': 0,
/**
* top
* @property namespace size/placeholder
*/
'multiple-md-placeholder-top': 10
};
// should alway use var statement to carray a assigngg
var variable = Object.assign(inputVariables, ComponentCustomStyle);
return variable;
}
module.exports = VariableMix;

@@ -1,1 +0,24 @@

"use strict";exports.isValidInput=function(element){if(element.validity&&!element.validity.valid)return!1;var value=element.value;return null!=value},exports.isValidNumber=function(value){var reg=/^[-+]?[0-9]*\.?[0-9]+$/;return reg.test(value)};
"use strict";
/**
* @param {dom node} element
* check whether the dom node's input is valid [ work in h5]
* number键盘输入非合法的时候value为空,此时需要校验是否合法。
* relative issue https://github.com/angular/angular.js/issues/2144
*/
exports.isValidInput = function (element) {
if (element.validity && !element.validity.valid) {
// if html5 validation says it's bad: it's bad
return false;
}
// Fallback to browsers that don't yet support html5 input validation
// Or we maybe want to perform additional validations
var value = element.value;
if (value != null) return true;
return false;
};
exports.isValidNumber = function (value) {
var reg = /^[-+]?[0-9]*\.?[0-9]+$/;
return reg.test(value);
};

@@ -1,1 +0,198 @@

'use strict';Object.defineProperty(exports,'__esModule',{value:!0});var _extends=Object.assign||function(target){for(var source,i=1;i<arguments.length;i++)for(var key in source=arguments[i],source)Object.prototype.hasOwnProperty.call(source,key)&&(target[key]=source[key]);return target},_typeof='function'==typeof Symbol&&'symbol'==typeof Symbol.iterator?function(obj){return typeof obj}:function(obj){return obj&&'function'==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?'symbol':typeof obj},_createClass=function(){function defineProperties(target,props){for(var descriptor,i=0;i<props.length;i++)descriptor=props[i],descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,'value'in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}(),_rax=require('rax'),_nukeEnv=require('nuke-env'),_nukeHelper=require('nuke-helper'),_util=require('../mods/util'),_inputComponent=require('../mods/input-component'),_inputComponent2=_interopRequireDefault(_inputComponent);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _objectWithoutProperties(obj,keys){var target={};for(var i in obj)0<=keys.indexOf(i)||Object.prototype.hasOwnProperty.call(obj,i)&&(target[i]=obj[i]);return target}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&&('object'==typeof call||'function'==typeof call)?call:self}function _inherits(subClass,superClass){if('function'!=typeof superClass&&null!==superClass)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:!1,writable:!0,configurable:!0}}),superClass&&(Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass)}var NoStyleInput=function(_InputComponent){function NoStyleInput(props,context){_classCallCheck(this,NoStyleInput);var _this=_possibleConstructorReturn(this,(NoStyleInput.__proto__||Object.getPrototypeOf(NoStyleInput)).call(this,props));return _this.fixedFont=context.commonConfigs&&context.commonConfigs.fixedFont,'fixedFont'in props&&(_this.fixedFont=props.fixedFont),_this.getRef=_this.getRef.bind(_this),_this.setNativeFormatRule=_this.setNativeFormatRule.bind(_this),_this.inputHandler=_this.inputHandler.bind(_this),_this.returnHandler=_this.returnHandler.bind(_this),_this}return _inherits(NoStyleInput,_InputComponent),_createClass(NoStyleInput,[{key:'shouldComponentUpdate',value:function shouldComponentUpdate(nextProps){return null===nextProps.value?_typeof(nextProps.value)!==_typeof(this.props.value)||nextProps.readOnly!==this.props.readOnly||nextProps.type!==this.props.type||nextProps.disabled!==this.props.disabled||nextProps.maxLength!==this.props.maxLength||nextProps.placeholder!==this.props.placeholder:nextProps.value!==this.props.value||nextProps.readOnly!==this.props.readOnly||nextProps.type!==this.props.type||nextProps.disabled!==this.props.disabled||nextProps.maxLength!==this.props.maxLength||nextProps.placeholder!==this.props.placeholder}},{key:'setNativeFormatRule',value:function setNativeFormatRule(rules){this.refs.input.setTextFormatter(rules)}},{key:'getRef',value:function getRef(){return this.refs.input}},{key:'returnHandler',value:function returnHandler(e){_nukeEnv.isWeb?13===e.keyCode&&this.trigger('onReturn',(0,_util.genEventObject)(e)):this.trigger('onReturn',(0,_util.genEventObject)(e))}},{key:'inputHandler',value:function inputHandler(e){this.trigger('onInput',(0,_util.getText)(e),(0,_util.genEventObject)(e))}},{key:'getInputStyle',value:function getInputStyle(){var _props=this.props,multiple=_props.multiple,disabled=_props.disabled,readOnly=_props.readOnly,inputStyle=_props.inputStyle,style=_props.style,themeStyle=_props.themeStyle,elementStyle=Object.assign({},themeStyle['input-inner'],themeStyle[(multiple?'multiple':'single')+'-input'],readOnly?themeStyle.readonly:{},disabled?themeStyle[(multiple?'multiple':'single')+'-disabled-input']:{},_nukeEnv.isWeb?themeStyle['web-normalize']:{},inputStyle,style);return this.fixedFont?(0,_nukeHelper.calcTextSize)(elementStyle):elementStyle}},{key:'getValue',value:function getValue(){return _nukeEnv.isWeb?this.refs.input.value:this.refs.input.attr.value}},{key:'render',value:function render(){var _props2=this.props,value=_props2.value,onFocus=_props2.onFocus,onInput=_props2.onInput,onBlur=_props2.onBlur,readOnly=_props2.readOnly,disabled=_props2.disabled,_props2$style=_props2.style,style=void 0===_props2$style?{}:_props2$style,maxLength=_props2.maxLength,multiple=_props2.multiple,returnKeyType=_props2.returnKeyType,autoFocus=_props2.autoFocus,fixedFont=_props2.fixedFont,rows=_props2.rows,type=_props2.type,placeholderColor=_props2.placeholderColor,others=_objectWithoutProperties(_props2,['value','onFocus','onInput','onBlur','readOnly','disabled','style','maxLength','multiple','returnKeyType','autoFocus','fixedFont','rows','type','placeholderColor']),attrs={onChange:this.changeHandler,onInput:this.inputHandler,onFocus:this.focusHandler,onBlur:this.blurHandler,disabled:disabled,rows:rows,returnKeyType:returnKeyType,maxlength:maxLength,readOnly:readOnly,autofocus:autoFocus,placeholderColor:placeholderColor,type:_nukeEnv.isWeex&&multiple?'text':type,style:this.getInputStyle()};'value'in this.props&&(attrs.value=this.props.value),_nukeEnv.isWeb?(attrs.onKeyUp=this.returnHandler,['readOnly','autofocus'].map(function(item){item in attrs&&!attrs[item]&&delete attrs[item]})):(attrs.onReturn=this.returnHandler,attrs['data-placeholder-color']=placeholderColor,multiple&&!this.props.onReturn&&(delete attrs.onReturn,delete attrs.returnKeyType));var inputElement;return inputElement=multiple?_nukeEnv.isWeb?(0,_rax.createElement)('textarea',_extends({},others,attrs,{ref:'input'}),attrs.value):(0,_rax.createElement)('textarea',_extends({},others,attrs,{ref:'input'})):(0,_rax.createElement)('input',_extends({},others,attrs,{ref:'input'})),inputElement}}]),NoStyleInput}(_inputComponent2.default);NoStyleInput.contextTypes={androidConfigs:_rax.PropTypes.any},exports.default=NoStyleInput,module.exports=exports['default'];
'use strict';
/** @jsx createElement */
Object.defineProperty(exports, "__esModule", {
value: true
});
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
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 _rax = require('rax');
var _nukeEnv = require('nuke-env');
var _nukeHelper = require('nuke-helper');
var _util = require('../mods/util');
var _inputComponent = require('../mods/input-component');
var _inputComponent2 = _interopRequireDefault(_inputComponent);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
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 NoStyleInput = function (_InputComponent) {
_inherits(NoStyleInput, _InputComponent);
function NoStyleInput(props, context) {
_classCallCheck(this, NoStyleInput);
var _this = _possibleConstructorReturn(this, (NoStyleInput.__proto__ || Object.getPrototypeOf(NoStyleInput)).call(this, props));
_this.fixedFont = context.commonConfigs && context.commonConfigs.fixedFont;
if ('fixedFont' in props) {
_this.fixedFont = props.fixedFont;
}
_this.getRef = _this.getRef.bind(_this);
_this.setNativeFormatRule = _this.setNativeFormatRule.bind(_this);
_this.inputHandler = _this.inputHandler.bind(_this);
_this.returnHandler = _this.returnHandler.bind(_this);
return _this;
}
_createClass(NoStyleInput, [{
key: 'shouldComponentUpdate',
value: function shouldComponentUpdate(nextProps) {
if (nextProps.value !== null) {
return nextProps.value !== this.props.value || nextProps.readOnly !== this.props.readOnly || nextProps.type !== this.props.type || nextProps.disabled !== this.props.disabled || nextProps.maxLength !== this.props.maxLength || nextProps.placeholder !== this.props.placeholder;
}
return _typeof(nextProps.value) !== _typeof(this.props.value) || nextProps.readOnly !== this.props.readOnly || nextProps.type !== this.props.type || nextProps.disabled !== this.props.disabled || nextProps.maxLength !== this.props.maxLength || nextProps.placeholder !== this.props.placeholder;
}
}, {
key: 'setNativeFormatRule',
value: function setNativeFormatRule(rules) {
this.refs.input.setTextFormatter(rules);
}
}, {
key: 'getRef',
value: function getRef() {
return this.refs.input;
}
}, {
key: 'returnHandler',
value: function returnHandler(e) {
if (_nukeEnv.isWeb) {
if (e.keyCode === 13) {
this.trigger('onReturn', (0, _util.genEventObject)(e));
}
} else {
this.trigger('onReturn', (0, _util.genEventObject)(e));
}
}
}, {
key: 'inputHandler',
value: function inputHandler(e) {
this.trigger('onInput', (0, _util.getText)(e), (0, _util.genEventObject)(e));
}
}, {
key: 'getInputStyle',
value: function getInputStyle() {
var _props = this.props,
multiple = _props.multiple,
disabled = _props.disabled,
readOnly = _props.readOnly,
inputStyle = _props.inputStyle,
style = _props.style,
themeStyle = _props.themeStyle;
var elementStyle = Object.assign({}, themeStyle['input-inner'], themeStyle[(multiple ? 'multiple' : 'single') + '-input'], readOnly ? themeStyle.readonly : {}, disabled ? themeStyle[(multiple ? 'multiple' : 'single') + '-disabled-input'] : {}, _nukeEnv.isWeb ? themeStyle['web-normalize'] : {}, inputStyle, style);
return this.fixedFont ? (0, _nukeHelper.calcTextSize)(elementStyle) : elementStyle;
}
}, {
key: 'getValue',
value: function getValue() {
if (_nukeEnv.isWeb) {
return this.refs.input.value;
}
return this.refs.input.attr.value;
}
}, {
key: 'render',
value: function render() {
var _props2 = this.props,
value = _props2.value,
onFocus = _props2.onFocus,
onInput = _props2.onInput,
onBlur = _props2.onBlur,
readOnly = _props2.readOnly,
disabled = _props2.disabled,
_props2$style = _props2.style,
style = _props2$style === undefined ? {} : _props2$style,
maxLength = _props2.maxLength,
multiple = _props2.multiple,
returnKeyType = _props2.returnKeyType,
autoFocus = _props2.autoFocus,
fixedFont = _props2.fixedFont,
rows = _props2.rows,
type = _props2.type,
placeholderColor = _props2.placeholderColor,
others = _objectWithoutProperties(_props2, ['value', 'onFocus', 'onInput', 'onBlur', 'readOnly', 'disabled', 'style', 'maxLength', 'multiple', 'returnKeyType', 'autoFocus', 'fixedFont', 'rows', 'type', 'placeholderColor']);
var attrs = {
onChange: this.changeHandler,
onInput: this.inputHandler,
onFocus: this.focusHandler,
onBlur: this.blurHandler,
disabled: disabled,
rows: rows,
returnKeyType: returnKeyType,
maxlength: maxLength,
readOnly: readOnly,
autofocus: autoFocus,
placeholderColor: placeholderColor,
type: _nukeEnv.isWeex && multiple ? 'text' : type, // force type="text" in weex multiple mode to avoid bugs http://dotwe.org/weex/6a75d9164c4186c9a9d46b51daed6b2e
style: this.getInputStyle()
};
if ('value' in this.props) {
attrs.value = this.props.value;
}
if (_nukeEnv.isWeb) {
attrs.onKeyUp = this.returnHandler;
// keys that should not be passed
['readOnly', 'autofocus'].map(function (item) {
if (item in attrs && !attrs[item]) {
delete attrs[item];
}
});
} else {
attrs.onReturn = this.returnHandler;
attrs['data-placeholder-color'] = placeholderColor;
// in multiple mode, passing returnKeyType to weex will get single line input
if (multiple && !this.props.onReturn) {
delete attrs.onReturn;
delete attrs.returnKeyType;
}
}
var inputElement = void 0;
if (multiple) {
if (_nukeEnv.isWeb) {
inputElement = (0, _rax.createElement)(
'textarea',
_extends({}, others, attrs, { ref: 'input' }),
attrs.value
);
} else {
inputElement = (0, _rax.createElement)('textarea', _extends({}, others, attrs, { ref: 'input' }));
}
} else {
// if ('height' in elementStyle) {
// delete elementStyle.height;
// }
inputElement = (0, _rax.createElement)('input', _extends({}, others, attrs, { ref: 'input' }));
}
return inputElement;
}
}]);
return NoStyleInput;
}(_inputComponent2.default);
NoStyleInput.contextTypes = {
androidConfigs: _rax.PropTypes.any
};
exports.default = NoStyleInput;
module.exports = exports['default'];

@@ -1,1 +0,647 @@

'use strict';Object.defineProperty(exports,'__esModule',{value:!0});var _extends=Object.assign||function(target){for(var source,i=1;i<arguments.length;i++)for(var key in source=arguments[i],source)Object.prototype.hasOwnProperty.call(source,key)&&(target[key]=source[key]);return target},_createClass=function(){function defineProperties(target,props){for(var descriptor,i=0;i<props.length;i++)descriptor=props[i],descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,'value'in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}(),_rax=require('rax'),_nukeView=require('nuke-view'),_nukeView2=_interopRequireDefault(_nukeView),_nukeText=require('nuke-text'),_nukeText2=_interopRequireDefault(_nukeText),_nukeImage=require('nuke-image'),_nukeImage2=_interopRequireDefault(_nukeImage),_nukeEnv=require('nuke-env'),_util=require('../mods/util'),_inheritKeys=require('../mods/inherit-keys'),_inheritKeys2=_interopRequireDefault(_inheritKeys),_base=require('./base'),_base2=_interopRequireDefault(_base),_image=require('../mods/image'),_image2=_interopRequireDefault(_image),_placeholder=require('../mods/placeholder'),_placeholder2=_interopRequireDefault(_placeholder),_count=require('../mods/count'),_count2=_interopRequireDefault(_count),_uitls=require('../uitls');function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _objectWithoutProperties(obj,keys){var target={};for(var i in obj)0<=keys.indexOf(i)||Object.prototype.hasOwnProperty.call(obj,i)&&(target[i]=obj[i]);return target}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&&('object'==typeof call||'function'==typeof call)?call:self}function _inherits(subClass,superClass){if('function'!=typeof superClass&&null!==superClass)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:!1,writable:!0,configurable:!0}}),superClass&&(Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass)}var textlineheight=36,Input=function(_Component){function Input(props,context){_classCallCheck(this,Input);var _this=_possibleConstructorReturn(this,(Input.__proto__||Object.getPrototypeOf(Input)).call(this,props));_this.validInput=!0;var value=null;'value'in props?value=props.value:'defaultValue'in props&&(value=props.defaultValue);var count=value&&value.length||0;return _this.state={focus:!1,value:value,lines:1,inputValue:value,count:count,maxLengthError:!!props.maxLength&&count>props.maxLength},_this.materialDesign=!0,_this.fixedFont=context.commonConfigs&&context.commonConfigs.fixedFont,'fixedFont'in props&&(_this.fixedFont=props.fixedFont),_this.inputHandler=_this.inputHandler.bind(_this),_this.focusHandler=_this.focusHandler.bind(_this),_this.blurHandler=_this.blurHandler.bind(_this),_this.clearHandler=_this.clearHandler.bind(_this),_this.changeHandler=_this.changeHandler.bind(_this),_this.returnHandler=_this.returnHandler.bind(_this),_this.getRef=_this.getRef.bind(_this),_this.getValue=_this.getValue.bind(_this),_this.focus=_this.focus.bind(_this),_this.blur=_this.blur.bind(_this),_this.clear=_this.clear.bind(_this),_this.setNativeFormatRule=_this.setNativeFormatRule.bind(_this),_this}return _inherits(Input,_Component),_createClass(Input,[{key:'componentDidMount',value:function componentDidMount(){var multiple=this.props.multiple;if(_nukeEnv.isWeb&&multiple){var textarea=(0,_rax.findDOMNode)(this.refs.baseinput);this.minHeight=textarea.scrollHeight,this._webAdjustHeight(textarea)}}},{key:'componentWillReceiveProps',value:function componentWillReceiveProps(nextProps){if('value'in nextProps&&('string'==typeof nextProps.value||'number'==typeof nextProps.value)&&nextProps.value!==this.state.inputValue){this.props.type;this.setState({value:nextProps.value,inputValue:nextProps.value,count:nextProps.value.length,maxLengthError:nextProps.value.length>this.props.maxLength})}}},{key:'getTextRect',value:function getTextRect(ref){return new Promise(function(resolve,reject){var domEl=(0,_rax.findDOMNode)(ref);if(!domEl)reject(0);else if(_nukeEnv.isWeex)try{var dom=require('@weex-module/dom');dom.getComponentRect(domEl.ref,function(e){e&&e.size&&e.size.height?resolve(e.size.height.toFixed()):reject(0)})}catch(e){reject(0)}})}},{key:'setTextareaHeight',value:function setTextareaHeight(lines){this.setState({lines:lines})}},{key:'getHideElement',value:function getHideElement(hiddenStyle){var _this2=this,_props=this.props,multiple=_props.multiple,maxRows=_props.maxRows;return!multiple||_nukeEnv.isWeb?null:(0,_rax.createElement)(_nukeText2.default,{fixedFont:this.fixedFont,ref:function ref(n){_this2.multipleText=n},style:hiddenStyle,numberOfLines:maxRows},this.state.inputValue)}},{key:'_webAdjustHeight',value:function _webAdjustHeight(el){var _Mathmax=Math.max,maxRows=this.props.maxRows,outerHeight=parseInt(window.getComputedStyle(el).height,10),diff=outerHeight-el.clientHeight,autoHeight=_Mathmax(this.minHeight,el.scrollHeight+diff);el.style.height=0,el.style.height=autoHeight>this.minHeight*maxRows?this.minHeight*maxRows+'px':_Mathmax(this.minHeight,el.scrollHeight+diff)+'px'}},{key:'clearHandler',value:function clearHandler(){this.setState({value:this.state.inputValue}),this.setState({value:'',inputValue:'',count:0,maxLengthError:!1}),this.focus(),this.trigger('onClear','')}},{key:'blur',value:function blur(){this.refs.baseinput.blur()}},{key:'focus',value:function focus(){this.refs.baseinput.focus()}},{key:'getRef',value:function getRef(){return this.refs.baseinput.getRef()}},{key:'setNativeFormatRule',value:function setNativeFormatRule(rules){return this.refs.baseinput.setNativeFormatRule(rules)}},{key:'clear',value:function clear(){this.setState({value:'',inputValue:'',count:0,maxLengthError:!1}),this.trigger('onClear','')}},{key:'trigger',value:function trigger(fn){if('string'==typeof fn&&(fn=this.props[fn]),'function'==typeof fn){for(var _len=arguments.length,attrs=Array(1<_len?_len-1:0),_key=1;_key<_len;_key++)attrs[_key-1]=arguments[_key];return fn.apply(this,attrs)}}},{key:'focusHandler',value:function focusHandler(e){this.setState({focus:!0}),this.trigger('onFocus',e)}},{key:'blurHandler',value:function blurHandler(e){var type=this.props.type;'number'===type&&_nukeEnv.isWeb&&(this.validInput=(0,_uitls.isValidInput)(e.srcElement)),this.setState({focus:!1}),this.trigger('onBlur',e)}},{key:'returnHandler',value:function returnHandler(e){this.trigger('onReturn',e)}},{key:'inputHandler',value:function inputHandler(text,eventObj){var _props2=this.props,multiple=_props2.multiple,maxLength=_props2.maxLength;this.setState({inputValue:text,count:text.length,maxLengthError:!!maxLength&&text.length>maxLength}),_nukeEnv.isWeb&&multiple&&this._webAdjustHeight(eventObj.originalEvent.target),this.trigger('onInput',eventObj)}},{key:'changeHandler',value:function changeHandler(text,eventObj){var _props3=this.props,type=_props3.type,maxLength=_props3.maxLength;'date'===type||'time'===type?this.setState({inputValue:text}):this.setState({value:text,inputValue:text,count:text.length,maxLengthError:text.length>maxLength}),this.trigger('onChange',text,eventObj)}},{key:'renderPlaceholder',value:function renderPlaceholder(){var _state=this.state,focus=_state.focus,inputValue=_state.inputValue,maxLengthError=_state.maxLengthError,_props4=this.props,placeholder=_props4.placeholder,placeholderColor=_props4.placeholderColor,themeStyle=_props4.themeStyle,status=_props4.status,disabled=_props4.disabled,errorMessage=_props4.errorMessage,floatPlaceholder=_props4.floatPlaceholder,hideErrorWhenFocus=_props4.hideErrorWhenFocus,placeholderAttrs={placeholder:placeholder,placeholderColor:placeholderColor,themeStyle:themeStyle,status:status,disabled:disabled,errorMessage:errorMessage,floatPlaceholder:floatPlaceholder,hideErrorWhenFocus:hideErrorWhenFocus,focus:focus,inputValue:inputValue,validInput:this.validInput,maxLengthError:maxLengthError,fixedFont:this.fixedFont};return(0,_rax.createElement)(_placeholder2.default,placeholderAttrs)}},{key:'renderCount',value:function(){var _props5=this.props,maxLength=_props5.maxLength,multiple=_props5.multiple,renderCount=_props5.renderCount,themeStyle=_props5.themeStyle;if(!maxLength||!renderCount)return null;var count=this.state.count,countAttrs={maxLength:maxLength,multiple:multiple,renderCount:renderCount,count:count,themeStyle:themeStyle,fixedFont:this.fixedFont};return(0,_rax.createElement)(_count2.default,countAttrs)}},{key:'renderClear',value:function renderClear(styles){return(0,_rax.createElement)(_nukeImage2.default,{source:{uri:_image2.default.clear},onClick:this.clearHandler,style:styles['md-clear']})}},{key:'renderCustomIcon',value:function renderCustomIcon(styles){var _props$icon=this.props.icon,icon=void 0===_props$icon?{}:_props$icon,uri=icon.uri,_icon$onPress=icon.onPress,onPress=void 0===_icon$onPress?function(){}:_icon$onPress,_icon$style=icon.style,style=void 0===_icon$style?{}:_icon$style;return uri?(0,_rax.createElement)(_nukeView2.default,{style:[styles['md-icon'],style],onClick:onPress},(0,_rax.createElement)(_nukeImage2.default,{source:{uri:uri},style:[styles['icon-image'],style]})):null}},{key:'renderHelpLine',value:function renderHelpLine(styles){var _props6=this.props,status=_props6.status,errorMessage=_props6.errorMessage,autoAdjustHeight=_props6.autoAdjustHeight,_props6$hideErrorWhen=_props6.hideErrorWhenFocus,renderCount=_props6.renderCount,_state2=this.state,focus=_state2.focus,maxLengthError=_state2.maxLengthError,renderErrorMessage=void 0;if(renderErrorMessage=void 0!==_props6$hideErrorWhen&&_props6$hideErrorWhen?!focus&&'error'===status&&errorMessage:'error'===status&&errorMessage,!renderErrorMessage&&!renderCount&&autoAdjustHeight)return null;var errorMessageDom;return errorMessage&&('string'==typeof errorMessage?errorMessageDom=(0,_rax.createElement)(_nukeText2.default,{fixedFont:this.fixedFont,style:styles['md-error-text']},errorMessage):errorMessageDom=(0,_rax.cloneElement)(errorMessage,{style:errorMessage.props.style?Object.assign({},styles['md-error-text'],errorMessage.props.style):styles['md-error-text']})),(0,_rax.createElement)(_nukeView2.default,{"data-role":'md-help',style:styles['md-help']},renderErrorMessage?errorMessageDom:null,this.renderCount())}},{key:'getValue',value:function getValue(){return this.refs.baseinput.getValue()}},{key:'render',value:function render(){var _props7=this.props,defaultValue=_props7.defaultValue,onChange=_props7.onChange,onFocus=_props7.onFocus,onInput=_props7.onInput,onBlur=_props7.onBlur,placeholder=_props7.placeholder,renderCount=_props7.renderCount,readOnly=_props7.readOnly,disabled=_props7.disabled,_props7$style=_props7.style,style=void 0===_props7$style?{}:_props7$style,maxLength=_props7.maxLength,multiple=_props7.multiple,inputStyle=_props7.inputStyle,returnKeyType=_props7.returnKeyType,hasClear=_props7.hasClear,rows=_props7.rows,type=_props7.type,icon=_props7.icon,autoAdjustHeight=_props7.autoAdjustHeight,status=_props7.status,floatPlaceholder=_props7.floatPlaceholder,hideErrorWhenFocus=_props7.hideErrorWhenFocus,errorMessage=_props7.errorMessage,maxRows=_props7.maxRows,others=_objectWithoutProperties(_props7,['defaultValue','onChange','onFocus','onInput','onBlur','placeholder','renderCount','readOnly','disabled','style','maxLength','multiple','inputStyle','returnKeyType','hasClear','rows','type','icon','autoAdjustHeight','status','floatPlaceholder','hideErrorWhenFocus','errorMessage','maxRows']),styles=this.props.themeStyle,_state3=this.state,focus=_state3.focus,value=_state3.value,lines=_state3.lines,maxLengthError=_state3.maxLengthError,mode=multiple?'multiple':'single',MDWrapperStyle=Object.assign({},styles['input-wrap'],styles[mode+'-md-wrap'],readOnly?styles.readonly:{},floatPlaceholder?{}:styles['static-placeholder'],disabled?styles['md-'+mode+'-disabled']:{},style),mdLineStyle=Object.assign({},styles['md-line'],'error'===status?styles['md-line-error']:{},focus?styles['md-line-focus']:{});('error'===status&&!hideErrorWhenFocus||maxLengthError)&&(mdLineStyle=Object.assign(mdLineStyle,styles['md-line-error'])),disabled&&(mdLineStyle=Object.assign(mdLineStyle,styles['md-line-disabled']));var inputAttrs={onInput:this.inputHandler,onFocus:this.focusHandler,onBlur:this.blurHandler,onChange:this.changeHandler,onReturn:this.returnHandler,onResize:this.resizeHandler,multiple:multiple,disabled:disabled,readOnly:readOnly,returnKeyType:returnKeyType,maxLength:maxLength,placeholder:'',value:null===typeof value?null:value,type:type,style:multiple?styles['multiple-md-input']:styles['md-input'],inputStyle:_extends({paddingLeft:0,paddingRight:0},multiple?styles['multiple-md-input']:styles['md-input']),themeStyle:this.props.themeStyle};_nukeEnv.isWeb&&'readOnly'in inputAttrs&&!inputAttrs.readOnly&&delete inputAttrs.readOnly,multiple&&(_nukeEnv.isWeb?inputAttrs.rows=1:(inputAttrs.style.height=maxRows*textlineheight,inputAttrs.rows=maxRows)),_inheritKeys2.default.map(function(item){styles[item]&&(inputAttrs.style[item]=styles[item])});var multipleTextStyle=Object.assign({},inputAttrs.style,styles['text-for-height']);return'height'in multipleTextStyle&&delete multipleTextStyle.height,(0,_rax.createElement)(_nukeView2.default,{"data-role":'md-wrap',style:MDWrapperStyle},this.renderPlaceholder(),this.getHideElement(multipleTextStyle),(0,_rax.createElement)(_base2.default,_extends({fixedFont:this.fixedFont,ref:'baseinput'},others,inputAttrs)),(0,_rax.createElement)(_nukeView2.default,{"data-role":'md-line',style:mdLineStyle}),this.renderHelpLine(styles),hasClear?this.renderClear(styles):null,hasClear?null:this.renderCustomIcon(styles))}}]),Input}(_rax.Component);Input.propTypes={defaultValue:_rax.PropTypes.any,onFocus:_rax.PropTypes.func,onInput:_rax.PropTypes.func,onBlur:_rax.PropTypes.func,placeholder:_rax.PropTypes.string,readOnly:_rax.PropTypes.boolean,disabled:_rax.PropTypes.boolean,style:_rax.PropTypes.any,maxLength:_rax.PropTypes.number,multiple:_rax.PropTypes.boolean,inputStyle:_rax.PropTypes.any,returnKeyType:_rax.PropTypes.any,hasClear:_rax.PropTypes.boolean,rows:_rax.PropTypes.number,maxRows:_rax.PropTypes.number,type:_rax.PropTypes.oneOf(['text','url','password','tel','date','time','email']),status:_rax.PropTypes.oneOf(['success','error']),errorMessage:_rax.PropTypes.string,placeholderColor:_rax.PropTypes.string,value:_rax.PropTypes.string,themeStyle:_rax.PropTypes.any,renderCount:_rax.PropTypes.boolean,floatPlaceholder:_rax.PropTypes.boolean,hideErrorWhenFocus:_rax.PropTypes.boolean,fixedFont:_rax.PropTypes.boolean},Input.defaultProps={onFocus:function onFocus(){},onInput:function onInput(){},onBlur:function onBlur(){},placeholder:'',readOnly:!1,disabled:!1,style:{},multiple:!1,inputStyle:{},themeStyle:{},hasClear:!1,type:'text',rows:1,maxRows:3,status:'success',renderCount:!1,placeholderColor:'#999999',floatPlaceholder:!0,hideErrorWhenFocus:!0,fixedFont:!0},Input.contextTypes={androidConfigs:_rax.PropTypes.any,commonConfigs:_rax.PropTypes.any},exports.default=Input,module.exports=exports['default'];
'use strict';
/** @jsx createElement */
Object.defineProperty(exports, "__esModule", {
value: true
});
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
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 _rax = require('rax');
var _nukeView = require('nuke-view');
var _nukeView2 = _interopRequireDefault(_nukeView);
var _nukeText = require('nuke-text');
var _nukeText2 = _interopRequireDefault(_nukeText);
var _nukeImage = require('nuke-image');
var _nukeImage2 = _interopRequireDefault(_nukeImage);
var _nukeEnv = require('nuke-env');
var _util = require('../mods/util');
var _inheritKeys = require('../mods/inherit-keys');
var _inheritKeys2 = _interopRequireDefault(_inheritKeys);
var _base = require('./base');
var _base2 = _interopRequireDefault(_base);
var _image = require('../mods/image');
var _image2 = _interopRequireDefault(_image);
var _placeholder = require('../mods/placeholder');
var _placeholder2 = _interopRequireDefault(_placeholder);
var _count = require('../mods/count');
var _count2 = _interopRequireDefault(_count);
var _uitls = require('../uitls');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
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 textlineheight = 36;
var Input = function (_Component) {
_inherits(Input, _Component);
function Input(props, context) {
_classCallCheck(this, Input);
var _this = _possibleConstructorReturn(this, (Input.__proto__ || Object.getPrototypeOf(Input)).call(this, props));
_this.validInput = true;
var value = null;
if ('value' in props) {
value = props.value;
} else if ('defaultValue' in props) {
value = props.defaultValue;
}
var count = value && value.length || 0;
_this.state = {
focus: false,
value: value,
lines: 1,
inputValue: value,
count: count,
maxLengthError: props.maxLength ? count > props.maxLength : false
};
_this.materialDesign = true;
_this.fixedFont = context.commonConfigs && context.commonConfigs.fixedFont;
if ('fixedFont' in props) {
_this.fixedFont = props.fixedFont;
}
_this.inputHandler = _this.inputHandler.bind(_this);
_this.focusHandler = _this.focusHandler.bind(_this);
_this.blurHandler = _this.blurHandler.bind(_this);
_this.clearHandler = _this.clearHandler.bind(_this);
_this.changeHandler = _this.changeHandler.bind(_this);
_this.returnHandler = _this.returnHandler.bind(_this);
_this.getRef = _this.getRef.bind(_this);
_this.getValue = _this.getValue.bind(_this);
_this.focus = _this.focus.bind(_this);
_this.blur = _this.blur.bind(_this);
_this.clear = _this.clear.bind(_this);
_this.setNativeFormatRule = _this.setNativeFormatRule.bind(_this);
return _this;
}
_createClass(Input, [{
key: 'componentDidMount',
value: function componentDidMount() {
var multiple = this.props.multiple;
if (_nukeEnv.isWeb && multiple) {
var textarea = (0, _rax.findDOMNode)(this.refs.baseinput);
this.minHeight = textarea.scrollHeight; // 18
this._webAdjustHeight(textarea);
}
}
}, {
key: 'componentWillReceiveProps',
value: function componentWillReceiveProps(nextProps) {
if ('value' in nextProps && (typeof nextProps.value === 'string' || typeof nextProps.value === 'number') && nextProps.value !== this.state.inputValue) {
var type = this.props.type;
// if (type === 'number' && !isValidNumber(nextProps.value)) return;
this.setState({
value: nextProps.value,
inputValue: nextProps.value,
count: nextProps.value.length,
maxLengthError: nextProps.value.length > this.props.maxLength
});
}
}
// getRem(n) {
// return n * 750 / appInfo.deviceWidth.toFixed();
// }
}, {
key: 'getTextRect',
value: function getTextRect(ref) {
return new Promise(function (resolve, reject) {
var domEl = (0, _rax.findDOMNode)(ref);
if (domEl) {
if (_nukeEnv.isWeex) {
try {
var dom = require('@weex-module/dom');
dom.getComponentRect(domEl.ref, function (e) {
if (e && e.size && e.size.height) {
resolve(e.size.height.toFixed());
} else {
reject(0);
}
});
} catch (e) {
reject(0);
}
}
} else {
reject(0);
}
});
}
}, {
key: 'setTextareaHeight',
value: function setTextareaHeight(lines) {
this.setState({
lines: lines
});
}
}, {
key: 'getHideElement',
value: function getHideElement(hiddenStyle) {
var _this2 = this;
var _props = this.props,
multiple = _props.multiple,
maxRows = _props.maxRows;
if (!multiple || _nukeEnv.isWeb) return null;
return (0, _rax.createElement)(
_nukeText2.default,
{
fixedFont: this.fixedFont,
ref: function ref(n) {
_this2.multipleText = n;
},
style: hiddenStyle,
numberOfLines: maxRows
},
this.state.inputValue
);
}
}, {
key: '_webAdjustHeight',
value: function _webAdjustHeight(el) {
var maxRows = this.props.maxRows;
// debugger;
var outerHeight = parseInt(window.getComputedStyle(el).height, 10);
var diff = outerHeight - el.clientHeight;
var autoHeight = Math.max(this.minHeight, el.scrollHeight + diff);
el.style.height = 0;
if (autoHeight > this.minHeight * maxRows) {
el.style.height = this.minHeight * maxRows + 'px';
} else {
el.style.height = Math.max(this.minHeight, el.scrollHeight + diff) + 'px';
}
}
}, {
key: 'clearHandler',
value: function clearHandler(e) {
this.setState({
value: this.state.inputValue
});
this.setState({
value: '',
inputValue: '',
count: 0,
maxLengthError: false
});
this.focus();
this.trigger('onClear', '');
}
}, {
key: 'blur',
value: function blur() {
this.refs.baseinput.blur();
}
}, {
key: 'focus',
value: function focus() {
this.refs.baseinput.focus();
}
}, {
key: 'getRef',
value: function getRef() {
return this.refs.baseinput.getRef();
}
}, {
key: 'setNativeFormatRule',
value: function setNativeFormatRule(rules) {
return this.refs.baseinput.setNativeFormatRule(rules);
}
}, {
key: 'clear',
value: function clear() {
this.setState({
value: '',
inputValue: '',
count: 0,
maxLengthError: false
});
this.trigger('onClear', '');
}
}, {
key: 'trigger',
value: function trigger(fn) {
if (typeof fn === 'string') fn = this.props[fn];
if (!(typeof fn === 'function')) return;
for (var _len = arguments.length, attrs = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
attrs[_key - 1] = arguments[_key];
}
return fn.apply(this, attrs);
}
}, {
key: 'focusHandler',
value: function focusHandler(e) {
this.setState({
focus: true
});
this.trigger('onFocus', e);
}
}, {
key: 'blurHandler',
value: function blurHandler(e) {
var type = this.props.type;
// hack For type number useage invalid input can't get any value
if (type === 'number' && _nukeEnv.isWeb) {
this.validInput = (0, _uitls.isValidInput)(e.srcElement);
}
this.setState({
focus: false
});
this.trigger('onBlur', e);
}
}, {
key: 'returnHandler',
value: function returnHandler(e) {
this.trigger('onReturn', e);
}
}, {
key: 'inputHandler',
value: function inputHandler(text, eventObj) {
var _props2 = this.props,
multiple = _props2.multiple,
maxLength = _props2.maxLength;
this.setState({
inputValue: text,
count: text.length,
maxLengthError: maxLength ? text.length > maxLength : false
});
if (_nukeEnv.isWeb && multiple) {
// works fine;
this._webAdjustHeight(eventObj.originalEvent.target);
} else {
// works bad in weex
// this._nativeCalculateMultipleHeight();
}
this.trigger('onInput', eventObj);
}
}, {
key: 'changeHandler',
value: function changeHandler(text, eventObj) {
var _props3 = this.props,
type = _props3.type,
maxLength = _props3.maxLength;
if (type === 'date' || type === 'time') {
this.setState({
inputValue: text
});
} else {
this.setState({
value: text,
inputValue: text,
count: text.length,
maxLengthError: text.length > maxLength
});
}
this.trigger('onChange', text, eventObj);
}
}, {
key: 'renderPlaceholder',
value: function renderPlaceholder() {
var _state = this.state,
focus = _state.focus,
inputValue = _state.inputValue,
maxLengthError = _state.maxLengthError;
var _props4 = this.props,
placeholder = _props4.placeholder,
placeholderColor = _props4.placeholderColor,
themeStyle = _props4.themeStyle,
status = _props4.status,
disabled = _props4.disabled,
errorMessage = _props4.errorMessage,
floatPlaceholder = _props4.floatPlaceholder,
hideErrorWhenFocus = _props4.hideErrorWhenFocus;
var placeholderAttrs = {
placeholder: placeholder,
placeholderColor: placeholderColor,
themeStyle: themeStyle,
status: status,
disabled: disabled,
errorMessage: errorMessage,
floatPlaceholder: floatPlaceholder,
hideErrorWhenFocus: hideErrorWhenFocus,
focus: focus,
inputValue: inputValue,
validInput: this.validInput,
maxLengthError: maxLengthError,
fixedFont: this.fixedFont
};
return (0, _rax.createElement)(_placeholder2.default, placeholderAttrs);
}
}, {
key: 'renderCount',
value: function renderCount() {
var _props5 = this.props,
maxLength = _props5.maxLength,
multiple = _props5.multiple,
renderCount = _props5.renderCount,
themeStyle = _props5.themeStyle;
if (!maxLength || !renderCount) return null;
var count = this.state.count;
var countAttrs = {
maxLength: maxLength,
multiple: multiple,
renderCount: renderCount,
count: count,
themeStyle: themeStyle,
fixedFont: this.fixedFont
};
return (0, _rax.createElement)(_count2.default, countAttrs);
}
}, {
key: 'renderClear',
value: function renderClear(styles) {
return (0, _rax.createElement)(_nukeImage2.default, {
source: { uri: _image2.default.clear },
onClick: this.clearHandler,
style: styles['md-clear']
});
}
}, {
key: 'renderCustomIcon',
value: function renderCustomIcon(styles) {
var _props$icon = this.props.icon,
icon = _props$icon === undefined ? {} : _props$icon;
var uri = icon.uri,
_icon$onPress = icon.onPress,
onPress = _icon$onPress === undefined ? function () {} : _icon$onPress,
_icon$style = icon.style,
style = _icon$style === undefined ? {} : _icon$style;
if (!uri) return null;
return (0, _rax.createElement)(
_nukeView2.default,
{ style: [styles['md-icon'], style], onClick: onPress },
(0, _rax.createElement)(_nukeImage2.default, { source: { uri: uri }, style: [styles['icon-image'], style] })
);
}
}, {
key: 'renderHelpLine',
value: function renderHelpLine(styles) {
var _props6 = this.props,
status = _props6.status,
errorMessage = _props6.errorMessage,
autoAdjustHeight = _props6.autoAdjustHeight,
_props6$hideErrorWhen = _props6.hideErrorWhenFocus,
hideErrorWhenFocus = _props6$hideErrorWhen === undefined ? false : _props6$hideErrorWhen,
renderCount = _props6.renderCount;
var _state2 = this.state,
focus = _state2.focus,
maxLengthError = _state2.maxLengthError;
var renderErrorMessage = void 0;
if (hideErrorWhenFocus) {
renderErrorMessage = !focus && status === 'error' && errorMessage;
} else {
renderErrorMessage = status === 'error' && errorMessage;
}
if (!renderErrorMessage && !renderCount && autoAdjustHeight) return null;
var errorMessageDom = void 0;
if (errorMessage) {
if (typeof errorMessage === 'string') {
errorMessageDom = (0, _rax.createElement)(
_nukeText2.default,
{ fixedFont: this.fixedFont, style: styles['md-error-text'] },
errorMessage
);
} else {
errorMessageDom = (0, _rax.cloneElement)(errorMessage, {
style: errorMessage.props.style ? Object.assign({}, styles['md-error-text'], errorMessage.props.style) : styles['md-error-text']
});
}
}
return (0, _rax.createElement)(
_nukeView2.default,
{ 'data-role': 'md-help', style: styles['md-help'] },
renderErrorMessage ? errorMessageDom : null,
this.renderCount()
);
}
}, {
key: 'getValue',
value: function getValue() {
return this.refs.baseinput.getValue();
}
}, {
key: 'render',
value: function render() {
var _props7 = this.props,
defaultValue = _props7.defaultValue,
onChange = _props7.onChange,
onFocus = _props7.onFocus,
onInput = _props7.onInput,
onBlur = _props7.onBlur,
placeholder = _props7.placeholder,
renderCount = _props7.renderCount,
readOnly = _props7.readOnly,
disabled = _props7.disabled,
_props7$style = _props7.style,
style = _props7$style === undefined ? {} : _props7$style,
maxLength = _props7.maxLength,
multiple = _props7.multiple,
inputStyle = _props7.inputStyle,
returnKeyType = _props7.returnKeyType,
hasClear = _props7.hasClear,
rows = _props7.rows,
type = _props7.type,
icon = _props7.icon,
autoAdjustHeight = _props7.autoAdjustHeight,
status = _props7.status,
floatPlaceholder = _props7.floatPlaceholder,
hideErrorWhenFocus = _props7.hideErrorWhenFocus,
errorMessage = _props7.errorMessage,
maxRows = _props7.maxRows,
others = _objectWithoutProperties(_props7, ['defaultValue', 'onChange', 'onFocus', 'onInput', 'onBlur', 'placeholder', 'renderCount', 'readOnly', 'disabled', 'style', 'maxLength', 'multiple', 'inputStyle', 'returnKeyType', 'hasClear', 'rows', 'type', 'icon', 'autoAdjustHeight', 'status', 'floatPlaceholder', 'hideErrorWhenFocus', 'errorMessage', 'maxRows']);
var styles = this.props.themeStyle;
var _state3 = this.state,
focus = _state3.focus,
value = _state3.value,
lines = _state3.lines,
maxLengthError = _state3.maxLengthError;
var mode = multiple ? 'multiple' : 'single';
var MDWrapperStyle = Object.assign({}, styles['input-wrap'], styles[mode + '-md-wrap'], readOnly ? styles.readonly : {}, floatPlaceholder ? {} : styles['static-placeholder'], disabled ? styles['md-' + mode + '-disabled'] : {}, style);
var mdLineStyle = Object.assign({}, styles['md-line'], status === 'error' ? styles['md-line-error'] : {}, focus ? styles['md-line-focus'] : {});
if (status === 'error' && !hideErrorWhenFocus || maxLengthError) {
mdLineStyle = Object.assign(mdLineStyle, styles['md-line-error']);
}
if (disabled) {
mdLineStyle = Object.assign(mdLineStyle, styles['md-line-disabled']);
}
var inputAttrs = {
onInput: this.inputHandler,
onFocus: this.focusHandler,
onBlur: this.blurHandler,
onChange: this.changeHandler,
onReturn: this.returnHandler,
onResize: this.resizeHandler,
multiple: multiple,
disabled: disabled,
readOnly: readOnly,
returnKeyType: returnKeyType,
maxLength: maxLength,
placeholder: '',
value: typeof value !== null ? value : null,
type: type,
style: multiple ? styles['multiple-md-input'] : styles['md-input'],
inputStyle: _extends({
paddingLeft: 0,
paddingRight: 0
}, multiple ? styles['multiple-md-input'] : styles['md-input']),
themeStyle: this.props.themeStyle
};
if (_nukeEnv.isWeb) {
if ('readOnly' in inputAttrs && !inputAttrs.readOnly) {
delete inputAttrs.readOnly;
}
}
if (multiple) {
if (_nukeEnv.isWeb) {
inputAttrs.rows = 1;
} else {
// maxRows
// inputAttrs.rows = lines;
inputAttrs.style.height = maxRows * textlineheight;
// not adjust maxRows
inputAttrs.rows = maxRows;
}
}
_inheritKeys2.default.map(function (item) {
if (styles[item]) {
inputAttrs.style[item] = styles[item];
}
});
var multipleTextStyle = Object.assign({}, inputAttrs.style, styles['text-for-height']
// {lineHeight: textlineheight }
);
if ('height' in multipleTextStyle) {
delete multipleTextStyle.height;
}
return (0, _rax.createElement)(
_nukeView2.default,
{ 'data-role': 'md-wrap', style: MDWrapperStyle },
this.renderPlaceholder(),
this.getHideElement(multipleTextStyle),
(0, _rax.createElement)(_base2.default, _extends({
fixedFont: this.fixedFont,
ref: 'baseinput'
}, others, inputAttrs)),
(0, _rax.createElement)(_nukeView2.default, { 'data-role': 'md-line', style: mdLineStyle }),
this.renderHelpLine(styles),
hasClear ? this.renderClear(styles) : null,
!hasClear ? this.renderCustomIcon(styles) : null
);
}
}]);
return Input;
}(_rax.Component);
Input.propTypes = {
defaultValue: _rax.PropTypes.any,
onFocus: _rax.PropTypes.func,
onInput: _rax.PropTypes.func,
onBlur: _rax.PropTypes.func,
placeholder: _rax.PropTypes.string,
readOnly: _rax.PropTypes.boolean,
disabled: _rax.PropTypes.boolean,
style: _rax.PropTypes.any,
maxLength: _rax.PropTypes.number,
multiple: _rax.PropTypes.boolean,
inputStyle: _rax.PropTypes.any,
returnKeyType: _rax.PropTypes.any,
hasClear: _rax.PropTypes.boolean,
rows: _rax.PropTypes.number,
maxRows: _rax.PropTypes.number,
type: _rax.PropTypes.oneOf(['text', 'url', 'password', 'tel', 'date', 'time', 'email']),
status: _rax.PropTypes.oneOf(['success', 'error']),
errorMessage: _rax.PropTypes.string,
placeholderColor: _rax.PropTypes.string,
value: _rax.PropTypes.string,
themeStyle: _rax.PropTypes.any,
renderCount: _rax.PropTypes.boolean,
floatPlaceholder: _rax.PropTypes.boolean,
hideErrorWhenFocus: _rax.PropTypes.boolean,
fixedFont: _rax.PropTypes.boolean
};
Input.defaultProps = {
onFocus: function onFocus() {},
onInput: function onInput() {},
onBlur: function onBlur() {},
placeholder: '',
readOnly: false,
disabled: false,
style: {},
multiple: false,
inputStyle: {},
themeStyle: {},
hasClear: false,
type: 'text',
rows: 1,
maxRows: 3,
status: 'success',
renderCount: false,
placeholderColor: '#999999',
floatPlaceholder: true,
hideErrorWhenFocus: true,
fixedFont: true
};
Input.contextTypes = {
androidConfigs: _rax.PropTypes.any,
commonConfigs: _rax.PropTypes.any
};
exports.default = Input;
module.exports = exports['default'];

@@ -1,1 +0,446 @@

'use strict';Object.defineProperty(exports,'__esModule',{value:!0});var _extends=Object.assign||function(target){for(var source,i=1;i<arguments.length;i++)for(var key in source=arguments[i],source)Object.prototype.hasOwnProperty.call(source,key)&&(target[key]=source[key]);return target},_createClass=function(){function defineProperties(target,props){for(var descriptor,i=0;i<props.length;i++)descriptor=props[i],descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,'value'in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}(),_rax=require('rax'),_nukeView=require('nuke-view'),_nukeView2=_interopRequireDefault(_nukeView),_nukeText=require('nuke-text'),_nukeText2=_interopRequireDefault(_nukeText),_nukeImage=require('nuke-image'),_nukeImage2=_interopRequireDefault(_nukeImage),_nukeEnv=require('nuke-env'),_nukeHelper=require('nuke-helper'),_base=require('./base'),_base2=_interopRequireDefault(_base),_inheritKeys=require('../mods/inherit-keys'),_inheritKeys2=_interopRequireDefault(_inheritKeys),_image=require('../mods/image'),_image2=_interopRequireDefault(_image);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _objectWithoutProperties(obj,keys){var target={};for(var i in obj)0<=keys.indexOf(i)||Object.prototype.hasOwnProperty.call(obj,i)&&(target[i]=obj[i]);return target}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&&('object'==typeof call||'function'==typeof call)?call:self}function _inherits(subClass,superClass){if('function'!=typeof superClass&&null!==superClass)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:!1,writable:!0,configurable:!0}}),superClass&&(Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass)}var Input=function(_Component){function Input(props,context){_classCallCheck(this,Input);var _this=_possibleConstructorReturn(this,(Input.__proto__||Object.getPrototypeOf(Input)).call(this,props)),value=null;'value'in props?value=props.value:'defaultValue'in props&&(value=props.defaultValue);var count=value&&value.length||0;return _this.state={value:value,inputValue:value,count:value&&value.length||0,maxLengthError:count>props.maxLength},_this.fixedFont=context.commonConfigs&&context.commonConfigs.fixedFont,'fixedFont'in props&&(_this.fixedFont=props.fixedFont),_this.inputHandler=_this.inputHandler.bind(_this),_this.changeHander=_this.changeHander.bind(_this),_this.clearHandler=_this.clearHandler.bind(_this),_this.focusHandler=_this.focusHandler.bind(_this),_this.blurHandler=_this.blurHandler.bind(_this),_this.getRef=_this.getRef.bind(_this),_this.getValue=_this.getValue.bind(_this),_this.focus=_this.focus.bind(_this),_this.blur=_this.blur.bind(_this),_this.clear=_this.clear.bind(_this),_this}return _inherits(Input,_Component),_createClass(Input,[{key:'componentWillReceiveProps',value:function componentWillReceiveProps(nextProps){'value'in nextProps&&('string'==typeof nextProps.value||'number'==typeof nextProps.value)&&nextProps.value!==this.state.inputValue&&this.setState({value:nextProps.value,inputValue:nextProps.value,count:nextProps.value.length,maxLengthError:nextProps.value.length>this.props.maxLength})}},{key:'inputHandler',value:function inputHandler(text,eventObj){var maxLength=this.props.maxLength;this.setState({inputValue:text,count:text.length,maxLengthError:text.length>maxLength}),this.trigger('onInput',eventObj)}},{key:'changeHander',value:function changeHander(text,eventObj){var maxLength=this.props.maxLength;this.setState({value:text,inputValue:text,count:text.length,maxLengthError:text.length>maxLength}),this.trigger('onChange',text,eventObj)}},{key:'getInput',value:function getInput(){var _this2=this,_props=this.props,readOnly=_props.readOnly,disabled=_props.disabled,onInput=_props.onInput,onChange=_props.onChange,_props$style=_props.style,style=void 0===_props$style?{}:_props$style,_props$inputStyle=_props.inputStyle,inputStyle=void 0===_props$inputStyle?{}:_props$inputStyle,hasClear=_props.hasClear,rows=_props.rows,multiple=_props.multiple,others=_objectWithoutProperties(_props,['readOnly','disabled','onInput','onChange','style','inputStyle','hasClear','rows','multiple']),value=this.state.value,styles=this.props.themeStyle,inputAttrs=_extends({},others,{value:null===typeof value?null:value,readOnly:readOnly,multiple:multiple,style:[styles.input,inputStyle],inputStyle:hasClear?styles['input-has-clear']:{},onInput:this.inputHandler,onChange:this.changeHander,onFocus:this.focusHandler,onBlur:this.blurHandler,disabled:disabled});return _nukeEnv.isWeex?multiple&&!this.props.onReturn&&(delete inputAttrs.onReturn,delete inputAttrs.returnKeyType):!disabled&&delete inputAttrs.disabled,multiple&&(inputAttrs.rows=rows||3),_inheritKeys2.default.map(function(item){styles[item]&&(inputAttrs.style[item]=styles[item])}),(0,_rax.createElement)(_base2.default,_extends({fixedFont:this.fixedFont},inputAttrs,{ref:function ref(n){_this2.input=n}}))}},{key:'clear',value:function clear(){this.setState({value:'',count:0})}},{key:'clearHandler',value:function clearHandler(){this.setState({value:this.state.inputValue}),this.setState({value:'',inputValue:'',count:0}),this.focus(),this.trigger('onClear','')}},{key:'focusHandler',value:function focusHandler(e){this.setState({focus:!0}),this.trigger('onFocus',e)}},{key:'trigger',value:function trigger(fn){if('string'==typeof fn&&(fn=this.props[fn]),'function'==typeof fn){for(var _len=arguments.length,attrs=Array(1<_len?_len-1:0),_key=1;_key<_len;_key++)attrs[_key-1]=arguments[_key];return fn.apply(this,attrs)}}},{key:'blurHandler',value:function blurHandler(e){this.setState({focus:!1}),this.trigger('onBlur',e)}},{key:'focus',value:function focus(){this.input.focus()}},{key:'getRef',value:function getRef(){return this.input.getRef()}},{key:'blur',value:function blur(){this.input.blur()}},{key:'getValue',value:function getValue(){return this.input.getValue()}},{key:'renderClear',value:function renderClear(styles,height){var count=this.state.count;return count?(0,_rax.createElement)(_nukeView2.default,{style:[styles.clearWrap,{height:height}],onClick:this.clearHandler},(0,_rax.createElement)(_nukeImage2.default,{source:{uri:_image2.default.clear},style:styles.clear})):null}},{key:'renderCustomIcon',value:function renderCustomIcon(styles,height){var _props$icon=this.props.icon,icon=void 0===_props$icon?{}:_props$icon,uri=icon.uri,_icon$onPress=icon.onPress,onPress=void 0===_icon$onPress?function(){}:_icon$onPress,_icon$style=icon.style,style=void 0===_icon$style?{}:_icon$style;return uri?(0,_rax.createElement)(_nukeView2.default,{style:[styles.icon,{height:height},style],onClick:onPress},(0,_rax.createElement)(_nukeImage2.default,{source:{uri:uri},style:[styles['icon-image'],style]})):null}},{key:'renderCount',value:function(styles){var _props2=this.props,maxLength=_props2.maxLength,multiple=_props2.multiple,renderCount=_props2.renderCount,maxLengthError=this.state.maxLengthError;if(!maxLength||!renderCount)return null;var count=this.state.count;return(0,_rax.createElement)(_nukeView2.default,{x:'count',style:styles[''+(multiple?'multiple-count-wrap':'single-count-wrap')]},(0,_rax.createElement)(_nukeText2.default,{fixedFont:this.fixedFont,style:[styles[''+(multiple?'multiple-count-text':'single-count-text')],maxLengthError?styles['count-error']:{}]},count,' / ',maxLength))}},{key:'render',value:function render(){var _props3=this.props,readOnly=_props3.readOnly,disabled=_props3.disabled,_props3$style=_props3.style,style=void 0===_props3$style?{}:_props3$style,renderCount=_props3.renderCount,hideErrorWhenFocus=_props3.hideErrorWhenFocus,hasClear=_props3.hasClear,multiple=_props3.multiple,status=_props3.status,errorMessage=_props3.errorMessage,styles=this.props.themeStyle,_state=this.state,focus=_state.focus,maxLengthError=_state.maxLengthError,inputWrapperStyle=Object.assign({},styles['input-wrap'],styles[''+(multiple?'multiple-wrap':'single-wrap')],readOnly?styles.readonly:{},'error'===status?styles['error-input-wrap']:{},focus?styles['focus-input-wrap']:{},disabled?styles[(multiple?'multiple':'single')+'-disabled']:{},style),customHeight=inputWrapperStyle.height;('error'===status&&!hideErrorWhenFocus||maxLengthError)&&(inputWrapperStyle=Object.assign(inputWrapperStyle,styles['error-input-wrap'])),disabled&&(inputWrapperStyle=Object.assign(inputWrapperStyle,styles[(multiple?'multiple':'single')+'-disabled']));var outerStyle={};return _nukeHelper.bubbleKeys.map(function(item){item in inputWrapperStyle&&(outerStyle[item]=inputWrapperStyle[item])}),outerStyle.height&&delete outerStyle.height,outerStyle.backgroundColor&&delete outerStyle.backgroundColor,(0,_rax.createElement)(_nukeView2.default,{x:'normal-outter',style:outerStyle},(0,_rax.createElement)(_nukeView2.default,{x:'input-wrap',style:inputWrapperStyle},this.getInput()),hasClear?this.renderClear(styles,customHeight):null,hasClear?null:this.renderCustomIcon(styles,customHeight),'error'===status&&errorMessage||renderCount?(0,_rax.createElement)(_nukeView2.default,{x:'help',style:styles.help},!focus&&'error'===status&&errorMessage?(0,_rax.createElement)(_nukeText2.default,{fixedFont:this.fixedFont,style:styles['error-text']},errorMessage):null,this.renderCount(styles)):null)}}]),Input}(_rax.Component);Input.propTypes={defaultValue:_rax.PropTypes.any,onFocus:_rax.PropTypes.func,onInput:_rax.PropTypes.func,onBlur:_rax.PropTypes.func,onReturn:_rax.PropTypes.func,placeholder:_rax.PropTypes.string,readOnly:_rax.PropTypes.boolean,disabled:_rax.PropTypes.boolean,style:_rax.PropTypes.any,maxLength:_rax.PropTypes.number,multiple:_rax.PropTypes.boolean,inputStyle:_rax.PropTypes.any,returnKeyType:_rax.PropTypes.any,hasClear:_rax.PropTypes.boolean,rows:_rax.PropTypes.number,maxRows:_rax.PropTypes.number,type:_rax.PropTypes.oneOf(['text','url','password','tel','date','time','email']),status:_rax.PropTypes.oneOf(['success','error']),errorMessage:_rax.PropTypes.string,renderCount:_rax.PropTypes.boolean,value:_rax.PropTypes.string,themeStyle:_rax.PropTypes.any,hideErrorWhenFocus:_rax.PropTypes.boolean},Input.defaultProps={onFocus:function onFocus(){},onInput:function onInput(){},onBlur:function onBlur(){},onReturn:function onReturn(){},placeholder:'',readOnly:!1,disabled:!1,style:{},multiple:!1,inputStyle:{},hasClear:!1,type:'text',status:'success',themeStyle:{},renderCount:!1,placeholderColor:'#999999',hideErrorWhenFocus:!0},Input.contextTypes={androidConfigs:_rax.PropTypes.any,commonConfigs:_rax.PropTypes.any},exports.default=Input,module.exports=exports['default'];
'use strict';
/** @jsx createElement */
Object.defineProperty(exports, "__esModule", {
value: true
});
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
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 _rax = require('rax');
var _nukeView = require('nuke-view');
var _nukeView2 = _interopRequireDefault(_nukeView);
var _nukeText = require('nuke-text');
var _nukeText2 = _interopRequireDefault(_nukeText);
var _nukeImage = require('nuke-image');
var _nukeImage2 = _interopRequireDefault(_nukeImage);
var _nukeEnv = require('nuke-env');
var _nukeHelper = require('nuke-helper');
var _base = require('./base');
var _base2 = _interopRequireDefault(_base);
var _inheritKeys = require('../mods/inherit-keys');
var _inheritKeys2 = _interopRequireDefault(_inheritKeys);
var _image = require('../mods/image');
var _image2 = _interopRequireDefault(_image);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
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 Input = function (_Component) {
_inherits(Input, _Component);
function Input(props, context) {
_classCallCheck(this, Input);
var _this = _possibleConstructorReturn(this, (Input.__proto__ || Object.getPrototypeOf(Input)).call(this, props));
var value = null;
if ('value' in props) {
value = props.value;
} else if ('defaultValue' in props) {
value = props.defaultValue;
}
var count = value && value.length || 0;
_this.state = {
value: value,
inputValue: value,
count: value && value.length || 0,
maxLengthError: count > props.maxLength
};
_this.fixedFont = context.commonConfigs && context.commonConfigs.fixedFont;
if ('fixedFont' in props) {
_this.fixedFont = props.fixedFont;
}
_this.inputHandler = _this.inputHandler.bind(_this);
_this.changeHander = _this.changeHander.bind(_this);
_this.clearHandler = _this.clearHandler.bind(_this);
_this.focusHandler = _this.focusHandler.bind(_this);
_this.blurHandler = _this.blurHandler.bind(_this);
_this.getRef = _this.getRef.bind(_this);
_this.getValue = _this.getValue.bind(_this);
_this.focus = _this.focus.bind(_this);
_this.blur = _this.blur.bind(_this);
_this.clear = _this.clear.bind(_this);
return _this;
}
_createClass(Input, [{
key: 'componentWillReceiveProps',
value: function componentWillReceiveProps(nextProps) {
if ('value' in nextProps && (typeof nextProps.value === 'string' || typeof nextProps.value === 'number') && nextProps.value !== this.state.inputValue) {
this.setState({
value: nextProps.value,
inputValue: nextProps.value,
count: nextProps.value.length,
maxLengthError: nextProps.value.length > this.props.maxLength
});
}
}
}, {
key: 'inputHandler',
value: function inputHandler(text, eventObj) {
var maxLength = this.props.maxLength;
this.setState({
// value: text,
inputValue: text,
count: text.length,
maxLengthError: text.length > maxLength
});
this.trigger('onInput', eventObj);
}
}, {
key: 'changeHander',
value: function changeHander(text, eventObj) {
var maxLength = this.props.maxLength;
this.setState({
value: text,
inputValue: text,
count: text.length,
maxLengthError: text.length > maxLength
});
this.trigger('onChange', text, eventObj);
}
}, {
key: 'getInput',
value: function getInput() {
var _this2 = this;
var _props = this.props,
readOnly = _props.readOnly,
disabled = _props.disabled,
onInput = _props.onInput,
onChange = _props.onChange,
_props$style = _props.style,
style = _props$style === undefined ? {} : _props$style,
_props$inputStyle = _props.inputStyle,
inputStyle = _props$inputStyle === undefined ? {} : _props$inputStyle,
hasClear = _props.hasClear,
rows = _props.rows,
multiple = _props.multiple,
others = _objectWithoutProperties(_props, ['readOnly', 'disabled', 'onInput', 'onChange', 'style', 'inputStyle', 'hasClear', 'rows', 'multiple']);
var value = this.state.value;
var styles = this.props.themeStyle;
var inputAttrs = _extends({}, others, {
value: typeof value !== null ? value : null,
readOnly: readOnly,
multiple: multiple,
style: [styles.input, inputStyle],
inputStyle: hasClear ? styles['input-has-clear'] : {},
onInput: this.inputHandler,
onChange: this.changeHander,
onFocus: this.focusHandler,
onBlur: this.blurHandler,
disabled: disabled
});
if (_nukeEnv.isWeex) {
// 如果是多行文本,添加 returnKeyType 会导致无法换换
if (multiple && !this.props.onReturn) {
delete inputAttrs.onReturn;
delete inputAttrs.returnKeyType;
}
} else if (!disabled) {
delete inputAttrs.disabled;
}
if (multiple) {
inputAttrs.rows = rows || 3;
}
_inheritKeys2.default.map(function (item) {
if (styles[item]) {
inputAttrs.style[item] = styles[item];
}
});
return (0, _rax.createElement)(_base2.default, _extends({
fixedFont: this.fixedFont
}, inputAttrs, {
ref: function ref(n) {
_this2.input = n;
}
}));
}
}, {
key: 'clear',
value: function clear() {
this.setState({
value: '',
count: 0
});
}
}, {
key: 'clearHandler',
value: function clearHandler(e) {
this.setState({
value: this.state.inputValue
});
this.setState({
value: '',
inputValue: '',
count: 0
});
this.focus();
this.trigger('onClear', '');
}
}, {
key: 'focusHandler',
value: function focusHandler(e) {
this.setState({
focus: true
});
this.trigger('onFocus', e);
}
}, {
key: 'trigger',
value: function trigger(fn) {
if (typeof fn === 'string') fn = this.props[fn];
if (!(typeof fn === 'function')) return;
for (var _len = arguments.length, attrs = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
attrs[_key - 1] = arguments[_key];
}
return fn.apply(this, attrs);
}
}, {
key: 'blurHandler',
value: function blurHandler(e) {
this.setState({
focus: false
});
this.trigger('onBlur', e);
}
}, {
key: 'focus',
value: function focus() {
this.input.focus();
}
}, {
key: 'getRef',
value: function getRef() {
return this.input.getRef();
}
}, {
key: 'blur',
value: function blur() {
this.input.blur();
}
}, {
key: 'getValue',
value: function getValue() {
return this.input.getValue();
}
}, {
key: 'renderClear',
value: function renderClear(styles, height) {
var count = this.state.count;
return count ? (0, _rax.createElement)(
_nukeView2.default,
{ style: [styles.clearWrap, { height: height }], onClick: this.clearHandler },
(0, _rax.createElement)(_nukeImage2.default, {
source: { uri: _image2.default.clear }
// onClick={this.clearHandler}
, style: styles.clear
})
) : null;
}
}, {
key: 'renderCustomIcon',
value: function renderCustomIcon(styles, height) {
var _props$icon = this.props.icon,
icon = _props$icon === undefined ? {} : _props$icon;
var uri = icon.uri,
_icon$onPress = icon.onPress,
onPress = _icon$onPress === undefined ? function () {} : _icon$onPress,
_icon$style = icon.style,
style = _icon$style === undefined ? {} : _icon$style;
if (!uri) return null;
return (0, _rax.createElement)(
_nukeView2.default,
{ style: [styles.icon, { height: height }, style], onClick: onPress },
(0, _rax.createElement)(_nukeImage2.default, { source: { uri: uri }, style: [styles['icon-image'], style] })
);
}
}, {
key: 'renderCount',
value: function renderCount(styles) {
var _props2 = this.props,
maxLength = _props2.maxLength,
multiple = _props2.multiple,
renderCount = _props2.renderCount;
var maxLengthError = this.state.maxLengthError;
if (!maxLength || !renderCount) return null;
var count = this.state.count;
return (0, _rax.createElement)(
_nukeView2.default,
{
x: 'count',
style: styles['' + (multiple ? 'multiple-count-wrap' : 'single-count-wrap')]
},
(0, _rax.createElement)(
_nukeText2.default,
{
fixedFont: this.fixedFont,
style: [styles['' + (multiple ? 'multiple-count-text' : 'single-count-text')], maxLengthError ? styles['count-error'] : {}]
},
count,
' / ',
maxLength
)
);
}
}, {
key: 'render',
value: function render() {
var _props3 = this.props,
readOnly = _props3.readOnly,
disabled = _props3.disabled,
_props3$style = _props3.style,
style = _props3$style === undefined ? {} : _props3$style,
renderCount = _props3.renderCount,
hideErrorWhenFocus = _props3.hideErrorWhenFocus,
hasClear = _props3.hasClear,
multiple = _props3.multiple,
status = _props3.status,
errorMessage = _props3.errorMessage;
var styles = this.props.themeStyle;
var _state = this.state,
focus = _state.focus,
maxLengthError = _state.maxLengthError;
var inputWrapperStyle = Object.assign({}, styles['input-wrap'], styles['' + (multiple ? 'multiple-wrap' : 'single-wrap')], readOnly ? styles.readonly : {}, status === 'error' ? styles['error-input-wrap'] : {}, focus ? styles['focus-input-wrap'] : {}, disabled ? styles[(multiple ? 'multiple' : 'single') + '-disabled'] : {}, style);
var customHeight = inputWrapperStyle.height;
// debugger;
if (status === 'error' && !hideErrorWhenFocus || maxLengthError) {
inputWrapperStyle = Object.assign(inputWrapperStyle, styles['error-input-wrap']);
}
if (disabled) {
inputWrapperStyle = Object.assign(inputWrapperStyle, styles[(multiple ? 'multiple' : 'single') + '-disabled']);
}
var outerStyle = {};
_nukeHelper.bubbleKeys.map(function (item) {
if (item in inputWrapperStyle) {
outerStyle[item] = inputWrapperStyle[item];
}
});
if (outerStyle.height) {
delete outerStyle.height;
}
if (outerStyle.backgroundColor) {
delete outerStyle.backgroundColor;
}
// console.log(inputWrapperStyle)
return (0, _rax.createElement)(
_nukeView2.default,
{ x: 'normal-outter', style: outerStyle },
(0, _rax.createElement)(
_nukeView2.default,
{ x: 'input-wrap', style: inputWrapperStyle },
this.getInput()
),
hasClear ? this.renderClear(styles, customHeight) : null,
!hasClear ? this.renderCustomIcon(styles, customHeight) : null,
status === 'error' && errorMessage || renderCount ? (0, _rax.createElement)(
_nukeView2.default,
{ x: 'help', style: styles.help },
!focus && status === 'error' && errorMessage ? (0, _rax.createElement)(
_nukeText2.default,
{ fixedFont: this.fixedFont, style: styles['error-text'] },
errorMessage
) : null,
this.renderCount(styles)
) : null
);
}
}]);
return Input;
}(_rax.Component);
Input.propTypes = {
defaultValue: _rax.PropTypes.any,
onFocus: _rax.PropTypes.func,
onInput: _rax.PropTypes.func,
onBlur: _rax.PropTypes.func,
onReturn: _rax.PropTypes.func,
placeholder: _rax.PropTypes.string,
readOnly: _rax.PropTypes.boolean,
disabled: _rax.PropTypes.boolean,
style: _rax.PropTypes.any,
maxLength: _rax.PropTypes.number,
multiple: _rax.PropTypes.boolean,
inputStyle: _rax.PropTypes.any,
returnKeyType: _rax.PropTypes.any,
hasClear: _rax.PropTypes.boolean,
rows: _rax.PropTypes.number,
maxRows: _rax.PropTypes.number,
type: _rax.PropTypes.oneOf(['text', 'url', 'password', 'tel', 'date', 'time', 'email']),
status: _rax.PropTypes.oneOf(['success', 'error']),
errorMessage: _rax.PropTypes.string,
renderCount: _rax.PropTypes.boolean,
value: _rax.PropTypes.string,
themeStyle: _rax.PropTypes.any,
hideErrorWhenFocus: _rax.PropTypes.boolean
};
Input.defaultProps = {
onFocus: function onFocus() {},
onInput: function onInput() {},
onBlur: function onBlur() {},
onReturn: function onReturn() {},
placeholder: '',
readOnly: false,
disabled: false,
style: {},
multiple: false,
inputStyle: {},
hasClear: false,
type: 'text',
status: 'success',
themeStyle: {},
renderCount: false,
placeholderColor: '#999999',
hideErrorWhenFocus: true
};
Input.contextTypes = {
androidConfigs: _rax.PropTypes.any,
commonConfigs: _rax.PropTypes.any
};
exports.default = Input;
module.exports = exports['default'];

@@ -1,1 +0,100 @@

'use strict';Object.defineProperty(exports,'__esModule',{value:!0});var _extends=Object.assign||function(target){for(var source,i=1;i<arguments.length;i++)for(var key in source=arguments[i],source)Object.prototype.hasOwnProperty.call(source,key)&&(target[key]=source[key]);return target},_createClass=function(){function defineProperties(target,props){for(var descriptor,i=0;i<props.length;i++)descriptor=props[i],descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,'value'in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}(),_rax=require('rax'),_nukeThemeProvider=require('nuke-theme-provider'),_styles=require('./styles'),_styles2=_interopRequireDefault(_styles),_material=require('./view/material'),_material2=_interopRequireDefault(_material),_normal=require('./view/normal'),_normal2=_interopRequireDefault(_normal);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&&('object'==typeof call||'function'==typeof call)?call:self}function _inherits(subClass,superClass){if('function'!=typeof superClass&&null!==superClass)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:!1,writable:!0,configurable:!0}}),superClass&&(Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass)}var Input=function(_Component){function Input(props,context){_classCallCheck(this,Input);var _this=_possibleConstructorReturn(this,(Input.__proto__||Object.getPrototypeOf(Input)).call(this,props));return _this.focus=_this.focus.bind(_this),_this.blur=_this.blur.bind(_this),_this.clear=_this.blur.bind(_this),_this.getRef=_this.getRef.bind(_this),_this.getValue=_this.getValue.bind(_this),_this.materialDesign=context.androidConfigs&&context.androidConfigs.materialDesign,'materialDesign'in props&&(_this.materialDesign=props.materialDesign),_this}return _inherits(Input,_Component),_createClass(Input,[{key:'focus',value:function focus(){this.refs.baseinput.focus()}},{key:'blur',value:function blur(){this.refs.baseinput.blur()}},{key:'clear',value:function clear(){this.refs.baseinput.clear()}},{key:'getValue',value:function getValue(){return this.refs.baseinput.getValue()}},{key:'getRef',value:function getRef(){return this.refs.baseinput.getRef()}},{key:'render',value:function render(){return this.materialDesign?(0,_rax.createElement)(_material2.default,_extends({ref:'baseinput'},this.props)):(0,_rax.createElement)(_normal2.default,_extends({ref:'baseinput'},this.props))}}]),Input}(_rax.Component);Input.contextTypes={androidConfigs:_rax.PropTypes.any,commonConfigs:_rax.PropTypes.any},Input.displayName='Input';var StyledInput=(0,_nukeThemeProvider.connectStyle)(_styles2.default,{withRef:!0})(Input);exports.default=StyledInput,module.exports=exports['default'];
'use strict';
/** @jsx createElement */
Object.defineProperty(exports, "__esModule", {
value: true
});
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
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 _rax = require('rax');
var _nukeThemeProvider = require('nuke-theme-provider');
var _styles = require('./styles');
var _styles2 = _interopRequireDefault(_styles);
var _material = require('./view/material');
var _material2 = _interopRequireDefault(_material);
var _normal = require('./view/normal');
var _normal2 = _interopRequireDefault(_normal);
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 Input = function (_Component) {
_inherits(Input, _Component);
function Input(props, context) {
_classCallCheck(this, Input);
var _this = _possibleConstructorReturn(this, (Input.__proto__ || Object.getPrototypeOf(Input)).call(this, props));
_this.focus = _this.focus.bind(_this);
_this.blur = _this.blur.bind(_this);
_this.clear = _this.blur.bind(_this);
_this.getRef = _this.getRef.bind(_this);
_this.getValue = _this.getValue.bind(_this);
_this.materialDesign = context.androidConfigs && context.androidConfigs.materialDesign;
if ('materialDesign' in props) {
_this.materialDesign = props.materialDesign;
}
return _this;
}
_createClass(Input, [{
key: 'focus',
value: function focus() {
this.refs.baseinput.focus();
}
}, {
key: 'blur',
value: function blur() {
this.refs.baseinput.blur();
}
}, {
key: 'clear',
value: function clear() {
this.refs.baseinput.clear();
}
}, {
key: 'getValue',
value: function getValue() {
return this.refs.baseinput.getValue();
}
}, {
key: 'getRef',
value: function getRef() {
return this.refs.baseinput.getRef();
}
}, {
key: 'render',
value: function render() {
return this.materialDesign ? (0, _rax.createElement)(_material2.default, _extends({ ref: 'baseinput' }, this.props)) : (0, _rax.createElement)(_normal2.default, _extends({ ref: 'baseinput' }, this.props));
}
}]);
return Input;
}(_rax.Component);
Input.contextTypes = {
androidConfigs: _rax.PropTypes.any,
commonConfigs: _rax.PropTypes.any
};
Input.displayName = 'Input';
var StyledInput = (0, _nukeThemeProvider.connectStyle)(_styles2.default, { withRef: true })(Input);
exports.default = StyledInput;
module.exports = exports['default'];

24

package.json
{
"name": "nuke-input",
"version": "2.1.10",
"version": "2.2.2",
"description": "输入框",

@@ -28,9 +28,9 @@ "main": "lib/index",

"dependencies": {
"nuke-core": "^2.1.10",
"nuke-env": "^2.1.10",
"nuke-helper": "^2.1.10",
"nuke-image": "^2.1.10",
"nuke-text": "^2.1.10",
"nuke-theme-provider": "^2.1.10",
"nuke-view": "^2.1.10"
"nuke-core": "^2.2.2",
"nuke-env": "^2.2.2",
"nuke-helper": "^2.2.2",
"nuke-image": "^2.2.2",
"nuke-text": "^2.2.2",
"nuke-theme-provider": "^2.2.2",
"nuke-view": "^2.2.2"
},

@@ -49,5 +49,5 @@ "devDependencies": {

"mocha": "^3.4.2",
"nuke-button": "^2.1.10",
"nuke-icon": "^2.1.10",
"nuke-page": "^2.1.10",
"nuke-button": "^2.2.2",
"nuke-icon": "^2.2.2",
"nuke-page": "^2.2.2",
"resemblejs-node": "^1.0.0",

@@ -60,3 +60,3 @@ "webdriver-keycode": "^1.0.3"

"license": "Apache",
"gitHead": "3f456cd7f92241938769ceee9057f543a2034fd1"
"gitHead": "ffcb4269489cb30dfded592190c4997ff2376c18"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc