@ucloud-fe/react-components 1.7.1 → 1.8.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.
@@ -1319,7 +1319,7 @@ var Select = function Select(_ref19) {
1319
1319
 
1320
1320
  var _useState5 = (0, _react.useState)(function () {
1321
1321
  (0, _newArrowCheck2.default)(this, _this21);
1322
- return hasSubGroup || !!(search && (renderContent || renderSelector));
1322
+ return hasSubGroup || !!(search && renderSelector);
1323
1323
  }.bind(this)),
1324
1324
  _useState6 = (0, _slicedToArray2.default)(_useState5, 1),
1325
1325
  v1 = _useState6[0];
@@ -64,7 +64,7 @@ var _style = require("./style");
64
64
  var _zh_CN = _interopRequireDefault(require("./locale/zh_CN"));
65
65
 
66
66
  var _excluded = ["value", "dragging", "index", "tipFormatter"],
67
- _excluded2 = ["value", "defaultValue", "onChange", "className", "style", "disabled", "min", "max", "step", "sliderClassName", "sliderStyle", "numberInput", "numberInputTipFormatter", "tipFormatter", "size", "marks", "isSensitive", "locale", "onLastChange"];
67
+ _excluded2 = ["value", "defaultValue", "range", "onChange", "className", "style", "disabled", "min", "max", "step", "sliderClassName", "sliderStyle", "numberInput", "numberInputTipFormatter", "tipFormatter", "size", "marks", "isSensitive", "locale", "onLastChange"];
68
68
 
69
69
  var _this = void 0,
70
70
  _dec,
@@ -86,6 +86,7 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
86
86
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
87
87
 
88
88
  var Handle = _rcSlider.default.Handle;
89
+ var Range = _rcSlider.default.Range;
89
90
  var Size = ['sm', 'md', 'lg'];
90
91
 
91
92
  var handle = function handle(props) {
@@ -258,7 +259,9 @@ var Slider = (_dec = (0, _localeConsumerDecorator.default)({
258
259
  return null;
259
260
  }
260
261
 
261
- var max = props.max;
262
+ var _props$max = props.max,
263
+ max = _props$max === void 0 ? 100 : _props$max,
264
+ range = props.range;
262
265
  var marks = {};
263
266
  var baseRatio = 0;
264
267
  (0, _each2.default)(_marks, function (_mark) {
@@ -268,7 +271,7 @@ var Slider = (_dec = (0, _localeConsumerDecorator.default)({
268
271
  return;
269
272
  }
270
273
 
271
- var value = (baseRatio += _mark.ratio) / 100 * sliderSplit;
274
+ var value = (baseRatio += _mark.ratio) / 100 * (range ? max : sliderSplit);
272
275
  var mark = {
273
276
  label: _mark.label,
274
277
  style: _objectSpread(_objectSpread({
@@ -340,8 +343,8 @@ var Slider = (_dec = (0, _localeConsumerDecorator.default)({
340
343
 
341
344
  _this3.onSliderChange = function (v, latest) {
342
345
  (0, _newArrowCheck2.default)(this, _this4);
343
-
344
- var value = _this3.translateSliderValueToValue(v);
346
+ var range = _this3.props.range;
347
+ var value = range ? v : _this3.translateSliderValueToValue(v);
345
348
 
346
349
  _this3.handleChange(value, latest);
347
350
  }.bind(this);
@@ -607,6 +610,7 @@ var Slider = (_dec = (0, _localeConsumerDecorator.default)({
607
610
  var _this$props = this.props,
608
611
  value = _this$props.value,
609
612
  defaultValue = _this$props.defaultValue,
613
+ range = _this$props.range,
610
614
  onChange = _this$props.onChange,
611
615
  className = _this$props.className,
612
616
  style = _this$props.style,
@@ -662,6 +666,31 @@ var Slider = (_dec = (0, _localeConsumerDecorator.default)({
662
666
  });
663
667
 
664
668
  var isNumberInputValid = numberInputValue + '' === value + '';
669
+
670
+ if (range) {
671
+ return /*#__PURE__*/_react.default.createElement(_style.SliderWrap, {
672
+ disabled: disabled,
673
+ style: style,
674
+ className: className,
675
+ size: size
676
+ }, /*#__PURE__*/_react.default.createElement(_style.RcSliderWrap, null, /*#__PURE__*/_react.default.createElement(Range, (0, _extends2.default)({
677
+ min: min,
678
+ max: max,
679
+ defaultValue: defaultValue,
680
+ value: value,
681
+ step: step,
682
+ prefixCls: _style.prefixCls,
683
+ marks: marksForSlider || {},
684
+ handle: function (handleProps) {
685
+ (0, _newArrowCheck2.default)(this, _this9);
686
+ return handle(_objectSpread(_objectSpread({}, handleProps), {}, {
687
+ // value,
688
+ tipFormatter: tipFormatter
689
+ }));
690
+ }.bind(this)
691
+ }, sliderProps, sharingProps))));
692
+ }
693
+
665
694
  return /*#__PURE__*/_react.default.createElement(_style.SliderWrap, {
666
695
  disabled: disabled,
667
696
  style: style,
@@ -702,10 +731,13 @@ var Slider = (_dec = (0, _localeConsumerDecorator.default)({
702
731
  return Slider;
703
732
  }(_react.Component), _class2.propTypes = {
704
733
  /** 值,受控 */
705
- value: _propTypes.default.number,
734
+ value: _propTypes.default.number | _propTypes.default.arrayOf(_propTypes.default.number),
706
735
 
707
736
  /** 默认值,非受控 */
708
- defaultValue: _propTypes.default.number,
737
+ defaultValue: _propTypes.default.number | _propTypes.default.arrayOf(_propTypes.default.number),
738
+
739
+ /** 是否为双滑块模式 */
740
+ range: _propTypes.default.bool,
709
741
 
710
742
  /** 修改回调 */
711
743
  onChange: _propTypes.default.func,
@@ -771,6 +803,7 @@ var Slider = (_dec = (0, _localeConsumerDecorator.default)({
771
803
  (0, _newArrowCheck2.default)(this, _this);
772
804
  }.bind(void 0),
773
805
  defaultValue: 0,
806
+ range: false,
774
807
  step: 1,
775
808
  size: 'md',
776
809
  min: 0,
@@ -586,7 +586,7 @@ var Table = (_dec = (0, _localeConsumerDecorator.default)({
586
586
  array.forEach(function (record) {
587
587
  (0, _newArrowCheck2.default)(this, _this17);
588
588
 
589
- if (record[childrenName]) {
589
+ if (record && record[childrenName]) {
590
590
  var newRecord = _objectSpread({}, record);
591
591
 
592
592
  delete newRecord[childrenName];
@@ -656,7 +656,7 @@ var Table = (_dec = (0, _localeConsumerDecorator.default)({
656
656
  }.bind(this) : _columnInfo$filter$ha;
657
657
  return (0, _filter2.default)(dataSource, function (record) {
658
658
  (0, _newArrowCheck2.default)(this, _this19);
659
- return handleFilter(record[dataIndex], record, value, multiple);
659
+ return handleFilter(record && record[dataIndex], record, value, multiple);
660
660
  }.bind(this));
661
661
  }.bind(this);
662
662
 
@@ -757,7 +757,7 @@ var Table = (_dec = (0, _localeConsumerDecorator.default)({
757
757
  _this2.getRowKey = function (record, index) {
758
758
  (0, _newArrowCheck2.default)(this, _this3);
759
759
  var rowKey = _this2.props.rowKey;
760
- var key = typeof rowKey === 'function' ? rowKey(record, index) : record[rowKey];
760
+ var key = typeof rowKey === 'function' ? rowKey(record, index) : record && record[rowKey];
761
761
  return key === undefined ? index : key;
762
762
  }.bind(this);
763
763
 
@@ -1503,7 +1503,9 @@ var Table = (_dec = (0, _localeConsumerDecorator.default)({
1503
1503
  "data-table-id": this.tableId
1504
1504
  }, /*#__PURE__*/_react.default.createElement(_style.PopupContainer, {
1505
1505
  ref: this.savePopupContainer
1506
- }), /*#__PURE__*/_react.default.createElement(_rcTable.default, (0, _extends2.default)({}, defaultExpandAllRowsProps, {
1506
+ }), /*#__PURE__*/_react.default.createElement(_rcTable.default, (0, _extends2.default)({
1507
+ defaultExpandAllRows: defaultExpandAllRows
1508
+ }, defaultExpandAllRowsProps, {
1507
1509
  onExpand: this.onExpandHandler
1508
1510
  }, rest, {
1509
1511
  scroll: scroll,
@@ -146,7 +146,7 @@ var ExpandableRow = /*#__PURE__*/function (_React$Component) {
146
146
  fixed = _this$props5.fixed;
147
147
  this.expandIconAsCell = fixed !== 'right' ? this.props.expandIconAsCell : false;
148
148
  this.expandIconColumnIndex = fixed !== 'right' ? this.props.expandIconColumnIndex : -1;
149
- var childrenData = record[childrenColumnName];
149
+ var childrenData = record && record[childrenColumnName];
150
150
  this.expandable = !!(childrenData || expandedRowRender);
151
151
  var expandableRowProps = {
152
152
  indentSize: indentSize,
@@ -125,7 +125,7 @@ var ExpandableTable = /*#__PURE__*/function (_React$Component) {
125
125
  expandedRowClassName = _this$props3.expandedRowClassName,
126
126
  expandedRowRender = _this$props3.expandedRowRender,
127
127
  childrenColumnName = _this$props3.childrenColumnName;
128
- var childrenData = record[childrenColumnName];
128
+ var childrenData = record && record[childrenColumnName];
129
129
  var nextAncestorKeys = [].concat((0, _toConsumableArray2.default)(ancestorKeys), [parentKey]);
130
130
  var nextIndent = indent + 1;
131
131
 
@@ -250,7 +250,7 @@ var ExpandableTable = /*#__PURE__*/function (_React$Component) {
250
250
  children = _this$props5.children;
251
251
  var needIndentSpaced = data.some(function (record) {
252
252
  (0, _newArrowCheck2.default)(this, _this4);
253
- return record[childrenColumnName];
253
+ return record && record[childrenColumnName];
254
254
  }.bind(this));
255
255
  return children({
256
256
  props: this.props,
@@ -294,8 +294,12 @@ ExpandableTable.defaultProps = {
294
294
  defaultExpandedRowKeys: [],
295
295
  childrenColumnName: 'children',
296
296
  indentSize: 15,
297
- onExpand: function onExpand() {},
298
- onExpandedRowsChange: function onExpandedRowsChange() {}
297
+ onExpand: function onExpand() {
298
+ (0, _newArrowCheck2.default)(this, _this5);
299
+ }.bind(void 0),
300
+ onExpandedRowsChange: function onExpandedRowsChange() {
301
+ (0, _newArrowCheck2.default)(this, _this5);
302
+ }.bind(void 0)
299
303
  };
300
304
  (0, _reactLifecyclesCompat.polyfill)(ExpandableTable);
301
305
 
@@ -72,7 +72,7 @@ var Table = /*#__PURE__*/function (_React$Component) {
72
72
  _this.getRowKey = function (record, index) {
73
73
  (0, _newArrowCheck2.default)(this, _this2);
74
74
  var rowKey = _this.props.rowKey;
75
- var key = typeof rowKey === 'function' ? rowKey(record, index) : record[rowKey];
75
+ var key = typeof rowKey === 'function' ? rowKey(record, index) : record && record[rowKey];
76
76
  (0, _utils.warningOnce)(key !== undefined, 'Each record in table should have a unique `key` prop,' + 'or set `rowKey` to an unique primary key.');
77
77
  return key === undefined ? index : key;
78
78
  }.bind(this);
@@ -84,7 +84,7 @@ var TableCell = /*#__PURE__*/function (_React$Component) {
84
84
  var colSpan;
85
85
  var rowSpan;
86
86
 
87
- if (render) {
87
+ if (render && record) {
88
88
  text = render(text, record, index);
89
89
 
90
90
  if (isInvalidRenderCellText(text)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ucloud-fe/react-components",
3
- "version": "1.7.1",
3
+ "version": "1.8.1",
4
4
  "title": "UCloud react components",
5
5
  "description": "UCloud react components",
6
6
  "keywords": [