@kne/react-filter 1.0.6 → 1.0.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.css +337 -240
- package/dist/index.css.map +1 -1
- package/dist/index.js +518 -335
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +299 -113
- package/dist/index.modern.js.map +1 -1
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -3,6 +3,7 @@ var react = require('react');
|
|
|
3
3
|
var antd = require('antd');
|
|
4
4
|
var reactIntl = require('@kne/react-intl');
|
|
5
5
|
var get = require('lodash/get');
|
|
6
|
+
var responsiveUtils = require('@kne/responsive-utils');
|
|
6
7
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
8
|
var icons = require('@ant-design/icons');
|
|
8
9
|
var clone = require('lodash/clone');
|
|
@@ -47,39 +48,80 @@ function _objectWithoutPropertiesLoose(r, e) {
|
|
|
47
48
|
return t;
|
|
48
49
|
}
|
|
49
50
|
|
|
50
|
-
var style$1 = {"filter":"kne-react-filter_b3gMw","filter-item-icon":"kne-react-filter_e3V6h","filter-item-option-icon":"kne-react-filter_dLoYj","filter-title":"kne-react-filter_khFt2","filter-title-hidden":"kne-react-filter_j2mP1","ad-filter-title":"kne-react-filter_HptIY","ad-filter-line":"kne-react-filter_7Ob6-","filter-line":"kne-react-filter_Y9XTa","clean-btn":"kne-react-filter_CJ935","filter-item":"kne-react-filter_JpaMr","un-expand":"kne-react-filter_LfQME","ad-filter-selected":"kne-react-filter_pBsaE","filter-label":"kne-react-filter_Bx3s8","filter-line-nowrap":"kne-react-filter_Ccx24","filter-line-measure":"kne-react-filter_uMXzo","filter-item-wrap":"kne-react-filter_Co4Pg","option":"kne-react-filter_G1cRp","is-active":"kne-react-filter_Aab98","is-visited":"kne-react-filter_Ww12R","un-expand-shadow":"kne-react-filter_2ExqW","filter-item-label":"kne-react-filter_JAmeE","filter-item-field":"kne-react-filter_WvRvl","filter-drop-tag":"kne-react-filter_dG8rq","filter-list":"kne-react-filter_qlWu6","filter-list-scroll-wrap":"kne-react-filter_oaIF4","filter-list-constrained":"kne-react-filter_3gXxO","filter-list-scroll":"kne-react-filter_Jq43Q","filter-scroll-next":"kne-react-filter_BdfSI","filter-list-tag":"kne-react-filter_LV2VI","filter-tag":"kne-react-filter_yyR3u","filter-tag-value":"kne-react-filter_8nm8n","filter-value-tag":"kne-react-filter_tWyCr","filter-value-tag-label":"kne-react-filter_XPzrL","filter-value-tag-content":"kne-react-filter_6e79l","filter-value-display-content":"kne-react-filter_v2dnw","filter-value-tags-wrap":"kne-react-filter_J1wBU","filter-value-tags":"kne-react-filter_rRhFE","filter-value-actions":"kne-react-filter_-Brt9","filter-value-toggle":"kne-react-filter_WuL0c","pop-util-content":"kne-react-filter_g-hXk","pop-util-body":"kne-react-filter_4n4MP","date-range-picker-popup":"kne-react-filter_6Zx60","pop-util-overlay":"kne-react-filter_m7Csi","pop-util-mask":"kne-react-filter_o2B3k","pop-util-mask-fade-in":"kne-react-filter_oCXiX","pop-util-mask-leave":"kne-react-filter_qGnRO","pop-util-mask-fade-out":"kne-react-filter_cDx1y","field-item-mobile-popup":"kne-react-filter_wq5nf","pop-util-mobile-expand-down":"kne-react-filter_6RxjE","date-picker-popup":"kne-react-filter_iwLs2","pop-util-mobile-collapse-up":"kne-react-filter_009r-","pop-util-footer":"kne-react-filter_iqe8W","pop-util-text":"kne-react-filter_72gGQ","filter-item-inner":"kne-react-filter_cYX12","filter-item-text":"kne-react-filter_cnMY-","filter-item-number-range":"kne-react-filter_Cv2Bw","filter-item-custom":"kne-react-filter_CBczA","filter-item-custom-active":"kne-react-filter_ldxUR","filter-item-number-range-split":"kne-react-filter_4p3C9","filter-item-number-input":"kne-react-filter_yy1y1","range-picker":"kne-react-filter_81zQn","cascader-select-wrap":"kne-react-filter_UHBfi","cascader-dropdown-menu":"kne-react-filter_bY8JQ","filter-advanced":"kne-react-filter_rg45N","filter-advanced-item-other":"kne-react-filter_HcsA8","filter-advanced-item-other-inner":"kne-react-filter_4Bqtz","filter-advanced-more":"kne-react-filter_jVH7z","
|
|
51
|
+
var style$1 = {"kne-responsive-boundary":"kne-react-filter_gh14z","kne-responsive-scroll":"kne-react-filter_Kfn6L","filter":"kne-react-filter_b3gMw","filter-item-icon":"kne-react-filter_e3V6h","filter-item-option-icon":"kne-react-filter_dLoYj","filter-title":"kne-react-filter_khFt2","filter-title-hidden":"kne-react-filter_j2mP1","ad-filter-title":"kne-react-filter_HptIY","ad-filter-line":"kne-react-filter_7Ob6-","filter-line":"kne-react-filter_Y9XTa","clean-btn":"kne-react-filter_CJ935","filter-item":"kne-react-filter_JpaMr","un-expand":"kne-react-filter_LfQME","ad-filter-selected":"kne-react-filter_pBsaE","filter-label":"kne-react-filter_Bx3s8","filter-line-nowrap":"kne-react-filter_Ccx24","filter-line-measure":"kne-react-filter_uMXzo","filter-item-wrap":"kne-react-filter_Co4Pg","option":"kne-react-filter_G1cRp","is-active":"kne-react-filter_Aab98","is-visited":"kne-react-filter_Ww12R","un-expand-shadow":"kne-react-filter_2ExqW","filter-item-label":"kne-react-filter_JAmeE","filter-item-field":"kne-react-filter_WvRvl","filter-drop-tag":"kne-react-filter_dG8rq","filter-list":"kne-react-filter_qlWu6","filter-list-scroll-wrap":"kne-react-filter_oaIF4","filter-list-constrained":"kne-react-filter_3gXxO","filter-list-scroll":"kne-react-filter_Jq43Q","filter-scroll-next":"kne-react-filter_BdfSI","filter-list-tag":"kne-react-filter_LV2VI","filter-tag":"kne-react-filter_yyR3u","filter-tag-value":"kne-react-filter_8nm8n","filter-value-tag":"kne-react-filter_tWyCr","filter-value-tag-label":"kne-react-filter_XPzrL","filter-value-tag-content":"kne-react-filter_6e79l","filter-value-display-content":"kne-react-filter_v2dnw","filter-value-display":"kne-react-filter_8-R34","is-hide-label":"kne-react-filter_zpGJE","is-flush":"kne-react-filter_z8bDM","filter-value-tags-wrap":"kne-react-filter_J1wBU","filter-value-tags":"kne-react-filter_rRhFE","filter-value-actions":"kne-react-filter_-Brt9","filter-value-toggle":"kne-react-filter_WuL0c","pop-util-content":"kne-react-filter_g-hXk","pop-util-body":"kne-react-filter_4n4MP","date-range-picker-popup":"kne-react-filter_6Zx60","pop-util-overlay":"kne-react-filter_m7Csi","pop-util-mask":"kne-react-filter_o2B3k","pop-util-mask-fade-in":"kne-react-filter_oCXiX","is-viewport":"kne-react-filter_3Wr-x","is-boundary":"kne-react-filter_pPiQ8","pop-util-mask-leave":"kne-react-filter_qGnRO","pop-util-mask-fade-out":"kne-react-filter_cDx1y","field-item-mobile-popup":"kne-react-filter_wq5nf","pop-util-mobile-expand-down":"kne-react-filter_6RxjE","date-picker-popup":"kne-react-filter_iwLs2","pop-util-mobile-collapse-up":"kne-react-filter_009r-","pop-util-footer":"kne-react-filter_iqe8W","pop-util-text":"kne-react-filter_72gGQ","filter-item-inner":"kne-react-filter_cYX12","filter-item-text":"kne-react-filter_cnMY-","filter-item-number-range":"kne-react-filter_Cv2Bw","filter-item-custom":"kne-react-filter_CBczA","filter-item-custom-active":"kne-react-filter_ldxUR","filter-item-number-range-split":"kne-react-filter_4p3C9","filter-item-number-input":"kne-react-filter_yy1y1","range-picker":"kne-react-filter_81zQn","cascader-select-wrap":"kne-react-filter_UHBfi","cascader-dropdown-menu":"kne-react-filter_bY8JQ","filter-advanced":"kne-react-filter_rg45N","filter-advanced-item-other":"kne-react-filter_HcsA8","filter-advanced-item-other-inner":"kne-react-filter_4Bqtz","filter-advanced-more":"kne-react-filter_jVH7z","is-mobile":"kne-react-filter_LtgJz","is-not-overflow":"kne-react-filter_TM1E2","is-expand":"kne-react-filter_7aclr","filter-value-scroll-prev-shadow":"kne-react-filter_C1t-q","filter-value-scroll-next-shadow":"kne-react-filter_ZFoeL","is-overflow":"kne-react-filter_GhFCl","filter-value-action-placeholder":"kne-react-filter_wGZp6","filter-value-action-right":"kne-react-filter_vyPwo","filter-scroll-prev-shadow":"kne-react-filter_fyhz3","filter-scroll-next-icon":"kne-react-filter_Fd6ab"};
|
|
51
52
|
|
|
52
53
|
const context = /*#__PURE__*/react.createContext({});
|
|
53
54
|
const Provider = context.Provider;
|
|
54
55
|
const useContext = () => react.useContext(context);
|
|
55
56
|
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
/**
|
|
58
|
+
* Filter 移动端判定:默认按视口宽度,仅在 ResponsiveProvider container 模式下按预览容器宽度。
|
|
59
|
+
* 避免 Filter 嵌入窄列时误用移动端布局。
|
|
60
|
+
*/
|
|
61
|
+
const useFilterIsMobile = () => {
|
|
62
|
+
const _useResponsiveContext = responsiveUtils.useResponsiveContext(),
|
|
63
|
+
mode = _useResponsiveContext.mode,
|
|
64
|
+
containerWidth = _useResponsiveContext.containerWidth;
|
|
65
|
+
const viewportIsMobile = responsiveUtils.useMediaQuery(responsiveUtils.IS_MOBILE_QUERY);
|
|
66
|
+
if (mode === 'container' && typeof containerWidth === 'number') {
|
|
67
|
+
return containerWidth < responsiveUtils.MOBILE_BREAKPOINT;
|
|
68
|
+
}
|
|
69
|
+
return viewportIsMobile;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const useResponsiveScrollListener = function (callback, enabled) {
|
|
73
|
+
if (enabled === void 0) {
|
|
74
|
+
enabled = true;
|
|
75
|
+
}
|
|
76
|
+
const getScrollElement = responsiveUtils.useScrollElement();
|
|
58
77
|
react.useEffect(() => {
|
|
59
|
-
if (typeof
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
78
|
+
if (!enabled || typeof callback !== 'function') {
|
|
79
|
+
return undefined;
|
|
80
|
+
}
|
|
81
|
+
const scrollEl = getScrollElement();
|
|
82
|
+
if (!scrollEl) {
|
|
83
|
+
return undefined;
|
|
84
|
+
}
|
|
85
|
+
callback();
|
|
86
|
+
const handleChange = () => {
|
|
87
|
+
callback();
|
|
63
88
|
};
|
|
64
|
-
|
|
65
|
-
|
|
89
|
+
scrollEl.addEventListener('scroll', handleChange, {
|
|
90
|
+
passive: true
|
|
91
|
+
});
|
|
92
|
+
window.addEventListener('resize', handleChange);
|
|
93
|
+
let resizeObserver;
|
|
94
|
+
if (typeof ResizeObserver !== 'undefined') {
|
|
95
|
+
resizeObserver = new ResizeObserver(handleChange);
|
|
96
|
+
resizeObserver.observe(scrollEl);
|
|
97
|
+
}
|
|
66
98
|
return () => {
|
|
67
|
-
|
|
99
|
+
var _resizeObserver;
|
|
100
|
+
scrollEl.removeEventListener('scroll', handleChange);
|
|
101
|
+
window.removeEventListener('resize', handleChange);
|
|
102
|
+
(_resizeObserver = resizeObserver) == null || _resizeObserver.disconnect();
|
|
68
103
|
};
|
|
69
|
-
}, []);
|
|
70
|
-
return isMobile;
|
|
104
|
+
}, [callback, enabled, getScrollElement]);
|
|
71
105
|
};
|
|
72
106
|
|
|
73
|
-
const useHorizontalScrollShadows = ({
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
107
|
+
const useHorizontalScrollShadows = function (_temp) {
|
|
108
|
+
let _ref = _temp === void 0 ? {} : _temp,
|
|
109
|
+
enabled = _ref.enabled,
|
|
110
|
+
_ref$suspend = _ref.suspend,
|
|
111
|
+
suspend = _ref$suspend === void 0 ? false : _ref$suspend,
|
|
112
|
+
_ref$preserveOverflow = _ref.preserveOverflowOnSuspend,
|
|
113
|
+
preserveOverflowOnSuspend = _ref$preserveOverflow === void 0 ? false : _ref$preserveOverflow,
|
|
114
|
+
refreshKey = _ref.refreshKey;
|
|
79
115
|
const scrollRef = react.useRef(null);
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
|
|
116
|
+
const _useState = react.useState(false),
|
|
117
|
+
isOverflow = _useState[0],
|
|
118
|
+
setIsOverflow = _useState[1];
|
|
119
|
+
const _useState2 = react.useState(false),
|
|
120
|
+
showScrollPrev = _useState2[0],
|
|
121
|
+
setShowScrollPrev = _useState2[1];
|
|
122
|
+
const _useState3 = react.useState(false),
|
|
123
|
+
showScrollNext = _useState3[0],
|
|
124
|
+
setShowScrollNext = _useState3[1];
|
|
83
125
|
const update = react.useCallback(() => {
|
|
84
126
|
const el = scrollRef.current;
|
|
85
127
|
if (!el || !enabled) {
|
|
@@ -108,14 +150,13 @@ const useHorizontalScrollShadows = ({
|
|
|
108
150
|
}
|
|
109
151
|
update();
|
|
110
152
|
el.addEventListener('scroll', update);
|
|
111
|
-
window.addEventListener('resize', update);
|
|
112
153
|
const rafId = window.requestAnimationFrame(update);
|
|
113
154
|
return () => {
|
|
114
155
|
el.removeEventListener('scroll', update);
|
|
115
|
-
window.removeEventListener('resize', update);
|
|
116
156
|
window.cancelAnimationFrame(rafId);
|
|
117
157
|
};
|
|
118
158
|
}, [enabled, refreshKey, suspend, update]);
|
|
159
|
+
useResponsiveScrollListener(update, enabled && !suspend);
|
|
119
160
|
return {
|
|
120
161
|
scrollRef,
|
|
121
162
|
isOverflow,
|
|
@@ -127,18 +168,23 @@ const useHorizontalScrollShadows = ({
|
|
|
127
168
|
|
|
128
169
|
const GAP = 8;
|
|
129
170
|
const SAFETY_GAP = 2;
|
|
130
|
-
const useVisibleItemCount =
|
|
131
|
-
items,
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
171
|
+
const useVisibleItemCount = _ref => {
|
|
172
|
+
let items = _ref.items,
|
|
173
|
+
enabled = _ref.enabled,
|
|
174
|
+
_ref$strategy = _ref.strategy,
|
|
175
|
+
strategy = _ref$strategy === void 0 ? 'asc' : _ref$strategy;
|
|
176
|
+
const safeItems = Array.isArray(items) ? items : [];
|
|
135
177
|
const containerRef = react.useRef(null);
|
|
136
178
|
const measureRef = react.useRef(null);
|
|
137
179
|
const moreMeasureRef = react.useRef(null);
|
|
138
180
|
const rafRef = react.useRef(null);
|
|
139
181
|
const lastWidthRef = react.useRef(0);
|
|
140
|
-
const
|
|
141
|
-
|
|
182
|
+
const _useState = react.useState(null),
|
|
183
|
+
containerEl = _useState[0],
|
|
184
|
+
setContainerEl = _useState[1];
|
|
185
|
+
const _useState2 = react.useState(() => safeItems.length > 0 ? 1 : 0),
|
|
186
|
+
visibleCount = _useState2[0],
|
|
187
|
+
setVisibleCount = _useState2[1];
|
|
142
188
|
const setContainerRef = react.useCallback(node => {
|
|
143
189
|
containerRef.current = node;
|
|
144
190
|
setContainerEl(node || null);
|
|
@@ -150,6 +196,7 @@ const useVisibleItemCount = ({
|
|
|
150
196
|
moreMeasureRef.current = node;
|
|
151
197
|
}, []);
|
|
152
198
|
const getWidths = react.useCallback(() => {
|
|
199
|
+
var _moreMeasureRef$curre;
|
|
153
200
|
const container = containerRef.current;
|
|
154
201
|
const measureEl = measureRef.current;
|
|
155
202
|
if (!container || !measureEl) {
|
|
@@ -163,8 +210,8 @@ const useVisibleItemCount = ({
|
|
|
163
210
|
if (!itemNodes.length) {
|
|
164
211
|
return null;
|
|
165
212
|
}
|
|
166
|
-
const moreButtonWidth = moreMeasureRef.current
|
|
167
|
-
if (
|
|
213
|
+
const moreButtonWidth = ((_moreMeasureRef$curre = moreMeasureRef.current) == null ? void 0 : _moreMeasureRef$curre.getBoundingClientRect().width) || 0;
|
|
214
|
+
if (safeItems.length > 1 && moreButtonWidth <= 0) {
|
|
168
215
|
return null;
|
|
169
216
|
}
|
|
170
217
|
const itemWidths = Array.from(itemNodes, node => node.getBoundingClientRect().width);
|
|
@@ -173,24 +220,22 @@ const useVisibleItemCount = ({
|
|
|
173
220
|
itemWidths,
|
|
174
221
|
moreButtonWidth
|
|
175
222
|
};
|
|
176
|
-
}, [
|
|
223
|
+
}, [safeItems.length]);
|
|
177
224
|
const getWidthForCount = react.useCallback((itemWidths, moreButtonWidth, count) => {
|
|
178
225
|
let usedWidth = 0;
|
|
179
226
|
for (let i = 0; i < count; i++) {
|
|
180
227
|
usedWidth += itemWidths[i] + (i > 0 ? GAP : 0);
|
|
181
228
|
}
|
|
182
|
-
if (count <
|
|
229
|
+
if (count < safeItems.length) {
|
|
183
230
|
usedWidth += GAP + moreButtonWidth;
|
|
184
231
|
}
|
|
185
232
|
return usedWidth;
|
|
186
|
-
}, [
|
|
233
|
+
}, [safeItems.length]);
|
|
187
234
|
const resolveVisibleCount = react.useCallback(widths => {
|
|
188
|
-
const
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
} = widths;
|
|
193
|
-
const maxCount = Math.min(items.length, itemWidths.length);
|
|
235
|
+
const containerWidth = widths.containerWidth,
|
|
236
|
+
itemWidths = widths.itemWidths,
|
|
237
|
+
moreButtonWidth = widths.moreButtonWidth;
|
|
238
|
+
const maxCount = Math.min(safeItems.length, itemWidths.length);
|
|
194
239
|
let count = 1;
|
|
195
240
|
if (strategy === 'desc') {
|
|
196
241
|
count = maxCount;
|
|
@@ -213,10 +258,10 @@ const useVisibleItemCount = ({
|
|
|
213
258
|
}
|
|
214
259
|
}
|
|
215
260
|
return Math.max(1, count);
|
|
216
|
-
}, [getWidthForCount,
|
|
261
|
+
}, [getWidthForCount, safeItems.length, strategy]);
|
|
217
262
|
const calculateByWidth = react.useCallback(() => {
|
|
218
|
-
if (!enabled || !
|
|
219
|
-
setVisibleCount(prev => prev ===
|
|
263
|
+
if (!enabled || !safeItems.length) {
|
|
264
|
+
setVisibleCount(prev => prev === safeItems.length ? prev : safeItems.length);
|
|
220
265
|
return;
|
|
221
266
|
}
|
|
222
267
|
const widths = getWidths();
|
|
@@ -225,7 +270,7 @@ const useVisibleItemCount = ({
|
|
|
225
270
|
}
|
|
226
271
|
const nextCount = resolveVisibleCount(widths);
|
|
227
272
|
setVisibleCount(prev => prev === nextCount ? prev : nextCount);
|
|
228
|
-
}, [enabled, getWidths,
|
|
273
|
+
}, [enabled, getWidths, safeItems.length, resolveVisibleCount]);
|
|
229
274
|
const scheduleCalculate = react.useCallback(() => {
|
|
230
275
|
if (rafRef.current) {
|
|
231
276
|
window.cancelAnimationFrame(rafRef.current);
|
|
@@ -243,14 +288,15 @@ const useVisibleItemCount = ({
|
|
|
243
288
|
rafRef.current = null;
|
|
244
289
|
}
|
|
245
290
|
};
|
|
246
|
-
}, [
|
|
291
|
+
}, [safeItems, scheduleCalculate]);
|
|
247
292
|
react.useEffect(() => {
|
|
248
293
|
if (!enabled || !containerEl) {
|
|
249
294
|
return undefined;
|
|
250
295
|
}
|
|
251
296
|
const observer = new ResizeObserver(entries => {
|
|
297
|
+
var _entry$contentRect$wi;
|
|
252
298
|
const entry = entries.find(item => item.target === containerEl);
|
|
253
|
-
const nextWidth = entry
|
|
299
|
+
const nextWidth = (_entry$contentRect$wi = entry == null ? void 0 : entry.contentRect.width) != null ? _entry$contentRect$wi : containerEl.clientWidth;
|
|
254
300
|
if (Math.abs(nextWidth - lastWidthRef.current) < 1) {
|
|
255
301
|
return;
|
|
256
302
|
}
|
|
@@ -259,16 +305,15 @@ const useVisibleItemCount = ({
|
|
|
259
305
|
});
|
|
260
306
|
lastWidthRef.current = containerEl.clientWidth;
|
|
261
307
|
observer.observe(containerEl);
|
|
262
|
-
window.addEventListener('resize', scheduleCalculate);
|
|
263
308
|
return () => {
|
|
264
309
|
observer.disconnect();
|
|
265
|
-
window.removeEventListener('resize', scheduleCalculate);
|
|
266
310
|
if (rafRef.current) {
|
|
267
311
|
window.cancelAnimationFrame(rafRef.current);
|
|
268
312
|
rafRef.current = null;
|
|
269
313
|
}
|
|
270
314
|
};
|
|
271
315
|
}, [containerEl, enabled, scheduleCalculate]);
|
|
316
|
+
useResponsiveScrollListener(scheduleCalculate, enabled && !!containerEl);
|
|
272
317
|
return {
|
|
273
318
|
setContainerRef,
|
|
274
319
|
setMeasureRef,
|
|
@@ -298,22 +343,21 @@ const normalizeFilterList = list => {
|
|
|
298
343
|
if (isNestedFilterList(safeList)) {
|
|
299
344
|
return {
|
|
300
345
|
mode: 'nested',
|
|
301
|
-
items:
|
|
346
|
+
items: [],
|
|
302
347
|
lines: safeList
|
|
303
348
|
};
|
|
304
349
|
}
|
|
305
350
|
return {
|
|
306
351
|
mode: 'flat',
|
|
307
352
|
items: safeList,
|
|
308
|
-
lines:
|
|
353
|
+
lines: []
|
|
309
354
|
};
|
|
310
355
|
};
|
|
311
356
|
const getMobileFilterList = list => {
|
|
312
|
-
const
|
|
313
|
-
mode,
|
|
314
|
-
items,
|
|
315
|
-
lines
|
|
316
|
-
} = normalizeFilterList(list);
|
|
357
|
+
const _normalizeFilterList = normalizeFilterList(list),
|
|
358
|
+
mode = _normalizeFilterList.mode,
|
|
359
|
+
items = _normalizeFilterList.items,
|
|
360
|
+
lines = _normalizeFilterList.lines;
|
|
317
361
|
if (mode === 'flat') return items;
|
|
318
362
|
return lines.reduce((result, line) => result.concat(line), []);
|
|
319
363
|
};
|
|
@@ -412,7 +456,7 @@ const FilterLines = _ref3 => {
|
|
|
412
456
|
const _useState = react.useState(false),
|
|
413
457
|
isExpand = _useState[0],
|
|
414
458
|
setIsExpand = _useState[1];
|
|
415
|
-
const isMobile =
|
|
459
|
+
const isMobile = useFilterIsMobile();
|
|
416
460
|
const _useHorizontalScrollS = useHorizontalScrollShadows({
|
|
417
461
|
enabled: isMobile,
|
|
418
462
|
refreshKey: list
|
|
@@ -686,7 +730,10 @@ const withLocale = reactIntl.createWithIntlProvider({
|
|
|
686
730
|
const FilterValueDisplay = withLocale(_ref => {
|
|
687
731
|
let filterValue = _ref.value,
|
|
688
732
|
extraExpand = _ref.extraExpand,
|
|
689
|
-
onChange = _ref.onChange
|
|
733
|
+
onChange = _ref.onChange,
|
|
734
|
+
className = _ref.className,
|
|
735
|
+
hideLabel = _ref.hideLabel,
|
|
736
|
+
flush = _ref.flush;
|
|
690
737
|
const _useIntl = reactIntl.useIntl({
|
|
691
738
|
moduleName: 'Filter'
|
|
692
739
|
}),
|
|
@@ -694,7 +741,7 @@ const FilterValueDisplay = withLocale(_ref => {
|
|
|
694
741
|
const _useState = react.useState(false),
|
|
695
742
|
isExpand = _useState[0],
|
|
696
743
|
setIsExpand = _useState[1];
|
|
697
|
-
const isMobile =
|
|
744
|
+
const isMobile = useFilterIsMobile();
|
|
698
745
|
const _useHorizontalScrollS = useHorizontalScrollShadows({
|
|
699
746
|
enabled: isMobile,
|
|
700
747
|
suspend: isExpand,
|
|
@@ -728,10 +775,13 @@ const FilterValueDisplay = withLocale(_ref => {
|
|
|
728
775
|
}, name);
|
|
729
776
|
});
|
|
730
777
|
return /*#__PURE__*/jsxRuntime.jsxs(antd.Space, {
|
|
731
|
-
className: classnames__default["default"](style$1['filter-title'], style$1['filter-value-display']
|
|
778
|
+
className: classnames__default["default"](style$1['filter-title'], style$1['filter-value-display'], 'filter-value-display-root', {
|
|
779
|
+
[style$1['is-hide-label']]: hideLabel,
|
|
780
|
+
[style$1['is-flush']]: flush
|
|
781
|
+
}, className),
|
|
732
782
|
align: "top",
|
|
733
|
-
size: 16,
|
|
734
|
-
children: [/*#__PURE__*/jsxRuntime.jsx("span", {
|
|
783
|
+
size: hideLabel ? 0 : 16,
|
|
784
|
+
children: [hideLabel ? null : /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
735
785
|
className: style$1['filter-label'],
|
|
736
786
|
children: formatMessage({
|
|
737
787
|
id: 'selectedText'
|
|
@@ -846,29 +896,58 @@ const FilterProvider = _ref => {
|
|
|
846
896
|
});
|
|
847
897
|
};
|
|
848
898
|
|
|
849
|
-
const
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
}
|
|
854
|
-
|
|
855
|
-
|
|
899
|
+
const useFilterViewportVars = () => {
|
|
900
|
+
const boundaryRef = react.useRef(null);
|
|
901
|
+
const {
|
|
902
|
+
mode
|
|
903
|
+
} = responsiveUtils.useResponsiveContext();
|
|
904
|
+
react.useEffect(() => {
|
|
905
|
+
const el = boundaryRef.current;
|
|
906
|
+
if (!el || typeof window === 'undefined' || mode === 'container') {
|
|
907
|
+
return undefined;
|
|
908
|
+
}
|
|
909
|
+
const update = () => {
|
|
910
|
+
responsiveUtils.applyViewportCssVars(el, {
|
|
911
|
+
width: window.innerWidth,
|
|
912
|
+
height: window.innerHeight
|
|
913
|
+
});
|
|
914
|
+
};
|
|
915
|
+
update();
|
|
916
|
+
window.addEventListener('resize', update, {
|
|
917
|
+
passive: true
|
|
918
|
+
});
|
|
919
|
+
return () => {
|
|
920
|
+
window.removeEventListener('resize', update);
|
|
921
|
+
responsiveUtils.resetViewportCssVars(el);
|
|
922
|
+
};
|
|
923
|
+
}, [mode]);
|
|
924
|
+
return boundaryRef;
|
|
925
|
+
};
|
|
926
|
+
|
|
927
|
+
const _excluded$d = ["children", "className"];
|
|
928
|
+
const FilterOuter = _ref => {
|
|
929
|
+
let children = _ref.children,
|
|
930
|
+
className = _ref.className,
|
|
931
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$d);
|
|
932
|
+
const isMobile = useFilterIsMobile();
|
|
933
|
+
const boundaryRef = useFilterViewportVars();
|
|
934
|
+
return /*#__PURE__*/jsxRuntime.jsx(FilterProvider, _extends({}, props, {
|
|
856
935
|
children: context => /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
936
|
+
ref: boundaryRef,
|
|
937
|
+
className: classnames__default["default"](style$1['filter'], 'filter', responsiveUtils.RESPONSIVE_BOUNDARY_CLASS, isMobile && style$1['is-mobile'], className),
|
|
938
|
+
children: children(_extends({}, context, {
|
|
860
939
|
props
|
|
861
|
-
})
|
|
940
|
+
}))
|
|
862
941
|
})
|
|
863
|
-
});
|
|
942
|
+
}));
|
|
864
943
|
};
|
|
865
944
|
|
|
866
|
-
const _excluded$
|
|
945
|
+
const _excluded$c = ["defaultValue"],
|
|
867
946
|
_excluded2 = ["extraExpand"];
|
|
868
947
|
const Filter = withLocale(_ref => {
|
|
869
948
|
let _ref$defaultValue = _ref.defaultValue,
|
|
870
949
|
defaultValue = _ref$defaultValue === void 0 ? [] : _ref$defaultValue,
|
|
871
|
-
props = _objectWithoutPropertiesLoose(_ref, _excluded$
|
|
950
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$c);
|
|
872
951
|
return /*#__PURE__*/jsxRuntime.jsx(FilterOuter, _extends({}, props, {
|
|
873
952
|
defaultValue: defaultValue,
|
|
874
953
|
children: _ref2 => {
|
|
@@ -889,6 +968,24 @@ const Filter = withLocale(_ref => {
|
|
|
889
968
|
}));
|
|
890
969
|
});
|
|
891
970
|
|
|
971
|
+
/**
|
|
972
|
+
* 与 system-layout Toolbar 一致:
|
|
973
|
+
* - container 模式(example 手机预览):absolute + boundary 挂载
|
|
974
|
+
* - viewport 模式(真实移动端):fixed + 视口坐标
|
|
975
|
+
*/
|
|
976
|
+
const useMobileFixedMode = () => {
|
|
977
|
+
const isMobile = useFilterIsMobile();
|
|
978
|
+
const _useResponsiveContext = responsiveUtils.useResponsiveContext(),
|
|
979
|
+
mode = _useResponsiveContext.mode;
|
|
980
|
+
const useBoundaryMount = isMobile && mode === 'container';
|
|
981
|
+
const useViewportFixed = isMobile && mode !== 'container';
|
|
982
|
+
return {
|
|
983
|
+
isMobile,
|
|
984
|
+
useBoundaryMount,
|
|
985
|
+
useViewportFixed
|
|
986
|
+
};
|
|
987
|
+
};
|
|
988
|
+
|
|
892
989
|
const FilterItem = withLocale(_ref => {
|
|
893
990
|
let open = _ref.open,
|
|
894
991
|
active = _ref.active,
|
|
@@ -918,46 +1015,109 @@ const FilterItem = withLocale(_ref => {
|
|
|
918
1015
|
});
|
|
919
1016
|
});
|
|
920
1017
|
|
|
921
|
-
const
|
|
1018
|
+
const getMobilePopupMetrics = function (triggerEl, _temp) {
|
|
1019
|
+
var _scrollRect$top, _scrollRect$bottom, _scrollRect$width;
|
|
1020
|
+
let _ref = _temp === void 0 ? {} : _temp,
|
|
1021
|
+
scrollEl = _ref.scrollEl,
|
|
1022
|
+
boundaryEl = _ref.boundaryEl,
|
|
1023
|
+
useBoundaryMount = _ref.useBoundaryMount,
|
|
1024
|
+
_ref$offset = _ref.offset,
|
|
1025
|
+
offset = _ref$offset === void 0 ? 4 : _ref$offset;
|
|
1026
|
+
if (typeof window === 'undefined' || !triggerEl) {
|
|
1027
|
+
return {
|
|
1028
|
+
top: 0,
|
|
1029
|
+
left: 0,
|
|
1030
|
+
height: 0,
|
|
1031
|
+
width: 0
|
|
1032
|
+
};
|
|
1033
|
+
}
|
|
1034
|
+
const rect = triggerEl.getBoundingClientRect();
|
|
1035
|
+
if (useBoundaryMount && boundaryEl) {
|
|
1036
|
+
const boundaryRect = boundaryEl.getBoundingClientRect();
|
|
1037
|
+
const top = Math.max(rect.bottom - boundaryRect.top + offset, 0);
|
|
1038
|
+
return {
|
|
1039
|
+
top,
|
|
1040
|
+
left: 0,
|
|
1041
|
+
height: Math.max(boundaryRect.height - top, 0),
|
|
1042
|
+
width: boundaryRect.width
|
|
1043
|
+
};
|
|
1044
|
+
}
|
|
1045
|
+
const scrollRect = scrollEl == null || scrollEl.getBoundingClientRect == null ? void 0 : scrollEl.getBoundingClientRect();
|
|
1046
|
+
const visibleTop = (_scrollRect$top = scrollRect == null ? void 0 : scrollRect.top) != null ? _scrollRect$top : 0;
|
|
1047
|
+
const visibleBottom = (_scrollRect$bottom = scrollRect == null ? void 0 : scrollRect.bottom) != null ? _scrollRect$bottom : window.innerHeight;
|
|
1048
|
+
const width = (_scrollRect$width = scrollRect == null ? void 0 : scrollRect.width) != null ? _scrollRect$width : window.innerWidth;
|
|
1049
|
+
const top = Math.max(rect.bottom + offset, visibleTop);
|
|
1050
|
+
return {
|
|
1051
|
+
top,
|
|
1052
|
+
left: 0,
|
|
1053
|
+
height: Math.max(visibleBottom - top, 0),
|
|
1054
|
+
width
|
|
1055
|
+
};
|
|
1056
|
+
};
|
|
1057
|
+
|
|
1058
|
+
const MOBILE_MASK_Z_INDEX = 1000;
|
|
1059
|
+
const MOBILE_POPUP_Z_INDEX = 1050;
|
|
1060
|
+
|
|
1061
|
+
const _excluded$b = ["value", "onChange", "interceptor", "label", "render"];
|
|
922
1062
|
const isNotEmpty$1 = value => {
|
|
923
1063
|
if (value === null || value === undefined) return false;
|
|
924
1064
|
if (typeof value === 'string' && value.trim() === '') return false;
|
|
925
1065
|
return !(Array.isArray(value) && value.length === 0);
|
|
926
1066
|
};
|
|
927
1067
|
const MASK_ANIMATION_DURATION$1 = 180;
|
|
928
|
-
const FIELD_MOBILE_POPUP_CLASS = 'react-filter-field-mobile-popup';
|
|
1068
|
+
const FIELD_MOBILE_POPUP_CLASS$1 = 'react-filter-field-mobile-popup';
|
|
929
1069
|
const MOBILE_POPUP_OFFSET$1 = 4;
|
|
930
1070
|
const withFieldItem = function (WrappedComponent, options) {
|
|
931
1071
|
if (options === void 0) {
|
|
932
1072
|
options = {};
|
|
933
1073
|
}
|
|
934
1074
|
return _ref => {
|
|
1075
|
+
var _popupMetrics$left;
|
|
935
1076
|
let value = _ref.value,
|
|
936
1077
|
onChange = _ref.onChange,
|
|
937
1078
|
interceptor = _ref.interceptor,
|
|
938
1079
|
label = _ref.label,
|
|
939
1080
|
render = _ref.render,
|
|
940
|
-
props = _objectWithoutPropertiesLoose(_ref, _excluded$
|
|
1081
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$b);
|
|
941
1082
|
const _useState = react.useState(false),
|
|
942
1083
|
open = _useState[0],
|
|
943
1084
|
setOpen = _useState[1];
|
|
1085
|
+
const _useMobileFixedMode = useMobileFixedMode(),
|
|
1086
|
+
isMobile = _useMobileFixedMode.isMobile,
|
|
1087
|
+
useBoundaryMount = _useMobileFixedMode.useBoundaryMount;
|
|
1088
|
+
const fixedModeClass = useBoundaryMount ? style$1['is-boundary'] : style$1['is-viewport'];
|
|
944
1089
|
const _useState2 = react.useState(false),
|
|
945
|
-
|
|
946
|
-
|
|
1090
|
+
renderMask = _useState2[0],
|
|
1091
|
+
setRenderMask = _useState2[1];
|
|
947
1092
|
const _useState3 = react.useState(false),
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
const _useState4 = react.useState(
|
|
951
|
-
maskClosing = _useState4[0],
|
|
952
|
-
setMaskClosing = _useState4[1];
|
|
953
|
-
const _useState5 = react.useState({
|
|
1093
|
+
maskClosing = _useState3[0],
|
|
1094
|
+
setMaskClosing = _useState3[1];
|
|
1095
|
+
const _useState4 = react.useState({
|
|
954
1096
|
top: 0,
|
|
955
1097
|
pageTop: 0,
|
|
956
1098
|
height: 0
|
|
957
1099
|
}),
|
|
958
|
-
popupMetrics =
|
|
959
|
-
setPopupMetrics =
|
|
1100
|
+
popupMetrics = _useState4[0],
|
|
1101
|
+
setPopupMetrics = _useState4[1];
|
|
960
1102
|
const triggerRef = react.useRef(null);
|
|
1103
|
+
const getBoundaryElement = responsiveUtils.usePopupContainer();
|
|
1104
|
+
const getScrollElement = responsiveUtils.useScrollElement();
|
|
1105
|
+
const resolveGetPopupContainer = react.useCallback(triggerNode => {
|
|
1106
|
+
if (typeof props.getPopupContainer === 'function') {
|
|
1107
|
+
const customContainer = props.getPopupContainer(triggerNode);
|
|
1108
|
+
if (customContainer) {
|
|
1109
|
+
return customContainer;
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
if (!isMobile) {
|
|
1113
|
+
return getBoundaryElement();
|
|
1114
|
+
}
|
|
1115
|
+
if (useBoundaryMount) {
|
|
1116
|
+
return getBoundaryElement();
|
|
1117
|
+
}
|
|
1118
|
+
return typeof document !== 'undefined' ? document.body : null;
|
|
1119
|
+
}, [getBoundaryElement, isMobile, props.getPopupContainer, useBoundaryMount]);
|
|
1120
|
+
const popupMountNode = typeof document !== 'undefined' ? isMobile ? useBoundaryMount ? getBoundaryElement() || document.body : document.body : getBoundaryElement() || document.body : null;
|
|
961
1121
|
const setMobilePopupVariables = react.useCallback(metrics => {
|
|
962
1122
|
if (typeof document === 'undefined') return;
|
|
963
1123
|
document.body.style.setProperty('--react-filter-field-mobile-height', metrics.height + "px");
|
|
@@ -966,37 +1126,16 @@ const withFieldItem = function (WrappedComponent, options) {
|
|
|
966
1126
|
}, []);
|
|
967
1127
|
const updatePopupMetrics = react.useCallback(() => {
|
|
968
1128
|
if (typeof window === 'undefined' || !triggerRef.current) return;
|
|
969
|
-
const
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
};
|
|
1129
|
+
const metrics = getMobilePopupMetrics(triggerRef.current, {
|
|
1130
|
+
scrollEl: getScrollElement(),
|
|
1131
|
+
boundaryEl: getBoundaryElement(),
|
|
1132
|
+
useBoundaryMount,
|
|
1133
|
+
offset: MOBILE_POPUP_OFFSET$1
|
|
1134
|
+
});
|
|
975
1135
|
setPopupMetrics(metrics);
|
|
976
1136
|
setMobilePopupVariables(metrics);
|
|
977
|
-
}, [setMobilePopupVariables]);
|
|
978
|
-
|
|
979
|
-
if (typeof window === 'undefined') return;
|
|
980
|
-
const mediaQuery = window.matchMedia('(max-width: 768px)');
|
|
981
|
-
const updateIsMobile = () => {
|
|
982
|
-
setIsMobile(mediaQuery.matches);
|
|
983
|
-
};
|
|
984
|
-
updateIsMobile();
|
|
985
|
-
mediaQuery.addEventListener ? mediaQuery.addEventListener('change', updateIsMobile) : mediaQuery.addListener(updateIsMobile);
|
|
986
|
-
return () => {
|
|
987
|
-
mediaQuery.removeEventListener ? mediaQuery.removeEventListener('change', updateIsMobile) : mediaQuery.removeListener(updateIsMobile);
|
|
988
|
-
};
|
|
989
|
-
}, []);
|
|
990
|
-
react.useEffect(() => {
|
|
991
|
-
if (!open || !isMobile) return;
|
|
992
|
-
updatePopupMetrics();
|
|
993
|
-
window.addEventListener('resize', updatePopupMetrics);
|
|
994
|
-
window.addEventListener('scroll', updatePopupMetrics, true);
|
|
995
|
-
return () => {
|
|
996
|
-
window.removeEventListener('resize', updatePopupMetrics);
|
|
997
|
-
window.removeEventListener('scroll', updatePopupMetrics, true);
|
|
998
|
-
};
|
|
999
|
-
}, [isMobile, open, updatePopupMetrics]);
|
|
1137
|
+
}, [getBoundaryElement, getScrollElement, setMobilePopupVariables, useBoundaryMount]);
|
|
1138
|
+
useResponsiveScrollListener(updatePopupMetrics, open && isMobile);
|
|
1000
1139
|
react.useEffect(() => {
|
|
1001
1140
|
if (typeof document === 'undefined' || !isMobile || popupMetrics.height <= 0) return;
|
|
1002
1141
|
setMobilePopupVariables(popupMetrics);
|
|
@@ -1040,14 +1179,15 @@ const withFieldItem = function (WrappedComponent, options) {
|
|
|
1040
1179
|
'--react-filter-popover-mobile-height': popupMetrics.height + "px",
|
|
1041
1180
|
'--react-filter-field-mobile-top': popupMetrics.top + "px",
|
|
1042
1181
|
top: popupMetrics.top,
|
|
1043
|
-
left: 0
|
|
1182
|
+
left: (_popupMetrics$left = popupMetrics.left) != null ? _popupMetrics$left : 0,
|
|
1183
|
+
zIndex: MOBILE_POPUP_Z_INDEX
|
|
1044
1184
|
} : undefined;
|
|
1045
1185
|
const mergePopupClassNames = classNames => {
|
|
1046
1186
|
var _classNames$popup;
|
|
1047
1187
|
if (!isMobile) return classNames;
|
|
1048
1188
|
return Object.assign({}, classNames, {
|
|
1049
1189
|
popup: Object.assign({}, classNames == null ? void 0 : classNames.popup, {
|
|
1050
|
-
root: classnames__default["default"](classNames == null || (_classNames$popup = classNames.popup) == null ? void 0 : _classNames$popup.root, style$1['field-item-mobile-popup'], FIELD_MOBILE_POPUP_CLASS)
|
|
1190
|
+
root: classnames__default["default"](classNames == null || (_classNames$popup = classNames.popup) == null ? void 0 : _classNames$popup.root, style$1['field-item-mobile-popup'], FIELD_MOBILE_POPUP_CLASS$1, fixedModeClass)
|
|
1051
1191
|
})
|
|
1052
1192
|
});
|
|
1053
1193
|
};
|
|
@@ -1074,9 +1214,10 @@ const withFieldItem = function (WrappedComponent, options) {
|
|
|
1074
1214
|
valueType: "all",
|
|
1075
1215
|
onOpenChange: handleOpenChange,
|
|
1076
1216
|
onDropdownVisibleChange: handleOpenChange,
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1217
|
+
getPopupContainer: resolveGetPopupContainer,
|
|
1218
|
+
popupClassName: classnames__default["default"](props.popupClassName, isMobile && style$1['field-item-mobile-popup'], isMobile && FIELD_MOBILE_POPUP_CLASS$1, isMobile && fixedModeClass),
|
|
1219
|
+
dropdownClassName: classnames__default["default"](props.dropdownClassName, isMobile && style$1['field-item-mobile-popup'], isMobile && FIELD_MOBILE_POPUP_CLASS$1, isMobile && fixedModeClass),
|
|
1220
|
+
overlayClassName: classnames__default["default"](props.overlayClassName, isMobile && style$1['field-item-mobile-popup'], isMobile && FIELD_MOBILE_POPUP_CLASS$1, isMobile && fixedModeClass),
|
|
1080
1221
|
overlayStyle: Object.assign({}, props.overlayStyle, mobilePopupStyle),
|
|
1081
1222
|
popupStyle: Object.assign({}, props.popupStyle, mobilePopupStyle),
|
|
1082
1223
|
dropdownStyle: Object.assign({}, props.dropdownStyle, mobilePopupStyle),
|
|
@@ -1088,21 +1229,27 @@ const withFieldItem = function (WrappedComponent, options) {
|
|
|
1088
1229
|
offset: [0, 0]
|
|
1089
1230
|
} : props.align,
|
|
1090
1231
|
isPopup: options.forcePopup ? true : props.isPopup,
|
|
1091
|
-
|
|
1232
|
+
zIndex: isMobile ? MOBILE_POPUP_Z_INDEX : props.zIndex,
|
|
1233
|
+
overlayWidth: isMobile && options.forcePopup ? typeof window === 'undefined' ? props.overlayWidth : getMobilePopupMetrics(triggerRef.current, {
|
|
1234
|
+
scrollEl: getScrollElement(),
|
|
1235
|
+
boundaryEl: getBoundaryElement(),
|
|
1236
|
+
useBoundaryMount
|
|
1237
|
+
}).width || window.innerWidth : props.overlayWidth
|
|
1092
1238
|
}));
|
|
1093
1239
|
};
|
|
1094
1240
|
return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
1095
|
-
children: [renderMask &&
|
|
1096
|
-
className: classnames__default["default"](style$1['pop-util-mask'], maskClosing && style$1['pop-util-mask-leave']),
|
|
1241
|
+
children: [renderMask && popupMountNode && /*#__PURE__*/reactDom.createPortal(/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
1242
|
+
className: classnames__default["default"](style$1['pop-util-mask'], maskClosing && style$1['pop-util-mask-leave'], fixedModeClass),
|
|
1097
1243
|
style: {
|
|
1098
1244
|
top: popupMetrics.top,
|
|
1099
|
-
height: popupMetrics.height
|
|
1245
|
+
height: popupMetrics.height,
|
|
1246
|
+
zIndex: MOBILE_MASK_Z_INDEX
|
|
1100
1247
|
},
|
|
1101
1248
|
onClick: closeFieldItem,
|
|
1102
1249
|
onTouchMove: e => {
|
|
1103
1250
|
e.preventDefault();
|
|
1104
1251
|
}
|
|
1105
|
-
}),
|
|
1252
|
+
}), popupMountNode), /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
1106
1253
|
ref: triggerRef,
|
|
1107
1254
|
children: /*#__PURE__*/jsxRuntime.jsx(FilterItem, {
|
|
1108
1255
|
label: label,
|
|
@@ -1126,6 +1273,7 @@ const isNotEmpty = value => {
|
|
|
1126
1273
|
const MASK_ANIMATION_DURATION = 180;
|
|
1127
1274
|
const MOBILE_POPUP_OFFSET = 4;
|
|
1128
1275
|
const PopoverItem = withLocale(_ref => {
|
|
1276
|
+
var _popupMetrics$left;
|
|
1129
1277
|
let value = _ref.value,
|
|
1130
1278
|
label = _ref.label,
|
|
1131
1279
|
onValidate = _ref.onValidate,
|
|
@@ -1134,6 +1282,7 @@ const PopoverItem = withLocale(_ref => {
|
|
|
1134
1282
|
placement = _ref$placement === void 0 ? 'bottomLeft' : _ref$placement,
|
|
1135
1283
|
onOpenChange = _ref.onOpenChange,
|
|
1136
1284
|
onChange = _ref.onChange,
|
|
1285
|
+
customGetPopupContainer = _ref.getPopupContainer,
|
|
1137
1286
|
children = _ref.children;
|
|
1138
1287
|
const _useState = react.useState(value),
|
|
1139
1288
|
state = _useState[0],
|
|
@@ -1141,22 +1290,41 @@ const PopoverItem = withLocale(_ref => {
|
|
|
1141
1290
|
const _useState2 = react.useState(false),
|
|
1142
1291
|
open = _useState2[0],
|
|
1143
1292
|
setOpen = _useState2[1];
|
|
1293
|
+
const _useMobileFixedMode = useMobileFixedMode(),
|
|
1294
|
+
isMobile = _useMobileFixedMode.isMobile,
|
|
1295
|
+
useBoundaryMount = _useMobileFixedMode.useBoundaryMount;
|
|
1296
|
+
const fixedModeClass = useBoundaryMount ? style$1['is-boundary'] : style$1['is-viewport'];
|
|
1297
|
+
const getBoundaryElement = responsiveUtils.usePopupContainer();
|
|
1298
|
+
const getScrollElement = responsiveUtils.useScrollElement();
|
|
1299
|
+
const resolveGetPopupContainer = react.useCallback(triggerNode => {
|
|
1300
|
+
if (typeof customGetPopupContainer === 'function') {
|
|
1301
|
+
const customContainer = customGetPopupContainer(triggerNode);
|
|
1302
|
+
if (customContainer) {
|
|
1303
|
+
return customContainer;
|
|
1304
|
+
}
|
|
1305
|
+
}
|
|
1306
|
+
if (!isMobile) {
|
|
1307
|
+
return getBoundaryElement();
|
|
1308
|
+
}
|
|
1309
|
+
if (useBoundaryMount) {
|
|
1310
|
+
return getBoundaryElement();
|
|
1311
|
+
}
|
|
1312
|
+
return typeof document !== 'undefined' ? document.body : null;
|
|
1313
|
+
}, [customGetPopupContainer, getBoundaryElement, isMobile, useBoundaryMount]);
|
|
1314
|
+
const popupMountNode = typeof document !== 'undefined' ? isMobile ? useBoundaryMount ? getBoundaryElement() || document.body : document.body : getBoundaryElement() || document.body : null;
|
|
1144
1315
|
const _useState3 = react.useState(false),
|
|
1145
|
-
|
|
1146
|
-
|
|
1316
|
+
renderMask = _useState3[0],
|
|
1317
|
+
setRenderMask = _useState3[1];
|
|
1147
1318
|
const _useState4 = react.useState(false),
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
const _useState5 = react.useState(
|
|
1151
|
-
maskClosing = _useState5[0],
|
|
1152
|
-
setMaskClosing = _useState5[1];
|
|
1153
|
-
const _useState6 = react.useState({
|
|
1319
|
+
maskClosing = _useState4[0],
|
|
1320
|
+
setMaskClosing = _useState4[1];
|
|
1321
|
+
const _useState5 = react.useState({
|
|
1154
1322
|
top: 0,
|
|
1155
1323
|
pageTop: 0,
|
|
1156
1324
|
height: 0
|
|
1157
1325
|
}),
|
|
1158
|
-
popupMetrics =
|
|
1159
|
-
setPopupMetrics =
|
|
1326
|
+
popupMetrics = _useState5[0],
|
|
1327
|
+
setPopupMetrics = _useState5[1];
|
|
1160
1328
|
const triggerRef = react.useRef(null);
|
|
1161
1329
|
const disabled = react.useMemo(() => {
|
|
1162
1330
|
return onValidate && !onValidate(state);
|
|
@@ -1165,37 +1333,17 @@ const PopoverItem = withLocale(_ref => {
|
|
|
1165
1333
|
moduleName: 'Filter'
|
|
1166
1334
|
}),
|
|
1167
1335
|
formatMessage = _useIntl.formatMessage;
|
|
1168
|
-
react.useEffect(() => {
|
|
1169
|
-
if (typeof window === 'undefined') return;
|
|
1170
|
-
const mediaQuery = window.matchMedia('(max-width: 768px)');
|
|
1171
|
-
const updateIsMobile = () => {
|
|
1172
|
-
setIsMobile(mediaQuery.matches);
|
|
1173
|
-
};
|
|
1174
|
-
updateIsMobile();
|
|
1175
|
-
mediaQuery.addEventListener ? mediaQuery.addEventListener('change', updateIsMobile) : mediaQuery.addListener(updateIsMobile);
|
|
1176
|
-
return () => {
|
|
1177
|
-
mediaQuery.removeEventListener ? mediaQuery.removeEventListener('change', updateIsMobile) : mediaQuery.removeListener(updateIsMobile);
|
|
1178
|
-
};
|
|
1179
|
-
}, []);
|
|
1180
1336
|
const updatePopupMetrics = react.useCallback(() => {
|
|
1181
1337
|
if (typeof window === 'undefined' || !triggerRef.current) return;
|
|
1182
|
-
const
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1338
|
+
const metrics = getMobilePopupMetrics(triggerRef.current, {
|
|
1339
|
+
scrollEl: getScrollElement(),
|
|
1340
|
+
boundaryEl: getBoundaryElement(),
|
|
1341
|
+
useBoundaryMount,
|
|
1342
|
+
offset: MOBILE_POPUP_OFFSET
|
|
1187
1343
|
});
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
updatePopupMetrics();
|
|
1192
|
-
window.addEventListener('resize', updatePopupMetrics);
|
|
1193
|
-
window.addEventListener('scroll', updatePopupMetrics, true);
|
|
1194
|
-
return () => {
|
|
1195
|
-
window.removeEventListener('resize', updatePopupMetrics);
|
|
1196
|
-
window.removeEventListener('scroll', updatePopupMetrics, true);
|
|
1197
|
-
};
|
|
1198
|
-
}, [isMobile, open, updatePopupMetrics]);
|
|
1344
|
+
setPopupMetrics(metrics);
|
|
1345
|
+
}, [getBoundaryElement, getScrollElement, useBoundaryMount]);
|
|
1346
|
+
useResponsiveScrollListener(updatePopupMetrics, open && isMobile);
|
|
1199
1347
|
react.useEffect(() => {
|
|
1200
1348
|
if (open && isMobile) {
|
|
1201
1349
|
setRenderMask(true);
|
|
@@ -1227,7 +1375,8 @@ const PopoverItem = withLocale(_ref => {
|
|
|
1227
1375
|
const mobileOverlayStyle = isMobile ? {
|
|
1228
1376
|
'--react-filter-popover-mobile-height': popupMetrics.height + "px",
|
|
1229
1377
|
top: popupMetrics.top,
|
|
1230
|
-
left: 0
|
|
1378
|
+
left: (_popupMetrics$left = popupMetrics.left) != null ? _popupMetrics$left : 0,
|
|
1379
|
+
zIndex: MOBILE_POPUP_Z_INDEX
|
|
1231
1380
|
} : undefined;
|
|
1232
1381
|
const overlayContent = /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1233
1382
|
className: style$1['pop-util-body'],
|
|
@@ -1269,17 +1418,18 @@ const PopoverItem = withLocale(_ref => {
|
|
|
1269
1418
|
})]
|
|
1270
1419
|
});
|
|
1271
1420
|
return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
1272
|
-
children: [renderMask &&
|
|
1273
|
-
className: classnames__default["default"](style$1['pop-util-mask'], maskClosing && style$1['pop-util-mask-leave']),
|
|
1421
|
+
children: [renderMask && popupMountNode && /*#__PURE__*/reactDom.createPortal(/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
1422
|
+
className: classnames__default["default"](style$1['pop-util-mask'], maskClosing && style$1['pop-util-mask-leave'], fixedModeClass),
|
|
1274
1423
|
style: {
|
|
1275
1424
|
top: popupMetrics.top,
|
|
1276
|
-
height: popupMetrics.height
|
|
1425
|
+
height: popupMetrics.height,
|
|
1426
|
+
zIndex: MOBILE_MASK_Z_INDEX
|
|
1277
1427
|
},
|
|
1278
1428
|
onClick: closeDropdown,
|
|
1279
1429
|
onTouchMove: e => {
|
|
1280
1430
|
e.preventDefault();
|
|
1281
1431
|
}
|
|
1282
|
-
}),
|
|
1432
|
+
}), popupMountNode), /*#__PURE__*/jsxRuntime.jsx(antd.Dropdown, {
|
|
1283
1433
|
open: open,
|
|
1284
1434
|
trigger: ['click'],
|
|
1285
1435
|
placement: isMobile ? 'bottomLeft' : placement,
|
|
@@ -1287,7 +1437,9 @@ const PopoverItem = withLocale(_ref => {
|
|
|
1287
1437
|
align: isMobile ? {
|
|
1288
1438
|
offset: [0, 0]
|
|
1289
1439
|
} : undefined,
|
|
1290
|
-
|
|
1440
|
+
getPopupContainer: resolveGetPopupContainer,
|
|
1441
|
+
zIndex: isMobile ? MOBILE_POPUP_Z_INDEX : undefined,
|
|
1442
|
+
overlayClassName: classnames__default["default"](style$1['pop-util-overlay'], overlayClassName, isMobile && fixedModeClass),
|
|
1291
1443
|
overlayStyle: mobileOverlayStyle,
|
|
1292
1444
|
onOpenChange: handleOpenChange,
|
|
1293
1445
|
menu: {
|
|
@@ -1309,17 +1461,17 @@ const PopoverItem = withLocale(_ref => {
|
|
|
1309
1461
|
});
|
|
1310
1462
|
});
|
|
1311
1463
|
|
|
1312
|
-
const
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1464
|
+
const _excluded$a = ["label", "value", "onChange", "placeholder", "onValidate", "overlayClassName", "placement", "onOpenChange"];
|
|
1465
|
+
const InputFilterItem$2 = withLocale(_ref => {
|
|
1466
|
+
let label = _ref.label,
|
|
1467
|
+
value = _ref.value,
|
|
1468
|
+
onChange = _ref.onChange,
|
|
1469
|
+
placeholder = _ref.placeholder,
|
|
1470
|
+
onValidate = _ref.onValidate,
|
|
1471
|
+
overlayClassName = _ref.overlayClassName,
|
|
1472
|
+
placement = _ref.placement,
|
|
1473
|
+
onOpenChange = _ref.onOpenChange,
|
|
1474
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$a);
|
|
1323
1475
|
return /*#__PURE__*/jsxRuntime.jsx(PopoverItem, {
|
|
1324
1476
|
label: label,
|
|
1325
1477
|
value: value,
|
|
@@ -1328,22 +1480,23 @@ const InputFilterItem$2 = withLocale(({
|
|
|
1328
1480
|
overlayClassName,
|
|
1329
1481
|
placement,
|
|
1330
1482
|
onOpenChange,
|
|
1331
|
-
children:
|
|
1332
|
-
value,
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
}
|
|
1343
|
-
}
|
|
1483
|
+
children: _ref2 => {
|
|
1484
|
+
let value = _ref2.value,
|
|
1485
|
+
onChange = _ref2.onChange;
|
|
1486
|
+
return /*#__PURE__*/jsxRuntime.jsx(antd.Input, _extends({}, props, {
|
|
1487
|
+
placeholder: placeholder || "\u8BF7\u8F93\u5165" + label,
|
|
1488
|
+
className: style$1['filter-item-text'],
|
|
1489
|
+
value: get__default["default"](value, 'value', ''),
|
|
1490
|
+
onChange: e => onChange(e.target.value ? {
|
|
1491
|
+
label: e.target.value,
|
|
1492
|
+
value: e.target.value
|
|
1493
|
+
} : null)
|
|
1494
|
+
}));
|
|
1495
|
+
}
|
|
1344
1496
|
});
|
|
1345
1497
|
});
|
|
1346
1498
|
|
|
1499
|
+
const _excluded$9 = ["label", "value", "onChange", "placeholder", "onValidate", "overlayClassName", "placement", "onOpenChange", "unit"];
|
|
1347
1500
|
const computedFilterValue = (range, unit, formatMessage) => {
|
|
1348
1501
|
if (!isNumber__default["default"](range[0]) && !isNumber__default["default"](range[1])) {
|
|
1349
1502
|
return null;
|
|
@@ -1351,7 +1504,7 @@ const computedFilterValue = (range, unit, formatMessage) => {
|
|
|
1351
1504
|
return {
|
|
1352
1505
|
label: (range => {
|
|
1353
1506
|
if (isNumber__default["default"](range[0]) && isNumber__default["default"](range[1])) {
|
|
1354
|
-
return
|
|
1507
|
+
return range[0] + "-" + range[1] + (unit || '');
|
|
1355
1508
|
}
|
|
1356
1509
|
if (isNumber__default["default"](range[0])) {
|
|
1357
1510
|
return formatMessage({
|
|
@@ -1377,23 +1530,22 @@ const defaultPropsOnValidate = value => {
|
|
|
1377
1530
|
const range = get__default["default"](value, 'value');
|
|
1378
1531
|
return !(range && isNumber__default["default"](range[0]) && isNumber__default["default"](range[1]) && range[1] < range[0]);
|
|
1379
1532
|
};
|
|
1380
|
-
const NumberRangeFilterItem$1 = withLocale(
|
|
1381
|
-
label,
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
const {
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
});
|
|
1533
|
+
const NumberRangeFilterItem$1 = withLocale(_ref => {
|
|
1534
|
+
let label = _ref.label,
|
|
1535
|
+
value = _ref.value,
|
|
1536
|
+
onChange = _ref.onChange,
|
|
1537
|
+
placeholder = _ref.placeholder,
|
|
1538
|
+
_ref$onValidate = _ref.onValidate,
|
|
1539
|
+
onValidate = _ref$onValidate === void 0 ? defaultPropsOnValidate : _ref$onValidate,
|
|
1540
|
+
overlayClassName = _ref.overlayClassName,
|
|
1541
|
+
placement = _ref.placement,
|
|
1542
|
+
onOpenChange = _ref.onOpenChange,
|
|
1543
|
+
unit = _ref.unit,
|
|
1544
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$9);
|
|
1545
|
+
const _useIntl = reactIntl.useIntl({
|
|
1546
|
+
moduleName: 'Filter'
|
|
1547
|
+
}),
|
|
1548
|
+
formatMessage = _useIntl.formatMessage;
|
|
1397
1549
|
return /*#__PURE__*/jsxRuntime.jsx(PopoverItem, {
|
|
1398
1550
|
label: label,
|
|
1399
1551
|
value: value,
|
|
@@ -1402,136 +1554,141 @@ const NumberRangeFilterItem$1 = withLocale(({
|
|
|
1402
1554
|
overlayClassName,
|
|
1403
1555
|
placement,
|
|
1404
1556
|
onOpenChange,
|
|
1405
|
-
children:
|
|
1406
|
-
value,
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
}
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
})
|
|
1557
|
+
children: _ref2 => {
|
|
1558
|
+
let value = _ref2.value,
|
|
1559
|
+
onChange = _ref2.onChange;
|
|
1560
|
+
return /*#__PURE__*/jsxRuntime.jsxs(antd.Space.Compact, {
|
|
1561
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(antd.InputNumber, _extends({}, props, {
|
|
1562
|
+
placeholder: placeholder || "" + formatMessage({
|
|
1563
|
+
id: 'pleaseInput'
|
|
1564
|
+
}) + label,
|
|
1565
|
+
className: style$1['filter-item-number-range'],
|
|
1566
|
+
value: get__default["default"](value, 'value[0]', ''),
|
|
1567
|
+
onChange: target => {
|
|
1568
|
+
onChange(computedFilterValue([target, get__default["default"](value, 'value[1]')], unit, formatMessage));
|
|
1569
|
+
}
|
|
1570
|
+
})), /*#__PURE__*/jsxRuntime.jsx(antd.Input, {
|
|
1571
|
+
style: {
|
|
1572
|
+
width: 30,
|
|
1573
|
+
borderLeft: 0,
|
|
1574
|
+
borderRight: 0,
|
|
1575
|
+
pointerEvents: 'none'
|
|
1576
|
+
},
|
|
1577
|
+
placeholder: "~",
|
|
1578
|
+
disabled: true
|
|
1579
|
+
}), /*#__PURE__*/jsxRuntime.jsx(antd.InputNumber, _extends({}, props, {
|
|
1580
|
+
placeholder: placeholder || "" + formatMessage({
|
|
1581
|
+
id: 'pleaseInput'
|
|
1582
|
+
}) + label,
|
|
1583
|
+
className: style$1['filter-item-number-range'],
|
|
1584
|
+
value: get__default["default"](value, 'value[1]', ''),
|
|
1585
|
+
onChange: target => {
|
|
1586
|
+
onChange(computedFilterValue([get__default["default"](value, 'value[0]'), target], unit, formatMessage));
|
|
1587
|
+
}
|
|
1588
|
+
})), unit && /*#__PURE__*/jsxRuntime.jsx(antd.Input, {
|
|
1589
|
+
style: {
|
|
1590
|
+
width: 50,
|
|
1591
|
+
borderLeft: 0
|
|
1592
|
+
},
|
|
1593
|
+
value: unit,
|
|
1594
|
+
disabled: true
|
|
1595
|
+
})]
|
|
1596
|
+
});
|
|
1597
|
+
}
|
|
1447
1598
|
});
|
|
1448
1599
|
});
|
|
1449
1600
|
|
|
1450
|
-
const
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1601
|
+
const _excluded$8 = ["value", "onChange", "picker"];
|
|
1602
|
+
const DatePickerFilterItem = withLocale(withFieldItem(_ref => {
|
|
1603
|
+
var _props$classNames, _props$classNames2;
|
|
1604
|
+
let value = _ref.value,
|
|
1605
|
+
onChange = _ref.onChange,
|
|
1606
|
+
_ref$picker = _ref.picker,
|
|
1607
|
+
picker = _ref$picker === void 0 ? 'date' : _ref$picker,
|
|
1608
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$8);
|
|
1609
|
+
return /*#__PURE__*/jsxRuntime.jsx(antd.DatePicker, _extends({}, props, {
|
|
1458
1610
|
inputReadOnly: true,
|
|
1459
1611
|
picker: picker,
|
|
1460
|
-
classNames: {
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
}
|
|
1466
|
-
},
|
|
1612
|
+
classNames: _extends({}, props.classNames, {
|
|
1613
|
+
popup: _extends({}, (_props$classNames = props.classNames) == null ? void 0 : _props$classNames.popup, {
|
|
1614
|
+
root: classnames__default["default"]((_props$classNames2 = props.classNames) == null || (_props$classNames2 = _props$classNames2.popup) == null ? void 0 : _props$classNames2.root, style$1['date-picker-popup'])
|
|
1615
|
+
})
|
|
1616
|
+
}),
|
|
1467
1617
|
value: value && dayjs__default["default"](value.value),
|
|
1468
1618
|
onChange: value => {
|
|
1469
|
-
const {
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
format
|
|
1473
|
-
}, props);
|
|
1619
|
+
const _Object$assign = Object.assign({
|
|
1620
|
+
format: 'YYYY-MM-DD'
|
|
1621
|
+
}, props),
|
|
1622
|
+
format = _Object$assign.format;
|
|
1474
1623
|
value && onChange({
|
|
1475
|
-
label: picker !== 'date' ?
|
|
1624
|
+
label: picker !== 'date' ? value.startOf(picker).format(format) + "~" + value.endOf(picker).format(format) : value.format(format),
|
|
1476
1625
|
value: new Date(value.startOf(picker).valueOf())
|
|
1477
1626
|
});
|
|
1478
1627
|
}
|
|
1479
|
-
});
|
|
1628
|
+
}));
|
|
1480
1629
|
}));
|
|
1481
1630
|
|
|
1482
|
-
const
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1631
|
+
const _excluded$7 = ["value", "onChange", "header"];
|
|
1632
|
+
const DateRangePickerFilterItem = withLocale(withFieldItem(_ref => {
|
|
1633
|
+
var _props$classNames, _props$classNames2;
|
|
1634
|
+
let value = _ref.value,
|
|
1635
|
+
onChange = _ref.onChange,
|
|
1636
|
+
header = _ref.header,
|
|
1637
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$7);
|
|
1488
1638
|
return /*#__PURE__*/jsxRuntime.jsxs(antd.Flex, {
|
|
1489
1639
|
vertical: true,
|
|
1490
1640
|
children: [typeof header === 'function' ? header({
|
|
1491
1641
|
value,
|
|
1492
1642
|
onChange
|
|
1493
|
-
}) : header, /*#__PURE__*/jsxRuntime.jsx(antd.DatePicker.RangePicker, {
|
|
1494
|
-
...props,
|
|
1643
|
+
}) : header, /*#__PURE__*/jsxRuntime.jsx(antd.DatePicker.RangePicker, _extends({}, props, {
|
|
1495
1644
|
inputReadOnly: true,
|
|
1496
1645
|
allowEmpty: [false, false],
|
|
1497
|
-
classNames: {
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
}
|
|
1503
|
-
},
|
|
1646
|
+
classNames: _extends({}, props.classNames, {
|
|
1647
|
+
popup: _extends({}, (_props$classNames = props.classNames) == null ? void 0 : _props$classNames.popup, {
|
|
1648
|
+
root: classnames__default["default"]((_props$classNames2 = props.classNames) == null || (_props$classNames2 = _props$classNames2.popup) == null ? void 0 : _props$classNames2.root, style$1['date-range-picker-popup'])
|
|
1649
|
+
})
|
|
1650
|
+
}),
|
|
1504
1651
|
value: value && Array.isArray(value.value) && value.value.length === 2 && value.value.map(item => dayjs__default["default"](item)),
|
|
1505
1652
|
onChange: value => {
|
|
1506
|
-
const {
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
format
|
|
1510
|
-
}, props);
|
|
1653
|
+
const _Object$assign = Object.assign({
|
|
1654
|
+
format: 'YYYY-MM-DD'
|
|
1655
|
+
}, props),
|
|
1656
|
+
format = _Object$assign.format;
|
|
1511
1657
|
onChange({
|
|
1512
1658
|
label: value.map(item => item.format(format)).join('~'),
|
|
1513
1659
|
value: value.map(item => new Date(item.valueOf()))
|
|
1514
1660
|
});
|
|
1515
1661
|
}
|
|
1516
|
-
})]
|
|
1662
|
+
}))]
|
|
1517
1663
|
});
|
|
1518
1664
|
}));
|
|
1519
1665
|
|
|
1520
1666
|
var style = {"shortcuts-container":"kne-react-filter_3w4Bb","shortcut-item":"kne-react-filter_myRhG","is-active":"kne-react-filter_FowoG"};
|
|
1521
1667
|
|
|
1522
|
-
const _excluded$
|
|
1668
|
+
const _excluded$6 = ["value", "onChange", "defaultValue", "shortcuts", "shortcutOptions"];
|
|
1669
|
+
const FIELD_MOBILE_POPUP_CLASS = 'react-filter-field-mobile-popup';
|
|
1523
1670
|
const TypeDateRangePickerField = _ref => {
|
|
1671
|
+
var _props$classNames, _props$classNames2, _props$styles, _props$styles2;
|
|
1524
1672
|
let valueProp = _ref.value,
|
|
1525
1673
|
onChangeProp = _ref.onChange,
|
|
1526
1674
|
defaultValue = _ref.defaultValue,
|
|
1527
1675
|
_ref$shortcuts = _ref.shortcuts,
|
|
1528
1676
|
shortcuts = _ref$shortcuts === void 0 ? true : _ref$shortcuts,
|
|
1529
1677
|
shortcutOptions = _ref.shortcutOptions,
|
|
1530
|
-
props = _objectWithoutPropertiesLoose(_ref, _excluded$
|
|
1678
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$6);
|
|
1531
1679
|
const _useIntl = reactIntl.useIntl({
|
|
1532
1680
|
moduleName: 'Filter'
|
|
1533
1681
|
}),
|
|
1534
1682
|
formatMessage = _useIntl.formatMessage;
|
|
1683
|
+
const getPopupContainer = responsiveUtils.usePopupContainer();
|
|
1684
|
+
const _useMobileFixedMode = useMobileFixedMode(),
|
|
1685
|
+
isMobile = _useMobileFixedMode.isMobile,
|
|
1686
|
+
useBoundaryMount = _useMobileFixedMode.useBoundaryMount;
|
|
1687
|
+
const fixedModeClass = useBoundaryMount ? style['is-boundary'] : style['is-viewport'];
|
|
1688
|
+
const nestedPopupClassName = classnames__default["default"](style['field-item-mobile-popup'], FIELD_MOBILE_POPUP_CLASS, fixedModeClass);
|
|
1689
|
+
const nestedPopupStyle = isMobile ? {
|
|
1690
|
+
zIndex: MOBILE_POPUP_Z_INDEX
|
|
1691
|
+
} : undefined;
|
|
1535
1692
|
const typeList = new Map([['date', formatMessage({
|
|
1536
1693
|
id: 'customTime'
|
|
1537
1694
|
})], ['month', formatMessage({
|
|
@@ -1625,6 +1782,19 @@ const TypeDateRangePickerField = _ref => {
|
|
|
1625
1782
|
style: {
|
|
1626
1783
|
width: '120px'
|
|
1627
1784
|
},
|
|
1785
|
+
getPopupContainer: getPopupContainer,
|
|
1786
|
+
popupClassName: isMobile ? nestedPopupClassName : undefined,
|
|
1787
|
+
classNames: isMobile ? {
|
|
1788
|
+
popup: {
|
|
1789
|
+
root: nestedPopupClassName
|
|
1790
|
+
}
|
|
1791
|
+
} : undefined,
|
|
1792
|
+
popupStyle: nestedPopupStyle,
|
|
1793
|
+
styles: isMobile ? {
|
|
1794
|
+
popup: {
|
|
1795
|
+
root: nestedPopupStyle
|
|
1796
|
+
}
|
|
1797
|
+
} : undefined,
|
|
1628
1798
|
value: (value == null ? void 0 : value.type) || 'date',
|
|
1629
1799
|
onChange: typeValue => {
|
|
1630
1800
|
onChange(currentValue => {
|
|
@@ -1652,6 +1822,18 @@ const TypeDateRangePickerField = _ref => {
|
|
|
1652
1822
|
};
|
|
1653
1823
|
})
|
|
1654
1824
|
}), /*#__PURE__*/jsxRuntime.jsx(antd.DatePicker.RangePicker, _extends({}, props, {
|
|
1825
|
+
getPopupContainer: getPopupContainer,
|
|
1826
|
+
classNames: isMobile ? _extends({}, props.classNames, {
|
|
1827
|
+
popup: _extends({}, (_props$classNames = props.classNames) == null ? void 0 : _props$classNames.popup, {
|
|
1828
|
+
root: classnames__default["default"]((_props$classNames2 = props.classNames) == null || (_props$classNames2 = _props$classNames2.popup) == null ? void 0 : _props$classNames2.root, nestedPopupClassName)
|
|
1829
|
+
})
|
|
1830
|
+
}) : props.classNames,
|
|
1831
|
+
styles: isMobile ? _extends({}, props.styles, {
|
|
1832
|
+
popup: _extends({}, (_props$styles = props.styles) == null ? void 0 : _props$styles.popup, {
|
|
1833
|
+
root: Object.assign({}, (_props$styles2 = props.styles) == null || (_props$styles2 = _props$styles2.popup) == null ? void 0 : _props$styles2.root, nestedPopupStyle)
|
|
1834
|
+
})
|
|
1835
|
+
}) : props.styles,
|
|
1836
|
+
popupStyle: nestedPopupStyle,
|
|
1655
1837
|
picker: (value == null ? void 0 : value.type) || 'date',
|
|
1656
1838
|
value: Array.isArray(value == null ? void 0 : value.value) && value.value.length === 2 ? value.value.map(item => item && dayjs__default["default"](item)) : null,
|
|
1657
1839
|
onChange: dateValue => {
|
|
@@ -1668,47 +1850,46 @@ const TypeDateRangePickerField = _ref => {
|
|
|
1668
1850
|
});
|
|
1669
1851
|
};
|
|
1670
1852
|
|
|
1671
|
-
const
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1853
|
+
const _excluded$5 = ["label", "value", "onChange"];
|
|
1854
|
+
const TypeDateRangePickerFilterItem = withLocale(_ref => {
|
|
1855
|
+
let label = _ref.label,
|
|
1856
|
+
value = _ref.value,
|
|
1857
|
+
onChange = _ref.onChange,
|
|
1858
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$5);
|
|
1677
1859
|
return /*#__PURE__*/jsxRuntime.jsx(PopoverItem, {
|
|
1678
1860
|
label: label,
|
|
1679
1861
|
value: value,
|
|
1680
1862
|
onChange: onChange,
|
|
1681
1863
|
onValidate: item => {
|
|
1682
|
-
const itemValue = item
|
|
1683
|
-
return itemValue
|
|
1864
|
+
const itemValue = item == null ? void 0 : item.value;
|
|
1865
|
+
return (itemValue == null ? void 0 : itemValue.type) && Array.isArray(itemValue == null ? void 0 : itemValue.value) && itemValue.value.length === 2;
|
|
1684
1866
|
},
|
|
1685
|
-
children:
|
|
1686
|
-
value,
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1867
|
+
children: _ref2 => {
|
|
1868
|
+
let value = _ref2.value,
|
|
1869
|
+
onChange = _ref2.onChange;
|
|
1870
|
+
return /*#__PURE__*/jsxRuntime.jsx(TypeDateRangePickerField, _extends({}, props, {
|
|
1871
|
+
inputReadOnly: true,
|
|
1872
|
+
className: style$1['filter-item-text'],
|
|
1873
|
+
value: get__default["default"](value, 'value'),
|
|
1874
|
+
onChange: pickerValue => {
|
|
1875
|
+
const _props$format = props.format,
|
|
1876
|
+
format = _props$format === void 0 ? 'YYYY-MM-DD' : _props$format;
|
|
1877
|
+
const val = (pickerValue == null ? void 0 : pickerValue.value) || [];
|
|
1878
|
+
let displayLabel = '';
|
|
1879
|
+
if (val[0] && !val[1]) {
|
|
1880
|
+
displayLabel = dayjs__default["default"](val[0]).format(format) + "\u4EE5\u540E";
|
|
1881
|
+
} else if (!val[0] && val[1]) {
|
|
1882
|
+
displayLabel = dayjs__default["default"](val[1]).format(format) + "\u4EE5\u524D";
|
|
1883
|
+
} else if (val[0] && val[1]) {
|
|
1884
|
+
displayLabel = dayjs__default["default"](val[0]).format(format) + "~" + dayjs__default["default"](val[1]).format(format);
|
|
1885
|
+
}
|
|
1886
|
+
onChange({
|
|
1887
|
+
label: displayLabel,
|
|
1888
|
+
value: pickerValue
|
|
1889
|
+
});
|
|
1705
1890
|
}
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
value: pickerValue
|
|
1709
|
-
});
|
|
1710
|
-
}
|
|
1711
|
-
})
|
|
1891
|
+
}));
|
|
1892
|
+
}
|
|
1712
1893
|
});
|
|
1713
1894
|
});
|
|
1714
1895
|
|
|
@@ -2607,6 +2788,7 @@ const CityFilterItemInner = ({
|
|
|
2607
2788
|
const {
|
|
2608
2789
|
message
|
|
2609
2790
|
} = antd.App.useApp();
|
|
2791
|
+
const getPopupContainer = responsiveUtils.usePopupContainer();
|
|
2610
2792
|
const {
|
|
2611
2793
|
locale
|
|
2612
2794
|
} = reactIntl.useIntl();
|
|
@@ -2680,6 +2862,7 @@ const CityFilterItemInner = ({
|
|
|
2680
2862
|
id: 'otherText'
|
|
2681
2863
|
}), /*#__PURE__*/jsxRuntime.jsx(superSelectPlus.SelectAddress, {
|
|
2682
2864
|
...props,
|
|
2865
|
+
getPopupContainer: getPopupContainer,
|
|
2683
2866
|
className: style$1['filter-advanced-item-other-inner'],
|
|
2684
2867
|
maxLength: maxLength,
|
|
2685
2868
|
allowClear: false,
|