shineout 1.11.7 → 1.11.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,6 +4,7 @@ import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized
4
4
  import React from 'react';
5
5
  import PropTypes from 'prop-types';
6
6
  import classnames from 'classnames';
7
+ import config from '../config';
7
8
  import Textarea from '../Textarea';
8
9
  import Input from '../Input';
9
10
  import Popover from '../Popover';
@@ -67,11 +68,28 @@ function (_React$PureComponent) {
67
68
  };
68
69
 
69
70
  _proto.onBlur = function onBlur(e) {
70
- var onBlur = this.props.onBlur;
71
+ var _this$props = this.props,
72
+ onBlur = _this$props.onBlur,
73
+ forceChange = _this$props.forceChange;
71
74
  this.hidePop();
75
+ var newValue = e.target.value;
76
+
77
+ if (this.getTrim()) {
78
+ newValue = newValue.trim();
79
+ e.target.value = newValue;
80
+ }
81
+
82
+ forceChange(newValue);
72
83
  if (typeof onBlur === 'function') onBlur(e);
73
84
  };
74
85
 
86
+ _proto.getTrim = function getTrim() {
87
+ var trim = this.props.trim;
88
+ if (trim !== undefined) return trim;
89
+ if (config.trim !== undefined) return config.trim;
90
+ return false;
91
+ };
92
+
75
93
  _proto.getErrorProps = function getErrorProps() {
76
94
  var p = {};
77
95
  if ('error' in this.props) p.error = this.props.error;
@@ -109,13 +127,13 @@ function (_React$PureComponent) {
109
127
 
110
128
  _proto.renderTextarea = function renderTextarea() {
111
129
  var showTextarea = this.state.showTextarea;
112
- var _this$props = this.props,
113
- placeholder = _this$props.placeholder,
114
- maxHeight = _this$props.maxHeight,
115
- value = _this$props.value,
116
- innerTitle = _this$props.innerTitle,
117
- placeTitle = _this$props.placeTitle,
118
- renderFooter = _this$props.renderFooter;
130
+ var _this$props2 = this.props,
131
+ placeholder = _this$props2.placeholder,
132
+ maxHeight = _this$props2.maxHeight,
133
+ value = _this$props2.value,
134
+ innerTitle = _this$props2.innerTitle,
135
+ placeTitle = _this$props2.placeTitle,
136
+ renderFooter = _this$props2.renderFooter;
119
137
  if (!showTextarea) return null;
120
138
  return React.createElement("div", {
121
139
  ref: this.bindContainer
@@ -137,14 +155,14 @@ function (_React$PureComponent) {
137
155
  };
138
156
 
139
157
  _proto.renderResult = function renderResult() {
140
- var _this$props2 = this.props,
141
- placeholder = _this$props2.placeholder,
142
- disabled = _this$props2.disabled,
143
- value = _this$props2.value,
144
- renderResult = _this$props2.renderResult,
145
- placeTitle = _this$props2.placeTitle,
146
- innerTitle = _this$props2.innerTitle,
147
- error = _this$props2.error;
158
+ var _this$props3 = this.props,
159
+ placeholder = _this$props3.placeholder,
160
+ disabled = _this$props3.disabled,
161
+ value = _this$props3.value,
162
+ renderResult = _this$props3.renderResult,
163
+ placeTitle = _this$props3.placeTitle,
164
+ innerTitle = _this$props3.innerTitle,
165
+ error = _this$props3.error;
148
166
  var result = renderResult(value);
149
167
  return React.createElement("div", {
150
168
  tabIndex: disabled ? undefined : 0,
@@ -163,12 +181,12 @@ function (_React$PureComponent) {
163
181
  };
164
182
 
165
183
  _proto.renderInput = function renderInput() {
166
- var _this$props3 = this.props,
167
- placeholder = _this$props3.placeholder,
168
- disabled = _this$props3.disabled,
169
- value = _this$props3.value,
170
- innerTitle = _this$props3.innerTitle,
171
- placeTitle = _this$props3.placeTitle;
184
+ var _this$props4 = this.props,
185
+ placeholder = _this$props4.placeholder,
186
+ disabled = _this$props4.disabled,
187
+ value = _this$props4.value,
188
+ innerTitle = _this$props4.innerTitle,
189
+ placeTitle = _this$props4.placeTitle;
172
190
  return React.createElement(Input, _extends({
173
191
  innerTitle: innerTitle,
174
192
  placeTitle: placeTitle,
@@ -194,14 +212,14 @@ function (_React$PureComponent) {
194
212
 
195
213
  _proto.render = function render() {
196
214
  var showTextarea = this.state.showTextarea;
197
- var _this$props4 = this.props,
198
- width = _this$props4.width,
199
- style = _this$props4.style,
200
- className = _this$props4.className,
201
- bordered = _this$props4.bordered,
202
- clearable = _this$props4.clearable,
203
- getPopupContainer = _this$props4.getPopupContainer,
204
- value = _this$props4.value;
215
+ var _this$props5 = this.props,
216
+ width = _this$props5.width,
217
+ style = _this$props5.style,
218
+ className = _this$props5.className,
219
+ bordered = _this$props5.bordered,
220
+ clearable = _this$props5.clearable,
221
+ getPopupContainer = _this$props5.getPopupContainer,
222
+ value = _this$props5.value;
205
223
  var cls = classnames(className, editableAreaClass('_', !bordered && 'none-bordered'));
206
224
  var ms = Object.assign({
207
225
  width: width
@@ -250,6 +268,8 @@ Editable.propTypes = {
250
268
  renderFooter: PropTypes.func,
251
269
  renderResult: PropTypes.func,
252
270
  onShowTextareaChange: PropTypes.func,
253
- error: PropTypes.object
271
+ error: PropTypes.object,
272
+ trim: PropTypes.bool,
273
+ forceChange: PropTypes.func
254
274
  };
255
275
  export default Editable;
@@ -1,8 +1,7 @@
1
1
  import { compose } from '../utils/func';
2
2
  import delay from '../hoc/delay';
3
- import trim from '../hoc/trim';
4
3
  import inputable from '../Form/inputable';
5
4
  import Component from './EditableArea';
6
- var EditableArea = compose(inputable, delay(400), trim)(Component);
5
+ var EditableArea = compose(inputable, delay(400))(Component);
7
6
  EditableArea.displayName = 'ShineoutEditableArea';
8
7
  export default EditableArea;
package/es/Input/Input.js CHANGED
@@ -6,6 +6,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
6
6
  import React, { PureComponent } from 'react';
7
7
  import PropTypes from 'prop-types';
8
8
  import classnames from 'classnames';
9
+ import config from '../config';
9
10
  import { inputTitleClass } from '../InputTitle/styles';
10
11
  import cleanProps from '../utils/cleanProps';
11
12
  import Clear from './clear';
@@ -39,6 +40,13 @@ function (_PureComponent) {
39
40
  return new Error(text);
40
41
  });
41
42
 
43
+ _defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "getTrim", function () {
44
+ var trim = _this.props.trim;
45
+ if (trim !== undefined) return trim;
46
+ if (config.trim !== undefined) return config.trim;
47
+ return false;
48
+ });
49
+
42
50
  _this.enterLock = false;
43
51
  _this.handleChange = _this.handleChange.bind(_assertThisInitialized(_assertThisInitialized(_this)));
44
52
  _this.handleKeyDown = _this.handleKeyDown.bind(_assertThisInitialized(_assertThisInitialized(_this)));
@@ -185,13 +193,19 @@ function (_PureComponent) {
185
193
  var value = e.target.value;
186
194
  var _this$props6 = this.props,
187
195
  forceChange = _this$props6.forceChange,
196
+ onChange = _this$props6.onChange,
188
197
  onBlur = _this$props6.onBlur,
189
- clearToUndefined = _this$props6.clearToUndefined,
190
- cancelChange = _this$props6.cancelChange;
191
- if (cancelChange) cancelChange();
198
+ clearToUndefined = _this$props6.clearToUndefined;
192
199
  var newVal = this.fixValue(value);
193
- var isChange = !(clearToUndefined && newVal === '' && this.props.value === undefined);
194
- if (isChange && forceChange && !this.invalidNumber(newVal)) forceChange(newVal);
200
+ var shouldKeepUndefined = clearToUndefined && newVal === '' && this.props.value === undefined;
201
+
202
+ if (!shouldKeepUndefined && !this.invalidNumber(newVal)) {
203
+ if (this.getTrim()) newVal = newVal.trim();
204
+ var change = forceChange || onChange;
205
+ change(newVal);
206
+ e.target.value = newVal;
207
+ }
208
+
195
209
  if (onBlur) onBlur(e);
196
210
  };
197
211
 
@@ -290,7 +304,6 @@ Input.propTypes = {
290
304
  htmlName: PropTypes.string,
291
305
  onBlur: PropTypes.func,
292
306
  onChange: PropTypes.func.isRequired,
293
- cancelChange: PropTypes.func,
294
307
  onEnterPress: PropTypes.func,
295
308
  type: PropTypes.string,
296
309
  value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
@@ -304,7 +317,8 @@ Input.propTypes = {
304
317
  inputFocus: PropTypes.bool,
305
318
  clearToUndefined: PropTypes.bool,
306
319
  placeholder: PropTypes.string,
307
- coin: PropTypes.bool
320
+ coin: PropTypes.bool,
321
+ trim: PropTypes.bool
308
322
  };
309
323
  Input.defaultProps = {
310
324
  type: 'text'
package/es/Input/index.js CHANGED
@@ -2,13 +2,12 @@ import { compose } from '../utils/func';
2
2
  import inputable from '../Form/inputable';
3
3
  import inputBorder from '../hoc/inputBorder';
4
4
  import delay from '../hoc/delay';
5
- import trim from '../hoc/trim';
6
5
  import coin from '../hoc/coin';
7
6
  import Input from './Input';
8
7
  import Number from './Number';
9
8
  import Group from './Group';
10
9
  import Password from './Password';
11
- var exports = compose(inputable, inputBorder({}), delay(400), trim, coin('input'))(Input);
10
+ var exports = compose(inputable, inputBorder({}), delay(400), coin('input'))(Input);
12
11
  exports.Group = inputBorder({
13
12
  tag: 'div',
14
13
  isGroup: true,
@@ -6,7 +6,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
6
6
  import React from 'react';
7
7
  import PropTypes from 'prop-types';
8
8
  import classnames from 'classnames';
9
- import { isRTL } from '../config';
9
+ import config, { isRTL } from '../config';
10
10
  import { PureComponent } from '../component';
11
11
  import { inputClass } from '../Input/styles';
12
12
  import cleanProps from '../utils/cleanProps';
@@ -55,6 +55,13 @@ function (_PureComponent) {
55
55
  if (this.props.autosize && prevProps.value !== this.props.value) this.resize(this.props.value);
56
56
  };
57
57
 
58
+ _proto.getTrim = function getTrim() {
59
+ var trim = this.props.trim;
60
+ if (trim !== undefined) return trim;
61
+ if (config.trim !== undefined) return config.trim;
62
+ return false;
63
+ };
64
+
58
65
  _proto.bindShadow = function bindShadow(el) {
59
66
  this.shadow = el;
60
67
  };
@@ -84,12 +91,18 @@ function (_PureComponent) {
84
91
  };
85
92
 
86
93
  _proto.handleBlur = function handleBlur(e) {
87
- var value = e.target.value;
94
+ var newValue = e.target.value;
88
95
  var _this$props = this.props,
89
96
  forceChange = _this$props.forceChange,
90
97
  onBlur = _this$props.onBlur;
98
+
99
+ if (this.getTrim()) {
100
+ newValue = newValue.trim();
101
+ e.target.value = newValue;
102
+ }
103
+
104
+ forceChange(newValue);
91
105
  if (onBlur) onBlur(e);
92
- forceChange(value);
93
106
  };
94
107
 
95
108
  _proto.renderFooter = function renderFooter() {
@@ -190,7 +203,8 @@ Textarea.propTypes = {
190
203
  renderFooter: PropTypes.func,
191
204
  innerTitle: PropTypes.node,
192
205
  inputFocus: PropTypes.bool,
193
- placeTitle: PropTypes.node
206
+ placeTitle: PropTypes.node,
207
+ trim: PropTypes.bool
194
208
  };
195
209
  Textarea.defaultProps = {
196
210
  rows: 4,
@@ -1,6 +1,5 @@
1
1
  import { compose } from '../utils/func';
2
2
  import delay from '../hoc/delay';
3
- import trim from '../hoc/trim';
4
3
  import inputable from '../Form/inputable';
5
4
  import inputBorder from '../hoc/inputBorder';
6
5
  import Component from './Textarea';
@@ -17,7 +16,7 @@ var input = compose(inputable, inputBorder({
17
16
 
18
17
  return footer && inputClass('with-footer');
19
18
  }
20
- }), delay(400), trim);
19
+ }), delay(400));
21
20
  var Textarea = input(Component);
22
21
  Textarea.displayName = 'ShineoutTextarea';
23
22
  export default Textarea;
package/es/hoc/delay.js CHANGED
@@ -81,6 +81,7 @@ export default curry(function (defaultDelay, Origin) {
81
81
  _proto.forceChange = function forceChange(value) {
82
82
  var _this$props2;
83
83
 
84
+ this.cancelChange();
84
85
  this.setState({
85
86
  value: value
86
87
  });
package/es/index.d.ts CHANGED
@@ -3,7 +3,7 @@ import * as utils from './utils'
3
3
 
4
4
  declare const __default: {
5
5
  utils: typeof utils,
6
- version: '1.11.7'
6
+ version: '1.11.8'
7
7
  }
8
8
 
9
9
  export default __default
package/es/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import * as utils from './utils';
3
3
  export default {
4
4
  utils: utils,
5
- version: '1.11.7'
5
+ version: '1.11.8'
6
6
  };
7
7
  export { utils };
8
8
  export { setLocale } from './locale';
@@ -4165,6 +4165,9 @@ var injects = {
4165
4165
  }, {
4166
4166
  name: 'spinDefaultName',
4167
4167
  className: exposeClass('common-spin-default'),
4168
+ parser: function parser(d) {
4169
+ return d === 'none' ? 'default' : d;
4170
+ },
4168
4171
  attr: 'animationName',
4169
4172
  type: ['default', 'chasing-dots', 'cube-grid', 'double-bounce', 'fading-circle', 'four-dots', 'plane', 'pulse', 'ring', 'scale-circle', 'three-bounce', 'wave'],
4170
4173
  desc: '默认加载中样式'
@@ -17,6 +17,8 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
17
17
 
18
18
  var _classnames = _interopRequireDefault(require("classnames"));
19
19
 
20
+ var _config = _interopRequireDefault(require("../config"));
21
+
20
22
  var _Textarea = _interopRequireDefault(require("../Textarea"));
21
23
 
22
24
  var _Input = _interopRequireDefault(require("../Input"));
@@ -88,11 +90,28 @@ function (_React$PureComponent) {
88
90
  };
89
91
 
90
92
  _proto.onBlur = function onBlur(e) {
91
- var onBlur = this.props.onBlur;
93
+ var _this$props = this.props,
94
+ onBlur = _this$props.onBlur,
95
+ forceChange = _this$props.forceChange;
92
96
  this.hidePop();
97
+ var newValue = e.target.value;
98
+
99
+ if (this.getTrim()) {
100
+ newValue = newValue.trim();
101
+ e.target.value = newValue;
102
+ }
103
+
104
+ forceChange(newValue);
93
105
  if (typeof onBlur === 'function') onBlur(e);
94
106
  };
95
107
 
108
+ _proto.getTrim = function getTrim() {
109
+ var trim = this.props.trim;
110
+ if (trim !== undefined) return trim;
111
+ if (_config.default.trim !== undefined) return _config.default.trim;
112
+ return false;
113
+ };
114
+
96
115
  _proto.getErrorProps = function getErrorProps() {
97
116
  var p = {};
98
117
  if ('error' in this.props) p.error = this.props.error;
@@ -130,13 +149,13 @@ function (_React$PureComponent) {
130
149
 
131
150
  _proto.renderTextarea = function renderTextarea() {
132
151
  var showTextarea = this.state.showTextarea;
133
- var _this$props = this.props,
134
- placeholder = _this$props.placeholder,
135
- maxHeight = _this$props.maxHeight,
136
- value = _this$props.value,
137
- innerTitle = _this$props.innerTitle,
138
- placeTitle = _this$props.placeTitle,
139
- renderFooter = _this$props.renderFooter;
152
+ var _this$props2 = this.props,
153
+ placeholder = _this$props2.placeholder,
154
+ maxHeight = _this$props2.maxHeight,
155
+ value = _this$props2.value,
156
+ innerTitle = _this$props2.innerTitle,
157
+ placeTitle = _this$props2.placeTitle,
158
+ renderFooter = _this$props2.renderFooter;
140
159
  if (!showTextarea) return null;
141
160
  return _react.default.createElement("div", {
142
161
  ref: this.bindContainer
@@ -158,14 +177,14 @@ function (_React$PureComponent) {
158
177
  };
159
178
 
160
179
  _proto.renderResult = function renderResult() {
161
- var _this$props2 = this.props,
162
- placeholder = _this$props2.placeholder,
163
- disabled = _this$props2.disabled,
164
- value = _this$props2.value,
165
- renderResult = _this$props2.renderResult,
166
- placeTitle = _this$props2.placeTitle,
167
- innerTitle = _this$props2.innerTitle,
168
- error = _this$props2.error;
180
+ var _this$props3 = this.props,
181
+ placeholder = _this$props3.placeholder,
182
+ disabled = _this$props3.disabled,
183
+ value = _this$props3.value,
184
+ renderResult = _this$props3.renderResult,
185
+ placeTitle = _this$props3.placeTitle,
186
+ innerTitle = _this$props3.innerTitle,
187
+ error = _this$props3.error;
169
188
  var result = renderResult(value);
170
189
  return _react.default.createElement("div", {
171
190
  tabIndex: disabled ? undefined : 0,
@@ -184,12 +203,12 @@ function (_React$PureComponent) {
184
203
  };
185
204
 
186
205
  _proto.renderInput = function renderInput() {
187
- var _this$props3 = this.props,
188
- placeholder = _this$props3.placeholder,
189
- disabled = _this$props3.disabled,
190
- value = _this$props3.value,
191
- innerTitle = _this$props3.innerTitle,
192
- placeTitle = _this$props3.placeTitle;
206
+ var _this$props4 = this.props,
207
+ placeholder = _this$props4.placeholder,
208
+ disabled = _this$props4.disabled,
209
+ value = _this$props4.value,
210
+ innerTitle = _this$props4.innerTitle,
211
+ placeTitle = _this$props4.placeTitle;
193
212
  return _react.default.createElement(_Input.default, (0, _extends2.default)({
194
213
  innerTitle: innerTitle,
195
214
  placeTitle: placeTitle,
@@ -215,14 +234,14 @@ function (_React$PureComponent) {
215
234
 
216
235
  _proto.render = function render() {
217
236
  var showTextarea = this.state.showTextarea;
218
- var _this$props4 = this.props,
219
- width = _this$props4.width,
220
- style = _this$props4.style,
221
- className = _this$props4.className,
222
- bordered = _this$props4.bordered,
223
- clearable = _this$props4.clearable,
224
- getPopupContainer = _this$props4.getPopupContainer,
225
- value = _this$props4.value;
237
+ var _this$props5 = this.props,
238
+ width = _this$props5.width,
239
+ style = _this$props5.style,
240
+ className = _this$props5.className,
241
+ bordered = _this$props5.bordered,
242
+ clearable = _this$props5.clearable,
243
+ getPopupContainer = _this$props5.getPopupContainer,
244
+ value = _this$props5.value;
226
245
  var cls = (0, _classnames.default)(className, (0, _styles.editableAreaClass)('_', !bordered && 'none-bordered'));
227
246
  var ms = Object.assign({
228
247
  width: width
@@ -271,7 +290,9 @@ Editable.propTypes = {
271
290
  renderFooter: _propTypes.default.func,
272
291
  renderResult: _propTypes.default.func,
273
292
  onShowTextareaChange: _propTypes.default.func,
274
- error: _propTypes.default.object
293
+ error: _propTypes.default.object,
294
+ trim: _propTypes.default.bool,
295
+ forceChange: _propTypes.default.func
275
296
  };
276
297
  var _default = Editable;
277
298
  exports.default = _default;
@@ -9,13 +9,11 @@ var _func = require("../utils/func");
9
9
 
10
10
  var _delay = _interopRequireDefault(require("../hoc/delay"));
11
11
 
12
- var _trim = _interopRequireDefault(require("../hoc/trim"));
13
-
14
12
  var _inputable = _interopRequireDefault(require("../Form/inputable"));
15
13
 
16
14
  var _EditableArea = _interopRequireDefault(require("./EditableArea"));
17
15
 
18
- var EditableArea = (0, _func.compose)(_inputable.default, (0, _delay.default)(400), _trim.default)(_EditableArea.default);
16
+ var EditableArea = (0, _func.compose)(_inputable.default, (0, _delay.default)(400))(_EditableArea.default);
19
17
  EditableArea.displayName = 'ShineoutEditableArea';
20
18
  var _default = EditableArea;
21
19
  exports.default = _default;
@@ -23,6 +23,8 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
23
23
 
24
24
  var _classnames = _interopRequireDefault(require("classnames"));
25
25
 
26
+ var _config = _interopRequireDefault(require("../config"));
27
+
26
28
  var _styles = require("../InputTitle/styles");
27
29
 
28
30
  var _cleanProps = _interopRequireDefault(require("../utils/cleanProps"));
@@ -58,6 +60,12 @@ function (_PureComponent) {
58
60
  if (value.length <= info) return text;
59
61
  return new Error(text);
60
62
  });
63
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)), "getTrim", function () {
64
+ var trim = _this.props.trim;
65
+ if (trim !== undefined) return trim;
66
+ if (_config.default.trim !== undefined) return _config.default.trim;
67
+ return false;
68
+ });
61
69
  _this.enterLock = false;
62
70
  _this.handleChange = _this.handleChange.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
63
71
  _this.handleKeyDown = _this.handleKeyDown.bind((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)));
@@ -204,13 +212,19 @@ function (_PureComponent) {
204
212
  var value = e.target.value;
205
213
  var _this$props6 = this.props,
206
214
  forceChange = _this$props6.forceChange,
215
+ onChange = _this$props6.onChange,
207
216
  onBlur = _this$props6.onBlur,
208
- clearToUndefined = _this$props6.clearToUndefined,
209
- cancelChange = _this$props6.cancelChange;
210
- if (cancelChange) cancelChange();
217
+ clearToUndefined = _this$props6.clearToUndefined;
211
218
  var newVal = this.fixValue(value);
212
- var isChange = !(clearToUndefined && newVal === '' && this.props.value === undefined);
213
- if (isChange && forceChange && !this.invalidNumber(newVal)) forceChange(newVal);
219
+ var shouldKeepUndefined = clearToUndefined && newVal === '' && this.props.value === undefined;
220
+
221
+ if (!shouldKeepUndefined && !this.invalidNumber(newVal)) {
222
+ if (this.getTrim()) newVal = newVal.trim();
223
+ var change = forceChange || onChange;
224
+ change(newVal);
225
+ e.target.value = newVal;
226
+ }
227
+
214
228
  if (onBlur) onBlur(e);
215
229
  };
216
230
 
@@ -308,7 +322,6 @@ Input.propTypes = {
308
322
  htmlName: _propTypes.default.string,
309
323
  onBlur: _propTypes.default.func,
310
324
  onChange: _propTypes.default.func.isRequired,
311
- cancelChange: _propTypes.default.func,
312
325
  onEnterPress: _propTypes.default.func,
313
326
  type: _propTypes.default.string,
314
327
  value: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
@@ -322,7 +335,8 @@ Input.propTypes = {
322
335
  inputFocus: _propTypes.default.bool,
323
336
  clearToUndefined: _propTypes.default.bool,
324
337
  placeholder: _propTypes.default.string,
325
- coin: _propTypes.default.bool
338
+ coin: _propTypes.default.bool,
339
+ trim: _propTypes.default.bool
326
340
  };
327
341
  Input.defaultProps = {
328
342
  type: 'text'
@@ -13,8 +13,6 @@ var _inputBorder = _interopRequireDefault(require("../hoc/inputBorder"));
13
13
 
14
14
  var _delay = _interopRequireDefault(require("../hoc/delay"));
15
15
 
16
- var _trim = _interopRequireDefault(require("../hoc/trim"));
17
-
18
16
  var _coin = _interopRequireDefault(require("../hoc/coin"));
19
17
 
20
18
  var _Input = _interopRequireDefault(require("./Input"));
@@ -25,7 +23,7 @@ var _Group = _interopRequireDefault(require("./Group"));
25
23
 
26
24
  var _Password = _interopRequireDefault(require("./Password"));
27
25
 
28
- var _exports = (0, _func.compose)(_inputable.default, (0, _inputBorder.default)({}), (0, _delay.default)(400), _trim.default, (0, _coin.default)('input'))(_Input.default);
26
+ var _exports = (0, _func.compose)(_inputable.default, (0, _inputBorder.default)({}), (0, _delay.default)(400), (0, _coin.default)('input'))(_Input.default);
29
27
 
30
28
  _exports.Group = (0, _inputBorder.default)({
31
29
  tag: 'div',
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
4
+
3
5
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
6
 
5
7
  exports.__esModule = true;
@@ -21,7 +23,7 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
21
23
 
22
24
  var _classnames = _interopRequireDefault(require("classnames"));
23
25
 
24
- var _config = require("../config");
26
+ var _config = _interopRequireWildcard(require("../config"));
25
27
 
26
28
  var _component = require("../component");
27
29
 
@@ -73,6 +75,13 @@ function (_PureComponent) {
73
75
  if (this.props.autosize && prevProps.value !== this.props.value) this.resize(this.props.value);
74
76
  };
75
77
 
78
+ _proto.getTrim = function getTrim() {
79
+ var trim = this.props.trim;
80
+ if (trim !== undefined) return trim;
81
+ if (_config.default.trim !== undefined) return _config.default.trim;
82
+ return false;
83
+ };
84
+
76
85
  _proto.bindShadow = function bindShadow(el) {
77
86
  this.shadow = el;
78
87
  };
@@ -102,12 +111,18 @@ function (_PureComponent) {
102
111
  };
103
112
 
104
113
  _proto.handleBlur = function handleBlur(e) {
105
- var value = e.target.value;
114
+ var newValue = e.target.value;
106
115
  var _this$props = this.props,
107
116
  forceChange = _this$props.forceChange,
108
117
  onBlur = _this$props.onBlur;
118
+
119
+ if (this.getTrim()) {
120
+ newValue = newValue.trim();
121
+ e.target.value = newValue;
122
+ }
123
+
124
+ forceChange(newValue);
109
125
  if (onBlur) onBlur(e);
110
- forceChange(value);
111
126
  };
112
127
 
113
128
  _proto.renderFooter = function renderFooter() {
@@ -207,7 +222,8 @@ Textarea.propTypes = {
207
222
  renderFooter: _propTypes.default.func,
208
223
  innerTitle: _propTypes.default.node,
209
224
  inputFocus: _propTypes.default.bool,
210
- placeTitle: _propTypes.default.node
225
+ placeTitle: _propTypes.default.node,
226
+ trim: _propTypes.default.bool
211
227
  };
212
228
  Textarea.defaultProps = {
213
229
  rows: 4,
@@ -9,8 +9,6 @@ var _func = require("../utils/func");
9
9
 
10
10
  var _delay = _interopRequireDefault(require("../hoc/delay"));
11
11
 
12
- var _trim = _interopRequireDefault(require("../hoc/trim"));
13
-
14
12
  var _inputable = _interopRequireDefault(require("../Form/inputable"));
15
13
 
16
14
  var _inputBorder = _interopRequireDefault(require("../hoc/inputBorder"));
@@ -31,7 +29,7 @@ var input = (0, _func.compose)(_inputable.default, (0, _inputBorder.default)({
31
29
 
32
30
  return footer && (0, _styles.inputClass)('with-footer');
33
31
  }
34
- }), (0, _delay.default)(400), _trim.default);
32
+ }), (0, _delay.default)(400));
35
33
  var Textarea = input(_Textarea.default);
36
34
  Textarea.displayName = 'ShineoutTextarea';
37
35
  var _default = Textarea;
package/lib/hoc/delay.js CHANGED
@@ -99,6 +99,7 @@ var _default = (0, _func.curry)(function (defaultDelay, Origin) {
99
99
  _proto.forceChange = function forceChange(value) {
100
100
  var _this$props2;
101
101
 
102
+ this.cancelChange();
102
103
  this.setState({
103
104
  value: value
104
105
  });
package/lib/index.d.ts CHANGED
@@ -3,7 +3,7 @@ import * as utils from './utils'
3
3
 
4
4
  declare const __default: {
5
5
  utils: typeof utils,
6
- version: '1.11.7'
6
+ version: '1.11.8'
7
7
  }
8
8
 
9
9
  export default __default