@kne/react-filter 1.0.7 → 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 +505 -323
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +285 -100
- 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,58 @@ 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 {
|
|
902
|
+
mode
|
|
903
|
+
} = responsiveUtils.useResponsiveContext();
|
|
904
|
+
react.useEffect(() => {
|
|
905
|
+
const el = boundaryRef.current;
|
|
906
|
+
if (!el || typeof window === 'undefined' || mode === 'container') {
|
|
907
|
+
return undefined;
|
|
908
|
+
}
|
|
909
|
+
const update = () => {
|
|
910
|
+
responsiveUtils.applyViewportCssVars(el, {
|
|
911
|
+
width: window.innerWidth,
|
|
912
|
+
height: window.innerHeight
|
|
913
|
+
});
|
|
914
|
+
};
|
|
915
|
+
update();
|
|
916
|
+
window.addEventListener('resize', update, {
|
|
917
|
+
passive: true
|
|
918
|
+
});
|
|
919
|
+
return () => {
|
|
920
|
+
window.removeEventListener('resize', update);
|
|
921
|
+
responsiveUtils.resetViewportCssVars(el);
|
|
922
|
+
};
|
|
923
|
+
}, [mode]);
|
|
924
|
+
return boundaryRef;
|
|
925
|
+
};
|
|
926
|
+
|
|
927
|
+
const _excluded$d = ["children", "className"];
|
|
928
|
+
const FilterOuter = _ref => {
|
|
929
|
+
let children = _ref.children,
|
|
930
|
+
className = _ref.className,
|
|
931
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$d);
|
|
932
|
+
const isMobile = useFilterIsMobile();
|
|
933
|
+
const boundaryRef = useFilterViewportVars();
|
|
934
|
+
return /*#__PURE__*/jsxRuntime.jsx(FilterProvider, _extends({}, props, {
|
|
857
935
|
children: context => /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
936
|
+
ref: boundaryRef,
|
|
937
|
+
className: classnames__default["default"](style$1['filter'], 'filter', responsiveUtils.RESPONSIVE_BOUNDARY_CLASS, isMobile && style$1['is-mobile'], className),
|
|
938
|
+
children: children(_extends({}, context, {
|
|
861
939
|
props
|
|
862
|
-
})
|
|
940
|
+
}))
|
|
863
941
|
})
|
|
864
|
-
});
|
|
942
|
+
}));
|
|
865
943
|
};
|
|
866
944
|
|
|
867
|
-
const _excluded$
|
|
945
|
+
const _excluded$c = ["defaultValue"],
|
|
868
946
|
_excluded2 = ["extraExpand"];
|
|
869
947
|
const Filter = withLocale(_ref => {
|
|
870
948
|
let _ref$defaultValue = _ref.defaultValue,
|
|
871
949
|
defaultValue = _ref$defaultValue === void 0 ? [] : _ref$defaultValue,
|
|
872
|
-
props = _objectWithoutPropertiesLoose(_ref, _excluded$
|
|
950
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$c);
|
|
873
951
|
return /*#__PURE__*/jsxRuntime.jsx(FilterOuter, _extends({}, props, {
|
|
874
952
|
defaultValue: defaultValue,
|
|
875
953
|
children: _ref2 => {
|
|
@@ -890,6 +968,24 @@ const Filter = withLocale(_ref => {
|
|
|
890
968
|
}));
|
|
891
969
|
});
|
|
892
970
|
|
|
971
|
+
/**
|
|
972
|
+
* 与 system-layout Toolbar 一致:
|
|
973
|
+
* - container 模式(example 手机预览):absolute + boundary 挂载
|
|
974
|
+
* - viewport 模式(真实移动端):fixed + 视口坐标
|
|
975
|
+
*/
|
|
976
|
+
const useMobileFixedMode = () => {
|
|
977
|
+
const isMobile = useFilterIsMobile();
|
|
978
|
+
const _useResponsiveContext = responsiveUtils.useResponsiveContext(),
|
|
979
|
+
mode = _useResponsiveContext.mode;
|
|
980
|
+
const useBoundaryMount = isMobile && mode === 'container';
|
|
981
|
+
const useViewportFixed = isMobile && mode !== 'container';
|
|
982
|
+
return {
|
|
983
|
+
isMobile,
|
|
984
|
+
useBoundaryMount,
|
|
985
|
+
useViewportFixed
|
|
986
|
+
};
|
|
987
|
+
};
|
|
988
|
+
|
|
893
989
|
const FilterItem = withLocale(_ref => {
|
|
894
990
|
let open = _ref.open,
|
|
895
991
|
active = _ref.active,
|
|
@@ -919,46 +1015,109 @@ const FilterItem = withLocale(_ref => {
|
|
|
919
1015
|
});
|
|
920
1016
|
});
|
|
921
1017
|
|
|
922
|
-
const
|
|
1018
|
+
const getMobilePopupMetrics = function (triggerEl, _temp) {
|
|
1019
|
+
var _scrollRect$top, _scrollRect$bottom, _scrollRect$width;
|
|
1020
|
+
let _ref = _temp === void 0 ? {} : _temp,
|
|
1021
|
+
scrollEl = _ref.scrollEl,
|
|
1022
|
+
boundaryEl = _ref.boundaryEl,
|
|
1023
|
+
useBoundaryMount = _ref.useBoundaryMount,
|
|
1024
|
+
_ref$offset = _ref.offset,
|
|
1025
|
+
offset = _ref$offset === void 0 ? 4 : _ref$offset;
|
|
1026
|
+
if (typeof window === 'undefined' || !triggerEl) {
|
|
1027
|
+
return {
|
|
1028
|
+
top: 0,
|
|
1029
|
+
left: 0,
|
|
1030
|
+
height: 0,
|
|
1031
|
+
width: 0
|
|
1032
|
+
};
|
|
1033
|
+
}
|
|
1034
|
+
const rect = triggerEl.getBoundingClientRect();
|
|
1035
|
+
if (useBoundaryMount && boundaryEl) {
|
|
1036
|
+
const boundaryRect = boundaryEl.getBoundingClientRect();
|
|
1037
|
+
const top = Math.max(rect.bottom - boundaryRect.top + offset, 0);
|
|
1038
|
+
return {
|
|
1039
|
+
top,
|
|
1040
|
+
left: 0,
|
|
1041
|
+
height: Math.max(boundaryRect.height - top, 0),
|
|
1042
|
+
width: boundaryRect.width
|
|
1043
|
+
};
|
|
1044
|
+
}
|
|
1045
|
+
const scrollRect = scrollEl == null || scrollEl.getBoundingClientRect == null ? void 0 : scrollEl.getBoundingClientRect();
|
|
1046
|
+
const visibleTop = (_scrollRect$top = scrollRect == null ? void 0 : scrollRect.top) != null ? _scrollRect$top : 0;
|
|
1047
|
+
const visibleBottom = (_scrollRect$bottom = scrollRect == null ? void 0 : scrollRect.bottom) != null ? _scrollRect$bottom : window.innerHeight;
|
|
1048
|
+
const width = (_scrollRect$width = scrollRect == null ? void 0 : scrollRect.width) != null ? _scrollRect$width : window.innerWidth;
|
|
1049
|
+
const top = Math.max(rect.bottom + offset, visibleTop);
|
|
1050
|
+
return {
|
|
1051
|
+
top,
|
|
1052
|
+
left: 0,
|
|
1053
|
+
height: Math.max(visibleBottom - top, 0),
|
|
1054
|
+
width
|
|
1055
|
+
};
|
|
1056
|
+
};
|
|
1057
|
+
|
|
1058
|
+
const MOBILE_MASK_Z_INDEX = 1000;
|
|
1059
|
+
const MOBILE_POPUP_Z_INDEX = 1050;
|
|
1060
|
+
|
|
1061
|
+
const _excluded$b = ["value", "onChange", "interceptor", "label", "render"];
|
|
923
1062
|
const isNotEmpty$1 = value => {
|
|
924
1063
|
if (value === null || value === undefined) return false;
|
|
925
1064
|
if (typeof value === 'string' && value.trim() === '') return false;
|
|
926
1065
|
return !(Array.isArray(value) && value.length === 0);
|
|
927
1066
|
};
|
|
928
1067
|
const MASK_ANIMATION_DURATION$1 = 180;
|
|
929
|
-
const FIELD_MOBILE_POPUP_CLASS = 'react-filter-field-mobile-popup';
|
|
1068
|
+
const FIELD_MOBILE_POPUP_CLASS$1 = 'react-filter-field-mobile-popup';
|
|
930
1069
|
const MOBILE_POPUP_OFFSET$1 = 4;
|
|
931
1070
|
const withFieldItem = function (WrappedComponent, options) {
|
|
932
1071
|
if (options === void 0) {
|
|
933
1072
|
options = {};
|
|
934
1073
|
}
|
|
935
1074
|
return _ref => {
|
|
1075
|
+
var _popupMetrics$left;
|
|
936
1076
|
let value = _ref.value,
|
|
937
1077
|
onChange = _ref.onChange,
|
|
938
1078
|
interceptor = _ref.interceptor,
|
|
939
1079
|
label = _ref.label,
|
|
940
1080
|
render = _ref.render,
|
|
941
|
-
props = _objectWithoutPropertiesLoose(_ref, _excluded$
|
|
1081
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$b);
|
|
942
1082
|
const _useState = react.useState(false),
|
|
943
1083
|
open = _useState[0],
|
|
944
1084
|
setOpen = _useState[1];
|
|
1085
|
+
const _useMobileFixedMode = useMobileFixedMode(),
|
|
1086
|
+
isMobile = _useMobileFixedMode.isMobile,
|
|
1087
|
+
useBoundaryMount = _useMobileFixedMode.useBoundaryMount;
|
|
1088
|
+
const fixedModeClass = useBoundaryMount ? style$1['is-boundary'] : style$1['is-viewport'];
|
|
945
1089
|
const _useState2 = react.useState(false),
|
|
946
|
-
|
|
947
|
-
|
|
1090
|
+
renderMask = _useState2[0],
|
|
1091
|
+
setRenderMask = _useState2[1];
|
|
948
1092
|
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({
|
|
1093
|
+
maskClosing = _useState3[0],
|
|
1094
|
+
setMaskClosing = _useState3[1];
|
|
1095
|
+
const _useState4 = react.useState({
|
|
955
1096
|
top: 0,
|
|
956
1097
|
pageTop: 0,
|
|
957
1098
|
height: 0
|
|
958
1099
|
}),
|
|
959
|
-
popupMetrics =
|
|
960
|
-
setPopupMetrics =
|
|
1100
|
+
popupMetrics = _useState4[0],
|
|
1101
|
+
setPopupMetrics = _useState4[1];
|
|
961
1102
|
const triggerRef = react.useRef(null);
|
|
1103
|
+
const getBoundaryElement = responsiveUtils.usePopupContainer();
|
|
1104
|
+
const getScrollElement = responsiveUtils.useScrollElement();
|
|
1105
|
+
const resolveGetPopupContainer = react.useCallback(triggerNode => {
|
|
1106
|
+
if (typeof props.getPopupContainer === 'function') {
|
|
1107
|
+
const customContainer = props.getPopupContainer(triggerNode);
|
|
1108
|
+
if (customContainer) {
|
|
1109
|
+
return customContainer;
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
if (!isMobile) {
|
|
1113
|
+
return getBoundaryElement();
|
|
1114
|
+
}
|
|
1115
|
+
if (useBoundaryMount) {
|
|
1116
|
+
return getBoundaryElement();
|
|
1117
|
+
}
|
|
1118
|
+
return typeof document !== 'undefined' ? document.body : null;
|
|
1119
|
+
}, [getBoundaryElement, isMobile, props.getPopupContainer, useBoundaryMount]);
|
|
1120
|
+
const popupMountNode = typeof document !== 'undefined' ? isMobile ? useBoundaryMount ? getBoundaryElement() || document.body : document.body : getBoundaryElement() || document.body : null;
|
|
962
1121
|
const setMobilePopupVariables = react.useCallback(metrics => {
|
|
963
1122
|
if (typeof document === 'undefined') return;
|
|
964
1123
|
document.body.style.setProperty('--react-filter-field-mobile-height', metrics.height + "px");
|
|
@@ -967,37 +1126,16 @@ const withFieldItem = function (WrappedComponent, options) {
|
|
|
967
1126
|
}, []);
|
|
968
1127
|
const updatePopupMetrics = react.useCallback(() => {
|
|
969
1128
|
if (typeof window === 'undefined' || !triggerRef.current) return;
|
|
970
|
-
const
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
};
|
|
1129
|
+
const metrics = getMobilePopupMetrics(triggerRef.current, {
|
|
1130
|
+
scrollEl: getScrollElement(),
|
|
1131
|
+
boundaryEl: getBoundaryElement(),
|
|
1132
|
+
useBoundaryMount,
|
|
1133
|
+
offset: MOBILE_POPUP_OFFSET$1
|
|
1134
|
+
});
|
|
976
1135
|
setPopupMetrics(metrics);
|
|
977
1136
|
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]);
|
|
1137
|
+
}, [getBoundaryElement, getScrollElement, setMobilePopupVariables, useBoundaryMount]);
|
|
1138
|
+
useResponsiveScrollListener(updatePopupMetrics, open && isMobile);
|
|
1001
1139
|
react.useEffect(() => {
|
|
1002
1140
|
if (typeof document === 'undefined' || !isMobile || popupMetrics.height <= 0) return;
|
|
1003
1141
|
setMobilePopupVariables(popupMetrics);
|
|
@@ -1041,14 +1179,15 @@ const withFieldItem = function (WrappedComponent, options) {
|
|
|
1041
1179
|
'--react-filter-popover-mobile-height': popupMetrics.height + "px",
|
|
1042
1180
|
'--react-filter-field-mobile-top': popupMetrics.top + "px",
|
|
1043
1181
|
top: popupMetrics.top,
|
|
1044
|
-
left: 0
|
|
1182
|
+
left: (_popupMetrics$left = popupMetrics.left) != null ? _popupMetrics$left : 0,
|
|
1183
|
+
zIndex: MOBILE_POPUP_Z_INDEX
|
|
1045
1184
|
} : undefined;
|
|
1046
1185
|
const mergePopupClassNames = classNames => {
|
|
1047
1186
|
var _classNames$popup;
|
|
1048
1187
|
if (!isMobile) return classNames;
|
|
1049
1188
|
return Object.assign({}, classNames, {
|
|
1050
1189
|
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)
|
|
1190
|
+
root: classnames__default["default"](classNames == null || (_classNames$popup = classNames.popup) == null ? void 0 : _classNames$popup.root, style$1['field-item-mobile-popup'], FIELD_MOBILE_POPUP_CLASS$1, fixedModeClass)
|
|
1052
1191
|
})
|
|
1053
1192
|
});
|
|
1054
1193
|
};
|
|
@@ -1075,9 +1214,10 @@ const withFieldItem = function (WrappedComponent, options) {
|
|
|
1075
1214
|
valueType: "all",
|
|
1076
1215
|
onOpenChange: handleOpenChange,
|
|
1077
1216
|
onDropdownVisibleChange: handleOpenChange,
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1217
|
+
getPopupContainer: resolveGetPopupContainer,
|
|
1218
|
+
popupClassName: classnames__default["default"](props.popupClassName, isMobile && style$1['field-item-mobile-popup'], isMobile && FIELD_MOBILE_POPUP_CLASS$1, isMobile && fixedModeClass),
|
|
1219
|
+
dropdownClassName: classnames__default["default"](props.dropdownClassName, isMobile && style$1['field-item-mobile-popup'], isMobile && FIELD_MOBILE_POPUP_CLASS$1, isMobile && fixedModeClass),
|
|
1220
|
+
overlayClassName: classnames__default["default"](props.overlayClassName, isMobile && style$1['field-item-mobile-popup'], isMobile && FIELD_MOBILE_POPUP_CLASS$1, isMobile && fixedModeClass),
|
|
1081
1221
|
overlayStyle: Object.assign({}, props.overlayStyle, mobilePopupStyle),
|
|
1082
1222
|
popupStyle: Object.assign({}, props.popupStyle, mobilePopupStyle),
|
|
1083
1223
|
dropdownStyle: Object.assign({}, props.dropdownStyle, mobilePopupStyle),
|
|
@@ -1089,21 +1229,27 @@ const withFieldItem = function (WrappedComponent, options) {
|
|
|
1089
1229
|
offset: [0, 0]
|
|
1090
1230
|
} : props.align,
|
|
1091
1231
|
isPopup: options.forcePopup ? true : props.isPopup,
|
|
1092
|
-
|
|
1232
|
+
zIndex: isMobile ? MOBILE_POPUP_Z_INDEX : props.zIndex,
|
|
1233
|
+
overlayWidth: isMobile && options.forcePopup ? typeof window === 'undefined' ? props.overlayWidth : getMobilePopupMetrics(triggerRef.current, {
|
|
1234
|
+
scrollEl: getScrollElement(),
|
|
1235
|
+
boundaryEl: getBoundaryElement(),
|
|
1236
|
+
useBoundaryMount
|
|
1237
|
+
}).width || window.innerWidth : props.overlayWidth
|
|
1093
1238
|
}));
|
|
1094
1239
|
};
|
|
1095
1240
|
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']),
|
|
1241
|
+
children: [renderMask && popupMountNode && /*#__PURE__*/reactDom.createPortal(/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
1242
|
+
className: classnames__default["default"](style$1['pop-util-mask'], maskClosing && style$1['pop-util-mask-leave'], fixedModeClass),
|
|
1098
1243
|
style: {
|
|
1099
1244
|
top: popupMetrics.top,
|
|
1100
|
-
height: popupMetrics.height
|
|
1245
|
+
height: popupMetrics.height,
|
|
1246
|
+
zIndex: MOBILE_MASK_Z_INDEX
|
|
1101
1247
|
},
|
|
1102
1248
|
onClick: closeFieldItem,
|
|
1103
1249
|
onTouchMove: e => {
|
|
1104
1250
|
e.preventDefault();
|
|
1105
1251
|
}
|
|
1106
|
-
}),
|
|
1252
|
+
}), popupMountNode), /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
1107
1253
|
ref: triggerRef,
|
|
1108
1254
|
children: /*#__PURE__*/jsxRuntime.jsx(FilterItem, {
|
|
1109
1255
|
label: label,
|
|
@@ -1127,6 +1273,7 @@ const isNotEmpty = value => {
|
|
|
1127
1273
|
const MASK_ANIMATION_DURATION = 180;
|
|
1128
1274
|
const MOBILE_POPUP_OFFSET = 4;
|
|
1129
1275
|
const PopoverItem = withLocale(_ref => {
|
|
1276
|
+
var _popupMetrics$left;
|
|
1130
1277
|
let value = _ref.value,
|
|
1131
1278
|
label = _ref.label,
|
|
1132
1279
|
onValidate = _ref.onValidate,
|
|
@@ -1135,6 +1282,7 @@ const PopoverItem = withLocale(_ref => {
|
|
|
1135
1282
|
placement = _ref$placement === void 0 ? 'bottomLeft' : _ref$placement,
|
|
1136
1283
|
onOpenChange = _ref.onOpenChange,
|
|
1137
1284
|
onChange = _ref.onChange,
|
|
1285
|
+
customGetPopupContainer = _ref.getPopupContainer,
|
|
1138
1286
|
children = _ref.children;
|
|
1139
1287
|
const _useState = react.useState(value),
|
|
1140
1288
|
state = _useState[0],
|
|
@@ -1142,22 +1290,41 @@ const PopoverItem = withLocale(_ref => {
|
|
|
1142
1290
|
const _useState2 = react.useState(false),
|
|
1143
1291
|
open = _useState2[0],
|
|
1144
1292
|
setOpen = _useState2[1];
|
|
1293
|
+
const _useMobileFixedMode = useMobileFixedMode(),
|
|
1294
|
+
isMobile = _useMobileFixedMode.isMobile,
|
|
1295
|
+
useBoundaryMount = _useMobileFixedMode.useBoundaryMount;
|
|
1296
|
+
const fixedModeClass = useBoundaryMount ? style$1['is-boundary'] : style$1['is-viewport'];
|
|
1297
|
+
const getBoundaryElement = responsiveUtils.usePopupContainer();
|
|
1298
|
+
const getScrollElement = responsiveUtils.useScrollElement();
|
|
1299
|
+
const resolveGetPopupContainer = react.useCallback(triggerNode => {
|
|
1300
|
+
if (typeof customGetPopupContainer === 'function') {
|
|
1301
|
+
const customContainer = customGetPopupContainer(triggerNode);
|
|
1302
|
+
if (customContainer) {
|
|
1303
|
+
return customContainer;
|
|
1304
|
+
}
|
|
1305
|
+
}
|
|
1306
|
+
if (!isMobile) {
|
|
1307
|
+
return getBoundaryElement();
|
|
1308
|
+
}
|
|
1309
|
+
if (useBoundaryMount) {
|
|
1310
|
+
return getBoundaryElement();
|
|
1311
|
+
}
|
|
1312
|
+
return typeof document !== 'undefined' ? document.body : null;
|
|
1313
|
+
}, [customGetPopupContainer, getBoundaryElement, isMobile, useBoundaryMount]);
|
|
1314
|
+
const popupMountNode = typeof document !== 'undefined' ? isMobile ? useBoundaryMount ? getBoundaryElement() || document.body : document.body : getBoundaryElement() || document.body : null;
|
|
1145
1315
|
const _useState3 = react.useState(false),
|
|
1146
|
-
|
|
1147
|
-
|
|
1316
|
+
renderMask = _useState3[0],
|
|
1317
|
+
setRenderMask = _useState3[1];
|
|
1148
1318
|
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({
|
|
1319
|
+
maskClosing = _useState4[0],
|
|
1320
|
+
setMaskClosing = _useState4[1];
|
|
1321
|
+
const _useState5 = react.useState({
|
|
1155
1322
|
top: 0,
|
|
1156
1323
|
pageTop: 0,
|
|
1157
1324
|
height: 0
|
|
1158
1325
|
}),
|
|
1159
|
-
popupMetrics =
|
|
1160
|
-
setPopupMetrics =
|
|
1326
|
+
popupMetrics = _useState5[0],
|
|
1327
|
+
setPopupMetrics = _useState5[1];
|
|
1161
1328
|
const triggerRef = react.useRef(null);
|
|
1162
1329
|
const disabled = react.useMemo(() => {
|
|
1163
1330
|
return onValidate && !onValidate(state);
|
|
@@ -1166,37 +1333,17 @@ const PopoverItem = withLocale(_ref => {
|
|
|
1166
1333
|
moduleName: 'Filter'
|
|
1167
1334
|
}),
|
|
1168
1335
|
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
1336
|
const updatePopupMetrics = react.useCallback(() => {
|
|
1182
1337
|
if (typeof window === 'undefined' || !triggerRef.current) return;
|
|
1183
|
-
const
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1338
|
+
const metrics = getMobilePopupMetrics(triggerRef.current, {
|
|
1339
|
+
scrollEl: getScrollElement(),
|
|
1340
|
+
boundaryEl: getBoundaryElement(),
|
|
1341
|
+
useBoundaryMount,
|
|
1342
|
+
offset: MOBILE_POPUP_OFFSET
|
|
1188
1343
|
});
|
|
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]);
|
|
1344
|
+
setPopupMetrics(metrics);
|
|
1345
|
+
}, [getBoundaryElement, getScrollElement, useBoundaryMount]);
|
|
1346
|
+
useResponsiveScrollListener(updatePopupMetrics, open && isMobile);
|
|
1200
1347
|
react.useEffect(() => {
|
|
1201
1348
|
if (open && isMobile) {
|
|
1202
1349
|
setRenderMask(true);
|
|
@@ -1228,7 +1375,8 @@ const PopoverItem = withLocale(_ref => {
|
|
|
1228
1375
|
const mobileOverlayStyle = isMobile ? {
|
|
1229
1376
|
'--react-filter-popover-mobile-height': popupMetrics.height + "px",
|
|
1230
1377
|
top: popupMetrics.top,
|
|
1231
|
-
left: 0
|
|
1378
|
+
left: (_popupMetrics$left = popupMetrics.left) != null ? _popupMetrics$left : 0,
|
|
1379
|
+
zIndex: MOBILE_POPUP_Z_INDEX
|
|
1232
1380
|
} : undefined;
|
|
1233
1381
|
const overlayContent = /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1234
1382
|
className: style$1['pop-util-body'],
|
|
@@ -1270,17 +1418,18 @@ const PopoverItem = withLocale(_ref => {
|
|
|
1270
1418
|
})]
|
|
1271
1419
|
});
|
|
1272
1420
|
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']),
|
|
1421
|
+
children: [renderMask && popupMountNode && /*#__PURE__*/reactDom.createPortal(/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
1422
|
+
className: classnames__default["default"](style$1['pop-util-mask'], maskClosing && style$1['pop-util-mask-leave'], fixedModeClass),
|
|
1275
1423
|
style: {
|
|
1276
1424
|
top: popupMetrics.top,
|
|
1277
|
-
height: popupMetrics.height
|
|
1425
|
+
height: popupMetrics.height,
|
|
1426
|
+
zIndex: MOBILE_MASK_Z_INDEX
|
|
1278
1427
|
},
|
|
1279
1428
|
onClick: closeDropdown,
|
|
1280
1429
|
onTouchMove: e => {
|
|
1281
1430
|
e.preventDefault();
|
|
1282
1431
|
}
|
|
1283
|
-
}),
|
|
1432
|
+
}), popupMountNode), /*#__PURE__*/jsxRuntime.jsx(antd.Dropdown, {
|
|
1284
1433
|
open: open,
|
|
1285
1434
|
trigger: ['click'],
|
|
1286
1435
|
placement: isMobile ? 'bottomLeft' : placement,
|
|
@@ -1288,7 +1437,9 @@ const PopoverItem = withLocale(_ref => {
|
|
|
1288
1437
|
align: isMobile ? {
|
|
1289
1438
|
offset: [0, 0]
|
|
1290
1439
|
} : undefined,
|
|
1291
|
-
|
|
1440
|
+
getPopupContainer: resolveGetPopupContainer,
|
|
1441
|
+
zIndex: isMobile ? MOBILE_POPUP_Z_INDEX : undefined,
|
|
1442
|
+
overlayClassName: classnames__default["default"](style$1['pop-util-overlay'], overlayClassName, isMobile && fixedModeClass),
|
|
1292
1443
|
overlayStyle: mobileOverlayStyle,
|
|
1293
1444
|
onOpenChange: handleOpenChange,
|
|
1294
1445
|
menu: {
|
|
@@ -1310,17 +1461,17 @@ const PopoverItem = withLocale(_ref => {
|
|
|
1310
1461
|
});
|
|
1311
1462
|
});
|
|
1312
1463
|
|
|
1313
|
-
const
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1464
|
+
const _excluded$a = ["label", "value", "onChange", "placeholder", "onValidate", "overlayClassName", "placement", "onOpenChange"];
|
|
1465
|
+
const InputFilterItem$2 = withLocale(_ref => {
|
|
1466
|
+
let label = _ref.label,
|
|
1467
|
+
value = _ref.value,
|
|
1468
|
+
onChange = _ref.onChange,
|
|
1469
|
+
placeholder = _ref.placeholder,
|
|
1470
|
+
onValidate = _ref.onValidate,
|
|
1471
|
+
overlayClassName = _ref.overlayClassName,
|
|
1472
|
+
placement = _ref.placement,
|
|
1473
|
+
onOpenChange = _ref.onOpenChange,
|
|
1474
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$a);
|
|
1324
1475
|
return /*#__PURE__*/jsxRuntime.jsx(PopoverItem, {
|
|
1325
1476
|
label: label,
|
|
1326
1477
|
value: value,
|
|
@@ -1329,22 +1480,23 @@ const InputFilterItem$2 = withLocale(({
|
|
|
1329
1480
|
overlayClassName,
|
|
1330
1481
|
placement,
|
|
1331
1482
|
onOpenChange,
|
|
1332
|
-
children:
|
|
1333
|
-
value,
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
}
|
|
1344
|
-
}
|
|
1483
|
+
children: _ref2 => {
|
|
1484
|
+
let value = _ref2.value,
|
|
1485
|
+
onChange = _ref2.onChange;
|
|
1486
|
+
return /*#__PURE__*/jsxRuntime.jsx(antd.Input, _extends({}, props, {
|
|
1487
|
+
placeholder: placeholder || "\u8BF7\u8F93\u5165" + label,
|
|
1488
|
+
className: style$1['filter-item-text'],
|
|
1489
|
+
value: get__default["default"](value, 'value', ''),
|
|
1490
|
+
onChange: e => onChange(e.target.value ? {
|
|
1491
|
+
label: e.target.value,
|
|
1492
|
+
value: e.target.value
|
|
1493
|
+
} : null)
|
|
1494
|
+
}));
|
|
1495
|
+
}
|
|
1345
1496
|
});
|
|
1346
1497
|
});
|
|
1347
1498
|
|
|
1499
|
+
const _excluded$9 = ["label", "value", "onChange", "placeholder", "onValidate", "overlayClassName", "placement", "onOpenChange", "unit"];
|
|
1348
1500
|
const computedFilterValue = (range, unit, formatMessage) => {
|
|
1349
1501
|
if (!isNumber__default["default"](range[0]) && !isNumber__default["default"](range[1])) {
|
|
1350
1502
|
return null;
|
|
@@ -1352,7 +1504,7 @@ const computedFilterValue = (range, unit, formatMessage) => {
|
|
|
1352
1504
|
return {
|
|
1353
1505
|
label: (range => {
|
|
1354
1506
|
if (isNumber__default["default"](range[0]) && isNumber__default["default"](range[1])) {
|
|
1355
|
-
return
|
|
1507
|
+
return range[0] + "-" + range[1] + (unit || '');
|
|
1356
1508
|
}
|
|
1357
1509
|
if (isNumber__default["default"](range[0])) {
|
|
1358
1510
|
return formatMessage({
|
|
@@ -1378,23 +1530,22 @@ const defaultPropsOnValidate = value => {
|
|
|
1378
1530
|
const range = get__default["default"](value, 'value');
|
|
1379
1531
|
return !(range && isNumber__default["default"](range[0]) && isNumber__default["default"](range[1]) && range[1] < range[0]);
|
|
1380
1532
|
};
|
|
1381
|
-
const NumberRangeFilterItem$1 = withLocale(
|
|
1382
|
-
label,
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
const {
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
});
|
|
1533
|
+
const NumberRangeFilterItem$1 = withLocale(_ref => {
|
|
1534
|
+
let label = _ref.label,
|
|
1535
|
+
value = _ref.value,
|
|
1536
|
+
onChange = _ref.onChange,
|
|
1537
|
+
placeholder = _ref.placeholder,
|
|
1538
|
+
_ref$onValidate = _ref.onValidate,
|
|
1539
|
+
onValidate = _ref$onValidate === void 0 ? defaultPropsOnValidate : _ref$onValidate,
|
|
1540
|
+
overlayClassName = _ref.overlayClassName,
|
|
1541
|
+
placement = _ref.placement,
|
|
1542
|
+
onOpenChange = _ref.onOpenChange,
|
|
1543
|
+
unit = _ref.unit,
|
|
1544
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$9);
|
|
1545
|
+
const _useIntl = reactIntl.useIntl({
|
|
1546
|
+
moduleName: 'Filter'
|
|
1547
|
+
}),
|
|
1548
|
+
formatMessage = _useIntl.formatMessage;
|
|
1398
1549
|
return /*#__PURE__*/jsxRuntime.jsx(PopoverItem, {
|
|
1399
1550
|
label: label,
|
|
1400
1551
|
value: value,
|
|
@@ -1403,136 +1554,141 @@ const NumberRangeFilterItem$1 = withLocale(({
|
|
|
1403
1554
|
overlayClassName,
|
|
1404
1555
|
placement,
|
|
1405
1556
|
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
|
-
})
|
|
1557
|
+
children: _ref2 => {
|
|
1558
|
+
let value = _ref2.value,
|
|
1559
|
+
onChange = _ref2.onChange;
|
|
1560
|
+
return /*#__PURE__*/jsxRuntime.jsxs(antd.Space.Compact, {
|
|
1561
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(antd.InputNumber, _extends({}, props, {
|
|
1562
|
+
placeholder: placeholder || "" + formatMessage({
|
|
1563
|
+
id: 'pleaseInput'
|
|
1564
|
+
}) + label,
|
|
1565
|
+
className: style$1['filter-item-number-range'],
|
|
1566
|
+
value: get__default["default"](value, 'value[0]', ''),
|
|
1567
|
+
onChange: target => {
|
|
1568
|
+
onChange(computedFilterValue([target, get__default["default"](value, 'value[1]')], unit, formatMessage));
|
|
1569
|
+
}
|
|
1570
|
+
})), /*#__PURE__*/jsxRuntime.jsx(antd.Input, {
|
|
1571
|
+
style: {
|
|
1572
|
+
width: 30,
|
|
1573
|
+
borderLeft: 0,
|
|
1574
|
+
borderRight: 0,
|
|
1575
|
+
pointerEvents: 'none'
|
|
1576
|
+
},
|
|
1577
|
+
placeholder: "~",
|
|
1578
|
+
disabled: true
|
|
1579
|
+
}), /*#__PURE__*/jsxRuntime.jsx(antd.InputNumber, _extends({}, props, {
|
|
1580
|
+
placeholder: placeholder || "" + formatMessage({
|
|
1581
|
+
id: 'pleaseInput'
|
|
1582
|
+
}) + label,
|
|
1583
|
+
className: style$1['filter-item-number-range'],
|
|
1584
|
+
value: get__default["default"](value, 'value[1]', ''),
|
|
1585
|
+
onChange: target => {
|
|
1586
|
+
onChange(computedFilterValue([get__default["default"](value, 'value[0]'), target], unit, formatMessage));
|
|
1587
|
+
}
|
|
1588
|
+
})), unit && /*#__PURE__*/jsxRuntime.jsx(antd.Input, {
|
|
1589
|
+
style: {
|
|
1590
|
+
width: 50,
|
|
1591
|
+
borderLeft: 0
|
|
1592
|
+
},
|
|
1593
|
+
value: unit,
|
|
1594
|
+
disabled: true
|
|
1595
|
+
})]
|
|
1596
|
+
});
|
|
1597
|
+
}
|
|
1448
1598
|
});
|
|
1449
1599
|
});
|
|
1450
1600
|
|
|
1451
|
-
const
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1601
|
+
const _excluded$8 = ["value", "onChange", "picker"];
|
|
1602
|
+
const DatePickerFilterItem = withLocale(withFieldItem(_ref => {
|
|
1603
|
+
var _props$classNames, _props$classNames2;
|
|
1604
|
+
let value = _ref.value,
|
|
1605
|
+
onChange = _ref.onChange,
|
|
1606
|
+
_ref$picker = _ref.picker,
|
|
1607
|
+
picker = _ref$picker === void 0 ? 'date' : _ref$picker,
|
|
1608
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$8);
|
|
1609
|
+
return /*#__PURE__*/jsxRuntime.jsx(antd.DatePicker, _extends({}, props, {
|
|
1459
1610
|
inputReadOnly: true,
|
|
1460
1611
|
picker: picker,
|
|
1461
|
-
classNames: {
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
}
|
|
1467
|
-
},
|
|
1612
|
+
classNames: _extends({}, props.classNames, {
|
|
1613
|
+
popup: _extends({}, (_props$classNames = props.classNames) == null ? void 0 : _props$classNames.popup, {
|
|
1614
|
+
root: classnames__default["default"]((_props$classNames2 = props.classNames) == null || (_props$classNames2 = _props$classNames2.popup) == null ? void 0 : _props$classNames2.root, style$1['date-picker-popup'])
|
|
1615
|
+
})
|
|
1616
|
+
}),
|
|
1468
1617
|
value: value && dayjs__default["default"](value.value),
|
|
1469
1618
|
onChange: value => {
|
|
1470
|
-
const {
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
format
|
|
1474
|
-
}, props);
|
|
1619
|
+
const _Object$assign = Object.assign({
|
|
1620
|
+
format: 'YYYY-MM-DD'
|
|
1621
|
+
}, props),
|
|
1622
|
+
format = _Object$assign.format;
|
|
1475
1623
|
value && onChange({
|
|
1476
|
-
label: picker !== 'date' ?
|
|
1624
|
+
label: picker !== 'date' ? value.startOf(picker).format(format) + "~" + value.endOf(picker).format(format) : value.format(format),
|
|
1477
1625
|
value: new Date(value.startOf(picker).valueOf())
|
|
1478
1626
|
});
|
|
1479
1627
|
}
|
|
1480
|
-
});
|
|
1628
|
+
}));
|
|
1481
1629
|
}));
|
|
1482
1630
|
|
|
1483
|
-
const
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1631
|
+
const _excluded$7 = ["value", "onChange", "header"];
|
|
1632
|
+
const DateRangePickerFilterItem = withLocale(withFieldItem(_ref => {
|
|
1633
|
+
var _props$classNames, _props$classNames2;
|
|
1634
|
+
let value = _ref.value,
|
|
1635
|
+
onChange = _ref.onChange,
|
|
1636
|
+
header = _ref.header,
|
|
1637
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$7);
|
|
1489
1638
|
return /*#__PURE__*/jsxRuntime.jsxs(antd.Flex, {
|
|
1490
1639
|
vertical: true,
|
|
1491
1640
|
children: [typeof header === 'function' ? header({
|
|
1492
1641
|
value,
|
|
1493
1642
|
onChange
|
|
1494
|
-
}) : header, /*#__PURE__*/jsxRuntime.jsx(antd.DatePicker.RangePicker, {
|
|
1495
|
-
...props,
|
|
1643
|
+
}) : header, /*#__PURE__*/jsxRuntime.jsx(antd.DatePicker.RangePicker, _extends({}, props, {
|
|
1496
1644
|
inputReadOnly: true,
|
|
1497
1645
|
allowEmpty: [false, false],
|
|
1498
|
-
classNames: {
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
}
|
|
1504
|
-
},
|
|
1646
|
+
classNames: _extends({}, props.classNames, {
|
|
1647
|
+
popup: _extends({}, (_props$classNames = props.classNames) == null ? void 0 : _props$classNames.popup, {
|
|
1648
|
+
root: classnames__default["default"]((_props$classNames2 = props.classNames) == null || (_props$classNames2 = _props$classNames2.popup) == null ? void 0 : _props$classNames2.root, style$1['date-range-picker-popup'])
|
|
1649
|
+
})
|
|
1650
|
+
}),
|
|
1505
1651
|
value: value && Array.isArray(value.value) && value.value.length === 2 && value.value.map(item => dayjs__default["default"](item)),
|
|
1506
1652
|
onChange: value => {
|
|
1507
|
-
const {
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
format
|
|
1511
|
-
}, props);
|
|
1653
|
+
const _Object$assign = Object.assign({
|
|
1654
|
+
format: 'YYYY-MM-DD'
|
|
1655
|
+
}, props),
|
|
1656
|
+
format = _Object$assign.format;
|
|
1512
1657
|
onChange({
|
|
1513
1658
|
label: value.map(item => item.format(format)).join('~'),
|
|
1514
1659
|
value: value.map(item => new Date(item.valueOf()))
|
|
1515
1660
|
});
|
|
1516
1661
|
}
|
|
1517
|
-
})]
|
|
1662
|
+
}))]
|
|
1518
1663
|
});
|
|
1519
1664
|
}));
|
|
1520
1665
|
|
|
1521
1666
|
var style = {"shortcuts-container":"kne-react-filter_3w4Bb","shortcut-item":"kne-react-filter_myRhG","is-active":"kne-react-filter_FowoG"};
|
|
1522
1667
|
|
|
1523
|
-
const _excluded$
|
|
1668
|
+
const _excluded$6 = ["value", "onChange", "defaultValue", "shortcuts", "shortcutOptions"];
|
|
1669
|
+
const FIELD_MOBILE_POPUP_CLASS = 'react-filter-field-mobile-popup';
|
|
1524
1670
|
const TypeDateRangePickerField = _ref => {
|
|
1671
|
+
var _props$classNames, _props$classNames2, _props$styles, _props$styles2;
|
|
1525
1672
|
let valueProp = _ref.value,
|
|
1526
1673
|
onChangeProp = _ref.onChange,
|
|
1527
1674
|
defaultValue = _ref.defaultValue,
|
|
1528
1675
|
_ref$shortcuts = _ref.shortcuts,
|
|
1529
1676
|
shortcuts = _ref$shortcuts === void 0 ? true : _ref$shortcuts,
|
|
1530
1677
|
shortcutOptions = _ref.shortcutOptions,
|
|
1531
|
-
props = _objectWithoutPropertiesLoose(_ref, _excluded$
|
|
1678
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$6);
|
|
1532
1679
|
const _useIntl = reactIntl.useIntl({
|
|
1533
1680
|
moduleName: 'Filter'
|
|
1534
1681
|
}),
|
|
1535
1682
|
formatMessage = _useIntl.formatMessage;
|
|
1683
|
+
const getPopupContainer = responsiveUtils.usePopupContainer();
|
|
1684
|
+
const _useMobileFixedMode = useMobileFixedMode(),
|
|
1685
|
+
isMobile = _useMobileFixedMode.isMobile,
|
|
1686
|
+
useBoundaryMount = _useMobileFixedMode.useBoundaryMount;
|
|
1687
|
+
const fixedModeClass = useBoundaryMount ? style['is-boundary'] : style['is-viewport'];
|
|
1688
|
+
const nestedPopupClassName = classnames__default["default"](style['field-item-mobile-popup'], FIELD_MOBILE_POPUP_CLASS, fixedModeClass);
|
|
1689
|
+
const nestedPopupStyle = isMobile ? {
|
|
1690
|
+
zIndex: MOBILE_POPUP_Z_INDEX
|
|
1691
|
+
} : undefined;
|
|
1536
1692
|
const typeList = new Map([['date', formatMessage({
|
|
1537
1693
|
id: 'customTime'
|
|
1538
1694
|
})], ['month', formatMessage({
|
|
@@ -1626,6 +1782,19 @@ const TypeDateRangePickerField = _ref => {
|
|
|
1626
1782
|
style: {
|
|
1627
1783
|
width: '120px'
|
|
1628
1784
|
},
|
|
1785
|
+
getPopupContainer: getPopupContainer,
|
|
1786
|
+
popupClassName: isMobile ? nestedPopupClassName : undefined,
|
|
1787
|
+
classNames: isMobile ? {
|
|
1788
|
+
popup: {
|
|
1789
|
+
root: nestedPopupClassName
|
|
1790
|
+
}
|
|
1791
|
+
} : undefined,
|
|
1792
|
+
popupStyle: nestedPopupStyle,
|
|
1793
|
+
styles: isMobile ? {
|
|
1794
|
+
popup: {
|
|
1795
|
+
root: nestedPopupStyle
|
|
1796
|
+
}
|
|
1797
|
+
} : undefined,
|
|
1629
1798
|
value: (value == null ? void 0 : value.type) || 'date',
|
|
1630
1799
|
onChange: typeValue => {
|
|
1631
1800
|
onChange(currentValue => {
|
|
@@ -1653,6 +1822,18 @@ const TypeDateRangePickerField = _ref => {
|
|
|
1653
1822
|
};
|
|
1654
1823
|
})
|
|
1655
1824
|
}), /*#__PURE__*/jsxRuntime.jsx(antd.DatePicker.RangePicker, _extends({}, props, {
|
|
1825
|
+
getPopupContainer: getPopupContainer,
|
|
1826
|
+
classNames: isMobile ? _extends({}, props.classNames, {
|
|
1827
|
+
popup: _extends({}, (_props$classNames = props.classNames) == null ? void 0 : _props$classNames.popup, {
|
|
1828
|
+
root: classnames__default["default"]((_props$classNames2 = props.classNames) == null || (_props$classNames2 = _props$classNames2.popup) == null ? void 0 : _props$classNames2.root, nestedPopupClassName)
|
|
1829
|
+
})
|
|
1830
|
+
}) : props.classNames,
|
|
1831
|
+
styles: isMobile ? _extends({}, props.styles, {
|
|
1832
|
+
popup: _extends({}, (_props$styles = props.styles) == null ? void 0 : _props$styles.popup, {
|
|
1833
|
+
root: Object.assign({}, (_props$styles2 = props.styles) == null || (_props$styles2 = _props$styles2.popup) == null ? void 0 : _props$styles2.root, nestedPopupStyle)
|
|
1834
|
+
})
|
|
1835
|
+
}) : props.styles,
|
|
1836
|
+
popupStyle: nestedPopupStyle,
|
|
1656
1837
|
picker: (value == null ? void 0 : value.type) || 'date',
|
|
1657
1838
|
value: Array.isArray(value == null ? void 0 : value.value) && value.value.length === 2 ? value.value.map(item => item && dayjs__default["default"](item)) : null,
|
|
1658
1839
|
onChange: dateValue => {
|
|
@@ -1669,47 +1850,46 @@ const TypeDateRangePickerField = _ref => {
|
|
|
1669
1850
|
});
|
|
1670
1851
|
};
|
|
1671
1852
|
|
|
1672
|
-
const
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1853
|
+
const _excluded$5 = ["label", "value", "onChange"];
|
|
1854
|
+
const TypeDateRangePickerFilterItem = withLocale(_ref => {
|
|
1855
|
+
let label = _ref.label,
|
|
1856
|
+
value = _ref.value,
|
|
1857
|
+
onChange = _ref.onChange,
|
|
1858
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$5);
|
|
1678
1859
|
return /*#__PURE__*/jsxRuntime.jsx(PopoverItem, {
|
|
1679
1860
|
label: label,
|
|
1680
1861
|
value: value,
|
|
1681
1862
|
onChange: onChange,
|
|
1682
1863
|
onValidate: item => {
|
|
1683
|
-
const itemValue = item
|
|
1684
|
-
return itemValue
|
|
1864
|
+
const itemValue = item == null ? void 0 : item.value;
|
|
1865
|
+
return (itemValue == null ? void 0 : itemValue.type) && Array.isArray(itemValue == null ? void 0 : itemValue.value) && itemValue.value.length === 2;
|
|
1685
1866
|
},
|
|
1686
|
-
children:
|
|
1687
|
-
value,
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1867
|
+
children: _ref2 => {
|
|
1868
|
+
let value = _ref2.value,
|
|
1869
|
+
onChange = _ref2.onChange;
|
|
1870
|
+
return /*#__PURE__*/jsxRuntime.jsx(TypeDateRangePickerField, _extends({}, props, {
|
|
1871
|
+
inputReadOnly: true,
|
|
1872
|
+
className: style$1['filter-item-text'],
|
|
1873
|
+
value: get__default["default"](value, 'value'),
|
|
1874
|
+
onChange: pickerValue => {
|
|
1875
|
+
const _props$format = props.format,
|
|
1876
|
+
format = _props$format === void 0 ? 'YYYY-MM-DD' : _props$format;
|
|
1877
|
+
const val = (pickerValue == null ? void 0 : pickerValue.value) || [];
|
|
1878
|
+
let displayLabel = '';
|
|
1879
|
+
if (val[0] && !val[1]) {
|
|
1880
|
+
displayLabel = dayjs__default["default"](val[0]).format(format) + "\u4EE5\u540E";
|
|
1881
|
+
} else if (!val[0] && val[1]) {
|
|
1882
|
+
displayLabel = dayjs__default["default"](val[1]).format(format) + "\u4EE5\u524D";
|
|
1883
|
+
} else if (val[0] && val[1]) {
|
|
1884
|
+
displayLabel = dayjs__default["default"](val[0]).format(format) + "~" + dayjs__default["default"](val[1]).format(format);
|
|
1885
|
+
}
|
|
1886
|
+
onChange({
|
|
1887
|
+
label: displayLabel,
|
|
1888
|
+
value: pickerValue
|
|
1889
|
+
});
|
|
1706
1890
|
}
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
value: pickerValue
|
|
1710
|
-
});
|
|
1711
|
-
}
|
|
1712
|
-
})
|
|
1891
|
+
}));
|
|
1892
|
+
}
|
|
1713
1893
|
});
|
|
1714
1894
|
});
|
|
1715
1895
|
|
|
@@ -2608,6 +2788,7 @@ const CityFilterItemInner = ({
|
|
|
2608
2788
|
const {
|
|
2609
2789
|
message
|
|
2610
2790
|
} = antd.App.useApp();
|
|
2791
|
+
const getPopupContainer = responsiveUtils.usePopupContainer();
|
|
2611
2792
|
const {
|
|
2612
2793
|
locale
|
|
2613
2794
|
} = reactIntl.useIntl();
|
|
@@ -2681,6 +2862,7 @@ const CityFilterItemInner = ({
|
|
|
2681
2862
|
id: 'otherText'
|
|
2682
2863
|
}), /*#__PURE__*/jsxRuntime.jsx(superSelectPlus.SelectAddress, {
|
|
2683
2864
|
...props,
|
|
2865
|
+
getPopupContainer: getPopupContainer,
|
|
2684
2866
|
className: style$1['filter-advanced-item-other-inner'],
|
|
2685
2867
|
maxLength: maxLength,
|
|
2686
2868
|
allowClear: false,
|