xmirror-components 1.0.36 → 1.0.38
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/build/dist/index.cjs +10 -8
- package/build/dist/index.mjs +287 -263
- package/build/es/components/SearchArea/index.js +1 -1
- package/build/es/hooks/useSearchParams/index.d.ts +9 -0
- package/build/es/hooks/useSearchParams/index.js +26 -5
- package/build/lib/components/SearchArea/index.js +1 -1
- package/build/lib/hooks/useSearchParams/index.js +26 -5
- package/build/package.json +1 -1
- package/build/types/hooks/useSearchParams/index.d.ts +9 -0
- package/package.json +1 -1
|
@@ -34,7 +34,7 @@ import { FormattedMessage } from '../IntlProvider';
|
|
|
34
34
|
var AnimatedContainer = styled('div', {
|
|
35
35
|
shouldForwardProp: function (prop) { return prop !== 'show'; },
|
|
36
36
|
})(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n overflow: hidden;\n transition: max-height 0.4s ease-in-out;\n max-height: ", ";\n"], ["\n overflow: hidden;\n transition: max-height 0.4s ease-in-out;\n max-height: ", ";\n"])), function (props) { return props.show ? '450px' : '0'; });
|
|
37
|
-
var StyledForm = styled(Form)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n padding: 20px;\n
|
|
37
|
+
var StyledForm = styled(Form)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n &.ant-form {\n padding: 20px;\n padding-bottom: 0;\n margin-bottom: 20px;\n background: #F7FAFB;\n border: 1px solid #F3F3F4;\n\n .ant-form-item {\n margin-bottom: 20px;\n }\n }\n"], ["\n &.ant-form {\n padding: 20px;\n padding-bottom: 0;\n margin-bottom: 20px;\n background: #F7FAFB;\n border: 1px solid #F3F3F4;\n\n .ant-form-item {\n margin-bottom: 20px;\n }\n }\n"])));
|
|
38
38
|
var SearchAreaHandle = styled.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n gap: 10px;\n display: flex;\n justify-content: flex-end;\n margin-bottom: 20px;\n"], ["\n gap: 10px;\n display: flex;\n justify-content: flex-end;\n margin-bottom: 20px;\n"])));
|
|
39
39
|
/**
|
|
40
40
|
* 高级筛选
|
|
@@ -1,3 +1,12 @@
|
|
|
1
1
|
import type { SearchParams, SearchParamsType, UseSearchParamsOptions } from './types.ts';
|
|
2
|
+
declare global {
|
|
3
|
+
interface Window {
|
|
4
|
+
routerHistory: Map<string, {
|
|
5
|
+
path: string;
|
|
6
|
+
replace: boolean;
|
|
7
|
+
state?: Record<string, any>;
|
|
8
|
+
}>;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
2
11
|
declare const useSearchParams: <T extends SearchParamsType>(initialValue: T, options?: UseSearchParamsOptions) => SearchParams<T>;
|
|
3
12
|
export default useSearchParams;
|
|
@@ -55,6 +55,8 @@ import { ConfigContext } from '../../components/ConfigProvider';
|
|
|
55
55
|
var initialSearchParams = {
|
|
56
56
|
y: undefined
|
|
57
57
|
};
|
|
58
|
+
// 确保 routerHistory 已初始化
|
|
59
|
+
window.routerHistory = window.routerHistory || new Map();
|
|
58
60
|
var useSearchParams = function (initialValue, options) {
|
|
59
61
|
var _a;
|
|
60
62
|
var defaultConfigOptions = useContext(ConfigContext).useSearchParams;
|
|
@@ -85,17 +87,33 @@ var useSearchParams = function (initialValue, options) {
|
|
|
85
87
|
* 根据配置更新存储
|
|
86
88
|
*/
|
|
87
89
|
var persistParams = function (params) { return __awaiter(void 0, void 0, void 0, function () {
|
|
88
|
-
var payload;
|
|
89
|
-
var _a;
|
|
90
|
-
return __generator(this, function (
|
|
90
|
+
var payload, params_1, search, key, value;
|
|
91
|
+
var _a, _b;
|
|
92
|
+
return __generator(this, function (_c) {
|
|
91
93
|
payload = __assign(__assign({}, params), { y: window.scrollY });
|
|
92
94
|
if (storage === 'url') {
|
|
93
|
-
|
|
95
|
+
params_1 = encodeParams(payload);
|
|
96
|
+
setUrlParams(params_1);
|
|
97
|
+
search = '';
|
|
98
|
+
for (key in params_1) {
|
|
99
|
+
value = params_1[key];
|
|
100
|
+
search += "".concat(key, "=").concat(value, "&");
|
|
101
|
+
}
|
|
102
|
+
search = search.slice(0, -1);
|
|
103
|
+
window.routerHistory.set(location.pathname, {
|
|
104
|
+
path: "".concat(location.pathname, "?").concat(search),
|
|
105
|
+
replace: true,
|
|
106
|
+
});
|
|
94
107
|
return [2 /*return*/];
|
|
95
108
|
}
|
|
109
|
+
window.routerHistory.set(location.pathname, {
|
|
110
|
+
path: location.pathname,
|
|
111
|
+
replace: true,
|
|
112
|
+
state: __assign(__assign({}, (location.state || {})), (_a = {}, _a[stateKey] = payload, _a)),
|
|
113
|
+
});
|
|
96
114
|
navigator(location.pathname, {
|
|
97
115
|
replace: true,
|
|
98
|
-
state: __assign(__assign({}, location.state), (
|
|
116
|
+
state: __assign(__assign({}, location.state), (_b = {}, _b[stateKey] = payload, _b))
|
|
99
117
|
});
|
|
100
118
|
return [2 /*return*/];
|
|
101
119
|
});
|
|
@@ -159,6 +177,9 @@ var useSearchParams = function (initialValue, options) {
|
|
|
159
177
|
!navEndRef.current))) {
|
|
160
178
|
setTimeout(function () {
|
|
161
179
|
var targetLocation = targetLocationRef.current;
|
|
180
|
+
if (!targetLocation) {
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
162
183
|
var path = "".concat(targetLocation.pathname).concat(targetLocation.search);
|
|
163
184
|
navigator(path, {
|
|
164
185
|
replace: targetLocation.historyAction !== 'PUSH',
|
|
@@ -72,7 +72,7 @@ var IntlProvider_1 = require("../IntlProvider");
|
|
|
72
72
|
var AnimatedContainer = (0, styled_1.default)('div', {
|
|
73
73
|
shouldForwardProp: function (prop) { return prop !== 'show'; },
|
|
74
74
|
})(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n overflow: hidden;\n transition: max-height 0.4s ease-in-out;\n max-height: ", ";\n"], ["\n overflow: hidden;\n transition: max-height 0.4s ease-in-out;\n max-height: ", ";\n"])), function (props) { return props.show ? '450px' : '0'; });
|
|
75
|
-
var StyledForm = (0, styled_1.default)(antd_1.Form)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n padding: 20px;\n
|
|
75
|
+
var StyledForm = (0, styled_1.default)(antd_1.Form)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n &.ant-form {\n padding: 20px;\n padding-bottom: 0;\n margin-bottom: 20px;\n background: #F7FAFB;\n border: 1px solid #F3F3F4;\n\n .ant-form-item {\n margin-bottom: 20px;\n }\n }\n"], ["\n &.ant-form {\n padding: 20px;\n padding-bottom: 0;\n margin-bottom: 20px;\n background: #F7FAFB;\n border: 1px solid #F3F3F4;\n\n .ant-form-item {\n margin-bottom: 20px;\n }\n }\n"])));
|
|
76
76
|
var SearchAreaHandle = styled_1.default.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n gap: 10px;\n display: flex;\n justify-content: flex-end;\n margin-bottom: 20px;\n"], ["\n gap: 10px;\n display: flex;\n justify-content: flex-end;\n margin-bottom: 20px;\n"])));
|
|
77
77
|
/**
|
|
78
78
|
* 高级筛选
|
|
@@ -60,6 +60,8 @@ var ConfigProvider_1 = require("../../components/ConfigProvider");
|
|
|
60
60
|
var initialSearchParams = {
|
|
61
61
|
y: undefined
|
|
62
62
|
};
|
|
63
|
+
// 确保 routerHistory 已初始化
|
|
64
|
+
window.routerHistory = window.routerHistory || new Map();
|
|
63
65
|
var useSearchParams = function (initialValue, options) {
|
|
64
66
|
var _a;
|
|
65
67
|
var defaultConfigOptions = (0, react_1.useContext)(ConfigProvider_1.ConfigContext).useSearchParams;
|
|
@@ -90,17 +92,33 @@ var useSearchParams = function (initialValue, options) {
|
|
|
90
92
|
* 根据配置更新存储
|
|
91
93
|
*/
|
|
92
94
|
var persistParams = function (params) { return __awaiter(void 0, void 0, void 0, function () {
|
|
93
|
-
var payload;
|
|
94
|
-
var _a;
|
|
95
|
-
return __generator(this, function (
|
|
95
|
+
var payload, params_1, search, key, value;
|
|
96
|
+
var _a, _b;
|
|
97
|
+
return __generator(this, function (_c) {
|
|
96
98
|
payload = __assign(__assign({}, params), { y: window.scrollY });
|
|
97
99
|
if (storage === 'url') {
|
|
98
|
-
|
|
100
|
+
params_1 = (0, util_1.encodeParams)(payload);
|
|
101
|
+
setUrlParams(params_1);
|
|
102
|
+
search = '';
|
|
103
|
+
for (key in params_1) {
|
|
104
|
+
value = params_1[key];
|
|
105
|
+
search += "".concat(key, "=").concat(value, "&");
|
|
106
|
+
}
|
|
107
|
+
search = search.slice(0, -1);
|
|
108
|
+
window.routerHistory.set(location.pathname, {
|
|
109
|
+
path: "".concat(location.pathname, "?").concat(search),
|
|
110
|
+
replace: true,
|
|
111
|
+
});
|
|
99
112
|
return [2 /*return*/];
|
|
100
113
|
}
|
|
114
|
+
window.routerHistory.set(location.pathname, {
|
|
115
|
+
path: location.pathname,
|
|
116
|
+
replace: true,
|
|
117
|
+
state: __assign(__assign({}, (location.state || {})), (_a = {}, _a[stateKey] = payload, _a)),
|
|
118
|
+
});
|
|
101
119
|
navigator(location.pathname, {
|
|
102
120
|
replace: true,
|
|
103
|
-
state: __assign(__assign({}, location.state), (
|
|
121
|
+
state: __assign(__assign({}, location.state), (_b = {}, _b[stateKey] = payload, _b))
|
|
104
122
|
});
|
|
105
123
|
return [2 /*return*/];
|
|
106
124
|
});
|
|
@@ -164,6 +182,9 @@ var useSearchParams = function (initialValue, options) {
|
|
|
164
182
|
!navEndRef.current))) {
|
|
165
183
|
setTimeout(function () {
|
|
166
184
|
var targetLocation = targetLocationRef.current;
|
|
185
|
+
if (!targetLocation) {
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
167
188
|
var path = "".concat(targetLocation.pathname).concat(targetLocation.search);
|
|
168
189
|
navigator(path, {
|
|
169
190
|
replace: targetLocation.historyAction !== 'PUSH',
|
package/build/package.json
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
1
|
import type { SearchParams, SearchParamsType, UseSearchParamsOptions } from './types.ts';
|
|
2
|
+
declare global {
|
|
3
|
+
interface Window {
|
|
4
|
+
routerHistory: Map<string, {
|
|
5
|
+
path: string;
|
|
6
|
+
replace: boolean;
|
|
7
|
+
state?: Record<string, any>;
|
|
8
|
+
}>;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
2
11
|
declare const useSearchParams: <T extends SearchParamsType>(initialValue: T, options?: UseSearchParamsOptions) => SearchParams<T>;
|
|
3
12
|
export default useSearchParams;
|