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.esm.js CHANGED
@@ -4,7 +4,7 @@ import 'antd/es/dropdown/style';
4
4
  import _Dropdown from 'antd/es/dropdown';
5
5
  import 'antd/es/menu/style';
6
6
  import _Menu from 'antd/es/menu';
7
- import React, { useState, useEffect, useMemo, useImperativeHandle, useRef } from 'react';
7
+ import React, { memo, useState, useEffect, useMemo, useImperativeHandle, useRef } from 'react';
8
8
  import { createFromIconfontCN, SearchOutlined, ReloadOutlined, CloseCircleOutlined, PlusOutlined, EllipsisOutlined, ExclamationCircleOutlined, EyeOutlined, EditOutlined, DeleteOutlined } from '@ant-design/icons';
9
9
  import 'antd/es/input/style';
10
10
  import _Input from 'antd/es/input';
@@ -640,24 +640,6 @@ function FrameBox(_ref) {
640
640
  }), children);
641
641
  }
642
642
 
643
- var usePreventUnmountEffect = function usePreventUnmountEffect(callback, deps) {
644
- // const isUnmountRef = useRef(false);
645
- var _useState = useState(false),
646
- _useState2 = _slicedToArray(_useState, 2),
647
- isUnmount = _useState2[0],
648
- setIsUnmount = _useState2[1];
649
-
650
- useEffect(function () {
651
- // !isUnmountRef.current && callback()
652
- !isUnmount && callback();
653
- return function () {
654
- // isUnmountRef.current = true;
655
- setIsUnmount(true);
656
- };
657
- }, // [isUnmountRef, ...deps],
658
- [isUnmount].concat(_toConsumableArray(deps)));
659
- };
660
-
661
643
  var _excluded$2 = ["request", "valueEnum", "onLoad", "children", "params"],
662
644
  _excluded2 = ["children"];
663
645
 
