@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.modern.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import classnames from 'classnames';
|
|
2
|
-
import { useContext as useContext$1, createContext,
|
|
2
|
+
import { useContext as useContext$1, createContext, useEffect, useRef, useState, useCallback, useLayoutEffect, useMemo, createElement } from 'react';
|
|
3
3
|
import { Space, Row, Col, Tag, Button, Dropdown, Input, InputNumber, DatePicker, Flex, Select, App } from 'antd';
|
|
4
4
|
import { useIntl, createWithIntlProvider } from '@kne/react-intl';
|
|
5
5
|
import get from 'lodash/get';
|
|
6
|
+
import { useResponsiveContext, useMediaQuery, IS_MOBILE_QUERY, MOBILE_BREAKPOINT, useScrollElement, resetViewportCssVars, applyViewportCssVars, RESPONSIVE_BOUNDARY_CLASS, usePopupContainer } from '@kne/responsive-utils';
|
|
6
7
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
7
8
|
import { UpOutlined, DownOutlined } from '@ant-design/icons';
|
|
8
9
|
import clone from 'lodash/clone';
|
|
@@ -36,7 +37,7 @@ function _objectWithoutPropertiesLoose(r, e) {
|
|
|
36
37
|
return t;
|
|
37
38
|
}
|
|
38
39
|
|
|
39
|
-
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","
|
|
40
|
+
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"};
|
|
40
41
|
|
|
41
42
|
const context = /*#__PURE__*/createContext({});
|
|
42
43
|
const {
|
|
@@ -44,21 +45,52 @@ const {
|
|
|
44
45
|
} = context;
|
|
45
46
|
const useContext = () => useContext$1(context);
|
|
46
47
|
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
/**
|
|
49
|
+
* Filter 移动端判定:默认按视口宽度,仅在 ResponsiveProvider container 模式下按预览容器宽度。
|
|
50
|
+
* 避免 Filter 嵌入窄列时误用移动端布局。
|
|
51
|
+
*/
|
|
52
|
+
const useFilterIsMobile = () => {
|
|
53
|
+
const {
|
|
54
|
+
mode,
|
|
55
|
+
containerWidth
|
|
56
|
+
} = useResponsiveContext();
|
|
57
|
+
const viewportIsMobile = useMediaQuery(IS_MOBILE_QUERY);
|
|
58
|
+
if (mode === 'container' && typeof containerWidth === 'number') {
|
|
59
|
+
return containerWidth < MOBILE_BREAKPOINT;
|
|
60
|
+
}
|
|
61
|
+
return viewportIsMobile;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const useResponsiveScrollListener = (callback, enabled = true) => {
|
|
65
|
+
const getScrollElement = useScrollElement();
|
|
49
66
|
useEffect(() => {
|
|
50
|
-
if (typeof
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
67
|
+
if (!enabled || typeof callback !== 'function') {
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
const scrollEl = getScrollElement();
|
|
71
|
+
if (!scrollEl) {
|
|
72
|
+
return undefined;
|
|
73
|
+
}
|
|
74
|
+
callback();
|
|
75
|
+
const handleChange = () => {
|
|
76
|
+
callback();
|
|
54
77
|
};
|
|
55
|
-
|
|
56
|
-
|
|
78
|
+
scrollEl.addEventListener('scroll', handleChange, {
|
|
79
|
+
passive: true
|
|
80
|
+
});
|
|
81
|
+
window.addEventListener('resize', handleChange);
|
|
82
|
+
let resizeObserver;
|
|
83
|
+
if (typeof ResizeObserver !== 'undefined') {
|
|
84
|
+
resizeObserver = new ResizeObserver(handleChange);
|
|
85
|
+
resizeObserver.observe(scrollEl);
|
|
86
|
+
}
|
|
57
87
|
return () => {
|
|
58
|
-
|
|
88
|
+
var _resizeObserver;
|
|
89
|
+
scrollEl.removeEventListener('scroll', handleChange);
|
|
90
|
+
window.removeEventListener('resize', handleChange);
|
|
91
|
+
(_resizeObserver = resizeObserver) == null || _resizeObserver.disconnect();
|
|
59
92
|
};
|
|
60
|
-
}, []);
|
|
61
|
-
return isMobile;
|
|
93
|
+
}, [callback, enabled, getScrollElement]);
|
|
62
94
|
};
|
|
63
95
|
|
|
64
96
|
const useHorizontalScrollShadows = ({
|
|
@@ -99,14 +131,13 @@ const useHorizontalScrollShadows = ({
|
|
|
99
131
|
}
|
|
100
132
|
update();
|
|
101
133
|
el.addEventListener('scroll', update);
|
|
102
|
-
window.addEventListener('resize', update);
|
|
103
134
|
const rafId = window.requestAnimationFrame(update);
|
|
104
135
|
return () => {
|
|
105
136
|
el.removeEventListener('scroll', update);
|
|
106
|
-
window.removeEventListener('resize', update);
|
|
107
137
|
window.cancelAnimationFrame(rafId);
|
|
108
138
|
};
|
|
109
139
|
}, [enabled, refreshKey, _suspend, update]);
|
|
140
|
+
useResponsiveScrollListener(update, enabled && !_suspend);
|
|
110
141
|
return {
|
|
111
142
|
scrollRef,
|
|
112
143
|
isOverflow,
|
|
@@ -123,13 +154,14 @@ const useVisibleItemCount = ({
|
|
|
123
154
|
enabled,
|
|
124
155
|
strategy: _strategy = 'asc'
|
|
125
156
|
}) => {
|
|
157
|
+
const safeItems = Array.isArray(items) ? items : [];
|
|
126
158
|
const containerRef = useRef(null);
|
|
127
159
|
const measureRef = useRef(null);
|
|
128
160
|
const moreMeasureRef = useRef(null);
|
|
129
161
|
const rafRef = useRef(null);
|
|
130
162
|
const lastWidthRef = useRef(0);
|
|
131
163
|
const [containerEl, setContainerEl] = useState(null);
|
|
132
|
-
const [visibleCount, setVisibleCount] = useState(() =>
|
|
164
|
+
const [visibleCount, setVisibleCount] = useState(() => safeItems.length > 0 ? 1 : 0);
|
|
133
165
|
const setContainerRef = useCallback(node => {
|
|
134
166
|
containerRef.current = node;
|
|
135
167
|
setContainerEl(node || null);
|
|
@@ -156,7 +188,7 @@ const useVisibleItemCount = ({
|
|
|
156
188
|
return null;
|
|
157
189
|
}
|
|
158
190
|
const moreButtonWidth = ((_moreMeasureRef$curre = moreMeasureRef.current) == null ? void 0 : _moreMeasureRef$curre.getBoundingClientRect().width) || 0;
|
|
159
|
-
if (
|
|
191
|
+
if (safeItems.length > 1 && moreButtonWidth <= 0) {
|
|
160
192
|
return null;
|
|
161
193
|
}
|
|
162
194
|
const itemWidths = Array.from(itemNodes, node => node.getBoundingClientRect().width);
|
|
@@ -165,24 +197,24 @@ const useVisibleItemCount = ({
|
|
|
165
197
|
itemWidths,
|
|
166
198
|
moreButtonWidth
|
|
167
199
|
};
|
|
168
|
-
}, [
|
|
200
|
+
}, [safeItems.length]);
|
|
169
201
|
const getWidthForCount = useCallback((itemWidths, moreButtonWidth, count) => {
|
|
170
202
|
let usedWidth = 0;
|
|
171
203
|
for (let i = 0; i < count; i++) {
|
|
172
204
|
usedWidth += itemWidths[i] + (i > 0 ? GAP : 0);
|
|
173
205
|
}
|
|
174
|
-
if (count <
|
|
206
|
+
if (count < safeItems.length) {
|
|
175
207
|
usedWidth += GAP + moreButtonWidth;
|
|
176
208
|
}
|
|
177
209
|
return usedWidth;
|
|
178
|
-
}, [
|
|
210
|
+
}, [safeItems.length]);
|
|
179
211
|
const resolveVisibleCount = useCallback(widths => {
|
|
180
212
|
const {
|
|
181
213
|
containerWidth,
|
|
182
214
|
itemWidths,
|
|
183
215
|
moreButtonWidth
|
|
184
216
|
} = widths;
|
|
185
|
-
const maxCount = Math.min(
|
|
217
|
+
const maxCount = Math.min(safeItems.length, itemWidths.length);
|
|
186
218
|
let count = 1;
|
|
187
219
|
if (_strategy === 'desc') {
|
|
188
220
|
count = maxCount;
|
|
@@ -205,10 +237,10 @@ const useVisibleItemCount = ({
|
|
|
205
237
|
}
|
|
206
238
|
}
|
|
207
239
|
return Math.max(1, count);
|
|
208
|
-
}, [getWidthForCount,
|
|
240
|
+
}, [getWidthForCount, safeItems.length, _strategy]);
|
|
209
241
|
const calculateByWidth = useCallback(() => {
|
|
210
|
-
if (!enabled || !
|
|
211
|
-
setVisibleCount(prev => prev ===
|
|
242
|
+
if (!enabled || !safeItems.length) {
|
|
243
|
+
setVisibleCount(prev => prev === safeItems.length ? prev : safeItems.length);
|
|
212
244
|
return;
|
|
213
245
|
}
|
|
214
246
|
const widths = getWidths();
|
|
@@ -217,7 +249,7 @@ const useVisibleItemCount = ({
|
|
|
217
249
|
}
|
|
218
250
|
const nextCount = resolveVisibleCount(widths);
|
|
219
251
|
setVisibleCount(prev => prev === nextCount ? prev : nextCount);
|
|
220
|
-
}, [enabled, getWidths,
|
|
252
|
+
}, [enabled, getWidths, safeItems.length, resolveVisibleCount]);
|
|
221
253
|
const scheduleCalculate = useCallback(() => {
|
|
222
254
|
if (rafRef.current) {
|
|
223
255
|
window.cancelAnimationFrame(rafRef.current);
|
|
@@ -235,7 +267,7 @@ const useVisibleItemCount = ({
|
|
|
235
267
|
rafRef.current = null;
|
|
236
268
|
}
|
|
237
269
|
};
|
|
238
|
-
}, [
|
|
270
|
+
}, [safeItems, scheduleCalculate]);
|
|
239
271
|
useEffect(() => {
|
|
240
272
|
if (!enabled || !containerEl) {
|
|
241
273
|
return undefined;
|
|
@@ -252,16 +284,15 @@ const useVisibleItemCount = ({
|
|
|
252
284
|
});
|
|
253
285
|
lastWidthRef.current = containerEl.clientWidth;
|
|
254
286
|
observer.observe(containerEl);
|
|
255
|
-
window.addEventListener('resize', scheduleCalculate);
|
|
256
287
|
return () => {
|
|
257
288
|
observer.disconnect();
|
|
258
|
-
window.removeEventListener('resize', scheduleCalculate);
|
|
259
289
|
if (rafRef.current) {
|
|
260
290
|
window.cancelAnimationFrame(rafRef.current);
|
|
261
291
|
rafRef.current = null;
|
|
262
292
|
}
|
|
263
293
|
};
|
|
264
294
|
}, [containerEl, enabled, scheduleCalculate]);
|
|
295
|
+
useResponsiveScrollListener(scheduleCalculate, enabled && !!containerEl);
|
|
265
296
|
return {
|
|
266
297
|
setContainerRef,
|
|
267
298
|
setMeasureRef,
|
|
@@ -291,14 +322,14 @@ const normalizeFilterList = list => {
|
|
|
291
322
|
if (isNestedFilterList(safeList)) {
|
|
292
323
|
return {
|
|
293
324
|
mode: 'nested',
|
|
294
|
-
items:
|
|
325
|
+
items: [],
|
|
295
326
|
lines: safeList
|
|
296
327
|
};
|
|
297
328
|
}
|
|
298
329
|
return {
|
|
299
330
|
mode: 'flat',
|
|
300
331
|
items: safeList,
|
|
301
|
-
lines:
|
|
332
|
+
lines: []
|
|
302
333
|
};
|
|
303
334
|
};
|
|
304
335
|
const getMobileFilterList = list => {
|
|
@@ -403,7 +434,7 @@ const FilterLines = ({
|
|
|
403
434
|
const mobileList = useMemo(() => getMobileFilterList(_list), [_list]);
|
|
404
435
|
const isFlatMode = mode === 'flat';
|
|
405
436
|
const [isExpand, setIsExpand] = useState(false);
|
|
406
|
-
const isMobile =
|
|
437
|
+
const isMobile = useFilterIsMobile();
|
|
407
438
|
const {
|
|
408
439
|
scrollRef,
|
|
409
440
|
showScrollPrev,
|
|
@@ -680,7 +711,10 @@ const withLocale = createWithIntlProvider({
|
|
|
680
711
|
const FilterValueDisplay = withLocale(({
|
|
681
712
|
value: filterValue,
|
|
682
713
|
extraExpand,
|
|
683
|
-
onChange
|
|
714
|
+
onChange,
|
|
715
|
+
className,
|
|
716
|
+
hideLabel,
|
|
717
|
+
flush
|
|
684
718
|
}) => {
|
|
685
719
|
const {
|
|
686
720
|
formatMessage
|
|
@@ -688,7 +722,7 @@ const FilterValueDisplay = withLocale(({
|
|
|
688
722
|
moduleName: 'Filter'
|
|
689
723
|
});
|
|
690
724
|
const [isExpand, setIsExpand] = useState(false);
|
|
691
|
-
const isMobile =
|
|
725
|
+
const isMobile = useFilterIsMobile();
|
|
692
726
|
const {
|
|
693
727
|
scrollRef,
|
|
694
728
|
isOverflow,
|
|
@@ -724,10 +758,13 @@ const FilterValueDisplay = withLocale(({
|
|
|
724
758
|
}, name);
|
|
725
759
|
});
|
|
726
760
|
return /*#__PURE__*/jsxs(Space, {
|
|
727
|
-
className: classnames(style$1['filter-title'], style$1['filter-value-display']
|
|
761
|
+
className: classnames(style$1['filter-title'], style$1['filter-value-display'], 'filter-value-display-root', {
|
|
762
|
+
[style$1['is-hide-label']]: hideLabel,
|
|
763
|
+
[style$1['is-flush']]: flush
|
|
764
|
+
}, className),
|
|
728
765
|
align: "top",
|
|
729
|
-
size: 16,
|
|
730
|
-
children: [/*#__PURE__*/jsx("span", {
|
|
766
|
+
size: hideLabel ? 0 : 16,
|
|
767
|
+
children: [hideLabel ? null : /*#__PURE__*/jsx("span", {
|
|
731
768
|
className: style$1['filter-label'],
|
|
732
769
|
children: formatMessage({
|
|
733
770
|
id: 'selectedText'
|
|
@@ -842,6 +879,34 @@ const FilterProvider = ({
|
|
|
842
879
|
});
|
|
843
880
|
};
|
|
844
881
|
|
|
882
|
+
const useFilterViewportVars = () => {
|
|
883
|
+
const boundaryRef = useRef(null);
|
|
884
|
+
const {
|
|
885
|
+
mode
|
|
886
|
+
} = useResponsiveContext();
|
|
887
|
+
useEffect(() => {
|
|
888
|
+
const el = boundaryRef.current;
|
|
889
|
+
if (!el || typeof window === 'undefined' || mode === 'container') {
|
|
890
|
+
return undefined;
|
|
891
|
+
}
|
|
892
|
+
const update = () => {
|
|
893
|
+
applyViewportCssVars(el, {
|
|
894
|
+
width: window.innerWidth,
|
|
895
|
+
height: window.innerHeight
|
|
896
|
+
});
|
|
897
|
+
};
|
|
898
|
+
update();
|
|
899
|
+
window.addEventListener('resize', update, {
|
|
900
|
+
passive: true
|
|
901
|
+
});
|
|
902
|
+
return () => {
|
|
903
|
+
window.removeEventListener('resize', update);
|
|
904
|
+
resetViewportCssVars(el);
|
|
905
|
+
};
|
|
906
|
+
}, [mode]);
|
|
907
|
+
return boundaryRef;
|
|
908
|
+
};
|
|
909
|
+
|
|
845
910
|
const _excluded$f = ["children", "className"];
|
|
846
911
|
const FilterOuter = _ref => {
|
|
847
912
|
let {
|
|
@@ -849,9 +914,12 @@ const FilterOuter = _ref => {
|
|
|
849
914
|
className
|
|
850
915
|
} = _ref,
|
|
851
916
|
props = _objectWithoutPropertiesLoose(_ref, _excluded$f);
|
|
917
|
+
const isMobile = useFilterIsMobile();
|
|
918
|
+
const boundaryRef = useFilterViewportVars();
|
|
852
919
|
return /*#__PURE__*/jsx(FilterProvider, _extends({}, props, {
|
|
853
920
|
children: context => /*#__PURE__*/jsx("div", {
|
|
854
|
-
|
|
921
|
+
ref: boundaryRef,
|
|
922
|
+
className: classnames(style$1['filter'], 'filter', RESPONSIVE_BOUNDARY_CLASS, isMobile && style$1['is-mobile'], className),
|
|
855
923
|
children: children(_extends({}, context, {
|
|
856
924
|
props
|
|
857
925
|
}))
|
|
@@ -888,6 +956,25 @@ const Filter = withLocale(_ref => {
|
|
|
888
956
|
}));
|
|
889
957
|
});
|
|
890
958
|
|
|
959
|
+
/**
|
|
960
|
+
* 与 system-layout Toolbar 一致:
|
|
961
|
+
* - container 模式(example 手机预览):absolute + boundary 挂载
|
|
962
|
+
* - viewport 模式(真实移动端):fixed + 视口坐标
|
|
963
|
+
*/
|
|
964
|
+
const useMobileFixedMode = () => {
|
|
965
|
+
const isMobile = useFilterIsMobile();
|
|
966
|
+
const {
|
|
967
|
+
mode
|
|
968
|
+
} = useResponsiveContext();
|
|
969
|
+
const useBoundaryMount = isMobile && mode === 'container';
|
|
970
|
+
const useViewportFixed = isMobile && mode !== 'container';
|
|
971
|
+
return {
|
|
972
|
+
isMobile,
|
|
973
|
+
useBoundaryMount,
|
|
974
|
+
useViewportFixed
|
|
975
|
+
};
|
|
976
|
+
};
|
|
977
|
+
|
|
891
978
|
const FilterItem = withLocale(({
|
|
892
979
|
open,
|
|
893
980
|
active,
|
|
@@ -918,6 +1005,48 @@ const FilterItem = withLocale(({
|
|
|
918
1005
|
});
|
|
919
1006
|
});
|
|
920
1007
|
|
|
1008
|
+
const getMobilePopupMetrics = (triggerEl, {
|
|
1009
|
+
scrollEl,
|
|
1010
|
+
boundaryEl,
|
|
1011
|
+
useBoundaryMount,
|
|
1012
|
+
offset: _offset = 4
|
|
1013
|
+
} = {}) => {
|
|
1014
|
+
var _scrollRect$top, _scrollRect$bottom, _scrollRect$width;
|
|
1015
|
+
if (typeof window === 'undefined' || !triggerEl) {
|
|
1016
|
+
return {
|
|
1017
|
+
top: 0,
|
|
1018
|
+
left: 0,
|
|
1019
|
+
height: 0,
|
|
1020
|
+
width: 0
|
|
1021
|
+
};
|
|
1022
|
+
}
|
|
1023
|
+
const rect = triggerEl.getBoundingClientRect();
|
|
1024
|
+
if (useBoundaryMount && boundaryEl) {
|
|
1025
|
+
const boundaryRect = boundaryEl.getBoundingClientRect();
|
|
1026
|
+
const _top = Math.max(rect.bottom - boundaryRect.top + _offset, 0);
|
|
1027
|
+
return {
|
|
1028
|
+
top: _top,
|
|
1029
|
+
left: 0,
|
|
1030
|
+
height: Math.max(boundaryRect.height - _top, 0),
|
|
1031
|
+
width: boundaryRect.width
|
|
1032
|
+
};
|
|
1033
|
+
}
|
|
1034
|
+
const scrollRect = scrollEl == null || scrollEl.getBoundingClientRect == null ? void 0 : scrollEl.getBoundingClientRect();
|
|
1035
|
+
const visibleTop = (_scrollRect$top = scrollRect == null ? void 0 : scrollRect.top) != null ? _scrollRect$top : 0;
|
|
1036
|
+
const visibleBottom = (_scrollRect$bottom = scrollRect == null ? void 0 : scrollRect.bottom) != null ? _scrollRect$bottom : window.innerHeight;
|
|
1037
|
+
const width = (_scrollRect$width = scrollRect == null ? void 0 : scrollRect.width) != null ? _scrollRect$width : window.innerWidth;
|
|
1038
|
+
const top = Math.max(rect.bottom + _offset, visibleTop);
|
|
1039
|
+
return {
|
|
1040
|
+
top,
|
|
1041
|
+
left: 0,
|
|
1042
|
+
height: Math.max(visibleBottom - top, 0),
|
|
1043
|
+
width
|
|
1044
|
+
};
|
|
1045
|
+
};
|
|
1046
|
+
|
|
1047
|
+
const MOBILE_MASK_Z_INDEX = 1000;
|
|
1048
|
+
const MOBILE_POPUP_Z_INDEX = 1050;
|
|
1049
|
+
|
|
921
1050
|
const _excluded$d = ["value", "onChange", "interceptor", "label", "render"];
|
|
922
1051
|
const isNotEmpty$1 = value => {
|
|
923
1052
|
if (value === null || value === undefined) return false;
|
|
@@ -925,9 +1054,10 @@ const isNotEmpty$1 = value => {
|
|
|
925
1054
|
return !(Array.isArray(value) && value.length === 0);
|
|
926
1055
|
};
|
|
927
1056
|
const MASK_ANIMATION_DURATION$1 = 180;
|
|
928
|
-
const FIELD_MOBILE_POPUP_CLASS = 'react-filter-field-mobile-popup';
|
|
1057
|
+
const FIELD_MOBILE_POPUP_CLASS$1 = 'react-filter-field-mobile-popup';
|
|
929
1058
|
const MOBILE_POPUP_OFFSET$1 = 4;
|
|
930
1059
|
const withFieldItem = (WrappedComponent, options = {}) => _ref => {
|
|
1060
|
+
var _popupMetrics$left;
|
|
931
1061
|
let {
|
|
932
1062
|
value,
|
|
933
1063
|
onChange,
|
|
@@ -937,7 +1067,11 @@ const withFieldItem = (WrappedComponent, options = {}) => _ref => {
|
|
|
937
1067
|
} = _ref,
|
|
938
1068
|
props = _objectWithoutPropertiesLoose(_ref, _excluded$d);
|
|
939
1069
|
const [open, setOpen] = useState(false);
|
|
940
|
-
const
|
|
1070
|
+
const {
|
|
1071
|
+
isMobile,
|
|
1072
|
+
useBoundaryMount
|
|
1073
|
+
} = useMobileFixedMode();
|
|
1074
|
+
const fixedModeClass = useBoundaryMount ? style$1['is-boundary'] : style$1['is-viewport'];
|
|
941
1075
|
const [renderMask, setRenderMask] = useState(false);
|
|
942
1076
|
const [maskClosing, setMaskClosing] = useState(false);
|
|
943
1077
|
const [popupMetrics, setPopupMetrics] = useState({
|
|
@@ -946,6 +1080,24 @@ const withFieldItem = (WrappedComponent, options = {}) => _ref => {
|
|
|
946
1080
|
height: 0
|
|
947
1081
|
});
|
|
948
1082
|
const triggerRef = useRef(null);
|
|
1083
|
+
const getBoundaryElement = usePopupContainer();
|
|
1084
|
+
const getScrollElement = useScrollElement();
|
|
1085
|
+
const resolveGetPopupContainer = useCallback(triggerNode => {
|
|
1086
|
+
if (typeof props.getPopupContainer === 'function') {
|
|
1087
|
+
const customContainer = props.getPopupContainer(triggerNode);
|
|
1088
|
+
if (customContainer) {
|
|
1089
|
+
return customContainer;
|
|
1090
|
+
}
|
|
1091
|
+
}
|
|
1092
|
+
if (!isMobile) {
|
|
1093
|
+
return getBoundaryElement();
|
|
1094
|
+
}
|
|
1095
|
+
if (useBoundaryMount) {
|
|
1096
|
+
return getBoundaryElement();
|
|
1097
|
+
}
|
|
1098
|
+
return typeof document !== 'undefined' ? document.body : null;
|
|
1099
|
+
}, [getBoundaryElement, isMobile, props.getPopupContainer, useBoundaryMount]);
|
|
1100
|
+
const popupMountNode = typeof document !== 'undefined' ? isMobile ? useBoundaryMount ? getBoundaryElement() || document.body : document.body : getBoundaryElement() || document.body : null;
|
|
949
1101
|
const setMobilePopupVariables = useCallback(metrics => {
|
|
950
1102
|
if (typeof document === 'undefined') return;
|
|
951
1103
|
document.body.style.setProperty('--react-filter-field-mobile-height', `${metrics.height}px`);
|
|
@@ -954,37 +1106,16 @@ const withFieldItem = (WrappedComponent, options = {}) => _ref => {
|
|
|
954
1106
|
}, []);
|
|
955
1107
|
const updatePopupMetrics = useCallback(() => {
|
|
956
1108
|
if (typeof window === 'undefined' || !triggerRef.current) return;
|
|
957
|
-
const
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
};
|
|
1109
|
+
const metrics = getMobilePopupMetrics(triggerRef.current, {
|
|
1110
|
+
scrollEl: getScrollElement(),
|
|
1111
|
+
boundaryEl: getBoundaryElement(),
|
|
1112
|
+
useBoundaryMount,
|
|
1113
|
+
offset: MOBILE_POPUP_OFFSET$1
|
|
1114
|
+
});
|
|
963
1115
|
setPopupMetrics(metrics);
|
|
964
1116
|
setMobilePopupVariables(metrics);
|
|
965
|
-
}, [setMobilePopupVariables]);
|
|
966
|
-
|
|
967
|
-
if (typeof window === 'undefined') return;
|
|
968
|
-
const mediaQuery = window.matchMedia('(max-width: 768px)');
|
|
969
|
-
const updateIsMobile = () => {
|
|
970
|
-
setIsMobile(mediaQuery.matches);
|
|
971
|
-
};
|
|
972
|
-
updateIsMobile();
|
|
973
|
-
mediaQuery.addEventListener ? mediaQuery.addEventListener('change', updateIsMobile) : mediaQuery.addListener(updateIsMobile);
|
|
974
|
-
return () => {
|
|
975
|
-
mediaQuery.removeEventListener ? mediaQuery.removeEventListener('change', updateIsMobile) : mediaQuery.removeListener(updateIsMobile);
|
|
976
|
-
};
|
|
977
|
-
}, []);
|
|
978
|
-
useEffect(() => {
|
|
979
|
-
if (!open || !isMobile) return;
|
|
980
|
-
updatePopupMetrics();
|
|
981
|
-
window.addEventListener('resize', updatePopupMetrics);
|
|
982
|
-
window.addEventListener('scroll', updatePopupMetrics, true);
|
|
983
|
-
return () => {
|
|
984
|
-
window.removeEventListener('resize', updatePopupMetrics);
|
|
985
|
-
window.removeEventListener('scroll', updatePopupMetrics, true);
|
|
986
|
-
};
|
|
987
|
-
}, [isMobile, open, updatePopupMetrics]);
|
|
1117
|
+
}, [getBoundaryElement, getScrollElement, setMobilePopupVariables, useBoundaryMount]);
|
|
1118
|
+
useResponsiveScrollListener(updatePopupMetrics, open && isMobile);
|
|
988
1119
|
useEffect(() => {
|
|
989
1120
|
if (typeof document === 'undefined' || !isMobile || popupMetrics.height <= 0) return;
|
|
990
1121
|
setMobilePopupVariables(popupMetrics);
|
|
@@ -1028,14 +1159,15 @@ const withFieldItem = (WrappedComponent, options = {}) => _ref => {
|
|
|
1028
1159
|
'--react-filter-popover-mobile-height': `${popupMetrics.height}px`,
|
|
1029
1160
|
'--react-filter-field-mobile-top': `${popupMetrics.top}px`,
|
|
1030
1161
|
top: popupMetrics.top,
|
|
1031
|
-
left: 0
|
|
1162
|
+
left: (_popupMetrics$left = popupMetrics.left) != null ? _popupMetrics$left : 0,
|
|
1163
|
+
zIndex: MOBILE_POPUP_Z_INDEX
|
|
1032
1164
|
} : undefined;
|
|
1033
1165
|
const mergePopupClassNames = classNames => {
|
|
1034
1166
|
var _classNames$popup;
|
|
1035
1167
|
if (!isMobile) return classNames;
|
|
1036
1168
|
return Object.assign({}, classNames, {
|
|
1037
1169
|
popup: Object.assign({}, classNames == null ? void 0 : classNames.popup, {
|
|
1038
|
-
root: classnames(classNames == null || (_classNames$popup = classNames.popup) == null ? void 0 : _classNames$popup.root, style$1['field-item-mobile-popup'], FIELD_MOBILE_POPUP_CLASS)
|
|
1170
|
+
root: classnames(classNames == null || (_classNames$popup = classNames.popup) == null ? void 0 : _classNames$popup.root, style$1['field-item-mobile-popup'], FIELD_MOBILE_POPUP_CLASS$1, fixedModeClass)
|
|
1039
1171
|
})
|
|
1040
1172
|
});
|
|
1041
1173
|
};
|
|
@@ -1060,9 +1192,10 @@ const withFieldItem = (WrappedComponent, options = {}) => _ref => {
|
|
|
1060
1192
|
valueType: "all",
|
|
1061
1193
|
onOpenChange: handleOpenChange,
|
|
1062
1194
|
onDropdownVisibleChange: handleOpenChange,
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1195
|
+
getPopupContainer: resolveGetPopupContainer,
|
|
1196
|
+
popupClassName: classnames(props.popupClassName, isMobile && style$1['field-item-mobile-popup'], isMobile && FIELD_MOBILE_POPUP_CLASS$1, isMobile && fixedModeClass),
|
|
1197
|
+
dropdownClassName: classnames(props.dropdownClassName, isMobile && style$1['field-item-mobile-popup'], isMobile && FIELD_MOBILE_POPUP_CLASS$1, isMobile && fixedModeClass),
|
|
1198
|
+
overlayClassName: classnames(props.overlayClassName, isMobile && style$1['field-item-mobile-popup'], isMobile && FIELD_MOBILE_POPUP_CLASS$1, isMobile && fixedModeClass),
|
|
1066
1199
|
overlayStyle: Object.assign({}, props.overlayStyle, mobilePopupStyle),
|
|
1067
1200
|
popupStyle: Object.assign({}, props.popupStyle, mobilePopupStyle),
|
|
1068
1201
|
dropdownStyle: Object.assign({}, props.dropdownStyle, mobilePopupStyle),
|
|
@@ -1074,21 +1207,27 @@ const withFieldItem = (WrappedComponent, options = {}) => _ref => {
|
|
|
1074
1207
|
offset: [0, 0]
|
|
1075
1208
|
} : props.align,
|
|
1076
1209
|
isPopup: options.forcePopup ? true : props.isPopup,
|
|
1077
|
-
|
|
1210
|
+
zIndex: isMobile ? MOBILE_POPUP_Z_INDEX : props.zIndex,
|
|
1211
|
+
overlayWidth: isMobile && options.forcePopup ? typeof window === 'undefined' ? props.overlayWidth : getMobilePopupMetrics(triggerRef.current, {
|
|
1212
|
+
scrollEl: getScrollElement(),
|
|
1213
|
+
boundaryEl: getBoundaryElement(),
|
|
1214
|
+
useBoundaryMount
|
|
1215
|
+
}).width || window.innerWidth : props.overlayWidth
|
|
1078
1216
|
}));
|
|
1079
1217
|
};
|
|
1080
1218
|
return /*#__PURE__*/jsxs(Fragment, {
|
|
1081
|
-
children: [renderMask &&
|
|
1082
|
-
className: classnames(style$1['pop-util-mask'], maskClosing && style$1['pop-util-mask-leave']),
|
|
1219
|
+
children: [renderMask && popupMountNode && /*#__PURE__*/createPortal(/*#__PURE__*/jsx("div", {
|
|
1220
|
+
className: classnames(style$1['pop-util-mask'], maskClosing && style$1['pop-util-mask-leave'], fixedModeClass),
|
|
1083
1221
|
style: {
|
|
1084
1222
|
top: popupMetrics.top,
|
|
1085
|
-
height: popupMetrics.height
|
|
1223
|
+
height: popupMetrics.height,
|
|
1224
|
+
zIndex: MOBILE_MASK_Z_INDEX
|
|
1086
1225
|
},
|
|
1087
1226
|
onClick: closeFieldItem,
|
|
1088
1227
|
onTouchMove: e => {
|
|
1089
1228
|
e.preventDefault();
|
|
1090
1229
|
}
|
|
1091
|
-
}),
|
|
1230
|
+
}), popupMountNode), /*#__PURE__*/jsx("span", {
|
|
1092
1231
|
ref: triggerRef,
|
|
1093
1232
|
children: /*#__PURE__*/jsx(FilterItem, {
|
|
1094
1233
|
label: label,
|
|
@@ -1118,11 +1257,35 @@ const PopoverItem = withLocale(({
|
|
|
1118
1257
|
placement: _placement = 'bottomLeft',
|
|
1119
1258
|
onOpenChange,
|
|
1120
1259
|
onChange,
|
|
1260
|
+
getPopupContainer: customGetPopupContainer,
|
|
1121
1261
|
children
|
|
1122
1262
|
}) => {
|
|
1263
|
+
var _popupMetrics$left;
|
|
1123
1264
|
const [state, setState] = useState(value);
|
|
1124
1265
|
const [open, setOpen] = useState(false);
|
|
1125
|
-
const
|
|
1266
|
+
const {
|
|
1267
|
+
isMobile,
|
|
1268
|
+
useBoundaryMount
|
|
1269
|
+
} = useMobileFixedMode();
|
|
1270
|
+
const fixedModeClass = useBoundaryMount ? style$1['is-boundary'] : style$1['is-viewport'];
|
|
1271
|
+
const getBoundaryElement = usePopupContainer();
|
|
1272
|
+
const getScrollElement = useScrollElement();
|
|
1273
|
+
const resolveGetPopupContainer = useCallback(triggerNode => {
|
|
1274
|
+
if (typeof customGetPopupContainer === 'function') {
|
|
1275
|
+
const customContainer = customGetPopupContainer(triggerNode);
|
|
1276
|
+
if (customContainer) {
|
|
1277
|
+
return customContainer;
|
|
1278
|
+
}
|
|
1279
|
+
}
|
|
1280
|
+
if (!isMobile) {
|
|
1281
|
+
return getBoundaryElement();
|
|
1282
|
+
}
|
|
1283
|
+
if (useBoundaryMount) {
|
|
1284
|
+
return getBoundaryElement();
|
|
1285
|
+
}
|
|
1286
|
+
return typeof document !== 'undefined' ? document.body : null;
|
|
1287
|
+
}, [customGetPopupContainer, getBoundaryElement, isMobile, useBoundaryMount]);
|
|
1288
|
+
const popupMountNode = typeof document !== 'undefined' ? isMobile ? useBoundaryMount ? getBoundaryElement() || document.body : document.body : getBoundaryElement() || document.body : null;
|
|
1126
1289
|
const [renderMask, setRenderMask] = useState(false);
|
|
1127
1290
|
const [maskClosing, setMaskClosing] = useState(false);
|
|
1128
1291
|
const [popupMetrics, setPopupMetrics] = useState({
|
|
@@ -1139,37 +1302,17 @@ const PopoverItem = withLocale(({
|
|
|
1139
1302
|
} = useIntl({
|
|
1140
1303
|
moduleName: 'Filter'
|
|
1141
1304
|
});
|
|
1142
|
-
useEffect(() => {
|
|
1143
|
-
if (typeof window === 'undefined') return;
|
|
1144
|
-
const mediaQuery = window.matchMedia('(max-width: 768px)');
|
|
1145
|
-
const updateIsMobile = () => {
|
|
1146
|
-
setIsMobile(mediaQuery.matches);
|
|
1147
|
-
};
|
|
1148
|
-
updateIsMobile();
|
|
1149
|
-
mediaQuery.addEventListener ? mediaQuery.addEventListener('change', updateIsMobile) : mediaQuery.addListener(updateIsMobile);
|
|
1150
|
-
return () => {
|
|
1151
|
-
mediaQuery.removeEventListener ? mediaQuery.removeEventListener('change', updateIsMobile) : mediaQuery.removeListener(updateIsMobile);
|
|
1152
|
-
};
|
|
1153
|
-
}, []);
|
|
1154
1305
|
const updatePopupMetrics = useCallback(() => {
|
|
1155
1306
|
if (typeof window === 'undefined' || !triggerRef.current) return;
|
|
1156
|
-
const
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1307
|
+
const metrics = getMobilePopupMetrics(triggerRef.current, {
|
|
1308
|
+
scrollEl: getScrollElement(),
|
|
1309
|
+
boundaryEl: getBoundaryElement(),
|
|
1310
|
+
useBoundaryMount,
|
|
1311
|
+
offset: MOBILE_POPUP_OFFSET
|
|
1161
1312
|
});
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
updatePopupMetrics();
|
|
1166
|
-
window.addEventListener('resize', updatePopupMetrics);
|
|
1167
|
-
window.addEventListener('scroll', updatePopupMetrics, true);
|
|
1168
|
-
return () => {
|
|
1169
|
-
window.removeEventListener('resize', updatePopupMetrics);
|
|
1170
|
-
window.removeEventListener('scroll', updatePopupMetrics, true);
|
|
1171
|
-
};
|
|
1172
|
-
}, [isMobile, open, updatePopupMetrics]);
|
|
1313
|
+
setPopupMetrics(metrics);
|
|
1314
|
+
}, [getBoundaryElement, getScrollElement, useBoundaryMount]);
|
|
1315
|
+
useResponsiveScrollListener(updatePopupMetrics, open && isMobile);
|
|
1173
1316
|
useEffect(() => {
|
|
1174
1317
|
if (open && isMobile) {
|
|
1175
1318
|
setRenderMask(true);
|
|
@@ -1201,7 +1344,8 @@ const PopoverItem = withLocale(({
|
|
|
1201
1344
|
const mobileOverlayStyle = isMobile ? {
|
|
1202
1345
|
'--react-filter-popover-mobile-height': `${popupMetrics.height}px`,
|
|
1203
1346
|
top: popupMetrics.top,
|
|
1204
|
-
left: 0
|
|
1347
|
+
left: (_popupMetrics$left = popupMetrics.left) != null ? _popupMetrics$left : 0,
|
|
1348
|
+
zIndex: MOBILE_POPUP_Z_INDEX
|
|
1205
1349
|
} : undefined;
|
|
1206
1350
|
const overlayContent = /*#__PURE__*/jsxs("div", {
|
|
1207
1351
|
className: style$1['pop-util-body'],
|
|
@@ -1243,17 +1387,18 @@ const PopoverItem = withLocale(({
|
|
|
1243
1387
|
})]
|
|
1244
1388
|
});
|
|
1245
1389
|
return /*#__PURE__*/jsxs(Fragment, {
|
|
1246
|
-
children: [renderMask &&
|
|
1247
|
-
className: classnames(style$1['pop-util-mask'], maskClosing && style$1['pop-util-mask-leave']),
|
|
1390
|
+
children: [renderMask && popupMountNode && /*#__PURE__*/createPortal(/*#__PURE__*/jsx("div", {
|
|
1391
|
+
className: classnames(style$1['pop-util-mask'], maskClosing && style$1['pop-util-mask-leave'], fixedModeClass),
|
|
1248
1392
|
style: {
|
|
1249
1393
|
top: popupMetrics.top,
|
|
1250
|
-
height: popupMetrics.height
|
|
1394
|
+
height: popupMetrics.height,
|
|
1395
|
+
zIndex: MOBILE_MASK_Z_INDEX
|
|
1251
1396
|
},
|
|
1252
1397
|
onClick: closeDropdown,
|
|
1253
1398
|
onTouchMove: e => {
|
|
1254
1399
|
e.preventDefault();
|
|
1255
1400
|
}
|
|
1256
|
-
}),
|
|
1401
|
+
}), popupMountNode), /*#__PURE__*/jsx(Dropdown, {
|
|
1257
1402
|
open: open,
|
|
1258
1403
|
trigger: ['click'],
|
|
1259
1404
|
placement: isMobile ? 'bottomLeft' : _placement,
|
|
@@ -1261,7 +1406,9 @@ const PopoverItem = withLocale(({
|
|
|
1261
1406
|
align: isMobile ? {
|
|
1262
1407
|
offset: [0, 0]
|
|
1263
1408
|
} : undefined,
|
|
1264
|
-
|
|
1409
|
+
getPopupContainer: resolveGetPopupContainer,
|
|
1410
|
+
zIndex: isMobile ? MOBILE_POPUP_Z_INDEX : undefined,
|
|
1411
|
+
overlayClassName: classnames(style$1['pop-util-overlay'], overlayClassName, isMobile && fixedModeClass),
|
|
1265
1412
|
overlayStyle: mobileOverlayStyle,
|
|
1266
1413
|
onOpenChange: handleOpenChange,
|
|
1267
1414
|
menu: {
|
|
@@ -1495,7 +1642,9 @@ const DateRangePickerFilterItem = withLocale(withFieldItem(_ref => {
|
|
|
1495
1642
|
var style = {"shortcuts-container":"kne-react-filter_3w4Bb","shortcut-item":"kne-react-filter_myRhG","is-active":"kne-react-filter_FowoG"};
|
|
1496
1643
|
|
|
1497
1644
|
const _excluded$8 = ["value", "onChange", "defaultValue", "shortcuts", "shortcutOptions"];
|
|
1645
|
+
const FIELD_MOBILE_POPUP_CLASS = 'react-filter-field-mobile-popup';
|
|
1498
1646
|
const TypeDateRangePickerField = _ref => {
|
|
1647
|
+
var _props$classNames, _props$classNames2, _props$styles, _props$styles2;
|
|
1499
1648
|
let {
|
|
1500
1649
|
value: valueProp,
|
|
1501
1650
|
onChange: onChangeProp,
|
|
@@ -1509,6 +1658,16 @@ const TypeDateRangePickerField = _ref => {
|
|
|
1509
1658
|
} = useIntl({
|
|
1510
1659
|
moduleName: 'Filter'
|
|
1511
1660
|
});
|
|
1661
|
+
const getPopupContainer = usePopupContainer();
|
|
1662
|
+
const {
|
|
1663
|
+
isMobile,
|
|
1664
|
+
useBoundaryMount
|
|
1665
|
+
} = useMobileFixedMode();
|
|
1666
|
+
const fixedModeClass = useBoundaryMount ? style['is-boundary'] : style['is-viewport'];
|
|
1667
|
+
const nestedPopupClassName = classnames(style['field-item-mobile-popup'], FIELD_MOBILE_POPUP_CLASS, fixedModeClass);
|
|
1668
|
+
const nestedPopupStyle = isMobile ? {
|
|
1669
|
+
zIndex: MOBILE_POPUP_Z_INDEX
|
|
1670
|
+
} : undefined;
|
|
1512
1671
|
const typeList = new Map([['date', formatMessage({
|
|
1513
1672
|
id: 'customTime'
|
|
1514
1673
|
})], ['month', formatMessage({
|
|
@@ -1598,6 +1757,19 @@ const TypeDateRangePickerField = _ref => {
|
|
|
1598
1757
|
style: {
|
|
1599
1758
|
width: '120px'
|
|
1600
1759
|
},
|
|
1760
|
+
getPopupContainer: getPopupContainer,
|
|
1761
|
+
popupClassName: isMobile ? nestedPopupClassName : undefined,
|
|
1762
|
+
classNames: isMobile ? {
|
|
1763
|
+
popup: {
|
|
1764
|
+
root: nestedPopupClassName
|
|
1765
|
+
}
|
|
1766
|
+
} : undefined,
|
|
1767
|
+
popupStyle: nestedPopupStyle,
|
|
1768
|
+
styles: isMobile ? {
|
|
1769
|
+
popup: {
|
|
1770
|
+
root: nestedPopupStyle
|
|
1771
|
+
}
|
|
1772
|
+
} : undefined,
|
|
1601
1773
|
value: (value == null ? void 0 : value.type) || 'date',
|
|
1602
1774
|
onChange: typeValue => {
|
|
1603
1775
|
onChange(currentValue => {
|
|
@@ -1621,6 +1793,18 @@ const TypeDateRangePickerField = _ref => {
|
|
|
1621
1793
|
value: val
|
|
1622
1794
|
}))
|
|
1623
1795
|
}), /*#__PURE__*/jsx(DatePicker.RangePicker, _extends({}, props, {
|
|
1796
|
+
getPopupContainer: getPopupContainer,
|
|
1797
|
+
classNames: isMobile ? _extends({}, props.classNames, {
|
|
1798
|
+
popup: _extends({}, (_props$classNames = props.classNames) == null ? void 0 : _props$classNames.popup, {
|
|
1799
|
+
root: classnames((_props$classNames2 = props.classNames) == null || (_props$classNames2 = _props$classNames2.popup) == null ? void 0 : _props$classNames2.root, nestedPopupClassName)
|
|
1800
|
+
})
|
|
1801
|
+
}) : props.classNames,
|
|
1802
|
+
styles: isMobile ? _extends({}, props.styles, {
|
|
1803
|
+
popup: _extends({}, (_props$styles = props.styles) == null ? void 0 : _props$styles.popup, {
|
|
1804
|
+
root: Object.assign({}, (_props$styles2 = props.styles) == null || (_props$styles2 = _props$styles2.popup) == null ? void 0 : _props$styles2.root, nestedPopupStyle)
|
|
1805
|
+
})
|
|
1806
|
+
}) : props.styles,
|
|
1807
|
+
popupStyle: nestedPopupStyle,
|
|
1624
1808
|
picker: (value == null ? void 0 : value.type) || 'date',
|
|
1625
1809
|
value: Array.isArray(value == null ? void 0 : value.value) && value.value.length === 2 ? value.value.map(item => item && dayjs(item)) : null,
|
|
1626
1810
|
onChange: dateValue => {
|
|
@@ -2577,6 +2761,7 @@ const CityFilterItemInner = _ref => {
|
|
|
2577
2761
|
const {
|
|
2578
2762
|
message
|
|
2579
2763
|
} = App.useApp();
|
|
2764
|
+
const getPopupContainer = usePopupContainer();
|
|
2580
2765
|
const {
|
|
2581
2766
|
locale
|
|
2582
2767
|
} = useIntl();
|
|
@@ -2649,6 +2834,7 @@ const CityFilterItemInner = _ref => {
|
|
|
2649
2834
|
children: [formatMessage({
|
|
2650
2835
|
id: 'otherText'
|
|
2651
2836
|
}), /*#__PURE__*/jsx(SelectAddress, _extends({}, props, {
|
|
2837
|
+
getPopupContainer: getPopupContainer,
|
|
2652
2838
|
className: style$1['filter-advanced-item-other-inner'],
|
|
2653
2839
|
maxLength: maxLength,
|
|
2654
2840
|
allowClear: false,
|