@kne/react-filter 1.0.7 → 1.0.9
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 +506 -323
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +287 -101
- 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,19 +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;
|
|
135
176
|
const safeItems = Array.isArray(items) ? items : [];
|
|
136
177
|
const containerRef = react.useRef(null);
|
|
137
178
|
const measureRef = react.useRef(null);
|
|
138
179
|
const moreMeasureRef = react.useRef(null);
|
|
139
180
|
const rafRef = react.useRef(null);
|
|
140
181
|
const lastWidthRef = react.useRef(0);
|
|
141
|
-
const
|
|
142
|
-
|
|
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];
|
|
143
188
|
const setContainerRef = react.useCallback(node => {
|
|
144
189
|
containerRef.current = node;
|
|
145
190
|
setContainerEl(node || null);
|
|
@@ -151,6 +196,7 @@ const useVisibleItemCount = ({
|
|
|
151
196
|
moreMeasureRef.current = node;
|
|
152
197
|
}, []);
|
|
153
198
|
const getWidths = react.useCallback(() => {
|
|
199
|
+
var _moreMeasureRef$curre;
|
|
154
200
|
const container = containerRef.current;
|
|
155
201
|
const measureEl = measureRef.current;
|
|
156
202
|
if (!container || !measureEl) {
|
|
@@ -164,7 +210,7 @@ const useVisibleItemCount = ({
|
|
|
164
210
|
if (!itemNodes.length) {
|
|
165
211
|
return null;
|
|
166
212
|
}
|
|
167
|
-
const moreButtonWidth = moreMeasureRef.current
|
|
213
|
+
const moreButtonWidth = ((_moreMeasureRef$curre = moreMeasureRef.current) == null ? void 0 : _moreMeasureRef$curre.getBoundingClientRect().width) || 0;
|
|
168
214
|
if (safeItems.length > 1 && moreButtonWidth <= 0) {
|
|
169
215
|
return null;
|
|
170
216
|
}
|
|
@@ -186,11 +232,9 @@ const useVisibleItemCount = ({
|
|
|
186
232
|
return usedWidth;
|
|
187
233
|
}, [safeItems.length]);
|
|
188
234
|
const resolveVisibleCount = react.useCallback(widths => {
|
|
189
|
-
const
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
moreButtonWidth
|
|
193
|
-
} = widths;
|
|
235
|
+
const containerWidth = widths.containerWidth,
|
|
236
|
+
itemWidths = widths.itemWidths,
|
|
237
|
+
moreButtonWidth = widths.moreButtonWidth;
|
|
194
238
|
const maxCount = Math.min(safeItems.length, itemWidths.length);
|
|
195
239
|
let count = 1;
|
|
196
240
|
if (strategy === 'desc') {
|
|
@@ -250,8 +294,9 @@ const useVisibleItemCount = ({
|
|
|
250
294
|
return undefined;
|
|
251
295
|
}
|
|
252
296
|
const observer = new ResizeObserver(entries => {
|
|
297
|
+
var _entry$contentRect$wi;
|
|
253
298
|
const entry = entries.find(item => item.target === containerEl);
|
|
254
|
-
const nextWidth = entry
|
|
299
|
+
const nextWidth = (_entry$contentRect$wi = entry == null ? void 0 : entry.contentRect.width) != null ? _entry$contentRect$wi : containerEl.clientWidth;
|
|
255
300
|
if (Math.abs(nextWidth - lastWidthRef.current) < 1) {
|
|
256
301
|
return;
|
|
257
302
|
}
|
|
@@ -260,16 +305,15 @@ const useVisibleItemCount = ({
|
|
|
260
305
|
});
|
|
261
306
|
lastWidthRef.current = containerEl.clientWidth;
|
|
262
307
|
observer.observe(containerEl);
|
|
263
|
-
window.addEventListener('resize', scheduleCalculate);
|
|
264
308
|
return () => {
|
|
265
309
|
observer.disconnect();
|
|
266
|
-
window.removeEventListener('resize', scheduleCalculate);
|
|
267
310
|
if (rafRef.current) {
|
|
268
311
|
window.cancelAnimationFrame(rafRef.current);
|
|
269
312
|
rafRef.current = null;
|
|
270
313
|
}
|
|
271
314
|
};
|
|
272
315
|
}, [containerEl, enabled, scheduleCalculate]);
|
|
316
|
+
useResponsiveScrollListener(scheduleCalculate, enabled && !!containerEl);
|
|
273
317
|
return {
|
|
274
318
|
setContainerRef,
|
|
275
319
|
setMeasureRef,
|
|
@@ -310,11 +354,10 @@ const normalizeFilterList = list => {
|
|
|
310
354
|
};
|
|
311
355
|
};
|
|
312
356
|
const getMobileFilterList = list => {
|
|
313
|
-
const
|
|
314
|
-
mode,
|
|
315
|
-
items,
|
|
316
|
-
lines
|
|
317
|
-
} = normalizeFilterList(list);
|
|
357
|
+
const _normalizeFilterList = normalizeFilterList(list),
|
|
358
|
+
mode = _normalizeFilterList.mode,
|
|
359
|
+
items = _normalizeFilterList.items,
|
|
360
|
+
lines = _normalizeFilterList.lines;
|
|
318
361
|
if (mode === 'flat') return items;
|
|
319
362
|
return lines.reduce((result, line) => result.concat(line), []);
|
|
320
363
|
};
|
|
@@ -413,7 +456,7 @@ const FilterLines = _ref3 => {
|
|
|
413
456
|
const _useState = react.useState(false),
|
|
414
457
|
isExpand = _useState[0],
|
|
415
458
|
setIsExpand = _useState[1];
|
|
416
|
-
const isMobile =
|
|
459
|
+
const isMobile = useFilterIsMobile();
|
|
417
460
|
const _useHorizontalScrollS = useHorizontalScrollShadows({
|
|
418
461
|
enabled: isMobile,
|
|
419
462
|
refreshKey: list
|
|
@@ -687,7 +730,10 @@ const withLocale = reactIntl.createWithIntlProvider({
|
|
|
687
730
|
const FilterValueDisplay = withLocale(_ref => {
|
|
688
731
|
let filterValue = _ref.value,
|
|
689
732
|
extraExpand = _ref.extraExpand,
|
|
690
|
-
onChange = _ref.onChange
|
|
733
|
+
onChange = _ref.onChange,
|
|
734
|
+
className = _ref.className,
|
|
735
|
+
hideLabel = _ref.hideLabel,
|
|
736
|
+
flush = _ref.flush;
|
|
691
737
|
const _useIntl = reactIntl.useIntl({
|
|
692
738
|
moduleName: 'Filter'
|
|
693
739
|
}),
|
|
@@ -695,7 +741,7 @@ const FilterValueDisplay = withLocale(_ref => {
|
|
|
695
741
|
const _useState = react.useState(false),
|
|
696
742
|
isExpand = _useState[0],
|
|
697
743
|
setIsExpand = _useState[1];
|
|
698
|
-
const isMobile =
|
|
744
|
+
const isMobile = useFilterIsMobile();
|
|
699
745
|
const _useHorizontalScrollS = useHorizontalScrollShadows({
|
|
700
746
|
enabled: isMobile,
|
|
701
747
|
suspend: isExpand,
|
|
@@ -729,10 +775,13 @@ const FilterValueDisplay = withLocale(_ref => {
|
|
|
729
775
|
}, name);
|
|
730
776
|
});
|
|
731
777
|
return /*#__PURE__*/jsxRuntime.jsxs(antd.Space, {
|
|
732
|
-
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),
|
|
733
782
|
align: "top",
|
|
734
|
-
size: 16,
|
|
735
|
-
children: [/*#__PURE__*/jsxRuntime.jsx("span", {
|
|
783
|
+
size: hideLabel ? 0 : 16,
|
|
784
|
+
children: [hideLabel ? null : /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
736
785
|
className: style$1['filter-label'],
|
|
737
786
|
children: formatMessage({
|
|
738
787
|
id: 'selectedText'
|
|
@@ -847,29 +896,57 @@ const FilterProvider = _ref => {
|
|
|
847
896
|
});
|
|
848
897
|
};
|
|
849
898
|
|
|
850
|
-
const
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
899
|
+
const useFilterViewportVars = () => {
|
|
900
|
+
const boundaryRef = react.useRef(null);
|
|
901
|
+
const _useResponsiveContext = responsiveUtils.useResponsiveContext(),
|
|
902
|
+
mode = _useResponsiveContext.mode;
|
|
903
|
+
react.useEffect(() => {
|
|
904
|
+
const el = boundaryRef.current;
|
|
905
|
+
if (!el || typeof window === 'undefined' || mode === 'container') {
|
|
906
|
+
return undefined;
|
|
907
|
+
}
|
|
908
|
+
const update = () => {
|
|
909
|
+
responsiveUtils.applyViewportCssVars(el, {
|
|
910
|
+
width: window.innerWidth,
|
|
911
|
+
height: window.innerHeight
|
|
912
|
+
});
|
|
913
|
+
};
|
|
914
|
+
update();
|
|
915
|
+
window.addEventListener('resize', update, {
|
|
916
|
+
passive: true
|
|
917
|
+
});
|
|
918
|
+
return () => {
|
|
919
|
+
window.removeEventListener('resize', update);
|
|
920
|
+
responsiveUtils.resetViewportCssVars(el);
|
|
921
|
+
};
|
|
922
|
+
}, [mode]);
|
|
923
|
+
return boundaryRef;
|
|
924
|
+
};
|
|
925
|
+
|
|
926
|
+
const _excluded$d = ["children", "className"];
|
|
927
|
+
const FilterOuter = _ref => {
|
|
928
|
+
let children = _ref.children,
|
|
929
|
+
className = _ref.className,
|
|
930
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$d);
|
|
931
|
+
const isMobile = useFilterIsMobile();
|
|
932
|
+
const boundaryRef = useFilterViewportVars();
|
|
933
|
+
return /*#__PURE__*/jsxRuntime.jsx(FilterProvider, _extends({}, props, {
|
|
857
934
|
children: context => /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
935
|
+
ref: boundaryRef,
|
|
936
|
+
className: classnames__default["default"](style$1['filter'], 'filter', responsiveUtils.RESPONSIVE_BOUNDARY_CLASS, isMobile && style$1['is-mobile'], className),
|
|
937
|
+
children: children(_extends({}, context, {
|
|
861
938
|
props
|
|
862
|
-
})
|
|
939
|
+
}))
|
|
863
940
|
})
|
|
864
|
-
});
|
|
941
|
+
}));
|
|
865
942
|
};
|
|
866
943
|
|
|
867
|
-
const _excluded$
|
|
944
|
+
const _excluded$c = ["defaultValue"],
|
|
868
945
|
_excluded2 = ["extraExpand"];
|
|
869
946
|
const Filter = withLocale(_ref => {
|
|
870
947
|
let _ref$defaultValue = _ref.defaultValue,
|
|
871
948
|
defaultValue = _ref$defaultValue === void 0 ? [] : _ref$defaultValue,
|
|
872
|
-
props = _objectWithoutPropertiesLoose(_ref, _excluded$
|
|
949
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$c);
|
|
873
950
|
return /*#__PURE__*/jsxRuntime.jsx(FilterOuter, _extends({}, props, {
|
|
874
951
|
defaultValue: defaultValue,
|
|
875
952
|
children: _ref2 => {
|
|
@@ -890,6 +967,24 @@ const Filter = withLocale(_ref => {
|
|
|
890
967
|
}));
|
|
891
968
|
});
|
|
892
969
|
|
|
970
|
+
/**
|
|
971
|
+
* 与 system-layout Toolbar 一致:
|
|
972
|
+
* - container 模式(example 手机预览):absolute + boundary 挂载
|
|
973
|
+
* - viewport 模式(真实移动端):fixed + 视口坐标
|
|
974
|
+
*/
|
|
975
|
+
const useMobileFixedMode = () => {
|
|
976
|
+
const isMobile = useFilterIsMobile();
|
|
977
|
+
const _useResponsiveContext = responsiveUtils.useResponsiveContext(),
|
|
978
|
+
mode = _useResponsiveContext.mode;
|
|
979
|
+
const useBoundaryMount = isMobile && mode === 'container';
|
|
980
|
+
const useViewportFixed = isMobile && mode !== 'container';
|
|
981
|
+
return {
|
|
982
|
+
isMobile,
|
|
983
|
+
useBoundaryMount,
|
|
984
|
+
useViewportFixed
|
|
985
|
+
};
|
|
986
|
+
};
|
|
987
|
+
|
|
893
988
|
const FilterItem = withLocale(_ref => {
|
|
894
989
|
let open = _ref.open,
|
|
895
990
|
active = _ref.active,
|
|
@@ -919,46 +1014,109 @@ const FilterItem = withLocale(_ref => {
|
|
|
919
1014
|
});
|
|
920
1015
|
});
|
|
921
1016
|
|
|
922
|
-
const
|
|
1017
|
+
const getMobilePopupMetrics = function (triggerEl, _temp) {
|
|
1018
|
+
var _scrollRect$top, _scrollRect$bottom, _scrollRect$width;
|
|
1019
|
+
let _ref = _temp === void 0 ? {} : _temp,
|
|
1020
|
+
scrollEl = _ref.scrollEl,
|
|
1021
|
+
boundaryEl = _ref.boundaryEl,
|
|
1022
|
+
useBoundaryMount = _ref.useBoundaryMount,
|
|
1023
|
+
_ref$offset = _ref.offset,
|
|
1024
|
+
offset = _ref$offset === void 0 ? 4 : _ref$offset;
|
|
1025
|
+
if (typeof window === 'undefined' || !triggerEl) {
|
|
1026
|
+
return {
|
|
1027
|
+
top: 0,
|
|
1028
|
+
left: 0,
|
|
1029
|
+
height: 0,
|
|
1030
|
+
width: 0
|
|
1031
|
+
};
|
|
1032
|
+
}
|
|
1033
|
+
const rect = triggerEl.getBoundingClientRect();
|
|
1034
|
+
if (useBoundaryMount && boundaryEl) {
|
|
1035
|
+
const boundaryRect = boundaryEl.getBoundingClientRect();
|
|
1036
|
+
const top = Math.max(rect.bottom - boundaryRect.top + offset, 0);
|
|
1037
|
+
return {
|
|
1038
|
+
top,
|
|
1039
|
+
left: 0,
|
|
1040
|
+
height: Math.max(boundaryRect.height - top, 0),
|
|
1041
|
+
width: boundaryRect.width
|
|
1042
|
+
};
|
|
1043
|
+
}
|
|
1044
|
+
const scrollRect = scrollEl == null || scrollEl.getBoundingClientRect == null ? void 0 : scrollEl.getBoundingClientRect();
|
|
1045
|
+
const visibleTop = (_scrollRect$top = scrollRect == null ? void 0 : scrollRect.top) != null ? _scrollRect$top : 0;
|
|
1046
|
+
const visibleBottom = (_scrollRect$bottom = scrollRect == null ? void 0 : scrollRect.bottom) != null ? _scrollRect$bottom : window.innerHeight;
|
|
1047
|
+
const width = (_scrollRect$width = scrollRect == null ? void 0 : scrollRect.width) != null ? _scrollRect$width : window.innerWidth;
|
|
1048
|
+
const top = Math.max(rect.bottom + offset, visibleTop);
|
|
1049
|
+
return {
|
|
1050
|
+
top,
|
|
1051
|
+
left: 0,
|
|
1052
|
+
height: Math.max(visibleBottom - top, 0),
|
|
1053
|
+
width
|
|
1054
|
+
};
|
|
1055
|
+
};
|
|
1056
|
+
|
|
1057
|
+
const MOBILE_MASK_Z_INDEX = 1000;
|
|
1058
|
+
const MOBILE_POPUP_Z_INDEX = 1050;
|
|
1059
|
+
|
|
1060
|
+
const _excluded$b = ["value", "onChange", "interceptor", "label", "render"];
|
|
923
1061
|
const isNotEmpty$1 = value => {
|
|
924
1062
|
if (value === null || value === undefined) return false;
|
|
925
1063
|
if (typeof value === 'string' && value.trim() === '') return false;
|
|
926
1064
|
return !(Array.isArray(value) && value.length === 0);
|
|
927
1065
|
};
|
|
928
1066
|
const MASK_ANIMATION_DURATION$1 = 180;
|
|
929
|
-
const FIELD_MOBILE_POPUP_CLASS = 'react-filter-field-mobile-popup';
|
|
1067
|
+
const FIELD_MOBILE_POPUP_CLASS$1 = 'react-filter-field-mobile-popup';
|
|
930
1068
|
const MOBILE_POPUP_OFFSET$1 = 4;
|
|
931
1069
|
const withFieldItem = function (WrappedComponent, options) {
|
|
932
1070
|
if (options === void 0) {
|
|
933
1071
|
options = {};
|
|
934
1072
|
}
|
|
935
1073
|
return _ref => {
|
|
1074
|
+
var _popupMetrics$left;
|
|
936
1075
|
let value = _ref.value,
|
|
937
1076
|
onChange = _ref.onChange,
|
|
938
1077
|
interceptor = _ref.interceptor,
|
|
939
1078
|
label = _ref.label,
|
|
940
1079
|
render = _ref.render,
|
|
941
|
-
props = _objectWithoutPropertiesLoose(_ref, _excluded$
|
|
1080
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$b);
|
|
942
1081
|
const _useState = react.useState(false),
|
|
943
1082
|
open = _useState[0],
|
|
944
1083
|
setOpen = _useState[1];
|
|
1084
|
+
const _useMobileFixedMode = useMobileFixedMode(),
|
|
1085
|
+
isMobile = _useMobileFixedMode.isMobile,
|
|
1086
|
+
useBoundaryMount = _useMobileFixedMode.useBoundaryMount;
|
|
1087
|
+
const fixedModeClass = useBoundaryMount ? style$1['is-boundary'] : style$1['is-viewport'];
|
|
945
1088
|
const _useState2 = react.useState(false),
|
|
946
|
-
|
|
947
|
-
|
|
1089
|
+
renderMask = _useState2[0],
|
|
1090
|
+
setRenderMask = _useState2[1];
|
|
948
1091
|
const _useState3 = react.useState(false),
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
const _useState4 = react.useState(
|
|
952
|
-
maskClosing = _useState4[0],
|
|
953
|
-
setMaskClosing = _useState4[1];
|
|
954
|
-
const _useState5 = react.useState({
|
|
1092
|
+
maskClosing = _useState3[0],
|
|
1093
|
+
setMaskClosing = _useState3[1];
|
|
1094
|
+
const _useState4 = react.useState({
|
|
955
1095
|
top: 0,
|
|
956
1096
|
pageTop: 0,
|
|
957
1097
|
height: 0
|
|
958
1098
|
}),
|
|
959
|
-
popupMetrics =
|
|
960
|
-
setPopupMetrics =
|
|
1099
|
+
popupMetrics = _useState4[0],
|
|
1100
|
+
setPopupMetrics = _useState4[1];
|
|
961
1101
|
const triggerRef = react.useRef(null);
|
|
1102
|
+
const getBoundaryElement = responsiveUtils.usePopupContainer();
|
|
1103
|
+
const getScrollElement = responsiveUtils.useScrollElement();
|
|
1104
|
+
const resolveGetPopupContainer = react.useCallback(triggerNode => {
|
|
1105
|
+
if (typeof props.getPopupContainer === 'function') {
|
|
1106
|
+
const customContainer = props.getPopupContainer(triggerNode);
|
|
1107
|
+
if (customContainer) {
|
|
1108
|
+
return customContainer;
|
|
1109
|
+
}
|
|
1110
|
+
}
|
|
1111
|
+
if (!isMobile) {
|
|
1112
|
+
return getBoundaryElement();
|
|
1113
|
+
}
|
|
1114
|
+
if (useBoundaryMount) {
|
|
1115
|
+
return getBoundaryElement();
|
|
1116
|
+
}
|
|
1117
|
+
return typeof document !== 'undefined' ? document.body : null;
|
|
1118
|
+
}, [getBoundaryElement, isMobile, props.getPopupContainer, useBoundaryMount]);
|
|
1119
|
+
const popupMountNode = typeof document !== 'undefined' ? isMobile ? useBoundaryMount ? getBoundaryElement() || document.body : document.body : getBoundaryElement() || document.body : null;
|
|
962
1120
|
const setMobilePopupVariables = react.useCallback(metrics => {
|
|
963
1121
|
if (typeof document === 'undefined') return;
|
|
964
1122
|
document.body.style.setProperty('--react-filter-field-mobile-height', metrics.height + "px");
|
|
@@ -967,37 +1125,16 @@ const withFieldItem = function (WrappedComponent, options) {
|
|
|
967
1125
|
}, []);
|
|
968
1126
|
const updatePopupMetrics = react.useCallback(() => {
|
|
969
1127
|
if (typeof window === 'undefined' || !triggerRef.current) return;
|
|
970
|
-
const
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
};
|
|
1128
|
+
const metrics = getMobilePopupMetrics(triggerRef.current, {
|
|
1129
|
+
scrollEl: getScrollElement(),
|
|
1130
|
+
boundaryEl: getBoundaryElement(),
|
|
1131
|
+
useBoundaryMount,
|
|
1132
|
+
offset: MOBILE_POPUP_OFFSET$1
|
|
1133
|
+
});
|
|
976
1134
|
setPopupMetrics(metrics);
|
|
977
1135
|
setMobilePopupVariables(metrics);
|
|
978
|
-
}, [setMobilePopupVariables]);
|
|
979
|
-
|
|
980
|
-
if (typeof window === 'undefined') return;
|
|
981
|
-
const mediaQuery = window.matchMedia('(max-width: 768px)');
|
|
982
|
-
const updateIsMobile = () => {
|
|
983
|
-
setIsMobile(mediaQuery.matches);
|
|
984
|
-
};
|
|
985
|
-
updateIsMobile();
|
|
986
|
-
mediaQuery.addEventListener ? mediaQuery.addEventListener('change', updateIsMobile) : mediaQuery.addListener(updateIsMobile);
|
|
987
|
-
return () => {
|
|
988
|
-
mediaQuery.removeEventListener ? mediaQuery.removeEventListener('change', updateIsMobile) : mediaQuery.removeListener(updateIsMobile);
|
|
989
|
-
};
|
|
990
|
-
}, []);
|
|
991
|
-
react.useEffect(() => {
|
|
992
|
-
if (!open || !isMobile) return;
|
|
993
|
-
updatePopupMetrics();
|
|
994
|
-
window.addEventListener('resize', updatePopupMetrics);
|
|
995
|
-
window.addEventListener('scroll', updatePopupMetrics, true);
|
|
996
|
-
return () => {
|
|
997
|
-
window.removeEventListener('resize', updatePopupMetrics);
|
|
998
|
-
window.removeEventListener('scroll', updatePopupMetrics, true);
|
|
999
|
-
};
|
|
1000
|
-
}, [isMobile, open, updatePopupMetrics]);
|
|
1136
|
+
}, [getBoundaryElement, getScrollElement, setMobilePopupVariables, useBoundaryMount]);
|
|
1137
|
+
useResponsiveScrollListener(updatePopupMetrics, open && isMobile);
|
|
1001
1138
|
react.useEffect(() => {
|
|
1002
1139
|
if (typeof document === 'undefined' || !isMobile || popupMetrics.height <= 0) return;
|
|
1003
1140
|
setMobilePopupVariables(popupMetrics);
|
|
@@ -1041,14 +1178,15 @@ const withFieldItem = function (WrappedComponent, options) {
|
|
|
1041
1178
|
'--react-filter-popover-mobile-height': popupMetrics.height + "px",
|
|
1042
1179
|
'--react-filter-field-mobile-top': popupMetrics.top + "px",
|
|
1043
1180
|
top: popupMetrics.top,
|
|
1044
|
-
left: 0
|
|
1181
|
+
left: (_popupMetrics$left = popupMetrics.left) != null ? _popupMetrics$left : 0,
|
|
1182
|
+
zIndex: MOBILE_POPUP_Z_INDEX
|
|
1045
1183
|
} : undefined;
|
|
1046
1184
|
const mergePopupClassNames = classNames => {
|
|
1047
1185
|
var _classNames$popup;
|
|
1048
1186
|
if (!isMobile) return classNames;
|
|
1049
1187
|
return Object.assign({}, classNames, {
|
|
1050
1188
|
popup: Object.assign({}, classNames == null ? void 0 : classNames.popup, {
|
|
1051
|
-
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)
|
|
1189
|
+
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)
|
|
1052
1190
|
})
|
|
1053
1191
|
});
|
|
1054
1192
|
};
|
|
@@ -1075,9 +1213,10 @@ const withFieldItem = function (WrappedComponent, options) {
|
|
|
1075
1213
|
valueType: "all",
|
|
1076
1214
|
onOpenChange: handleOpenChange,
|
|
1077
1215
|
onDropdownVisibleChange: handleOpenChange,
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1216
|
+
getPopupContainer: resolveGetPopupContainer,
|
|
1217
|
+
popupClassName: classnames__default["default"](props.popupClassName, isMobile && style$1['field-item-mobile-popup'], isMobile && FIELD_MOBILE_POPUP_CLASS$1, isMobile && fixedModeClass),
|
|
1218
|
+
dropdownClassName: classnames__default["default"](props.dropdownClassName, isMobile && style$1['field-item-mobile-popup'], isMobile && FIELD_MOBILE_POPUP_CLASS$1, isMobile && fixedModeClass),
|
|
1219
|
+
overlayClassName: classnames__default["default"](props.overlayClassName, isMobile && style$1['field-item-mobile-popup'], isMobile && FIELD_MOBILE_POPUP_CLASS$1, isMobile && fixedModeClass),
|
|
1081
1220
|
overlayStyle: Object.assign({}, props.overlayStyle, mobilePopupStyle),
|
|
1082
1221
|
popupStyle: Object.assign({}, props.popupStyle, mobilePopupStyle),
|
|
1083
1222
|
dropdownStyle: Object.assign({}, props.dropdownStyle, mobilePopupStyle),
|
|
@@ -1089,21 +1228,27 @@ const withFieldItem = function (WrappedComponent, options) {
|
|
|
1089
1228
|
offset: [0, 0]
|
|
1090
1229
|
} : props.align,
|
|
1091
1230
|
isPopup: options.forcePopup ? true : props.isPopup,
|
|
1092
|
-
|
|
1231
|
+
zIndex: isMobile ? MOBILE_POPUP_Z_INDEX : props.zIndex,
|
|
1232
|
+
overlayWidth: isMobile && options.forcePopup ? typeof window === 'undefined' ? props.overlayWidth : getMobilePopupMetrics(triggerRef.current, {
|
|
1233
|
+
scrollEl: getScrollElement(),
|
|
1234
|
+
boundaryEl: getBoundaryElement(),
|
|
1235
|
+
useBoundaryMount
|
|
1236
|
+
}).width || window.innerWidth : props.overlayWidth
|
|
1093
1237
|
}));
|
|
1094
1238
|
};
|
|
1095
1239
|
return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
1096
|
-
children: [renderMask &&
|
|
1097
|
-
className: classnames__default["default"](style$1['pop-util-mask'], maskClosing && style$1['pop-util-mask-leave']),
|
|
1240
|
+
children: [renderMask && popupMountNode && /*#__PURE__*/reactDom.createPortal(/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
1241
|
+
className: classnames__default["default"](style$1['pop-util-mask'], maskClosing && style$1['pop-util-mask-leave'], fixedModeClass),
|
|
1098
1242
|
style: {
|
|
1099
1243
|
top: popupMetrics.top,
|
|
1100
|
-
height: popupMetrics.height
|
|
1244
|
+
height: popupMetrics.height,
|
|
1245
|
+
zIndex: MOBILE_MASK_Z_INDEX
|
|
1101
1246
|
},
|
|
1102
1247
|
onClick: closeFieldItem,
|
|
1103
1248
|
onTouchMove: e => {
|
|
1104
1249
|
e.preventDefault();
|
|
1105
1250
|
}
|
|
1106
|
-
}),
|
|
1251
|
+
}), popupMountNode), /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
1107
1252
|
ref: triggerRef,
|
|
1108
1253
|
children: /*#__PURE__*/jsxRuntime.jsx(FilterItem, {
|
|
1109
1254
|
label: label,
|
|
@@ -1127,6 +1272,7 @@ const isNotEmpty = value => {
|
|
|
1127
1272
|
const MASK_ANIMATION_DURATION = 180;
|
|
1128
1273
|
const MOBILE_POPUP_OFFSET = 4;
|
|
1129
1274
|
const PopoverItem = withLocale(_ref => {
|
|
1275
|
+
var _popupMetrics$left;
|
|
1130
1276
|
let value = _ref.value,
|
|
1131
1277
|
label = _ref.label,
|
|
1132
1278
|
onValidate = _ref.onValidate,
|
|
@@ -1135,6 +1281,7 @@ const PopoverItem = withLocale(_ref => {
|
|
|
1135
1281
|
placement = _ref$placement === void 0 ? 'bottomLeft' : _ref$placement,
|
|
1136
1282
|
onOpenChange = _ref.onOpenChange,
|
|
1137
1283
|
onChange = _ref.onChange,
|
|
1284
|
+
customGetPopupContainer = _ref.getPopupContainer,
|
|
1138
1285
|
children = _ref.children;
|
|
1139
1286
|
const _useState = react.useState(value),
|
|
1140
1287
|
state = _useState[0],
|
|
@@ -1142,22 +1289,41 @@ const PopoverItem = withLocale(_ref => {
|
|
|
1142
1289
|
const _useState2 = react.useState(false),
|
|
1143
1290
|
open = _useState2[0],
|
|
1144
1291
|
setOpen = _useState2[1];
|
|
1292
|
+
const _useMobileFixedMode = useMobileFixedMode(),
|
|
1293
|
+
isMobile = _useMobileFixedMode.isMobile,
|
|
1294
|
+
useBoundaryMount = _useMobileFixedMode.useBoundaryMount;
|
|
1295
|
+
const fixedModeClass = useBoundaryMount ? style$1['is-boundary'] : style$1['is-viewport'];
|
|
1296
|
+
const getBoundaryElement = responsiveUtils.usePopupContainer();
|
|
1297
|
+
const getScrollElement = responsiveUtils.useScrollElement();
|
|
1298
|
+
const resolveGetPopupContainer = react.useCallback(triggerNode => {
|
|
1299
|
+
if (typeof customGetPopupContainer === 'function') {
|
|
1300
|
+
const customContainer = customGetPopupContainer(triggerNode);
|
|
1301
|
+
if (customContainer) {
|
|
1302
|
+
return customContainer;
|
|
1303
|
+
}
|
|
1304
|
+
}
|
|
1305
|
+
if (!isMobile) {
|
|
1306
|
+
return getBoundaryElement();
|
|
1307
|
+
}
|
|
1308
|
+
if (useBoundaryMount) {
|
|
1309
|
+
return getBoundaryElement();
|
|
1310
|
+
}
|
|
1311
|
+
return typeof document !== 'undefined' ? document.body : null;
|
|
1312
|
+
}, [customGetPopupContainer, getBoundaryElement, isMobile, useBoundaryMount]);
|
|
1313
|
+
const popupMountNode = typeof document !== 'undefined' ? isMobile ? useBoundaryMount ? getBoundaryElement() || document.body : document.body : getBoundaryElement() || document.body : null;
|
|
1145
1314
|
const _useState3 = react.useState(false),
|
|
1146
|
-
|
|
1147
|
-
|
|
1315
|
+
renderMask = _useState3[0],
|
|
1316
|
+
setRenderMask = _useState3[1];
|
|
1148
1317
|
const _useState4 = react.useState(false),
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
const _useState5 = react.useState(
|
|
1152
|
-
maskClosing = _useState5[0],
|
|
1153
|
-
setMaskClosing = _useState5[1];
|
|
1154
|
-
const _useState6 = react.useState({
|
|
1318
|
+
maskClosing = _useState4[0],
|
|
1319
|
+
setMaskClosing = _useState4[1];
|
|
1320
|
+
const _useState5 = react.useState({
|
|
1155
1321
|
top: 0,
|
|
1156
1322
|
pageTop: 0,
|
|
1157
1323
|
height: 0
|
|
1158
1324
|
}),
|
|
1159
|
-
popupMetrics =
|
|
1160
|
-
setPopupMetrics =
|
|
1325
|
+
popupMetrics = _useState5[0],
|
|
1326
|
+
setPopupMetrics = _useState5[1];
|
|
1161
1327
|
const triggerRef = react.useRef(null);
|
|
1162
1328
|
const disabled = react.useMemo(() => {
|
|
1163
1329
|
return onValidate && !onValidate(state);
|
|
@@ -1166,37 +1332,17 @@ const PopoverItem = withLocale(_ref => {
|
|
|
1166
1332
|
moduleName: 'Filter'
|
|
1167
1333
|
}),
|
|
1168
1334
|
formatMessage = _useIntl.formatMessage;
|
|
1169
|
-
react.useEffect(() => {
|
|
1170
|
-
if (typeof window === 'undefined') return;
|
|
1171
|
-
const mediaQuery = window.matchMedia('(max-width: 768px)');
|
|
1172
|
-
const updateIsMobile = () => {
|
|
1173
|
-
setIsMobile(mediaQuery.matches);
|
|
1174
|
-
};
|
|
1175
|
-
updateIsMobile();
|
|
1176
|
-
mediaQuery.addEventListener ? mediaQuery.addEventListener('change', updateIsMobile) : mediaQuery.addListener(updateIsMobile);
|
|
1177
|
-
return () => {
|
|
1178
|
-
mediaQuery.removeEventListener ? mediaQuery.removeEventListener('change', updateIsMobile) : mediaQuery.removeListener(updateIsMobile);
|
|
1179
|
-
};
|
|
1180
|
-
}, []);
|
|
1181
1335
|
const updatePopupMetrics = react.useCallback(() => {
|
|
1182
1336
|
if (typeof window === 'undefined' || !triggerRef.current) return;
|
|
1183
|
-
const
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1337
|
+
const metrics = getMobilePopupMetrics(triggerRef.current, {
|
|
1338
|
+
scrollEl: getScrollElement(),
|
|
1339
|
+
boundaryEl: getBoundaryElement(),
|
|
1340
|
+
useBoundaryMount,
|
|
1341
|
+
offset: MOBILE_POPUP_OFFSET
|
|
1188
1342
|
});
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
updatePopupMetrics();
|
|
1193
|
-
window.addEventListener('resize', updatePopupMetrics);
|
|
1194
|
-
window.addEventListener('scroll', updatePopupMetrics, true);
|
|
1195
|
-
return () => {
|
|
1196
|
-
window.removeEventListener('resize', updatePopupMetrics);
|
|
1197
|
-
window.removeEventListener('scroll', updatePopupMetrics, true);
|
|
1198
|
-
};
|
|
1199
|
-
}, [isMobile, open, updatePopupMetrics]);
|
|
1343
|
+
setPopupMetrics(metrics);
|
|
1344
|
+
}, [getBoundaryElement, getScrollElement, useBoundaryMount]);
|
|
1345
|
+
useResponsiveScrollListener(updatePopupMetrics, open && isMobile);
|
|
1200
1346
|
react.useEffect(() => {
|
|
1201
1347
|
if (open && isMobile) {
|
|
1202
1348
|
setRenderMask(true);
|
|
@@ -1228,7 +1374,8 @@ const PopoverItem = withLocale(_ref => {
|
|
|
1228
1374
|
const mobileOverlayStyle = isMobile ? {
|
|
1229
1375
|
'--react-filter-popover-mobile-height': popupMetrics.height + "px",
|
|
1230
1376
|
top: popupMetrics.top,
|
|
1231
|
-
left: 0
|
|
1377
|
+
left: (_popupMetrics$left = popupMetrics.left) != null ? _popupMetrics$left : 0,
|
|
1378
|
+
zIndex: MOBILE_POPUP_Z_INDEX
|
|
1232
1379
|
} : undefined;
|
|
1233
1380
|
const overlayContent = /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1234
1381
|
className: style$1['pop-util-body'],
|
|
@@ -1270,17 +1417,18 @@ const PopoverItem = withLocale(_ref => {
|
|
|
1270
1417
|
})]
|
|
1271
1418
|
});
|
|
1272
1419
|
return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
1273
|
-
children: [renderMask &&
|
|
1274
|
-
className: classnames__default["default"](style$1['pop-util-mask'], maskClosing && style$1['pop-util-mask-leave']),
|
|
1420
|
+
children: [renderMask && popupMountNode && /*#__PURE__*/reactDom.createPortal(/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
1421
|
+
className: classnames__default["default"](style$1['pop-util-mask'], maskClosing && style$1['pop-util-mask-leave'], fixedModeClass),
|
|
1275
1422
|
style: {
|
|
1276
1423
|
top: popupMetrics.top,
|
|
1277
|
-
height: popupMetrics.height
|
|
1424
|
+
height: popupMetrics.height,
|
|
1425
|
+
zIndex: MOBILE_MASK_Z_INDEX
|
|
1278
1426
|
},
|
|
1279
1427
|
onClick: closeDropdown,
|
|
1280
1428
|
onTouchMove: e => {
|
|
1281
1429
|
e.preventDefault();
|
|
1282
1430
|
}
|
|
1283
|
-
}),
|
|
1431
|
+
}), popupMountNode), /*#__PURE__*/jsxRuntime.jsx(antd.Dropdown, {
|
|
1284
1432
|
open: open,
|
|
1285
1433
|
trigger: ['click'],
|
|
1286
1434
|
placement: isMobile ? 'bottomLeft' : placement,
|
|
@@ -1288,7 +1436,9 @@ const PopoverItem = withLocale(_ref => {
|
|
|
1288
1436
|
align: isMobile ? {
|
|
1289
1437
|
offset: [0, 0]
|
|
1290
1438
|
} : undefined,
|
|
1291
|
-
|
|
1439
|
+
getPopupContainer: resolveGetPopupContainer,
|
|
1440
|
+
zIndex: isMobile ? MOBILE_POPUP_Z_INDEX : undefined,
|
|
1441
|
+
overlayClassName: classnames__default["default"](style$1['pop-util-overlay'], overlayClassName, isMobile && fixedModeClass),
|
|
1292
1442
|
overlayStyle: mobileOverlayStyle,
|
|
1293
1443
|
onOpenChange: handleOpenChange,
|
|
1294
1444
|
menu: {
|
|
@@ -1310,17 +1460,17 @@ const PopoverItem = withLocale(_ref => {
|
|
|
1310
1460
|
});
|
|
1311
1461
|
});
|
|
1312
1462
|
|
|
1313
|
-
const
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1463
|
+
const _excluded$a = ["label", "value", "onChange", "placeholder", "onValidate", "overlayClassName", "placement", "onOpenChange"];
|
|
1464
|
+
const InputFilterItem$2 = withLocale(_ref => {
|
|
1465
|
+
let label = _ref.label,
|
|
1466
|
+
value = _ref.value,
|
|
1467
|
+
onChange = _ref.onChange,
|
|
1468
|
+
placeholder = _ref.placeholder,
|
|
1469
|
+
onValidate = _ref.onValidate,
|
|
1470
|
+
overlayClassName = _ref.overlayClassName,
|
|
1471
|
+
placement = _ref.placement,
|
|
1472
|
+
onOpenChange = _ref.onOpenChange,
|
|
1473
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$a);
|
|
1324
1474
|
return /*#__PURE__*/jsxRuntime.jsx(PopoverItem, {
|
|
1325
1475
|
label: label,
|
|
1326
1476
|
value: value,
|
|
@@ -1329,22 +1479,23 @@ const InputFilterItem$2 = withLocale(({
|
|
|
1329
1479
|
overlayClassName,
|
|
1330
1480
|
placement,
|
|
1331
1481
|
onOpenChange,
|
|
1332
|
-
children:
|
|
1333
|
-
value,
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
}
|
|
1344
|
-
}
|
|
1482
|
+
children: _ref2 => {
|
|
1483
|
+
let value = _ref2.value,
|
|
1484
|
+
onChange = _ref2.onChange;
|
|
1485
|
+
return /*#__PURE__*/jsxRuntime.jsx(antd.Input, _extends({}, props, {
|
|
1486
|
+
placeholder: placeholder || "\u8BF7\u8F93\u5165" + label,
|
|
1487
|
+
className: style$1['filter-item-text'],
|
|
1488
|
+
value: get__default["default"](value, 'value', ''),
|
|
1489
|
+
onChange: e => onChange(e.target.value ? {
|
|
1490
|
+
label: e.target.value,
|
|
1491
|
+
value: e.target.value
|
|
1492
|
+
} : null)
|
|
1493
|
+
}));
|
|
1494
|
+
}
|
|
1345
1495
|
});
|
|
1346
1496
|
});
|
|
1347
1497
|
|
|
1498
|
+
const _excluded$9 = ["label", "value", "onChange", "placeholder", "onValidate", "overlayClassName", "placement", "onOpenChange", "unit"];
|
|
1348
1499
|
const computedFilterValue = (range, unit, formatMessage) => {
|
|
1349
1500
|
if (!isNumber__default["default"](range[0]) && !isNumber__default["default"](range[1])) {
|
|
1350
1501
|
return null;
|
|
@@ -1352,7 +1503,7 @@ const computedFilterValue = (range, unit, formatMessage) => {
|
|
|
1352
1503
|
return {
|
|
1353
1504
|
label: (range => {
|
|
1354
1505
|
if (isNumber__default["default"](range[0]) && isNumber__default["default"](range[1])) {
|
|
1355
|
-
return
|
|
1506
|
+
return range[0] + "-" + range[1] + (unit || '');
|
|
1356
1507
|
}
|
|
1357
1508
|
if (isNumber__default["default"](range[0])) {
|
|
1358
1509
|
return formatMessage({
|
|
@@ -1378,23 +1529,22 @@ const defaultPropsOnValidate = value => {
|
|
|
1378
1529
|
const range = get__default["default"](value, 'value');
|
|
1379
1530
|
return !(range && isNumber__default["default"](range[0]) && isNumber__default["default"](range[1]) && range[1] < range[0]);
|
|
1380
1531
|
};
|
|
1381
|
-
const NumberRangeFilterItem$1 = withLocale(
|
|
1382
|
-
label,
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
const {
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
});
|
|
1532
|
+
const NumberRangeFilterItem$1 = withLocale(_ref => {
|
|
1533
|
+
let label = _ref.label,
|
|
1534
|
+
value = _ref.value,
|
|
1535
|
+
onChange = _ref.onChange,
|
|
1536
|
+
placeholder = _ref.placeholder,
|
|
1537
|
+
_ref$onValidate = _ref.onValidate,
|
|
1538
|
+
onValidate = _ref$onValidate === void 0 ? defaultPropsOnValidate : _ref$onValidate,
|
|
1539
|
+
overlayClassName = _ref.overlayClassName,
|
|
1540
|
+
placement = _ref.placement,
|
|
1541
|
+
onOpenChange = _ref.onOpenChange,
|
|
1542
|
+
unit = _ref.unit,
|
|
1543
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$9);
|
|
1544
|
+
const _useIntl = reactIntl.useIntl({
|
|
1545
|
+
moduleName: 'Filter'
|
|
1546
|
+
}),
|
|
1547
|
+
formatMessage = _useIntl.formatMessage;
|
|
1398
1548
|
return /*#__PURE__*/jsxRuntime.jsx(PopoverItem, {
|
|
1399
1549
|
label: label,
|
|
1400
1550
|
value: value,
|
|
@@ -1403,136 +1553,141 @@ const NumberRangeFilterItem$1 = withLocale(({
|
|
|
1403
1553
|
overlayClassName,
|
|
1404
1554
|
placement,
|
|
1405
1555
|
onOpenChange,
|
|
1406
|
-
children:
|
|
1407
|
-
value,
|
|
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
|
-
|
|
1447
|
-
})
|
|
1556
|
+
children: _ref2 => {
|
|
1557
|
+
let value = _ref2.value,
|
|
1558
|
+
onChange = _ref2.onChange;
|
|
1559
|
+
return /*#__PURE__*/jsxRuntime.jsxs(antd.Space.Compact, {
|
|
1560
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(antd.InputNumber, _extends({}, props, {
|
|
1561
|
+
placeholder: placeholder || "" + formatMessage({
|
|
1562
|
+
id: 'pleaseInput'
|
|
1563
|
+
}) + label,
|
|
1564
|
+
className: style$1['filter-item-number-range'],
|
|
1565
|
+
value: get__default["default"](value, 'value[0]', ''),
|
|
1566
|
+
onChange: target => {
|
|
1567
|
+
onChange(computedFilterValue([target, get__default["default"](value, 'value[1]')], unit, formatMessage));
|
|
1568
|
+
}
|
|
1569
|
+
})), /*#__PURE__*/jsxRuntime.jsx(antd.Input, {
|
|
1570
|
+
style: {
|
|
1571
|
+
width: 30,
|
|
1572
|
+
borderLeft: 0,
|
|
1573
|
+
borderRight: 0,
|
|
1574
|
+
pointerEvents: 'none'
|
|
1575
|
+
},
|
|
1576
|
+
placeholder: "~",
|
|
1577
|
+
disabled: true
|
|
1578
|
+
}), /*#__PURE__*/jsxRuntime.jsx(antd.InputNumber, _extends({}, props, {
|
|
1579
|
+
placeholder: placeholder || "" + formatMessage({
|
|
1580
|
+
id: 'pleaseInput'
|
|
1581
|
+
}) + label,
|
|
1582
|
+
className: style$1['filter-item-number-range'],
|
|
1583
|
+
value: get__default["default"](value, 'value[1]', ''),
|
|
1584
|
+
onChange: target => {
|
|
1585
|
+
onChange(computedFilterValue([get__default["default"](value, 'value[0]'), target], unit, formatMessage));
|
|
1586
|
+
}
|
|
1587
|
+
})), unit && /*#__PURE__*/jsxRuntime.jsx(antd.Input, {
|
|
1588
|
+
style: {
|
|
1589
|
+
width: 50,
|
|
1590
|
+
borderLeft: 0
|
|
1591
|
+
},
|
|
1592
|
+
value: unit,
|
|
1593
|
+
disabled: true
|
|
1594
|
+
})]
|
|
1595
|
+
});
|
|
1596
|
+
}
|
|
1448
1597
|
});
|
|
1449
1598
|
});
|
|
1450
1599
|
|
|
1451
|
-
const
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1600
|
+
const _excluded$8 = ["value", "onChange", "picker"];
|
|
1601
|
+
const DatePickerFilterItem = withLocale(withFieldItem(_ref => {
|
|
1602
|
+
var _props$classNames, _props$classNames2;
|
|
1603
|
+
let value = _ref.value,
|
|
1604
|
+
onChange = _ref.onChange,
|
|
1605
|
+
_ref$picker = _ref.picker,
|
|
1606
|
+
picker = _ref$picker === void 0 ? 'date' : _ref$picker,
|
|
1607
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$8);
|
|
1608
|
+
return /*#__PURE__*/jsxRuntime.jsx(antd.DatePicker, _extends({}, props, {
|
|
1459
1609
|
inputReadOnly: true,
|
|
1460
1610
|
picker: picker,
|
|
1461
|
-
classNames: {
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
}
|
|
1467
|
-
},
|
|
1611
|
+
classNames: _extends({}, props.classNames, {
|
|
1612
|
+
popup: _extends({}, (_props$classNames = props.classNames) == null ? void 0 : _props$classNames.popup, {
|
|
1613
|
+
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'])
|
|
1614
|
+
})
|
|
1615
|
+
}),
|
|
1468
1616
|
value: value && dayjs__default["default"](value.value),
|
|
1469
1617
|
onChange: value => {
|
|
1470
|
-
const {
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
format
|
|
1474
|
-
}, props);
|
|
1618
|
+
const _Object$assign = Object.assign({
|
|
1619
|
+
format: 'YYYY-MM-DD'
|
|
1620
|
+
}, props),
|
|
1621
|
+
format = _Object$assign.format;
|
|
1475
1622
|
value && onChange({
|
|
1476
|
-
label: picker !== 'date' ?
|
|
1623
|
+
label: picker !== 'date' ? value.startOf(picker).format(format) + "~" + value.endOf(picker).format(format) : value.format(format),
|
|
1477
1624
|
value: new Date(value.startOf(picker).valueOf())
|
|
1478
1625
|
});
|
|
1479
1626
|
}
|
|
1480
|
-
});
|
|
1627
|
+
}));
|
|
1481
1628
|
}));
|
|
1482
1629
|
|
|
1483
|
-
const
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1630
|
+
const _excluded$7 = ["value", "onChange", "header"];
|
|
1631
|
+
const DateRangePickerFilterItem = withLocale(withFieldItem(_ref => {
|
|
1632
|
+
var _props$classNames, _props$classNames2;
|
|
1633
|
+
let value = _ref.value,
|
|
1634
|
+
onChange = _ref.onChange,
|
|
1635
|
+
header = _ref.header,
|
|
1636
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$7);
|
|
1489
1637
|
return /*#__PURE__*/jsxRuntime.jsxs(antd.Flex, {
|
|
1490
1638
|
vertical: true,
|
|
1491
1639
|
children: [typeof header === 'function' ? header({
|
|
1492
1640
|
value,
|
|
1493
1641
|
onChange
|
|
1494
|
-
}) : header, /*#__PURE__*/jsxRuntime.jsx(antd.DatePicker.RangePicker, {
|
|
1495
|
-
...props,
|
|
1642
|
+
}) : header, /*#__PURE__*/jsxRuntime.jsx(antd.DatePicker.RangePicker, _extends({}, props, {
|
|
1496
1643
|
inputReadOnly: true,
|
|
1497
1644
|
allowEmpty: [false, false],
|
|
1498
|
-
classNames: {
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
}
|
|
1504
|
-
},
|
|
1645
|
+
classNames: _extends({}, props.classNames, {
|
|
1646
|
+
popup: _extends({}, (_props$classNames = props.classNames) == null ? void 0 : _props$classNames.popup, {
|
|
1647
|
+
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'])
|
|
1648
|
+
})
|
|
1649
|
+
}),
|
|
1505
1650
|
value: value && Array.isArray(value.value) && value.value.length === 2 && value.value.map(item => dayjs__default["default"](item)),
|
|
1506
1651
|
onChange: value => {
|
|
1507
|
-
const {
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
format
|
|
1511
|
-
}, props);
|
|
1652
|
+
const _Object$assign = Object.assign({
|
|
1653
|
+
format: 'YYYY-MM-DD'
|
|
1654
|
+
}, props),
|
|
1655
|
+
format = _Object$assign.format;
|
|
1512
1656
|
onChange({
|
|
1513
1657
|
label: value.map(item => item.format(format)).join('~'),
|
|
1514
1658
|
value: value.map(item => new Date(item.valueOf()))
|
|
1515
1659
|
});
|
|
1516
1660
|
}
|
|
1517
|
-
})]
|
|
1661
|
+
}))]
|
|
1518
1662
|
});
|
|
1519
1663
|
}));
|
|
1520
1664
|
|
|
1521
1665
|
var style = {"shortcuts-container":"kne-react-filter_3w4Bb","shortcut-item":"kne-react-filter_myRhG","is-active":"kne-react-filter_FowoG"};
|
|
1522
1666
|
|
|
1523
|
-
const _excluded$
|
|
1667
|
+
const _excluded$6 = ["value", "onChange", "defaultValue", "shortcuts", "shortcutOptions"];
|
|
1668
|
+
const FIELD_MOBILE_POPUP_CLASS = 'react-filter-field-mobile-popup';
|
|
1524
1669
|
const TypeDateRangePickerField = _ref => {
|
|
1670
|
+
var _props$classNames, _props$classNames2, _props$styles, _props$styles2;
|
|
1525
1671
|
let valueProp = _ref.value,
|
|
1526
1672
|
onChangeProp = _ref.onChange,
|
|
1527
1673
|
defaultValue = _ref.defaultValue,
|
|
1528
1674
|
_ref$shortcuts = _ref.shortcuts,
|
|
1529
1675
|
shortcuts = _ref$shortcuts === void 0 ? true : _ref$shortcuts,
|
|
1530
1676
|
shortcutOptions = _ref.shortcutOptions,
|
|
1531
|
-
props = _objectWithoutPropertiesLoose(_ref, _excluded$
|
|
1677
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$6);
|
|
1532
1678
|
const _useIntl = reactIntl.useIntl({
|
|
1533
1679
|
moduleName: 'Filter'
|
|
1534
1680
|
}),
|
|
1535
1681
|
formatMessage = _useIntl.formatMessage;
|
|
1682
|
+
const getPopupContainer = responsiveUtils.usePopupContainer();
|
|
1683
|
+
const _useMobileFixedMode = useMobileFixedMode(),
|
|
1684
|
+
isMobile = _useMobileFixedMode.isMobile,
|
|
1685
|
+
useBoundaryMount = _useMobileFixedMode.useBoundaryMount;
|
|
1686
|
+
const fixedModeClass = useBoundaryMount ? style['is-boundary'] : style['is-viewport'];
|
|
1687
|
+
const nestedPopupClassName = classnames__default["default"](style['field-item-mobile-popup'], FIELD_MOBILE_POPUP_CLASS, fixedModeClass);
|
|
1688
|
+
const nestedPopupStyle = isMobile ? {
|
|
1689
|
+
zIndex: MOBILE_POPUP_Z_INDEX
|
|
1690
|
+
} : undefined;
|
|
1536
1691
|
const typeList = new Map([['date', formatMessage({
|
|
1537
1692
|
id: 'customTime'
|
|
1538
1693
|
})], ['month', formatMessage({
|
|
@@ -1626,6 +1781,19 @@ const TypeDateRangePickerField = _ref => {
|
|
|
1626
1781
|
style: {
|
|
1627
1782
|
width: '120px'
|
|
1628
1783
|
},
|
|
1784
|
+
getPopupContainer: getPopupContainer,
|
|
1785
|
+
popupClassName: isMobile ? nestedPopupClassName : undefined,
|
|
1786
|
+
classNames: isMobile ? {
|
|
1787
|
+
popup: {
|
|
1788
|
+
root: nestedPopupClassName
|
|
1789
|
+
}
|
|
1790
|
+
} : undefined,
|
|
1791
|
+
popupStyle: nestedPopupStyle,
|
|
1792
|
+
styles: isMobile ? {
|
|
1793
|
+
popup: {
|
|
1794
|
+
root: nestedPopupStyle
|
|
1795
|
+
}
|
|
1796
|
+
} : undefined,
|
|
1629
1797
|
value: (value == null ? void 0 : value.type) || 'date',
|
|
1630
1798
|
onChange: typeValue => {
|
|
1631
1799
|
onChange(currentValue => {
|
|
@@ -1653,6 +1821,18 @@ const TypeDateRangePickerField = _ref => {
|
|
|
1653
1821
|
};
|
|
1654
1822
|
})
|
|
1655
1823
|
}), /*#__PURE__*/jsxRuntime.jsx(antd.DatePicker.RangePicker, _extends({}, props, {
|
|
1824
|
+
getPopupContainer: getPopupContainer,
|
|
1825
|
+
classNames: isMobile ? _extends({}, props.classNames, {
|
|
1826
|
+
popup: _extends({}, (_props$classNames = props.classNames) == null ? void 0 : _props$classNames.popup, {
|
|
1827
|
+
root: classnames__default["default"]((_props$classNames2 = props.classNames) == null || (_props$classNames2 = _props$classNames2.popup) == null ? void 0 : _props$classNames2.root, nestedPopupClassName)
|
|
1828
|
+
})
|
|
1829
|
+
}) : props.classNames,
|
|
1830
|
+
styles: isMobile ? _extends({}, props.styles, {
|
|
1831
|
+
popup: _extends({}, (_props$styles = props.styles) == null ? void 0 : _props$styles.popup, {
|
|
1832
|
+
root: Object.assign({}, (_props$styles2 = props.styles) == null || (_props$styles2 = _props$styles2.popup) == null ? void 0 : _props$styles2.root, nestedPopupStyle)
|
|
1833
|
+
})
|
|
1834
|
+
}) : props.styles,
|
|
1835
|
+
popupStyle: nestedPopupStyle,
|
|
1656
1836
|
picker: (value == null ? void 0 : value.type) || 'date',
|
|
1657
1837
|
value: Array.isArray(value == null ? void 0 : value.value) && value.value.length === 2 ? value.value.map(item => item && dayjs__default["default"](item)) : null,
|
|
1658
1838
|
onChange: dateValue => {
|
|
@@ -1669,47 +1849,46 @@ const TypeDateRangePickerField = _ref => {
|
|
|
1669
1849
|
});
|
|
1670
1850
|
};
|
|
1671
1851
|
|
|
1672
|
-
const
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1852
|
+
const _excluded$5 = ["label", "value", "onChange"];
|
|
1853
|
+
const TypeDateRangePickerFilterItem = withLocale(_ref => {
|
|
1854
|
+
let label = _ref.label,
|
|
1855
|
+
value = _ref.value,
|
|
1856
|
+
onChange = _ref.onChange,
|
|
1857
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$5);
|
|
1678
1858
|
return /*#__PURE__*/jsxRuntime.jsx(PopoverItem, {
|
|
1679
1859
|
label: label,
|
|
1680
1860
|
value: value,
|
|
1681
1861
|
onChange: onChange,
|
|
1682
1862
|
onValidate: item => {
|
|
1683
|
-
const itemValue = item
|
|
1684
|
-
return itemValue
|
|
1863
|
+
const itemValue = item == null ? void 0 : item.value;
|
|
1864
|
+
return (itemValue == null ? void 0 : itemValue.type) && Array.isArray(itemValue == null ? void 0 : itemValue.value) && itemValue.value.length === 2;
|
|
1685
1865
|
},
|
|
1686
|
-
children:
|
|
1687
|
-
value,
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1866
|
+
children: _ref2 => {
|
|
1867
|
+
let value = _ref2.value,
|
|
1868
|
+
onChange = _ref2.onChange;
|
|
1869
|
+
return /*#__PURE__*/jsxRuntime.jsx(TypeDateRangePickerField, _extends({}, props, {
|
|
1870
|
+
inputReadOnly: true,
|
|
1871
|
+
className: style$1['filter-item-text'],
|
|
1872
|
+
value: get__default["default"](value, 'value'),
|
|
1873
|
+
onChange: pickerValue => {
|
|
1874
|
+
const _props$format = props.format,
|
|
1875
|
+
format = _props$format === void 0 ? 'YYYY-MM-DD' : _props$format;
|
|
1876
|
+
const val = (pickerValue == null ? void 0 : pickerValue.value) || [];
|
|
1877
|
+
let displayLabel = '';
|
|
1878
|
+
if (val[0] && !val[1]) {
|
|
1879
|
+
displayLabel = dayjs__default["default"](val[0]).format(format) + "\u4EE5\u540E";
|
|
1880
|
+
} else if (!val[0] && val[1]) {
|
|
1881
|
+
displayLabel = dayjs__default["default"](val[1]).format(format) + "\u4EE5\u524D";
|
|
1882
|
+
} else if (val[0] && val[1]) {
|
|
1883
|
+
displayLabel = dayjs__default["default"](val[0]).format(format) + "~" + dayjs__default["default"](val[1]).format(format);
|
|
1884
|
+
}
|
|
1885
|
+
onChange({
|
|
1886
|
+
label: displayLabel,
|
|
1887
|
+
value: pickerValue
|
|
1888
|
+
});
|
|
1706
1889
|
}
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
value: pickerValue
|
|
1710
|
-
});
|
|
1711
|
-
}
|
|
1712
|
-
})
|
|
1890
|
+
}));
|
|
1891
|
+
}
|
|
1713
1892
|
});
|
|
1714
1893
|
});
|
|
1715
1894
|
|
|
@@ -2608,6 +2787,7 @@ const CityFilterItemInner = ({
|
|
|
2608
2787
|
const {
|
|
2609
2788
|
message
|
|
2610
2789
|
} = antd.App.useApp();
|
|
2790
|
+
const getPopupContainer = responsiveUtils.usePopupContainer();
|
|
2611
2791
|
const {
|
|
2612
2792
|
locale
|
|
2613
2793
|
} = reactIntl.useIntl();
|
|
@@ -2681,6 +2861,7 @@ const CityFilterItemInner = ({
|
|
|
2681
2861
|
id: 'otherText'
|
|
2682
2862
|
}), /*#__PURE__*/jsxRuntime.jsx(superSelectPlus.SelectAddress, {
|
|
2683
2863
|
...props,
|
|
2864
|
+
getPopupContainer: getPopupContainer,
|
|
2684
2865
|
className: style$1['filter-advanced-item-other-inner'],
|
|
2685
2866
|
maxLength: maxLength,
|
|
2686
2867
|
allowClear: false,
|
|
@@ -2792,6 +2973,7 @@ Filter.useFilter = useContext;
|
|
|
2792
2973
|
Filter.SearchInput = SearchInput;
|
|
2793
2974
|
Filter.withFilterValue = withFilterValue;
|
|
2794
2975
|
Filter.FilterProvider = FilterProvider;
|
|
2976
|
+
Filter.FilterOuter = FilterOuter;
|
|
2795
2977
|
Filter.pickSelectValues = pickSelectValues;
|
|
2796
2978
|
Filter.createFilterValueMapper = createFilterValueMapper;
|
|
2797
2979
|
Filter.useUrlFilter = useUrlFilter;
|
|
@@ -2812,6 +2994,7 @@ exports.DateRangePickerFilterItem = DateRangePickerFilterItem;
|
|
|
2812
2994
|
exports.FilterItem = FilterItem;
|
|
2813
2995
|
exports.FilterItemContainer = FilterItemContainer;
|
|
2814
2996
|
exports.FilterLines = FilterLines;
|
|
2997
|
+
exports.FilterOuter = FilterOuter;
|
|
2815
2998
|
exports.FilterProvider = FilterProvider;
|
|
2816
2999
|
exports.FilterValueDisplay = FilterValueDisplay;
|
|
2817
3000
|
exports.InputFilterItem = InputFilterItem$1;
|