wargerm 0.5.10 → 0.5.13

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
@@ -584,14 +584,17 @@ var Index = WInput;
584
584
  Index.TextArea = _Input.TextArea;
585
585
  WInput.defaultProps = {};
586
586
 
587
- var _excluded$1 = ["value", "onChange", "beforeUpload", "uploadButton", "maxCount", "fetchMethod", "getFileList"];
587
+ var _excluded$1 = ["value", "onChange", "onRemove", "beforeUpload", "uploadButton", "maxCount", "splitStr", "fetchMethod", "getFileList"];
588
588
 
589
589
  function Index$1(_ref, ref) {
590
590
  var value = _ref.value,
591
591
  onChange = _ref.onChange,
592
+ onRemove = _ref.onRemove,
592
593
  beforeUpload = _ref.beforeUpload,
593
594
  uploadButton = _ref.uploadButton,
594
595
  maxCount = _ref.maxCount,
596
+ _ref$splitStr = _ref.splitStr,
597
+ splitStr = _ref$splitStr === void 0 ? ',' : _ref$splitStr,
595
598
  fetchMethod = _ref.fetchMethod,
596
599
  getFileList = _ref.getFileList,
597
600
  props = _objectWithoutProperties(_ref, _excluded$1);
@@ -602,7 +605,7 @@ function Index$1(_ref, ref) {
602
605
  setFileList = _useState2[1];
603
606
 
604
607
  useEffect(function () {
605
- setFileList(value ? value.split(',').map(function (url) {
608
+ setFileList(value ? value.split(splitStr).map(function (url) {
606
609
  return {
607
610
  uid: Math.random().toString(36).slice(2, 36),
608
611
  name: '',
@@ -682,7 +685,7 @@ function Index$1(_ref, ref) {
682
685
  }
683
686
 
684
687
  _context.next = 4;
685
- return fetchMethod ? fetchMethod(file.originFileObj) : getBase64(file.originFileObj);
688
+ return fetchMethod ? fetchMethod(file.originFileObj) : file.originFileObj ? getBase64(file.originFileObj) : Promise.resolve(file.url);
686
689
 
687
690
  case 4:
688
691
  url = _context.sent;
@@ -694,7 +697,7 @@ function Index$1(_ref, ref) {
694
697
  case 6:
695
698
  urls = newFileList.map(function (file) {
696
699
  return file.url;
697
- }).join(',');
700
+ }).join(splitStr);
698
701
  onChange && onChange(urls);
699
702
  setFileList(newFileList);
700
703
 
@@ -711,6 +714,15 @@ function Index$1(_ref, ref) {
711
714
  };
712
715
  }();
713
716
 
717
+ var handleronRemove = function handleronRemove(file) {
718
+ var index = fileList.indexOf(file);
719
+ onRemove && onRemove(file, function () {
720
+ var newFileList = fileList.slice();
721
+ newFileList.splice(index, 1);
722
+ setFileList(newFileList);
723
+ });
724
+ };
725
+
714
726
  var handlePreview = /*#__PURE__*/function () {
715
727
  var _ref4 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(file) {
716
728
  return regeneratorRuntime.wrap(function _callee2$(_context2) {
@@ -761,7 +773,8 @@ function Index$1(_ref, ref) {
761
773
  listType: "picture-card",
762
774
  beforeUpload: beforeUploadIn,
763
775
  onPreview: handlePreview,
764
- onChange: handleChange
776
+ onChange: handleChange,
777
+ onRemove: handleronRemove
765
778
  }, props), fileList.length >= maxCount ? null : uploadButton ? uploadButton : uploadButtonDom), /*#__PURE__*/React.createElement(_Modal, {
766
779
  visible: previewVisible,
767
780
  title: previewTitle,
@@ -828,7 +841,7 @@ Index$4.Group = _Checkbox.Group;
828
841
  /*
829
842
  * @Author: lijin
830
843
  * @Date: 2021-10-27 22:18:49
831
- * @LastEditTime: 2022-08-09 09:35:23
844
+ * @LastEditTime: 2022-08-11 10:57:14
832
845
  * @LastEditors: lijin
833
846
  * @Description:
834
847
  * @FilePath: \wargerm-components\src\utils\index.ts
@@ -902,10 +915,26 @@ function deepCopy(target) {
902
915
  var result = Array.isArray(target) ? [] : {}; // eslint-disable-next-line no-restricted-syntax
903
916
 
904
917
  for (var key in target) {
905
- var _target$key;
918
+ if (_typeof(target[key]) === 'object') {
919
+ if (Object.prototype.toString.call(target).slice(8, -1) == 'Object') {
920
+ var _target$key, _target$key2;
921
+
922
+ if (((_target$key = target[key]) === null || _target$key === void 0 ? void 0 : _target$key['$$typeof']) || ((_target$key2 = target[key]) === null || _target$key2 === void 0 ? void 0 : _target$key2['_isAMomentObject'])) {
923
+ result[key] = target[key];
924
+ } else {
925
+ result[key] = deepCopy(target[key]);
926
+ }
927
+ } else if (Object.prototype.toString.call(target).slice(8, -1) == 'Array') {
928
+ var _target$key3, _target$key4;
906
929
 
907
- if (Object.prototype.toString.call(target).slice(8, -1) == 'Object' && !((_target$key = target[key]) === null || _target$key === void 0 ? void 0 : _target$key['$$typeof'])) {
908
- result[key] = deepCopy(target[key]);
930
+ if (((_target$key3 = target[key]) === null || _target$key3 === void 0 ? void 0 : _target$key3['$$typeof']) || ((_target$key4 = target[key]) === null || _target$key4 === void 0 ? void 0 : _target$key4['_isAMomentObject'])) {
931
+ result[key] = target[key];
932
+ } else {
933
+ result[key] = deepCopy(target[key]);
934
+ }
935
+ } else {
936
+ result[key] = target[key];
937
+ }
909
938
  } else {
910
939
  result[key] = target[key];
911
940
  }
@@ -10849,7 +10878,7 @@ function DragBox(_ref) {
10849
10878
  }, children)) : /*#__PURE__*/React.createElement(React.Fragment, null);
10850
10879
  }
10851
10880
 
10852
- var _excluded$h = ["columns", "extraColumns", "search", "visible", "setVisible", "disabled", "submitMethod", "onSubmitSuccess", "title", "record", "onFormChange", "formItemChild", "onCancel"];
10881
+ var _excluded$h = ["columns", "extraColumns", "search", "visible", "setVisible", "modalFormOpend", "disabled", "submitMethod", "onSubmitSuccess", "title", "record", "onFormChange", "formItemChild", "onCancel"];
10853
10882
 
10854
10883
  var ModalForm = function ModalForm(props, ref) {
10855
10884
  var columns = props.columns,
@@ -10857,6 +10886,7 @@ var ModalForm = function ModalForm(props, ref) {
10857
10886
  search = props.search,
10858
10887
  visible = props.visible,
10859
10888
  setVisible = props.setVisible,
10889
+ modalFormOpend = props.modalFormOpend,
10860
10890
  disabled = props.disabled,
10861
10891
  submitMethod = props.submitMethod,
10862
10892
  onSubmitSuccess = props.onSubmitSuccess,
@@ -10901,7 +10931,8 @@ var ModalForm = function ModalForm(props, ref) {
10901
10931
  useImperativeHandle(ref, function () {
10902
10932
  return {
10903
10933
  formRef: formRef.current,
10904
- onSubmit: onSubmit
10934
+ onSubmit: onSubmit,
10935
+ modalFormvisible: visible
10905
10936
  };
10906
10937
  });
10907
10938
 
@@ -10972,6 +11003,7 @@ var ModalForm = function ModalForm(props, ref) {
10972
11003
  if (visible) {
10973
11004
  resetFields();
10974
11005
  setFieldsValue(record);
11006
+ modalFormOpend && modalFormOpend(record);
10975
11007
  }
10976
11008
  }, [visible, record]);
10977
11009
  return /*#__PURE__*/React.createElement(_Modal, _objectSpread2(_objectSpread2({
@@ -11036,6 +11068,8 @@ var TabelCard = function TabelCard(props, ref) {
11036
11068
  formSearch = _useState6[0],
11037
11069
  setFormSearch = _useState6[1];
11038
11070
 
11071
+ var modalFormColumn = deepCopy(columns) || [];
11072
+ var formSearchColumn = deepCopy(columns) || [];
11039
11073
  useImperativeHandle(ref, function () {
11040
11074
  return {
11041
11075
  actionRef: actionRef.current,
@@ -11387,7 +11421,6 @@ var TabelCard = function TabelCard(props, ref) {
11387
11421
  setFormSearch(obj);
11388
11422
  }
11389
11423
  }, [columns]);
11390
- var formSearchColumn = columns || [];
11391
11424
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ModalForm$1, _objectSpread2(_objectSpread2({
11392
11425
  ref: modalFormRef,
11393
11426
  title: modalFormConfig.type || '新增',
@@ -11428,7 +11461,7 @@ var TabelCard = function TabelCard(props, ref) {
11428
11461
  }, modalConfig), {}, {
11429
11462
  onFormChange: onFormChange,
11430
11463
  extraColumns: extraColumns || [],
11431
- columns: (columns || []).filter(function (item) {
11464
+ columns: (modalFormColumn || []).filter(function (item) {
11432
11465
  if (item.hiddenInModalForm) {
11433
11466
  return false;
11434
11467
  }
package/dist/index.js CHANGED
@@ -644,14 +644,17 @@ var Index = WInput;
644
644
  Index.TextArea = _Input__default['default'].TextArea;
645
645
  WInput.defaultProps = {};
646
646
 
647
- var _excluded$1 = ["value", "onChange", "beforeUpload", "uploadButton", "maxCount", "fetchMethod", "getFileList"];
647
+ var _excluded$1 = ["value", "onChange", "onRemove", "beforeUpload", "uploadButton", "maxCount", "splitStr", "fetchMethod", "getFileList"];
648
648
 
649
649
  function Index$1(_ref, ref) {
650
650
  var value = _ref.value,
651
651
  onChange = _ref.onChange,
652
+ onRemove = _ref.onRemove,
652
653
  beforeUpload = _ref.beforeUpload,
653
654
  uploadButton = _ref.uploadButton,
654
655
  maxCount = _ref.maxCount,
656
+ _ref$splitStr = _ref.splitStr,
657
+ splitStr = _ref$splitStr === void 0 ? ',' : _ref$splitStr,
655
658
  fetchMethod = _ref.fetchMethod,
656
659
  getFileList = _ref.getFileList,
657
660
  props = _objectWithoutProperties(_ref, _excluded$1);
@@ -662,7 +665,7 @@ function Index$1(_ref, ref) {
662
665
  setFileList = _useState2[1];
663
666
 
664
667
  React.useEffect(function () {
665
- setFileList(value ? value.split(',').map(function (url) {
668
+ setFileList(value ? value.split(splitStr).map(function (url) {
666
669
  return {
667
670
  uid: Math.random().toString(36).slice(2, 36),
668
671
  name: '',
@@ -742,7 +745,7 @@ function Index$1(_ref, ref) {
742
745
  }
743
746
 
744
747
  _context.next = 4;
745
- return fetchMethod ? fetchMethod(file.originFileObj) : getBase64(file.originFileObj);
748
+ return fetchMethod ? fetchMethod(file.originFileObj) : file.originFileObj ? getBase64(file.originFileObj) : Promise.resolve(file.url);
746
749
 
747
750
  case 4:
748
751
  url = _context.sent;
@@ -754,7 +757,7 @@ function Index$1(_ref, ref) {
754
757
  case 6:
755
758
  urls = newFileList.map(function (file) {
756
759
  return file.url;
757
- }).join(',');
760
+ }).join(splitStr);
758
761
  onChange && onChange(urls);
759
762
  setFileList(newFileList);
760
763
 
@@ -771,6 +774,15 @@ function Index$1(_ref, ref) {
771
774
  };
772
775
  }();
773
776
 
777
+ var handleronRemove = function handleronRemove(file) {
778
+ var index = fileList.indexOf(file);
779
+ onRemove && onRemove(file, function () {
780
+ var newFileList = fileList.slice();
781
+ newFileList.splice(index, 1);
782
+ setFileList(newFileList);
783
+ });
784
+ };
785
+
774
786
  var handlePreview = /*#__PURE__*/function () {
775
787
  var _ref4 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(file) {
776
788
  return regeneratorRuntime.wrap(function _callee2$(_context2) {
@@ -821,7 +833,8 @@ function Index$1(_ref, ref) {
821
833
  listType: "picture-card",
822
834
  beforeUpload: beforeUploadIn,
823
835
  onPreview: handlePreview,
824
- onChange: handleChange
836
+ onChange: handleChange,
837
+ onRemove: handleronRemove
825
838
  }, props), fileList.length >= maxCount ? null : uploadButton ? uploadButton : uploadButtonDom), /*#__PURE__*/React__default['default'].createElement(_Modal__default['default'], {
826
839
  visible: previewVisible,
827
840
  title: previewTitle,
@@ -888,7 +901,7 @@ Index$4.Group = _Checkbox__default['default'].Group;
888
901
  /*
889
902
  * @Author: lijin
890
903
  * @Date: 2021-10-27 22:18:49
891
- * @LastEditTime: 2022-08-09 09:35:23
904
+ * @LastEditTime: 2022-08-11 10:57:14
892
905
  * @LastEditors: lijin
893
906
  * @Description:
894
907
  * @FilePath: \wargerm-components\src\utils\index.ts
@@ -962,10 +975,26 @@ function deepCopy(target) {
962
975
  var result = Array.isArray(target) ? [] : {}; // eslint-disable-next-line no-restricted-syntax
963
976
 
964
977
  for (var key in target) {
965
- var _target$key;
978
+ if (_typeof(target[key]) === 'object') {
979
+ if (Object.prototype.toString.call(target).slice(8, -1) == 'Object') {
980
+ var _target$key, _target$key2;
981
+
982
+ if (((_target$key = target[key]) === null || _target$key === void 0 ? void 0 : _target$key['$$typeof']) || ((_target$key2 = target[key]) === null || _target$key2 === void 0 ? void 0 : _target$key2['_isAMomentObject'])) {
983
+ result[key] = target[key];
984
+ } else {
985
+ result[key] = deepCopy(target[key]);
986
+ }
987
+ } else if (Object.prototype.toString.call(target).slice(8, -1) == 'Array') {
988
+ var _target$key3, _target$key4;
966
989
 
967
- if (Object.prototype.toString.call(target).slice(8, -1) == 'Object' && !((_target$key = target[key]) === null || _target$key === void 0 ? void 0 : _target$key['$$typeof'])) {
968
- result[key] = deepCopy(target[key]);
990
+ if (((_target$key3 = target[key]) === null || _target$key3 === void 0 ? void 0 : _target$key3['$$typeof']) || ((_target$key4 = target[key]) === null || _target$key4 === void 0 ? void 0 : _target$key4['_isAMomentObject'])) {
991
+ result[key] = target[key];
992
+ } else {
993
+ result[key] = deepCopy(target[key]);
994
+ }
995
+ } else {
996
+ result[key] = target[key];
997
+ }
969
998
  } else {
970
999
  result[key] = target[key];
971
1000
  }
@@ -10909,7 +10938,7 @@ function DragBox(_ref) {
10909
10938
  }, children)) : /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null);
10910
10939
  }
10911
10940
 
10912
- var _excluded$h = ["columns", "extraColumns", "search", "visible", "setVisible", "disabled", "submitMethod", "onSubmitSuccess", "title", "record", "onFormChange", "formItemChild", "onCancel"];
10941
+ var _excluded$h = ["columns", "extraColumns", "search", "visible", "setVisible", "modalFormOpend", "disabled", "submitMethod", "onSubmitSuccess", "title", "record", "onFormChange", "formItemChild", "onCancel"];
10913
10942
 
10914
10943
  var ModalForm = function ModalForm(props, ref) {
10915
10944
  var columns = props.columns,
@@ -10917,6 +10946,7 @@ var ModalForm = function ModalForm(props, ref) {
10917
10946
  search = props.search,
10918
10947
  visible = props.visible,
10919
10948
  setVisible = props.setVisible,
10949
+ modalFormOpend = props.modalFormOpend,
10920
10950
  disabled = props.disabled,
10921
10951
  submitMethod = props.submitMethod,
10922
10952
  onSubmitSuccess = props.onSubmitSuccess,
@@ -10961,7 +10991,8 @@ var ModalForm = function ModalForm(props, ref) {
10961
10991
  React.useImperativeHandle(ref, function () {
10962
10992
  return {
10963
10993
  formRef: formRef.current,
10964
- onSubmit: onSubmit
10994
+ onSubmit: onSubmit,
10995
+ modalFormvisible: visible
10965
10996
  };
10966
10997
  });
10967
10998
 
@@ -11032,6 +11063,7 @@ var ModalForm = function ModalForm(props, ref) {
11032
11063
  if (visible) {
11033
11064
  resetFields();
11034
11065
  setFieldsValue(record);
11066
+ modalFormOpend && modalFormOpend(record);
11035
11067
  }
11036
11068
  }, [visible, record]);
11037
11069
  return /*#__PURE__*/React__default['default'].createElement(_Modal__default['default'], _objectSpread2(_objectSpread2({
@@ -11096,6 +11128,8 @@ var TabelCard = function TabelCard(props, ref) {
11096
11128
  formSearch = _useState6[0],
11097
11129
  setFormSearch = _useState6[1];
11098
11130
 
11131
+ var modalFormColumn = deepCopy(columns) || [];
11132
+ var formSearchColumn = deepCopy(columns) || [];
11099
11133
  React.useImperativeHandle(ref, function () {
11100
11134
  return {
11101
11135
  actionRef: actionRef.current,
@@ -11447,7 +11481,6 @@ var TabelCard = function TabelCard(props, ref) {
11447
11481
  setFormSearch(obj);
11448
11482
  }
11449
11483
  }, [columns]);
11450
- var formSearchColumn = columns || [];
11451
11484
  return /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement(ModalForm$1, _objectSpread2(_objectSpread2({
11452
11485
  ref: modalFormRef,
11453
11486
  title: modalFormConfig.type || '新增',
@@ -11488,7 +11521,7 @@ var TabelCard = function TabelCard(props, ref) {
11488
11521
  }, modalConfig), {}, {
11489
11522
  onFormChange: onFormChange,
11490
11523
  extraColumns: extraColumns || [],
11491
- columns: (columns || []).filter(function (item) {
11524
+ columns: (modalFormColumn || []).filter(function (item) {
11492
11525
  if (item.hiddenInModalForm) {
11493
11526
  return false;
11494
11527
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "wargerm",
4
- "version": "0.5.10",
4
+ "version": "0.5.13",
5
5
  "scripts": {
6
6
  "dev": "dumi dev",
7
7
  "docs:build": "dumi build",