wargerm 0.4.5 → 0.4.6
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/components/Select/index.d.ts +2 -1
- package/dist/index.esm.js +84 -51
- package/dist/index.js +83 -50
- package/package.json +1 -1
- package/dist/hooks/index.d.ts +0 -1
@@ -1,4 +1,4 @@
|
|
1
|
-
import React from 'react';
|
1
|
+
import React, { ReactNode } from 'react';
|
2
2
|
import { SelectProps, OptionProps } from 'antd/lib/Select';
|
3
3
|
export interface IOptionProps extends OptionProps {
|
4
4
|
}
|
@@ -7,6 +7,7 @@ export interface ISelect extends SelectProps<any> {
|
|
7
7
|
valueEnum?: Record<string, any>;
|
8
8
|
params?: Record<string, any>;
|
9
9
|
onLoad?: (options: Record<string, any>[]) => void;
|
10
|
+
children?: ReactNode;
|
10
11
|
}
|
11
12
|
export declare type IWSelectComponent = React.FC<ISelect> & {
|
12
13
|
Option?: React.FC<IOptionProps>;
|
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
|
-
|
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 =
|
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
|
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__*/
|
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
|
-
|
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 =
|
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 =
|
6642
|
+
_context.next = 11;
|
6636
6643
|
break;
|
6637
6644
|
|
6638
|
-
case
|
6645
|
+
case 10:
|
6639
6646
|
setTreeData(treePropsData || []);
|
6640
6647
|
|
6641
|
-
case
|
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
|
-
|
6676
|
-
|
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
|
-
|
6688
|
-
|
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
|
-
|
6691
|
-
|
6692
|
-
setResList(res);
|
6693
|
-
onLoad && onLoad(res);
|
6701
|
+
_context.next = 3;
|
6702
|
+
return request();
|
6694
6703
|
|
6695
|
-
|
6696
|
-
|
6697
|
-
|
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
|
-
}
|
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,
|
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
|
-
|
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 =
|
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
|
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__*/
|
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
|
-
|
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 =
|
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 =
|
6677
|
+
_context.next = 11;
|
6671
6678
|
break;
|
6672
6679
|
|
6673
|
-
case
|
6680
|
+
case 10:
|
6674
6681
|
setTreeData(treePropsData || []);
|
6675
6682
|
|
6676
|
-
case
|
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
|
-
|
6711
|
-
|
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
|
-
|
6723
|
-
|
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
|
-
|
6726
|
-
|
6727
|
-
setResList(res);
|
6728
|
-
onLoad && onLoad(res);
|
6736
|
+
_context.next = 3;
|
6737
|
+
return request();
|
6729
6738
|
|
6730
|
-
|
6731
|
-
|
6732
|
-
|
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
|
-
}
|
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,
|
package/package.json
CHANGED
package/dist/hooks/index.d.ts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export declare const usePreventUnmountEffect: (callback: Function, deps: Array<any>) => void;
|