cloud-b2b 1.0.9 → 1.1.0
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/es/SuperTable2/SuperTable2.js +17 -14
- package/lib/SuperTable2/SuperTable2.js +17 -14
- package/package.json +1 -1
|
@@ -26,13 +26,13 @@ import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty";
|
|
|
26
26
|
|
|
27
27
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"]; if (!it) { if (_Array$isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
28
28
|
|
|
29
|
-
function _unsupportedIterableToArray(o, minLen) { var
|
|
29
|
+
function _unsupportedIterableToArray(o, minLen) { var _context13; if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = _sliceInstanceProperty(_context13 = Object.prototype.toString.call(o)).call(_context13, 8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return _Array$from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
30
30
|
|
|
31
31
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
32
32
|
|
|
33
33
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
34
34
|
|
|
35
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var
|
|
35
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context11, _context12; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context11 = ownKeys(Object(source), !0)).call(_context11, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context12 = ownKeys(Object(source))).call(_context12, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
36
36
|
|
|
37
37
|
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
|
38
38
|
import _Array$isArray from "@babel/runtime-corejs3/core-js-stable/array/is-array";
|
|
@@ -361,7 +361,7 @@ var SuperTable2 = /*#__PURE__*/function (_React$Component) {
|
|
|
361
361
|
|
|
362
362
|
_defineProperty(_assertThisInitialized(_this), "getCellRender", function (col) {
|
|
363
363
|
return function (value, record, index) {
|
|
364
|
-
var _context3, _context4, _context5;
|
|
364
|
+
var _context3, _context4, _context5, _context6;
|
|
365
365
|
|
|
366
366
|
var realType = record._isEdit === true && _this.canReadonly(col.type) ? col.editType : col.type;
|
|
367
367
|
|
|
@@ -424,9 +424,12 @@ var SuperTable2 = /*#__PURE__*/function (_React$Component) {
|
|
|
424
424
|
return _this.props.callback.onRenderCustom(record.key, col.key, value, col.props);
|
|
425
425
|
|
|
426
426
|
case 'toolbar':
|
|
427
|
+
//showByKey为true时,每条数据中与按钮key相同的属性值决定按钮是否显示,建议key用下划线开始命名,避免与后台数据冲突
|
|
427
428
|
var props = {
|
|
428
429
|
onClick: _this.props.callback.onToolbar ? _bindInstanceProperty(_context4 = _this.props.callback.onToolbar).call(_context4, null, col.key, record.key, record) : undefined,
|
|
429
|
-
buttons: _filterInstanceProperty(_context5 = col.props.buttons).call(_context5, function (item) {
|
|
430
|
+
buttons: col.props.showByKey ? _filterInstanceProperty(_context5 = col.props.buttons).call(_context5, function (item) {
|
|
431
|
+
return record[item.key] === true;
|
|
432
|
+
}) : _filterInstanceProperty(_context6 = col.props.buttons).call(_context6, function (item) {
|
|
430
433
|
return item.defaultShow === !record._isEdit;
|
|
431
434
|
})
|
|
432
435
|
};
|
|
@@ -527,18 +530,18 @@ var SuperTable2 = /*#__PURE__*/function (_React$Component) {
|
|
|
527
530
|
});
|
|
528
531
|
|
|
529
532
|
_defineProperty(_assertThisInitialized(_this), "canReadonly", function (type) {
|
|
530
|
-
var
|
|
533
|
+
var _context7;
|
|
531
534
|
|
|
532
|
-
return !_includesInstanceProperty(
|
|
535
|
+
return !_includesInstanceProperty(_context7 = ['index', 'checkbox', 'link', 'button', 'switch', 'custom', 'img', 'toolbar']).call(_context7, type);
|
|
533
536
|
});
|
|
534
537
|
|
|
535
538
|
_defineProperty(_assertThisInitialized(_this), "getColumns", function (cols) {
|
|
536
|
-
var
|
|
539
|
+
var _context8;
|
|
537
540
|
|
|
538
541
|
var readonly = _this.props.readonly;
|
|
539
|
-
return _mapInstanceProperty(
|
|
542
|
+
return _mapInstanceProperty(_context8 = _filterInstanceProperty(cols).call(cols, function (col) {
|
|
540
543
|
return !col.hide;
|
|
541
|
-
})).call(
|
|
544
|
+
})).call(_context8, function (_ref11, index) {
|
|
542
545
|
var col = _extends({}, _ref11);
|
|
543
546
|
|
|
544
547
|
col.className = _this.getColumnClassName(col);
|
|
@@ -566,13 +569,13 @@ var SuperTable2 = /*#__PURE__*/function (_React$Component) {
|
|
|
566
569
|
_defineProperty(_assertThisInitialized(_this), "getDataSource", function (items, cols) {
|
|
567
570
|
return _mapInstanceProperty(items).call(items, function (item, index) {
|
|
568
571
|
return _reduceInstanceProperty(cols).call(cols, function (result, _ref12) {
|
|
569
|
-
var
|
|
572
|
+
var _context9;
|
|
570
573
|
|
|
571
574
|
var key = _ref12.key,
|
|
572
575
|
type = _ref12.type,
|
|
573
576
|
options = _ref12.options;
|
|
574
577
|
|
|
575
|
-
if (!_this.props.readonly && type && type !== 'readonly' && (!item.isReadonly || _Array$isArray(item.isReadonly) && !_includesInstanceProperty(
|
|
578
|
+
if (!_this.props.readonly && type && type !== 'readonly' && (!item.isReadonly || _Array$isArray(item.isReadonly) && !_includesInstanceProperty(_context9 = item.isReadonly).call(_context9, key))) {
|
|
576
579
|
result[key] = item[key];
|
|
577
580
|
} else {
|
|
578
581
|
result[key] = getTitle(item[key], options);
|
|
@@ -606,7 +609,7 @@ var SuperTable2 = /*#__PURE__*/function (_React$Component) {
|
|
|
606
609
|
});
|
|
607
610
|
|
|
608
611
|
_defineProperty(_assertThisInitialized(_this), "getProps", function () {
|
|
609
|
-
var
|
|
612
|
+
var _context10;
|
|
610
613
|
|
|
611
614
|
var _this$props3 = _this.props,
|
|
612
615
|
cols = _this$props3.cols,
|
|
@@ -621,9 +624,9 @@ var SuperTable2 = /*#__PURE__*/function (_React$Component) {
|
|
|
621
624
|
isEmphasized = _this$props3$isEmphas === void 0 ? false : _this$props3$isEmphas,
|
|
622
625
|
maxHeight = _this$props3.maxHeight;
|
|
623
626
|
|
|
624
|
-
var widthX = _reduceInstanceProperty(
|
|
627
|
+
var widthX = _reduceInstanceProperty(_context10 = _filterInstanceProperty(cols).call(cols, function (col) {
|
|
625
628
|
return !col.hide;
|
|
626
|
-
})).call(
|
|
629
|
+
})).call(_context10, function (width, item) {
|
|
627
630
|
return width += item.width ? item.width : 120;
|
|
628
631
|
}, 0);
|
|
629
632
|
|
|
@@ -96,13 +96,13 @@ var _variables = _interopRequireDefault(require("../variables"));
|
|
|
96
96
|
|
|
97
97
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"]; if (!it) { if (_Array$isArray2(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
98
98
|
|
|
99
|
-
function _unsupportedIterableToArray(o, minLen) { var
|
|
99
|
+
function _unsupportedIterableToArray(o, minLen) { var _context13; if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = _sliceInstanceProperty(_context13 = Object.prototype.toString.call(o)).call(_context13, 8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return _Array$from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
100
100
|
|
|
101
101
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
102
102
|
|
|
103
103
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty2(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
104
104
|
|
|
105
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var
|
|
105
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context11, _context12; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context11 = ownKeys(Object(source), !0)).call(_context11, function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context12 = ownKeys(Object(source))).call(_context12, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
106
106
|
|
|
107
107
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = _Reflect$construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
108
108
|
|
|
@@ -400,7 +400,7 @@ var SuperTable2 = /*#__PURE__*/function (_React$Component) {
|
|
|
400
400
|
});
|
|
401
401
|
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "getCellRender", function (col) {
|
|
402
402
|
return function (value, record, index) {
|
|
403
|
-
var _context3, _context4, _context5;
|
|
403
|
+
var _context3, _context4, _context5, _context6;
|
|
404
404
|
|
|
405
405
|
var realType = record._isEdit === true && _this.canReadonly(col.type) ? col.editType : col.type;
|
|
406
406
|
|
|
@@ -463,9 +463,12 @@ var SuperTable2 = /*#__PURE__*/function (_React$Component) {
|
|
|
463
463
|
return _this.props.callback.onRenderCustom(record.key, col.key, value, col.props);
|
|
464
464
|
|
|
465
465
|
case 'toolbar':
|
|
466
|
+
//showByKey为true时,每条数据中与按钮key相同的属性值决定按钮是否显示,建议key用下划线开始命名,避免与后台数据冲突
|
|
466
467
|
var props = {
|
|
467
468
|
onClick: _this.props.callback.onToolbar ? (0, _bind["default"])(_context4 = _this.props.callback.onToolbar).call(_context4, null, col.key, record.key, record) : undefined,
|
|
468
|
-
buttons: (0, _filter["default"])(_context5 = col.props.buttons).call(_context5, function (item) {
|
|
469
|
+
buttons: col.props.showByKey ? (0, _filter["default"])(_context5 = col.props.buttons).call(_context5, function (item) {
|
|
470
|
+
return record[item.key] === true;
|
|
471
|
+
}) : (0, _filter["default"])(_context6 = col.props.buttons).call(_context6, function (item) {
|
|
469
472
|
return item.defaultShow === !record._isEdit;
|
|
470
473
|
})
|
|
471
474
|
};
|
|
@@ -561,17 +564,17 @@ var SuperTable2 = /*#__PURE__*/function (_React$Component) {
|
|
|
561
564
|
}
|
|
562
565
|
});
|
|
563
566
|
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "canReadonly", function (type) {
|
|
564
|
-
var
|
|
567
|
+
var _context7;
|
|
565
568
|
|
|
566
|
-
return !(0, _includes["default"])(
|
|
569
|
+
return !(0, _includes["default"])(_context7 = ['index', 'checkbox', 'link', 'button', 'switch', 'custom', 'img', 'toolbar']).call(_context7, type);
|
|
567
570
|
});
|
|
568
571
|
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "getColumns", function (cols) {
|
|
569
|
-
var
|
|
572
|
+
var _context8;
|
|
570
573
|
|
|
571
574
|
var readonly = _this.props.readonly;
|
|
572
|
-
return (0, _map["default"])(
|
|
575
|
+
return (0, _map["default"])(_context8 = (0, _filter["default"])(cols).call(cols, function (col) {
|
|
573
576
|
return !col.hide;
|
|
574
|
-
})).call(
|
|
577
|
+
})).call(_context8, function (_ref11, index) {
|
|
575
578
|
var col = (0, _extends2["default"])({}, _ref11);
|
|
576
579
|
col.className = _this.getColumnClassName(col);
|
|
577
580
|
col.title = _this.getColumnTitle(col);
|
|
@@ -597,13 +600,13 @@ var SuperTable2 = /*#__PURE__*/function (_React$Component) {
|
|
|
597
600
|
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "getDataSource", function (items, cols) {
|
|
598
601
|
return (0, _map["default"])(items).call(items, function (item, index) {
|
|
599
602
|
return (0, _reduce["default"])(cols).call(cols, function (result, _ref12) {
|
|
600
|
-
var
|
|
603
|
+
var _context9;
|
|
601
604
|
|
|
602
605
|
var key = _ref12.key,
|
|
603
606
|
type = _ref12.type,
|
|
604
607
|
options = _ref12.options;
|
|
605
608
|
|
|
606
|
-
if (!_this.props.readonly && type && type !== 'readonly' && (!item.isReadonly || (0, _isArray["default"])(item.isReadonly) && !(0, _includes["default"])(
|
|
609
|
+
if (!_this.props.readonly && type && type !== 'readonly' && (!item.isReadonly || (0, _isArray["default"])(item.isReadonly) && !(0, _includes["default"])(_context9 = item.isReadonly).call(_context9, key))) {
|
|
607
610
|
result[key] = item[key];
|
|
608
611
|
} else {
|
|
609
612
|
result[key] = (0, _Control.getTitle)(item[key], options);
|
|
@@ -635,7 +638,7 @@ var SuperTable2 = /*#__PURE__*/function (_React$Component) {
|
|
|
635
638
|
};
|
|
636
639
|
});
|
|
637
640
|
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "getProps", function () {
|
|
638
|
-
var
|
|
641
|
+
var _context10;
|
|
639
642
|
|
|
640
643
|
var _this$props3 = _this.props,
|
|
641
644
|
cols = _this$props3.cols,
|
|
@@ -649,9 +652,9 @@ var SuperTable2 = /*#__PURE__*/function (_React$Component) {
|
|
|
649
652
|
_this$props3$isEmphas = _this$props3.isEmphasized,
|
|
650
653
|
isEmphasized = _this$props3$isEmphas === void 0 ? false : _this$props3$isEmphas,
|
|
651
654
|
maxHeight = _this$props3.maxHeight;
|
|
652
|
-
var widthX = (0, _reduce["default"])(
|
|
655
|
+
var widthX = (0, _reduce["default"])(_context10 = (0, _filter["default"])(cols).call(cols, function (col) {
|
|
653
656
|
return !col.hide;
|
|
654
|
-
})).call(
|
|
657
|
+
})).call(_context10, function (width, item) {
|
|
655
658
|
return width += item.width ? item.width : 120;
|
|
656
659
|
}, 0);
|
|
657
660
|
return _objectSpread({
|