@@ -684,7 +666,9 @@ var WSelect = function WSelect(props) {
684
666
  resList = _useState6[0],
685
667
  setResList = _useState6[1];
686
668
 
687
- usePreventUnmountEffect(function () {
669
+ useEffect(function () {
670
+ var isUnmount = false;
671
+
688
672
  _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
689
673
  var res, node;
690
674
  return regeneratorRuntime.wrap(function _callee$(_context) {
@@ -692,7 +676,7 @@ var WSelect = function WSelect(props) {
692
676
  switch (_context.prev = _context.next) {
693
677
  case 0:
694
678
  if (!request) {
695
- _context.next = 8;
679
+ _context.next = 10;
696
680
  break;
697
681
  }
698
682
 
@@ -701,6 +685,15 @@ var WSelect = function WSelect(props) {
701
685
 
702
686
  case 3:
703
687
  res = _context.sent;
688
+
689
+ if (!isUnmount) {
690
+ _context.next = 6;
691
+ break;
692
+ }
693
+
694
+ return _context.abrupt("return");
695
+
696
+ case 6:
704
697
  setResList(res);
705
698
  onLoad && onLoad(res);
706
699
  node = res.map(function (item) {
@@ -711,7 +704,7 @@ var WSelect = function WSelect(props) {
711
704
  });
712
705
  setChildrenNode(node);
713
706
 
714
- case 8:
707
+ case 10:
715
708
  case "end":
716
709
  return _context.stop();
717
710
  }
@@ -747,6 +740,9 @@ var WSelect = function WSelect(props) {
747
740
 
748
741
  onLoad && onLoad(options);
749
742
  setValueEnumList(valueEnumNode);
743
+ return function () {
744
+ isUnmount = true;
745
+ };
750
746
  }, [JSON.stringify(params || {})]);
751
747
  return /*#__PURE__*/React.createElement(_Select, _objectSpread2({
752
748
  showSearch: true,
@@ -767,7 +763,7 @@ var Option = function Option(props) {
767
763
 
768
764
  var Index$4 = WSelect;
769
765
  Index$4.Option = Option;
770
- var Select = /*#__PURE__*/React.memo(Index$4);
766
+ var Select = /*#__PURE__*/memo(Index$4);
771
767
 
772
768
  //! moment.js
773
769
  //! version : 2.29.1
@@ -6613,7 +6609,9 @@ var TreeSelect = function TreeSelect(_ref) {
6613
6609
  treeData = _useState2[0],
6614
6610
  setTreeData = _useState2[1];
6615
6611
 
6616
- usePreventUnmountEffect(function () {
6612
+ useEffect(function () {
6613
+ var isUnmount = false;
6614
+
6617
6615
  _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
6618
6616
  var res;
6619
6617
  return regeneratorRuntime.wrap(function _callee$(_context) {
@@ -6621,7 +6619,7 @@ var TreeSelect = function TreeSelect(_ref) {
6621
6619
  switch (_context.prev = _context.next) {
6622
6620
  case 0:
6623
6621
  if (!request) {
6624
- _context.next = 8;
6622
+ _context.next = 10;
6625
6623
  break;
6626
6624
  }
6627
6625
 
@@ -6630,21 +6628,34 @@ var TreeSelect = function TreeSelect(_ref) {
6630
6628
 
6631
6629
  case 3:
6632
6630
  res = _context.sent;
6631
+
6632
+ if (!isUnmount) {
6633
+ _context.next = 6;
6634
+ break;
6635
+ }
6636
+
6637
+ return _context.abrupt("return");
6638
+
6639
+ case 6:
6633
6640
  onLoad && onLoad(res);
6634
6641
  setTreeData(res);
6635
- _context.next = 9;
6642
+ _context.next = 11;
6636
6643
  break;
6637
6644
 
6638
- case 8:
6645
+ case 10:
6639
6646
  setTreeData(treePropsData || []);
6640
6647
 
6641
- case 9:
6648
+ case 11:
6642
6649
  case "end":
6643
6650
  return _context.stop();
6644
6651
  }
6645
6652
  }
6646
6653
  }, _callee);
6647
6654
  }))();
6655
+
6656
+ return function () {
6657
+ isUnmount = true;
6658
+ };
6648
6659
  }, [JSON.stringify(params)]);
6649
6660
  return /*#__PURE__*/React.createElement(_TreeSelect, _objectSpread2({
6650
6661
  showSearch: true,
@@ -6672,33 +6683,55 @@ var WCascader = function WCascader(props) {
6672
6683
  resList = _useState2[0],
6673
6684
  setResList = _useState2[1];
6674
6685
 
6675
- usePreventUnmountEffect(function () {
6676
- _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
6677
- var res;
6678
- return regeneratorRuntime.wrap(function _callee$(_context) {
6679
- while (1) {
6680
- switch (_context.prev = _context.next) {
6681
- case 0:
6682
- if (!request) {
6683
- _context.next = 6;
6684
- break;
6685
- }
6686
+ useEffect(function () {
6687
+ var isUnmount = false;
6686
6688
 
6687
- _context.next = 3;
6688
- return request();
6689
+ var fetch = /*#__PURE__*/function () {
6690
+ var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
6691
+ var res;
6692
+ return regeneratorRuntime.wrap(function _callee$(_context) {
6693
+ while (1) {
6694
+ switch (_context.prev = _context.next) {
6695
+ case 0:
6696
+ if (!request) {
6697
+ _context.next = 8;
6698
+ break;
6699
+ }
6689
6700
 
6690
- case 3:
6691
- res = _context.sent;
6692
- setResList(res);
6693
- onLoad && onLoad(res);
6701
+ _context.next = 3;
6702
+ return request();
6694
6703
 
6695
- case 6:
6696
- case "end":
6697
- return _context.stop();
6704
+ case 3:
6705
+ res = _context.sent;
6706
+
6707
+ if (!isUnmount) {
6708
+ _context.next = 6;
6709
+ break;
6710
+ }
6711
+
6712
+ return _context.abrupt("return");
6713
+
6714
+ case 6:
6715
+ setResList(res);
6716
+ onLoad && onLoad(res);
6717
+
6718
+ case 8:
6719
+ case "end":
6720
+ return _context.stop();
6721
+ }
6698
6722
  }
6699
- }
6700
- }, _callee);
6701
- }))();
6723
+ }, _callee);
6724
+ }));
6725
+
6726
+ return function fetch() {
6727
+ return _ref.apply(this, arguments);
6728
+ };
6729
+ }();
6730
+
6731
+ fetch();
6732
+ return function () {
6733
+ isUnmount = true;
6734
+ };
6702
6735
  }, [JSON.stringify(params)]);
6703
6736
  return /*#__PURE__*/React.createElement(_Cascader, _objectSpread2({
6704
6737
  value: typeof value === 'string' ? [value] : value,
@@ -7933,7 +7966,7 @@ var WForm$1 = /*#__PURE__*/React.forwardRef(WForm);
7933
7966
 
7934
7967
  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"];
7935
7968
  function Table(_ref) {
7936
- var _formSearchRef$curren4, _classnames2;
7969
+ var _formSearchRef$curren4, _classnames2, _columns$, _columns$2;
7937
7970
 
7938
7971
  var columns = _ref.columns,
7939
7972
  tableList = _ref.dataSource,
@@ -8046,6 +8079,22 @@ function Table(_ref) {
8046
8079
  return !c.hideInTable;
8047
8080
  });
8048
8081
  }, [columns]);
8082
+
8083
+ var calcWidth = function calcWidth(columns) {
8084
+ return columns.reduce(function (pre, cur) {
8085
+ var width = cur.width;
8086
+
8087
+ if (width) {
8088
+ return pre + width;
8089
+ }
8090
+
8091
+ return pre;
8092
+ }, 0);
8093
+ };
8094
+
8095
+ var showColumns = columns.filter(function (c) {
8096
+ return !c.hideInTable;
8097
+ });
8049
8098
  var renderTh = useMemo(function () {
8050
8099
  var renderThFc = function renderThFc(columns, parentHeight, isChild) {
8051
8100
  var showColumns = columns.filter(function (c) {
@@ -8083,13 +8132,17 @@ function Table(_ref) {
8083
8132
  } else {
8084
8133
  return /*#__PURE__*/React.createElement("div", {
8085
8134
  key: c.dataIndex,
8086
- style: {
8135
+ style: _objectSpread2({
8087
8136
  width: c.width + 'px',
8088
8137
  flex: c.width ? '0 1 auto' : '1',
8089
8138
  height: !c.children ? '100%' : '32px',
8090
8139
  borderRight: index != showColumns.length - 1 && filterColumns.length !== showColumns.length ? '1px solid #3b5173' : 'none'
8091
- },
8092
- className: "td"
8140
+ }, c.fixed == 'left' ? {
8141
+ left: ((rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.type) ? 56 : 6) + calcWidth(showColumns.slice(0, index - 2 > 0 ? index - 1 : 0))
8142
+ } : c.fixed == 'right' ? {
8143
+ right: calcWidth(showColumns.slice(index + 1))
8144
+ } : {}),
8145
+ className: "td ".concat(c.fixed == 'left' ? 'fixedLeft' : c.fixed == 'right' ? 'fixedRight' : '')
8093
8146
  }, c.title);
8094
8147
  }
8095
8148
  });
@@ -8131,12 +8184,16 @@ function Table(_ref) {
8131
8184
  placement: "top",
8132
8185
  title: record[c.dataIndex]
8133
8186
  }, /*#__PURE__*/React.createElement("div", {
8134
- className: 'td' + (c.ellipsis ? ' ellipsis' : ''),
8135
- style: {
8187
+ className: "td ".concat(c.fixed == 'left' ? 'fixedLeft' : c.fixed == 'right' ? 'fixedRight' : '', " ").concat(c.ellipsis ? ' ellipsis' : ''),
8188
+ style: _objectSpread2({
8136
8189
  width: c.width + 'px',
8137
8190
  flex: c.width ? '0 1 auto' : '1',
8138
8191
  overflow: 'hidden'
8139
- }
8192
+ }, c.fixed == 'left' ? {
8193
+ left: ((rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.type) ? 56 : 6) + calcWidth(showColumns.slice(0, index - 2 > 0 ? index - 1 : 0))
8194
+ } : c.fixed == 'right' ? {
8195
+ right: calcWidth(showColumns.slice(index + 1))
8196
+ } : {})
8140
8197
  }, /*#__PURE__*/React.createElement("div", {
8141
8198
  style: {
8142
8199
  width: '100%',
@@ -8152,12 +8209,16 @@ function Table(_ref) {
8152
8209
 
8153
8210
  return /*#__PURE__*/React.createElement("div", {
8154
8211
  key: c.dataIndex,
8155
- className: 'td' + (c.ellipsis ? ' ellipsis' : ''),
8156
- style: {
8212
+ className: "td ".concat(c.fixed == 'left' ? 'fixedLeft' : c.fixed == 'right' ? 'fixedRight' : '', " ").concat(c.ellipsis ? ' ellipsis' : ''),
8213
+ style: _objectSpread2({
8157
8214
  width: c.width + 'px',
8158
8215
  flex: c.width ? '0 1 auto' : '1',
8159
8216
  overflow: 'hidden'
8160
- },
8217
+ }, c.fixed == 'left' ? {
8218
+ left: ((rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.type) ? 56 : 6) + calcWidth(showColumns.slice(0, index - 2 > 0 ? index - 1 : 0))
8219
+ } : c.fixed == 'right' ? {
8220
+ right: calcWidth(showColumns.slice(index + 1))
8221
+ } : {}),
8161
8222
  title: record[c.dataIndex]
8162
8223
  }, c.ellipsis ? /*#__PURE__*/React.createElement("div", {
8163
8224
  style: {
@@ -8188,11 +8249,13 @@ function Table(_ref) {
8188
8249
  tr: true
8189
8250
  }, typeof rowClassName === 'function' ? rowClassName(record, index) : '', true))
8190
8251
  }, typeof onRow === 'function' ? onRow(record, index) : {}), (rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.type) === 'checkbox' && /*#__PURE__*/React.createElement("div", {
8191
- style: {
8252
+ style: _objectSpread2({
8192
8253
  width: '50px',
8193
8254
  flex: '0 1 auto'
8194
- },
8195
- className: "td"
8255
+ }, showColumns[0].fixed == 'left' ? {
8256
+ left: 6
8257
+ } : {}),
8258
+ className: "td ".concat(showColumns[0].fixed == 'left' ? 'fixedLeft' : '')
8196
8259
  }, /*#__PURE__*/React.createElement(Index$3, {
8197
8260
  checked: (_ref2 = [].concat(_toConsumableArray((rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.selectedRowKeys) || []), _toConsumableArray(selectedRowKeys))) === null || _ref2 === void 0 ? void 0 : _ref2.includes(key),
8198
8261
  onClick: function onClick(e) {
@@ -8226,11 +8289,13 @@ function Table(_ref) {
8226
8289
  });
8227
8290
  }
8228
8291
  })), (rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.type) === 'radio' && /*#__PURE__*/React.createElement("div", {
8229
- style: {
8292
+ style: _objectSpread2({
8230
8293
  width: '50px',
8231
8294
  flex: '0 1 auto'
8232
- },
8233
- className: "td"
8295
+ }, showColumns[0].fixed == 'left' ? {
8296
+ left: 6
8297
+ } : {}),
8298
+ className: "td ".concat(showColumns[0].fixed == 'left' ? 'fixedLeft' : '')
8234
8299
  }, /*#__PURE__*/React.createElement(Index$2, {
8235
8300
  checked: (_ref3 = [].concat(_toConsumableArray((rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.selectedRowKeys) || []), _toConsumableArray(selectedRowKeys))) === null || _ref3 === void 0 ? void 0 : _ref3.includes(key),
8236
8301
  onClick: function onClick(e) {
@@ -8386,20 +8451,27 @@ function Table(_ref) {
8386
8451
  className: classnames((_classnames2 = {
8387
8452
  container: true
8388
8453
  }, _defineProperty(_classnames2, 'w-table', true), _defineProperty(_classnames2, 'w-frame-box-table', frameBoxTable), _defineProperty(_classnames2, className || 'defalut-table', true), _classnames2)),
8389
- style: style
8454
+ style: _objectSpread2(_objectSpread2({}, (scroll === null || scroll === void 0 ? void 0 : scroll.y) ? {
8455
+ height: scroll.y
8456
+ } : {}), style)
8390
8457
  }, /*#__PURE__*/React.createElement("div", {
8391
8458
  className: "theader"
8392
8459
  }, /*#__PURE__*/React.createElement("div", {
8393
8460
  className: "th",
8394
8461
  style: _objectSpread2(_objectSpread2({}, thStyle), {}, {
8395
8462
  height: layerIndex * 32 + 'px'
8396
- })
8463
+ }, (scroll === null || scroll === void 0 ? void 0 : scroll.x) ? {
8464
+ width: scroll.x
8465
+ } : {})
8397
8466
  }, (rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.type) === 'checkbox' && /*#__PURE__*/React.createElement("div", {
8398
- style: {
8467
+ style: _objectSpread2({
8399
8468
  width: '50px',
8400
- flex: '0 1 auto'
8401
- },
8402
- className: "td"
8469
+ flex: '0 1 auto',
8470
+ height: '100%'
8471
+ }, showColumns[0].fixed == 'left' ? {
8472
+ left: 6
8473
+ } : {}),
8474
+ className: "td ".concat(((_columns$ = columns[0]) === null || _columns$ === void 0 ? void 0 : _columns$.fixed) == 'left' ? 'fixedLeft' : '')
8403
8475
  }, /*#__PURE__*/React.createElement(Index$3, {
8404
8476
  checked: dataSource.every(function (record) {
8405
8477
  return selectedRowKeys.includes(typeof rowKey === 'function' ? record[rowKey(record)] : record[rowKey]);
@@ -8411,15 +8483,23 @@ function Table(_ref) {
8411
8483
  }),
8412
8484
  onChange: onSelectAllChange
8413
8485
  })), (rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.type) === 'radio' && /*#__PURE__*/React.createElement("div", {
8414
- style: {
8486
+ style: _objectSpread2({
8415
8487
  width: '50px',
8416
- flex: '0 1 auto'
8417
- },
8418
- className: "td"
8488
+ flex: '0 1 auto',
8489
+ height: '100%'
8490
+ }, showColumns[0].fixed == 'left' ? {
8491
+ left: 6
8492
+ } : {}),
8493
+ className: "td ".concat(((_columns$2 = columns[0]) === null || _columns$2 === void 0 ? void 0 : _columns$2.fixed) == 'left' ? 'fixedLeft' : '')
8419
8494
  }), renderTh)), /*#__PURE__*/React.createElement("div", {
8495
+ className: "tbodyContainer",
8496
+ style: _objectSpread2({}, (scroll === null || scroll === void 0 ? void 0 : scroll.x) ? {
8497
+ width: scroll.x
8498
+ } : {})
8499
+ }, /*#__PURE__*/React.createElement("div", {
8420
8500
  className: "tbody",
8421
8501
  style: _objectSpread2({
8422
- height: (style === null || style === void 0 ? void 0 : style.height) ? "calc(".concat(style.height, " - ").concat(52 + (pagination === false ? 0 : 42), "px)") : '200px'
8502
+ 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'
8423
8503
  }, tbodyStyle)
8424
8504
  }, dataSource.length > 0 ? dataSource.map(function (record, index) {
8425
8505
  var key = typeof rowKey === 'function' ? record[rowKey(record)] : record[rowKey];
@@ -8438,12 +8518,12 @@ function Table(_ref) {
8438
8518
  justifyContent: 'center',
8439
8519
  alignItems: 'center'
8440
8520
  }
8441
- }, none || '暂无数据')), _typeof(pagination) === 'object' && /*#__PURE__*/React.createElement(_Pagination, _objectSpread2({
8521
+ }, none || '暂无数据')))), _typeof(pagination) === 'object' && /*#__PURE__*/React.createElement(_Pagination, _objectSpread2({
8442
8522
  style: {
8443
8523
  textAlign: 'right',
8444
8524
  marginTop: '10px'
8445
8525
  }
8446
- }, paginationParams))));
8526
+ }, paginationParams)));
8447
8527
  }
8448
8528
  Table.defaultProps = {
8449
8529
  rowKey: 'key'
@@ -10167,7 +10247,7 @@ var ModalForm = function ModalForm(props, ref) {
10167
10247
  resetFields();
10168
10248
  setFieldsValue(record);
10169
10249
  }
10170
- }, [visible, record, formRef === null || formRef === void 0 ? void 0 : formRef.current]);
10250
+ }, [visible, record]);
10171
10251
  return /*#__PURE__*/React.createElement(_Modal, _objectSpread2(_objectSpread2({
10172
10252
  title: title,
10173
10253
  visible: visible