assui 2.0.74 → 2.0.78
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/keep-tab/index.js +17 -21
- package/lib/keep-tab/index.js +18 -21
- package/package.json +3 -3
package/es/keep-tab/index.js
CHANGED
|
@@ -60,6 +60,7 @@ import Badge from 'antd/es/badge';
|
|
|
60
60
|
import Tabs from 'antd/es/tabs';
|
|
61
61
|
import { useParams } from 'react-router-dom';
|
|
62
62
|
import useUrlState from '@ahooksjs/use-url-state';
|
|
63
|
+
import useControllableValue from 'ahooks/es/useControllableValue';
|
|
63
64
|
import toArray from 'rc-util/lib/Children/toArray';
|
|
64
65
|
var TabPane = Tabs.TabPane;
|
|
65
66
|
var defaultBadgeProps = {};
|
|
@@ -70,11 +71,10 @@ var KeepTab = function KeepTab(props) {
|
|
|
70
71
|
var children = props.children,
|
|
71
72
|
defaultActiveKey = props.defaultActiveKey,
|
|
72
73
|
saveActiveKeyName = props.saveActiveKeyName,
|
|
73
|
-
tabActiveKey = props.activeKey,
|
|
74
74
|
onChange = props.onChange,
|
|
75
75
|
_b = props.badgeProps,
|
|
76
76
|
badgeProps = _b === void 0 ? defaultBadgeProps : _b,
|
|
77
|
-
restProps = __rest(props, ["children", "defaultActiveKey", "saveActiveKeyName", "
|
|
77
|
+
restProps = __rest(props, ["children", "defaultActiveKey", "saveActiveKeyName", "onChange", "badgeProps"]);
|
|
78
78
|
|
|
79
79
|
var defaultUrlParams = useParams();
|
|
80
80
|
|
|
@@ -82,21 +82,28 @@ var KeepTab = function KeepTab(props) {
|
|
|
82
82
|
urlParams = _c[0],
|
|
83
83
|
setUrlParams = _c[1];
|
|
84
84
|
|
|
85
|
+
var _d = __read(useControllableValue(props, {
|
|
86
|
+
valuePropName: 'activeKey',
|
|
87
|
+
defaultValue: defaultUrlParams[saveActiveKeyName] || defaultActiveKey
|
|
88
|
+
}), 2),
|
|
89
|
+
tabActiveKey = _d[0],
|
|
90
|
+
setTabActiveKey = _d[1];
|
|
91
|
+
|
|
85
92
|
var arrayChildren = toArray(children);
|
|
86
93
|
React.useEffect(function () {
|
|
87
94
|
var _a, _b;
|
|
88
95
|
|
|
89
|
-
if (
|
|
96
|
+
if (!('activeKey' in props)) {
|
|
90
97
|
var resultActiveTab = find(arrayChildren, {
|
|
91
|
-
key:
|
|
98
|
+
key: urlParams[saveActiveKeyName]
|
|
92
99
|
});
|
|
93
100
|
|
|
94
101
|
if (!resultActiveTab || resultActiveTab.props.disabled) {
|
|
95
102
|
setUrlParams((_a = {}, _a[saveActiveKeyName] = arrayChildren[0].key, _a));
|
|
96
|
-
|
|
97
|
-
} else {
|
|
98
|
-
setUrlParams((_b = {}, _b[saveActiveKeyName] = tabActiveKey, _b));
|
|
103
|
+
setTabActiveKey(arrayChildren[0].key);
|
|
99
104
|
}
|
|
105
|
+
} else {
|
|
106
|
+
setUrlParams((_b = {}, _b[saveActiveKeyName] = tabActiveKey, _b));
|
|
100
107
|
}
|
|
101
108
|
}, [tabActiveKey]);
|
|
102
109
|
|
|
@@ -104,10 +111,7 @@ var KeepTab = function KeepTab(props) {
|
|
|
104
111
|
var _a;
|
|
105
112
|
|
|
106
113
|
setUrlParams((_a = {}, _a[saveActiveKeyName] = nextActiveKey, _a));
|
|
107
|
-
|
|
108
|
-
if (onChange) {
|
|
109
|
-
onChange(nextActiveKey);
|
|
110
|
-
}
|
|
114
|
+
setTabActiveKey(nextActiveKey);
|
|
111
115
|
};
|
|
112
116
|
|
|
113
117
|
var resultChildren = arrayChildren.map(function (childItem) {
|
|
@@ -127,20 +131,12 @@ var KeepTab = function KeepTab(props) {
|
|
|
127
131
|
|
|
128
132
|
return childItem;
|
|
129
133
|
});
|
|
130
|
-
var resultTabActiveKey = {};
|
|
131
|
-
|
|
132
|
-
if (tabActiveKey) {
|
|
133
|
-
resultTabActiveKey = {
|
|
134
|
-
activeKey: tabActiveKey
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
|
|
138
134
|
return /*#__PURE__*/React.createElement(Tabs, __assign({
|
|
139
135
|
animated: false,
|
|
140
136
|
onChange: handleTabChange,
|
|
141
137
|
destroyInactiveTabPane: true,
|
|
142
|
-
|
|
143
|
-
},
|
|
138
|
+
activeKey: tabActiveKey
|
|
139
|
+
}, restProps), resultChildren);
|
|
144
140
|
};
|
|
145
141
|
|
|
146
142
|
KeepTab.defaultProps = {
|
package/lib/keep-tab/index.js
CHANGED
|
@@ -112,6 +112,8 @@ var react_router_dom_1 = require("react-router-dom");
|
|
|
112
112
|
|
|
113
113
|
var use_url_state_1 = __importDefault(require("@ahooksjs/use-url-state"));
|
|
114
114
|
|
|
115
|
+
var useControllableValue_1 = __importDefault(require("ahooks/es/useControllableValue"));
|
|
116
|
+
|
|
115
117
|
var toArray_1 = __importDefault(require("rc-util/lib/Children/toArray"));
|
|
116
118
|
|
|
117
119
|
var TabPane = tabs_1["default"].TabPane;
|
|
@@ -123,11 +125,10 @@ var KeepTab = function KeepTab(props) {
|
|
|
123
125
|
var children = props.children,
|
|
124
126
|
defaultActiveKey = props.defaultActiveKey,
|
|
125
127
|
saveActiveKeyName = props.saveActiveKeyName,
|
|
126
|
-
tabActiveKey = props.activeKey,
|
|
127
128
|
onChange = props.onChange,
|
|
128
129
|
_b = props.badgeProps,
|
|
129
130
|
badgeProps = _b === void 0 ? defaultBadgeProps : _b,
|
|
130
|
-
restProps = __rest(props, ["children", "defaultActiveKey", "saveActiveKeyName", "
|
|
131
|
+
restProps = __rest(props, ["children", "defaultActiveKey", "saveActiveKeyName", "onChange", "badgeProps"]);
|
|
131
132
|
|
|
132
133
|
var defaultUrlParams = react_router_dom_1.useParams();
|
|
133
134
|
|
|
@@ -135,21 +136,28 @@ var KeepTab = function KeepTab(props) {
|
|
|
135
136
|
urlParams = _c[0],
|
|
136
137
|
setUrlParams = _c[1];
|
|
137
138
|
|
|
139
|
+
var _d = __read(useControllableValue_1["default"](props, {
|
|
140
|
+
valuePropName: 'activeKey',
|
|
141
|
+
defaultValue: defaultUrlParams[saveActiveKeyName] || defaultActiveKey
|
|
142
|
+
}), 2),
|
|
143
|
+
tabActiveKey = _d[0],
|
|
144
|
+
setTabActiveKey = _d[1];
|
|
145
|
+
|
|
138
146
|
var arrayChildren = toArray_1["default"](children);
|
|
139
147
|
React.useEffect(function () {
|
|
140
148
|
var _a, _b;
|
|
141
149
|
|
|
142
|
-
if (
|
|
150
|
+
if (!('activeKey' in props)) {
|
|
143
151
|
var resultActiveTab = lodash_1.find(arrayChildren, {
|
|
144
|
-
key:
|
|
152
|
+
key: urlParams[saveActiveKeyName]
|
|
145
153
|
});
|
|
146
154
|
|
|
147
155
|
if (!resultActiveTab || resultActiveTab.props.disabled) {
|
|
148
156
|
setUrlParams((_a = {}, _a[saveActiveKeyName] = arrayChildren[0].key, _a));
|
|
149
|
-
|
|
150
|
-
} else {
|
|
151
|
-
setUrlParams((_b = {}, _b[saveActiveKeyName] = tabActiveKey, _b));
|
|
157
|
+
setTabActiveKey(arrayChildren[0].key);
|
|
152
158
|
}
|
|
159
|
+
} else {
|
|
160
|
+
setUrlParams((_b = {}, _b[saveActiveKeyName] = tabActiveKey, _b));
|
|
153
161
|
}
|
|
154
162
|
}, [tabActiveKey]);
|
|
155
163
|
|
|
@@ -157,10 +165,7 @@ var KeepTab = function KeepTab(props) {
|
|
|
157
165
|
var _a;
|
|
158
166
|
|
|
159
167
|
setUrlParams((_a = {}, _a[saveActiveKeyName] = nextActiveKey, _a));
|
|
160
|
-
|
|
161
|
-
if (onChange) {
|
|
162
|
-
onChange(nextActiveKey);
|
|
163
|
-
}
|
|
168
|
+
setTabActiveKey(nextActiveKey);
|
|
164
169
|
};
|
|
165
170
|
|
|
166
171
|
var resultChildren = arrayChildren.map(function (childItem) {
|
|
@@ -180,20 +185,12 @@ var KeepTab = function KeepTab(props) {
|
|
|
180
185
|
|
|
181
186
|
return childItem;
|
|
182
187
|
});
|
|
183
|
-
var resultTabActiveKey = {};
|
|
184
|
-
|
|
185
|
-
if (tabActiveKey) {
|
|
186
|
-
resultTabActiveKey = {
|
|
187
|
-
activeKey: tabActiveKey
|
|
188
|
-
};
|
|
189
|
-
}
|
|
190
|
-
|
|
191
188
|
return React.createElement(tabs_1["default"], __assign({
|
|
192
189
|
animated: false,
|
|
193
190
|
onChange: handleTabChange,
|
|
194
191
|
destroyInactiveTabPane: true,
|
|
195
|
-
|
|
196
|
-
},
|
|
192
|
+
activeKey: tabActiveKey
|
|
193
|
+
}, restProps), resultChildren);
|
|
197
194
|
};
|
|
198
195
|
|
|
199
196
|
KeepTab.defaultProps = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "assui",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.78",
|
|
4
4
|
"description": "react ui library",
|
|
5
5
|
"author": "jason <usochen@gmail.com>",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"@ahooksjs/use-url-state": "^2.5.8",
|
|
34
34
|
"@tinymce/tinymce-react": "^3.13.0",
|
|
35
35
|
"@types/react-beautiful-dnd": "^13.1.2",
|
|
36
|
-
"a-icons": "^1.0.
|
|
36
|
+
"a-icons": "^1.0.43",
|
|
37
37
|
"ahooks": "^3.0.8",
|
|
38
38
|
"bignumber.js": "^9.0.1",
|
|
39
39
|
"copy-to-clipboard": "^3.3.1",
|
|
@@ -69,5 +69,5 @@
|
|
|
69
69
|
"node": ">=10.0.0"
|
|
70
70
|
},
|
|
71
71
|
"license": "MIT",
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "b2c664a6401c4e18e4d5ce6ddf01f565f8e85777"
|
|
73
73
|
}
|