wargerm 0.4.5 → 0.4.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.
package/dist/index.js CHANGED
@@ -675,24 +675,6 @@ function FrameBox(_ref) {
675
675
  }), children);
676
676
  }
677
677
 
678
- var usePreventUnmountEffect = function usePreventUnmountEffect(callback, deps) {
679
- // const isUnmountRef = useRef(false);
680
- var _useState = React.useState(false),
681
- _useState2 = _slicedToArray(_useState, 2),
682
- isUnmount = _useState2[0],
683
- setIsUnmount = _useState2[1];
684
-
685
- React.useEffect(function () {
686
- // !isUnmountRef.current && callback()
687
- !isUnmount && callback();
688
- return function () {
689
- // isUnmountRef.current = true;
690
- setIsUnmount(true);
691
- };
692
- }, // [isUnmountRef, ...deps],
693
- [isUnmount].concat(_toConsumableArray(deps)));
694
- };
695
-
696
678
  var _excluded$2 = ["request", "valueEnum", "onLoad", "children", "params"],
697
679
  _excluded2 = ["children"];
698
680
 
@@ -719,7 +701,9 @@ var WSelect = function WSelect(props) {
719
701
  resList = _useState6[0],
720
702
  setResList = _useState6[1];
721
703
 
722
- usePreventUnmountEffect(function () {
704
+ React.useEffect(function () {
705
+ var isUnmount = false;
706
+
723
707
  _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
724
708
  var res, node;
725
709
  return regeneratorRuntime.wrap(function _callee$(_context) {
@@ -727,7 +711,7 @@ var WSelect = function WSelect(props) {
727
711
  switch (_context.prev = _context.next) {
728
712
  case 0:
729
713
  if (!request) {
730
- _context.next = 8;
714
+ _context.next = 10;
731
715
  break;
732
716
  }
733
717
 
@@ -736,6 +720,15 @@ var WSelect = function WSelect(props) {
736
720
 
737
721
  case 3:
738
722
  res = _context.sent;
723
+
724
+ if (!isUnmount) {
725
+ _context.next = 6;
726
+ break;
727
+ }
728
+
729
+ return _context.abrupt("return");
730
+
731
+ case 6:
739
732
  setResList(res);
740
733
  onLoad && onLoad(res);
741
734
  node = res.map(function (item) {
@@ -746,7 +739,7 @@ var WSelect = function WSelect(props) {
746
739
  });
747
740
  setChildrenNode(node);
748
741
 
749
- case 8:
742
+ case 10:
750
743
  case "end":
751
744
  return _context.stop();
752
745
  }
@@ -782,6 +775,9 @@ var WSelect = function WSelect(props) {
782
775
 
783
776
  onLoad && onLoad(options);
784
777
  setValueEnumList(valueEnumNode);
778
+ return function () {
779
+ isUnmount = true;
780
+ };
785
781
  }, [JSON.stringify(params || {})]);
786
782
  return /*#__PURE__*/React__default['default'].createElement(_Select__default['default'], _objectSpread2({
787
783
  showSearch: true,
@@ -802,7 +798,7 @@ var Option = function Option(props) {
802
798
 
803
799
  var Index$4 = WSelect;
804
800
  Index$4.Option = Option;
805
- var Select = /*#__PURE__*/React__default['default'].memo(Index$4);
801
+ var Select = /*#__PURE__*/React.memo(Index$4);
806
802
 
807
803
  //! moment.js
808
804
  //! version : 2.29.1
@@ -6648,7 +6644,9 @@ var TreeSelect = function TreeSelect(_ref) {
6648
6644
  treeData = _useState2[0],
6649
6645
  setTreeData = _useState2[1];
6650
6646
 
6651
- usePreventUnmountEffect(function () {
6647
+ React.useEffect(function () {
6648
+ var isUnmount = false;
6649
+
6652
6650
  _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
6653
6651
  var res;
6654
6652
  return regeneratorRuntime.wrap(function _callee$(_context) {
@@ -6656,7 +6654,7 @@ var TreeSelect = function TreeSelect(_ref) {
6656
6654
  switch (_context.prev = _context.next) {
6657
6655
  case 0:
6658
6656
  if (!request) {
6659
- _context.next = 8;
6657
+ _context.next = 10;
6660
6658
  break;
6661
6659
  }
6662
6660
 
@@ -6665,21 +6663,34 @@ var TreeSelect = function TreeSelect(_ref) {
6665
6663
 
6666
6664
  case 3:
6667
6665
  res = _context.sent;
6666
+
6667
+ if (!isUnmount) {
6668
+ _context.next = 6;
6669
+ break;
6670
+ }
6671
+
6672
+ return _context.abrupt("return");
6673
+
6674
+ case 6:
6668
6675
  onLoad && onLoad(res);
6669
6676
  setTreeData(res);
6670
- _context.next = 9;
6677
+ _context.next = 11;
6671
6678
  break;
6672
6679
 
6673
- case 8:
6680
+ case 10:
6674
6681
  setTreeData(treePropsData || []);
6675
6682
 
6676
- case 9:
6683
+ case 11:
6677
6684
  case "end":
6678
6685
  return _context.stop();
6679
6686
  }
6680
6687
  }
6681
6688
  }, _callee);
6682
6689
  }))();
6690
+
6691
+ return function () {
6692
+ isUnmount = true;
6693
+ };
6683
6694
  }, [JSON.stringify(params)]);
6684
6695
  return /*#__PURE__*/React__default['default'].createElement(_TreeSelect__default['default'], _objectSpread2({
6685
6696
  showSearch: true,
@@ -6707,33 +6718,55 @@ var WCascader = function WCascader(props) {
6707
6718
  resList = _useState2[0],
6708
6719
  setResList = _useState2[1];
6709
6720
 
6710
- usePreventUnmountEffect(function () {
6711
- _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
6712
- var res;
6713
- return regeneratorRuntime.wrap(function _callee$(_context) {
6714
- while (1) {
6715
- switch (_context.prev = _context.next) {
6716
- case 0:
6717
- if (!request) {
6718
- _context.next = 6;
6719
- break;
6720
- }
6721
+ React.useEffect(function () {
6722
+ var isUnmount = false;
6721
6723
 
6722
- _context.next = 3;
6723
- return request();
6724
+ var fetch = /*#__PURE__*/function () {
6725
+ var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
6726
+ var res;
6727
+ return regeneratorRuntime.wrap(function _callee$(_context) {
6728
+ while (1) {
6729
+ switch (_context.prev = _context.next) {
6730
+ case 0:
6731
+ if (!request) {
6732
+ _context.next = 8;
6733
+ break;
6734
+ }
6724
6735
 
6725
- case 3:
6726
- res = _context.sent;
6727
- setResList(res);
6728
- onLoad && onLoad(res);
6736
+ _context.next = 3;
6737
+ return request();
6729
6738
 
6730
- case 6:
6731
- case "end":
6732
- return _context.stop();
6739
+ case 3:
6740
+ res = _context.sent;
6741
+
6742
+ if (!isUnmount) {
6743
+ _context.next = 6;
6744
+ break;
6745
+ }
6746
+
6747
+ return _context.abrupt("return");
6748
+
6749
+ case 6:
6750
+ setResList(res);
6751
+ onLoad && onLoad(res);
6752
+
6753
+ case 8:
6754
+ case "end":
6755
+ return _context.stop();
6756
+ }
6733
6757
  }
6734
- }
6735
- }, _callee);
6736
- }))();
6758
+ }, _callee);
6759
+ }));
6760
+
6761
+ return function fetch() {
6762
+ return _ref.apply(this, arguments);
6763
+ };
6764
+ }();
6765
+
6766
+ fetch();
6767
+ return function () {
6768
+ isUnmount = true;
6769
+ };
6737
6770
  }, [JSON.stringify(params)]);
6738
6771
  return /*#__PURE__*/React__default['default'].createElement(_Cascader__default['default'], _objectSpread2({
6739
6772
  value: typeof value === 'string' ? [value] : value,
@@ -7968,7 +8001,7 @@ var WForm$1 = /*#__PURE__*/React__default['default'].forwardRef(WForm);
7968
8001
 
7969
8002
  var _excluded$7 = ["columns", "dataSource", "request", "onLoad", "params", "onSubmit", "rowKey", "onRow", "className", "rowClassName", "rowSelection", "style", "tbodyStyle", "thStyle", "border", "scroll", "pagination", "search", "frameBoxTable", "frameBoxDirection", "formRef", "none"];
7970
8003
  function Table(_ref) {
7971
- var _formSearchRef$curren4, _classnames2;
8004
+ var _formSearchRef$curren4, _classnames2, _columns$, _columns$2;
7972
8005
 
7973
8006
  var columns = _ref.columns,
7974
8007
  tableList = _ref.dataSource,
@@ -8081,6 +8114,22 @@ function Table(_ref) {
8081
8114
  return !c.hideInTable;
8082
8115
  });
8083
8116
  }, [columns]);
8117
+
8118
+ var calcWidth = function calcWidth(columns) {
8119
+ return columns.reduce(function (pre, cur) {
8120
+ var width = cur.width;
8121
+
8122
+ if (width) {
8123
+ return pre + width;
8124
+ }
8125
+
8126
+ return pre;
8127
+ }, 0);
8128
+ };
8129
+
8130
+ var showColumns = columns.filter(function (c) {
8131
+ return !c.hideInTable;
8132
+ });
8084
8133
  var renderTh = React.useMemo(function () {
8085
8134
  var renderThFc = function renderThFc(columns, parentHeight, isChild) {
8086
8135
  var showColumns = columns.filter(function (c) {
@@ -8118,13 +8167,17 @@ function Table(_ref) {
8118
8167
  } else {
8119
8168
  return /*#__PURE__*/React__default['default'].createElement("div", {
8120
8169
  key: c.dataIndex,
8121
- style: {
8170
+ style: _objectSpread2({
8122
8171
  width: c.width + 'px',
8123
8172
  flex: c.width ? '0 1 auto' : '1',
8124
8173
  height: !c.children ? '100%' : '32px',
8125
8174
  borderRight: index != showColumns.length - 1 && filterColumns.length !== showColumns.length ? '1px solid #3b5173' : 'none'
8126
- },
8127
- className: "td"
8175
+ }, c.fixed == 'left' ? {
8176
+ left: ((rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.type) ? 56 : 6) + calcWidth(showColumns.slice(0, index - 2 > 0 ? index - 1 : 0))
8177
+ } : c.fixed == 'right' ? {
8178
+ right: calcWidth(showColumns.slice(index + 1))
8179
+ } : {}),
8180
+ className: "td ".concat(c.fixed == 'left' ? 'fixedLeft' : c.fixed == 'right' ? 'fixedRight' : '')
8128
8181
  }, c.title);
8129
8182
  }
8130
8183
  });
@@ -8166,12 +8219,16 @@ function Table(_ref) {
8166
8219
  placement: "top",
8167
8220
  title: record[c.dataIndex]
8168
8221
  }, /*#__PURE__*/React__default['default'].createElement("div", {
8169
- className: 'td' + (c.ellipsis ? ' ellipsis' : ''),
8170
- style: {
8222
+ className: "td ".concat(c.fixed == 'left' ? 'fixedLeft' : c.fixed == 'right' ? 'fixedRight' : '', " ").concat(c.ellipsis ? ' ellipsis' : ''),
8223
+ style: _objectSpread2({
8171
8224
  width: c.width + 'px',
8172
8225
  flex: c.width ? '0 1 auto' : '1',
8173
8226
  overflow: 'hidden'
8174
- }
8227
+ }, c.fixed == 'left' ? {
8228
+ left: ((rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.type) ? 56 : 6) + calcWidth(showColumns.slice(0, index - 2 > 0 ? index - 1 : 0))
8229
+ } : c.fixed == 'right' ? {
8230
+ right: calcWidth(showColumns.slice(index + 1))
8231
+ } : {})
8175
8232
  }, /*#__PURE__*/React__default['default'].createElement("div", {
8176
8233
  style: {
8177
8234
  width: '100%',
@@ -8187,12 +8244,16 @@ function Table(_ref) {
8187
8244
 
8188
8245
  return /*#__PURE__*/React__default['default'].createElement("div", {
8189
8246
  key: c.dataIndex,
8190
- className: 'td' + (c.ellipsis ? ' ellipsis' : ''),
8191
- style: {
8247
+ className: "td ".concat(c.fixed == 'left' ? 'fixedLeft' : c.fixed == 'right' ? 'fixedRight' : '', " ").concat(c.ellipsis ? ' ellipsis' : ''),
8248
+ style: _objectSpread2({
8192
8249
  width: c.width + 'px',
8193
8250
  flex: c.width ? '0 1 auto' : '1',
8194
8251
  overflow: 'hidden'
8195
- },
8252
+ }, c.fixed == 'left' ? {
8253
+ left: ((rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.type) ? 56 : 6) + calcWidth(showColumns.slice(0, index - 2 > 0 ? index - 1 : 0))
8254
+ } : c.fixed == 'right' ? {
8255
+ right: calcWidth(showColumns.slice(index + 1))
8256
+ } : {}),
8196
8257
  title: record[c.dataIndex]
8197
8258
  }, c.ellipsis ? /*#__PURE__*/React__default['default'].createElement("div", {
8198
8259
  style: {
@@ -8223,11 +8284,13 @@ function Table(_ref) {
8223
8284
  tr: true
8224
8285
  }, typeof rowClassName === 'function' ? rowClassName(record, index) : '', true))
8225
8286
  }, typeof onRow === 'function' ? onRow(record, index) : {}), (rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.type) === 'checkbox' && /*#__PURE__*/React__default['default'].createElement("div", {
8226
- style: {
8287
+ style: _objectSpread2({
8227
8288
  width: '50px',
8228
8289
  flex: '0 1 auto'
8229
- },
8230
- className: "td"
8290
+ }, showColumns[0].fixed == 'left' ? {
8291
+ left: 6
8292
+ } : {}),
8293
+ className: "td ".concat(showColumns[0].fixed == 'left' ? 'fixedLeft' : '')
8231
8294
  }, /*#__PURE__*/React__default['default'].createElement(Index$3, {
8232
8295
  checked: (_ref2 = [].concat(_toConsumableArray((rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.selectedRowKeys) || []), _toConsumableArray(selectedRowKeys))) === null || _ref2 === void 0 ? void 0 : _ref2.includes(key),
8233
8296
  onClick: function onClick(e) {
@@ -8261,11 +8324,13 @@ function Table(_ref) {
8261
8324
  });
8262
8325
  }
8263
8326
  })), (rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.type) === 'radio' && /*#__PURE__*/React__default['default'].createElement("div", {
8264
- style: {
8327
+ style: _objectSpread2({
8265
8328
  width: '50px',
8266
8329
  flex: '0 1 auto'
8267
- },
8268
- className: "td"
8330
+ }, showColumns[0].fixed == 'left' ? {
8331
+ left: 6
8332
+ } : {}),
8333
+ className: "td ".concat(showColumns[0].fixed == 'left' ? 'fixedLeft' : '')
8269
8334
  }, /*#__PURE__*/React__default['default'].createElement(Index$2, {
8270
8335
  checked: (_ref3 = [].concat(_toConsumableArray((rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.selectedRowKeys) || []), _toConsumableArray(selectedRowKeys))) === null || _ref3 === void 0 ? void 0 : _ref3.includes(key),
8271
8336
  onClick: function onClick(e) {
@@ -8421,20 +8486,27 @@ function Table(_ref) {
8421
8486
  className: classnames__default['default']((_classnames2 = {
8422
8487
  container: true
8423
8488
  }, _defineProperty(_classnames2, 'w-table', true), _defineProperty(_classnames2, 'w-frame-box-table', frameBoxTable), _defineProperty(_classnames2, className || 'defalut-table', true), _classnames2)),
8424
- style: style
8489
+ style: _objectSpread2(_objectSpread2({}, (scroll === null || scroll === void 0 ? void 0 : scroll.y) ? {
8490
+ height: scroll.y
8491
+ } : {}), style)
8425
8492
  }, /*#__PURE__*/React__default['default'].createElement("div", {
8426
8493
  className: "theader"
8427
8494
  }, /*#__PURE__*/React__default['default'].createElement("div", {
8428
8495
  className: "th",
8429
8496
  style: _objectSpread2(_objectSpread2({}, thStyle), {}, {
8430
8497
  height: layerIndex * 32 + 'px'
8431
- })
8498
+ }, (scroll === null || scroll === void 0 ? void 0 : scroll.x) ? {
8499
+ width: scroll.x
8500
+ } : {})
8432
8501
  }, (rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.type) === 'checkbox' && /*#__PURE__*/React__default['default'].createElement("div", {
8433
- style: {
8502
+ style: _objectSpread2({
8434
8503
  width: '50px',
8435
- flex: '0 1 auto'
8436
- },
8437
- className: "td"
8504
+ flex: '0 1 auto',
8505
+ height: '100%'
8506
+ }, showColumns[0].fixed == 'left' ? {
8507
+ left: 6
8508
+ } : {}),
8509
+ className: "td ".concat(((_columns$ = columns[0]) === null || _columns$ === void 0 ? void 0 : _columns$.fixed) == 'left' ? 'fixedLeft' : '')
8438
8510
  }, /*#__PURE__*/React__default['default'].createElement(Index$3, {
8439
8511
  checked: dataSource.every(function (record) {
8440
8512
  return selectedRowKeys.includes(typeof rowKey === 'function' ? record[rowKey(record)] : record[rowKey]);
@@ -8446,15 +8518,23 @@ function Table(_ref) {
8446
8518
  }),
8447
8519
  onChange: onSelectAllChange
8448
8520
  })), (rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.type) === 'radio' && /*#__PURE__*/React__default['default'].createElement("div", {
8449
- style: {
8521
+ style: _objectSpread2({
8450
8522
  width: '50px',
8451
- flex: '0 1 auto'
8452
- },
8453
- className: "td"
8523
+ flex: '0 1 auto',
8524
+ height: '100%'
8525
+ }, showColumns[0].fixed == 'left' ? {
8526
+ left: 6
8527
+ } : {}),
8528
+ className: "td ".concat(((_columns$2 = columns[0]) === null || _columns$2 === void 0 ? void 0 : _columns$2.fixed) == 'left' ? 'fixedLeft' : '')
8454
8529
  }), renderTh)), /*#__PURE__*/React__default['default'].createElement("div", {
8530
+ className: "tbodyContainer",
8531
+ style: _objectSpread2({}, (scroll === null || scroll === void 0 ? void 0 : scroll.x) ? {
8532
+ width: scroll.x
8533
+ } : {})
8534
+ }, /*#__PURE__*/React__default['default'].createElement("div", {
8455
8535
  className: "tbody",
8456
8536
  style: _objectSpread2({
8457
- height: (style === null || style === void 0 ? void 0 : style.height) ? "calc(".concat(style.height, " - ").concat(52 + (pagination === false ? 0 : 42), "px)") : '200px'
8537
+ height: (style === null || style === void 0 ? void 0 : style.height) || (scroll === null || scroll === void 0 ? void 0 : scroll.y) ? "calc(".concat(style === null || style === void 0 ? void 0 : style.height, " - ").concat(52 + (pagination === false ? 0 : 42), "px)") : '200px'
8458
8538
  }, tbodyStyle)
8459
8539
  }, dataSource.length > 0 ? dataSource.map(function (record, index) {
8460
8540
  var key = typeof rowKey === 'function' ? record[rowKey(record)] : record[rowKey];
@@ -8473,12 +8553,12 @@ function Table(_ref) {
8473
8553
  justifyContent: 'center',
8474
8554
  alignItems: 'center'
8475
8555
  }
8476
- }, none || '暂无数据')), _typeof(pagination) === 'object' && /*#__PURE__*/React__default['default'].createElement(_Pagination__default['default'], _objectSpread2({
8556
+ }, none || '暂无数据')))), _typeof(pagination) === 'object' && /*#__PURE__*/React__default['default'].createElement(_Pagination__default['default'], _objectSpread2({
8477
8557
  style: {
8478
8558
  textAlign: 'right',
8479
8559
  marginTop: '10px'
8480
8560
  }
8481
- }, paginationParams))));
8561
+ }, paginationParams)));
8482
8562
  }
8483
8563
  Table.defaultProps = {
8484
8564
  rowKey: 'key'
@@ -10202,7 +10282,7 @@ var ModalForm = function ModalForm(props, ref) {
10202
10282
  resetFields();
10203
10283
  setFieldsValue(record);
10204
10284
  }
10205
- }, [visible, record, formRef === null || formRef === void 0 ? void 0 : formRef.current]);
10285
+ }, [visible, record]);
10206
10286
  return /*#__PURE__*/React__default['default'].createElement(_Modal__default['default'], _objectSpread2(_objectSpread2({
10207
10287
  title: title,
10208
10288
  visible: visible
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "wargerm",
4
- "version": "0.4.5",
4
+ "version": "0.4.8",
5
5
  "scripts": {
6
6
  "dev": "dumi dev",
7
7
  "docs:build": "dumi build",
@@ -1 +0,0 @@
1
- export declare const usePreventUnmountEffect: (callback: Function, deps: Array<any>) => void;