shineout 1.9.0-rc.7 → 1.9.1
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.
- package/css/Cascader/Cascader.js +93 -47
- package/css/Input/Input.js +25 -6
- package/css/Input/Number.js +9 -2
- package/css/Input/clear.js +6 -3
- package/css/Input/index.d.ts +9 -0
- package/css/TreeSelect/Result.js +1 -1
- package/css/index.d.ts +1 -1
- package/css/index.js +1 -1
- package/dist/shineout.js +192 -213
- package/dist/shineout.js.map +1 -1
- package/dist/shineout.min.js +1 -1
- package/es/Cascader/Cascader.js +93 -47
- package/es/Input/Input.js +25 -6
- package/es/Input/Number.js +9 -2
- package/es/Input/clear.js +6 -3
- package/es/Input/index.d.ts +9 -0
- package/es/TreeSelect/Result.js +1 -1
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/lib/Cascader/Cascader.js +93 -47
- package/lib/Input/Input.js +25 -6
- package/lib/Input/Number.js +9 -2
- package/lib/Input/clear.js +6 -3
- package/lib/Input/index.d.ts +9 -0
- package/lib/TreeSelect/Result.js +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/package.json +1 -1
package/css/Cascader/Cascader.js
CHANGED
|
@@ -116,6 +116,12 @@ function (_PureComponent) {
|
|
|
116
116
|
|
|
117
117
|
var _proto = Cascader.prototype;
|
|
118
118
|
|
|
119
|
+
_proto.componentDidMount = function componentDidMount() {
|
|
120
|
+
_PureComponent.prototype.componentDidMount.call(this);
|
|
121
|
+
|
|
122
|
+
this.updatePathByValue();
|
|
123
|
+
};
|
|
124
|
+
|
|
119
125
|
_proto.componentDidUpdate = function componentDidUpdate(prevProps, prevState) {
|
|
120
126
|
this.datum.mode = this.props.mode;
|
|
121
127
|
var _this$props = this.props,
|
|
@@ -123,7 +129,11 @@ function (_PureComponent) {
|
|
|
123
129
|
filterDataChange = _this$props.filterDataChange,
|
|
124
130
|
filterText = _this$props.filterText;
|
|
125
131
|
if (!filterDataChange && prevProps.data !== this.props.data) this.datum.setData(this.props.data, true);
|
|
126
|
-
|
|
132
|
+
|
|
133
|
+
if (prevProps.value !== this.props.value) {
|
|
134
|
+
this.datum.setValue(this.props.value || []);
|
|
135
|
+
this.updatePathByValue();
|
|
136
|
+
}
|
|
127
137
|
|
|
128
138
|
if (prevState.focus !== this.state.focus && !this.state.focus && onFilter) {
|
|
129
139
|
setTimeout(function () {
|
|
@@ -185,6 +195,30 @@ function (_PureComponent) {
|
|
|
185
195
|
}));
|
|
186
196
|
};
|
|
187
197
|
|
|
198
|
+
_proto.updatePathByValue = function updatePathByValue() {
|
|
199
|
+
var _this$props3 = this.props,
|
|
200
|
+
mode = _this$props3.mode,
|
|
201
|
+
value = _this$props3.value;
|
|
202
|
+
if (mode !== undefined) return;
|
|
203
|
+
if (value === this.lastValue) return;
|
|
204
|
+
|
|
205
|
+
if (!value || !value.length) {
|
|
206
|
+
this.setState({
|
|
207
|
+
path: []
|
|
208
|
+
});
|
|
209
|
+
} else {
|
|
210
|
+
var v = value[value.length - 1];
|
|
211
|
+
var data = this.datum.getDataById(v);
|
|
212
|
+
var id = this.datum.getKey(data);
|
|
213
|
+
|
|
214
|
+
var _ref2 = this.datum.getPath(id) || {},
|
|
215
|
+
path = _ref2.path;
|
|
216
|
+
|
|
217
|
+
path = path || [];
|
|
218
|
+
this.handlePathChange(id, null, path);
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
|
|
188
222
|
_proto.handleClickAway = function handleClickAway(e) {
|
|
189
223
|
var desc = isDescendent(e.target, this.selectId);
|
|
190
224
|
|
|
@@ -198,12 +232,18 @@ function (_PureComponent) {
|
|
|
198
232
|
_proto.handlePathChange = function handlePathChange(id, data, path, fromClick) {
|
|
199
233
|
var _this2 = this;
|
|
200
234
|
|
|
201
|
-
var _this$
|
|
202
|
-
childrenKey = _this$
|
|
203
|
-
finalDismiss = _this$
|
|
235
|
+
var _this$props4 = this.props,
|
|
236
|
+
childrenKey = _this$props4.childrenKey,
|
|
237
|
+
finalDismiss = _this$props4.finalDismiss,
|
|
238
|
+
loader = _this$props4.loader;
|
|
204
239
|
|
|
205
240
|
if (fromClick && data) {
|
|
206
241
|
var leaf = !data[childrenKey] || data[childrenKey].length === 0;
|
|
242
|
+
|
|
243
|
+
if (loader && typeof loader === 'function' && data[childrenKey] === undefined) {
|
|
244
|
+
leaf = false;
|
|
245
|
+
}
|
|
246
|
+
|
|
207
247
|
if (finalDismiss && leaf) this.handleState(false);
|
|
208
248
|
}
|
|
209
249
|
|
|
@@ -248,9 +288,9 @@ function (_PureComponent) {
|
|
|
248
288
|
if (focus && e && e.target.classList.contains((0, _styles2.cascaderClass)('close'))) return; // if remove node, return
|
|
249
289
|
|
|
250
290
|
if (e && (0, _element.getParent)(e.target, "." + (0, _styles2.cascaderClass)('remove-container'))) return;
|
|
251
|
-
var _this$
|
|
252
|
-
height = _this$
|
|
253
|
-
onCollapse = _this$
|
|
291
|
+
var _this$props5 = this.props,
|
|
292
|
+
height = _this$props5.height,
|
|
293
|
+
onCollapse = _this$props5.onCollapse;
|
|
254
294
|
var position = this.props.position;
|
|
255
295
|
|
|
256
296
|
if (!position) {
|
|
@@ -294,34 +334,40 @@ function (_PureComponent) {
|
|
|
294
334
|
};
|
|
295
335
|
|
|
296
336
|
_proto.handleChange = function handleChange() {
|
|
297
|
-
var _this$
|
|
298
|
-
onChange = _this$
|
|
299
|
-
onFilter = _this$
|
|
300
|
-
filterText = _this$
|
|
337
|
+
var _this$props6 = this.props,
|
|
338
|
+
onChange = _this$props6.onChange,
|
|
339
|
+
onFilter = _this$props6.onFilter,
|
|
340
|
+
filterText = _this$props6.filterText;
|
|
301
341
|
|
|
302
342
|
if (this.input) {
|
|
303
343
|
this.input.reset();
|
|
304
344
|
this.input.focus();
|
|
305
345
|
}
|
|
306
346
|
|
|
307
|
-
|
|
347
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
348
|
+
args[_key] = arguments[_key];
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
var value = args[0];
|
|
352
|
+
this.lastValue = value;
|
|
353
|
+
onChange.apply(void 0, args);
|
|
308
354
|
if (onFilter && filterText) onFilter('');
|
|
309
355
|
};
|
|
310
356
|
|
|
311
357
|
_proto.renderList = function renderList() {
|
|
312
358
|
var _this4 = this;
|
|
313
359
|
|
|
314
|
-
var _this$
|
|
315
|
-
data = _this$
|
|
316
|
-
keygen = _this$
|
|
317
|
-
renderItem = _this$
|
|
318
|
-
mode = _this$
|
|
319
|
-
loader = _this$
|
|
320
|
-
onItemClick = _this$
|
|
321
|
-
expandTrigger = _this$
|
|
322
|
-
childrenKey = _this$
|
|
323
|
-
absolute = _this$
|
|
324
|
-
height = _this$
|
|
360
|
+
var _this$props7 = this.props,
|
|
361
|
+
data = _this$props7.data,
|
|
362
|
+
keygen = _this$props7.keygen,
|
|
363
|
+
renderItem = _this$props7.renderItem,
|
|
364
|
+
mode = _this$props7.mode,
|
|
365
|
+
loader = _this$props7.loader,
|
|
366
|
+
onItemClick = _this$props7.onItemClick,
|
|
367
|
+
expandTrigger = _this$props7.expandTrigger,
|
|
368
|
+
childrenKey = _this$props7.childrenKey,
|
|
369
|
+
absolute = _this$props7.absolute,
|
|
370
|
+
height = _this$props7.height;
|
|
325
371
|
var path = this.state.path;
|
|
326
372
|
var props = {
|
|
327
373
|
datum: this.datum,
|
|
@@ -382,9 +428,9 @@ function (_PureComponent) {
|
|
|
382
428
|
};
|
|
383
429
|
|
|
384
430
|
_proto.renderAbsoluteList = function renderAbsoluteList() {
|
|
385
|
-
var _this$
|
|
386
|
-
absolute = _this$
|
|
387
|
-
zIndex = _this$
|
|
431
|
+
var _this$props8 = this.props,
|
|
432
|
+
absolute = _this$props8.absolute,
|
|
433
|
+
zIndex = _this$props8.zIndex;
|
|
388
434
|
var _this$state = this.state,
|
|
389
435
|
focus = _this$state.focus,
|
|
390
436
|
position = _this$state.position;
|
|
@@ -406,17 +452,17 @@ function (_PureComponent) {
|
|
|
406
452
|
};
|
|
407
453
|
|
|
408
454
|
_proto.renderFilterList = function renderFilterList() {
|
|
409
|
-
var _this$
|
|
410
|
-
absolute = _this$
|
|
411
|
-
onFilter = _this$
|
|
412
|
-
filterText = _this$
|
|
413
|
-
zIndex = _this$
|
|
414
|
-
data = _this$
|
|
415
|
-
childrenKey = _this$
|
|
416
|
-
renderItem = _this$
|
|
417
|
-
expandTrigger = _this$
|
|
418
|
-
height = _this$
|
|
419
|
-
loading = _this$
|
|
455
|
+
var _this$props9 = this.props,
|
|
456
|
+
absolute = _this$props9.absolute,
|
|
457
|
+
onFilter = _this$props9.onFilter,
|
|
458
|
+
filterText = _this$props9.filterText,
|
|
459
|
+
zIndex = _this$props9.zIndex,
|
|
460
|
+
data = _this$props9.data,
|
|
461
|
+
childrenKey = _this$props9.childrenKey,
|
|
462
|
+
renderItem = _this$props9.renderItem,
|
|
463
|
+
expandTrigger = _this$props9.expandTrigger,
|
|
464
|
+
height = _this$props9.height,
|
|
465
|
+
loading = _this$props9.loading;
|
|
420
466
|
var _this$state2 = this.state,
|
|
421
467
|
focus = _this$state2.focus,
|
|
422
468
|
position = _this$state2.position;
|
|
@@ -445,11 +491,11 @@ function (_PureComponent) {
|
|
|
445
491
|
};
|
|
446
492
|
|
|
447
493
|
_proto.renderPanel = function renderPanel() {
|
|
448
|
-
var _this$
|
|
449
|
-
filterText = _this$
|
|
450
|
-
data = _this$
|
|
451
|
-
mode = _this$
|
|
452
|
-
loading = _this$
|
|
494
|
+
var _this$props10 = this.props,
|
|
495
|
+
filterText = _this$props10.filterText,
|
|
496
|
+
data = _this$props10.data,
|
|
497
|
+
mode = _this$props10.mode,
|
|
498
|
+
loading = _this$props10.loading;
|
|
453
499
|
if (loading) return this.renderFilterList();
|
|
454
500
|
if (!filterText || filterText && mode !== undefined || data.length === 0) return this.renderAbsoluteList();
|
|
455
501
|
return this.renderFilterList();
|
|
@@ -458,11 +504,11 @@ function (_PureComponent) {
|
|
|
458
504
|
_proto.render = function render() {
|
|
459
505
|
var _this5 = this;
|
|
460
506
|
|
|
461
|
-
var _this$
|
|
462
|
-
placeholder = _this$
|
|
463
|
-
disabled = _this$
|
|
464
|
-
size = _this$
|
|
465
|
-
other = (0, _objectWithoutPropertiesLoose2.default)(_this$
|
|
507
|
+
var _this$props11 = this.props,
|
|
508
|
+
placeholder = _this$props11.placeholder,
|
|
509
|
+
disabled = _this$props11.disabled,
|
|
510
|
+
size = _this$props11.size,
|
|
511
|
+
other = (0, _objectWithoutPropertiesLoose2.default)(_this$props11, ["placeholder", "disabled", "size"]);
|
|
466
512
|
var focus = this.state.focus;
|
|
467
513
|
var className = (0, _classnames.default)((0, _styles2.cascaderClass)('_', size, focus && 'focus', other.mode !== undefined && 'multiple', disabled === true && 'disabled', (0, _config.isRTL)() && 'rtl'), (0, _styles.selectClass)(this.state.position, focus && 'focus'));
|
|
468
514
|
return _react.default.createElement("div", {
|
package/css/Input/Input.js
CHANGED
|
@@ -96,6 +96,12 @@ function (_PureComponent) {
|
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
var value = e.target.value;
|
|
99
|
+
|
|
100
|
+
if (clearClick && this.props.clearToUndefined) {
|
|
101
|
+
this.props.onChange(value);
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
|
|
99
105
|
if (type === 'number' && typeof value !== 'number') value = String(value).replace(/。/g, '.');
|
|
100
106
|
|
|
101
107
|
if (this.invalidNumber(value)) {
|
|
@@ -138,9 +144,15 @@ function (_PureComponent) {
|
|
|
138
144
|
var value = e.target.value;
|
|
139
145
|
var _this$props4 = this.props,
|
|
140
146
|
forceChange = _this$props4.forceChange,
|
|
141
|
-
onBlur = _this$props4.onBlur
|
|
147
|
+
onBlur = _this$props4.onBlur,
|
|
148
|
+
clearToUndefined = _this$props4.clearToUndefined;
|
|
142
149
|
if (onBlur) onBlur(e);
|
|
143
150
|
if (this.invalidNumber(value)) return;
|
|
151
|
+
|
|
152
|
+
if (clearToUndefined && value === '' && this.props.value === undefined) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
|
|
144
156
|
if (forceChange) forceChange(value);
|
|
145
157
|
};
|
|
146
158
|
|
|
@@ -176,9 +188,12 @@ function (_PureComponent) {
|
|
|
176
188
|
forwardedRef = _this$props5.forwardedRef,
|
|
177
189
|
innerTitle = _this$props5.innerTitle,
|
|
178
190
|
inputFocus = _this$props5.inputFocus,
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
191
|
+
clearToUndefined = _this$props5.clearToUndefined,
|
|
192
|
+
placeholder = _this$props5.placeholder,
|
|
193
|
+
other = (0, _objectWithoutPropertiesLoose2.default)(_this$props5, ["type", "defaultValue", "digits", "className", "clearable", "htmlName", "forceChange", "onEnterPress", "forwardedRef", "innerTitle", "inputFocus", "clearToUndefined", "placeholder"]);
|
|
194
|
+
var value = this.props.value == null || this.props.value === undefined ? '' : this.props.value;
|
|
195
|
+
var needClearUndefined = clearToUndefined && this.props.value !== undefined;
|
|
196
|
+
var showClear = !other.disabled && clearable && (value !== '' || needClearUndefined);
|
|
182
197
|
var mc = (0, _classnames.default)(className, showClear && (0, _styles2.inputClass)('clearable'), innerTitle && (0, _styles.inputTitleClass)('hidable', 'item'));
|
|
183
198
|
var isNumber = className && className.indexOf((0, _styles2.inputClass)('number')) > -1;
|
|
184
199
|
return [_react.default.createElement(_InputTitle.default, {
|
|
@@ -187,6 +202,7 @@ function (_PureComponent) {
|
|
|
187
202
|
innerTitle: innerTitle,
|
|
188
203
|
open: !!inputFocus || !!value
|
|
189
204
|
}, _react.default.createElement("input", (0, _extends2.default)({}, (0, _cleanProps.default)(other), {
|
|
205
|
+
placeholder: needClearUndefined ? '' : placeholder,
|
|
190
206
|
className: mc || undefined,
|
|
191
207
|
name: other.name || htmlName,
|
|
192
208
|
type: type === 'password' ? type : 'text',
|
|
@@ -199,7 +215,8 @@ function (_PureComponent) {
|
|
|
199
215
|
onBlur: this.handleBlur
|
|
200
216
|
}))), showClear && _react.default.createElement(_clear.default, {
|
|
201
217
|
onClick: this.handleChange,
|
|
202
|
-
key: "close"
|
|
218
|
+
key: "close",
|
|
219
|
+
clearResult: needClearUndefined ? undefined : ''
|
|
203
220
|
}), this.renderInfo()];
|
|
204
221
|
};
|
|
205
222
|
|
|
@@ -224,7 +241,9 @@ Input.propTypes = {
|
|
|
224
241
|
onKeyDown: _propTypes.default.func,
|
|
225
242
|
onKeyUp: _propTypes.default.func,
|
|
226
243
|
innerTitle: _propTypes.default.node,
|
|
227
|
-
inputFocus: _propTypes.default.bool
|
|
244
|
+
inputFocus: _propTypes.default.bool,
|
|
245
|
+
clearToUndefined: _propTypes.default.bool,
|
|
246
|
+
placeholder: _propTypes.default.string
|
|
228
247
|
};
|
|
229
248
|
Input.defaultProps = {
|
|
230
249
|
type: 'text'
|
package/css/Input/Number.js
CHANGED
|
@@ -56,7 +56,7 @@ function (_PureComponent) {
|
|
|
56
56
|
};
|
|
57
57
|
|
|
58
58
|
_proto.handleChange = function handleChange(value, check, isEmpty) {
|
|
59
|
-
if (isEmpty) {
|
|
59
|
+
if (isEmpty || value === undefined) {
|
|
60
60
|
this.props.onChange(value);
|
|
61
61
|
return;
|
|
62
62
|
}
|
|
@@ -98,7 +98,13 @@ function (_PureComponent) {
|
|
|
98
98
|
|
|
99
99
|
|
|
100
100
|
if (isNaN(value)) value = 0;
|
|
101
|
-
|
|
101
|
+
|
|
102
|
+
if (this.props.clearToUndefined && e.target.value === '' && this.props.value === undefined) {
|
|
103
|
+
this.handleChange(undefined, true, true);
|
|
104
|
+
} else {
|
|
105
|
+
this.handleChange(value, true, value === null);
|
|
106
|
+
}
|
|
107
|
+
|
|
102
108
|
this.props.onBlur(e);
|
|
103
109
|
};
|
|
104
110
|
|
|
@@ -245,6 +251,7 @@ Number.propTypes = {
|
|
|
245
251
|
digits: _propTypes.default.number,
|
|
246
252
|
allowNull: _propTypes.default.bool,
|
|
247
253
|
hideArrow: _propTypes.default.bool,
|
|
254
|
+
clearToUndefined: _propTypes.default.bool,
|
|
248
255
|
value: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string])
|
|
249
256
|
};
|
|
250
257
|
Number.defaultProps = {
|
package/css/Input/clear.js
CHANGED
|
@@ -35,10 +35,12 @@ function (_Component) {
|
|
|
35
35
|
_proto.handleClick = function handleClick(e) {
|
|
36
36
|
// do not blur
|
|
37
37
|
e.preventDefault();
|
|
38
|
-
var
|
|
38
|
+
var _this$props = this.props,
|
|
39
|
+
onClick = _this$props.onClick,
|
|
40
|
+
clearResult = _this$props.clearResult;
|
|
39
41
|
if (onClick) onClick({
|
|
40
42
|
target: {
|
|
41
|
-
value:
|
|
43
|
+
value: clearResult
|
|
42
44
|
}
|
|
43
45
|
}, true);
|
|
44
46
|
};
|
|
@@ -56,7 +58,8 @@ function (_Component) {
|
|
|
56
58
|
}(_react.Component);
|
|
57
59
|
|
|
58
60
|
Clear.propTypes = {
|
|
59
|
-
onClick: _propTypes.default.func
|
|
61
|
+
onClick: _propTypes.default.func,
|
|
62
|
+
clearResult: _propTypes.default.any
|
|
60
63
|
};
|
|
61
64
|
var _default = Clear;
|
|
62
65
|
exports.default = _default;
|
package/css/Input/index.d.ts
CHANGED
|
@@ -190,6 +190,15 @@ FormItemStandardProps<Value> {
|
|
|
190
190
|
*/
|
|
191
191
|
placeTitle?: ReactNode,
|
|
192
192
|
|
|
193
|
+
/**
|
|
194
|
+
* 点击清除按钮后数据变为 undefined
|
|
195
|
+
*
|
|
196
|
+
* After clicking the clear button, the data becomes undefined
|
|
197
|
+
*
|
|
198
|
+
* default: -
|
|
199
|
+
*
|
|
200
|
+
*/
|
|
201
|
+
clearToUndefined?: boolean
|
|
193
202
|
}
|
|
194
203
|
|
|
195
204
|
export interface InputNumberProps <Value> extends InputProps<Value> {
|
package/css/TreeSelect/Result.js
CHANGED
|
@@ -230,7 +230,7 @@ function (_PureComponent) {
|
|
|
230
230
|
}
|
|
231
231
|
|
|
232
232
|
return _react.default.createElement("span", {
|
|
233
|
-
className: (0, _classnames.default)((0, _styles2.inputClass)('placeholder'), (0, _styles.treeSelectClass)('ellipsis'), innerTitle && (0, _styles3.inputTitleClass)('
|
|
233
|
+
className: (0, _classnames.default)((0, _styles2.inputClass)('placeholder'), (0, _styles.treeSelectClass)('ellipsis'), innerTitle && (0, _styles3.inputTitleClass)('hidable'))
|
|
234
234
|
}, this.props.placeholder, "\xA0");
|
|
235
235
|
};
|
|
236
236
|
|
package/css/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Created by scripts/src-index.js.
|
|
2
2
|
import * as utils from './utils'
|
|
3
3
|
|
|
4
|
-
export default { utils, version: '1.9.
|
|
4
|
+
export default { utils, version: '1.9.1' }
|
|
5
5
|
export { utils }
|
|
6
6
|
export { setLocale } from './locale'
|
|
7
7
|
export { color, style } from './utils/expose'
|