@kne/react-filter 1.0.2 → 1.0.3
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/README.md +1 -1
- package/dist/index.css +133 -7
- package/dist/index.css.map +1 -1
- package/dist/index.js +217 -110
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +217 -106
- package/dist/index.modern.js.map +1 -1
- package/package.json +23 -6
package/dist/index.modern.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import classnames from 'classnames';
|
|
2
|
-
import { useContext as useContext$1, createContext, useState, useRef, useCallback,
|
|
2
|
+
import { useContext as useContext$1, createContext, useState, useEffect, useRef, useCallback, createElement, useMemo } from 'react';
|
|
3
3
|
import { Space, Row, Col, Tag, Button, Dropdown, Input, InputNumber, DatePicker, Flex, Select, App } from 'antd';
|
|
4
4
|
import { useIntl, createWithIntlProvider } from '@kne/react-intl';
|
|
5
5
|
import get from 'lodash/get';
|
|
6
6
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
7
|
+
import { UpOutlined, DownOutlined } from '@ant-design/icons';
|
|
7
8
|
import clone from 'lodash/clone';
|
|
8
9
|
import { createPortal } from 'react-dom';
|
|
9
10
|
import isNumber from 'lodash/isNumber';
|
|
@@ -34,7 +35,7 @@ function _objectWithoutPropertiesLoose(r, e) {
|
|
|
34
35
|
return t;
|
|
35
36
|
}
|
|
36
37
|
|
|
37
|
-
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-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-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","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","filter-value-display":"kne-react-filter_8-R34","filter-scroll-next-icon":"kne-react-filter_Fd6ab"};
|
|
38
|
+
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-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-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","filter-value-display":"kne-react-filter_8-R34","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"};
|
|
38
39
|
|
|
39
40
|
const context = /*#__PURE__*/createContext({});
|
|
40
41
|
const {
|
|
@@ -42,6 +43,78 @@ const {
|
|
|
42
43
|
} = context;
|
|
43
44
|
const useContext = () => useContext$1(context);
|
|
44
45
|
|
|
46
|
+
const useMobile = () => {
|
|
47
|
+
const [isMobile, setIsMobile] = useState(false);
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
if (typeof window === 'undefined') return;
|
|
50
|
+
const mediaQuery = window.matchMedia('(max-width: 768px)');
|
|
51
|
+
const updateIsMobile = () => {
|
|
52
|
+
setIsMobile(mediaQuery.matches);
|
|
53
|
+
};
|
|
54
|
+
updateIsMobile();
|
|
55
|
+
mediaQuery.addEventListener ? mediaQuery.addEventListener('change', updateIsMobile) : mediaQuery.addListener(updateIsMobile);
|
|
56
|
+
return () => {
|
|
57
|
+
mediaQuery.removeEventListener ? mediaQuery.removeEventListener('change', updateIsMobile) : mediaQuery.removeListener(updateIsMobile);
|
|
58
|
+
};
|
|
59
|
+
}, []);
|
|
60
|
+
return isMobile;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const useHorizontalScrollShadows = ({
|
|
64
|
+
enabled,
|
|
65
|
+
suspend: _suspend = false,
|
|
66
|
+
preserveOverflowOnSuspend: _preserveOverflowOnSuspend = false,
|
|
67
|
+
refreshKey
|
|
68
|
+
} = {}) => {
|
|
69
|
+
const scrollRef = useRef(null);
|
|
70
|
+
const [isOverflow, setIsOverflow] = useState(false);
|
|
71
|
+
const [showScrollPrev, setShowScrollPrev] = useState(false);
|
|
72
|
+
const [showScrollNext, setShowScrollNext] = useState(false);
|
|
73
|
+
const update = useCallback(() => {
|
|
74
|
+
const el = scrollRef.current;
|
|
75
|
+
if (!el || !enabled) {
|
|
76
|
+
setShowScrollPrev(false);
|
|
77
|
+
setShowScrollNext(false);
|
|
78
|
+
setIsOverflow(false);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
if (_suspend) {
|
|
82
|
+
setShowScrollPrev(false);
|
|
83
|
+
setShowScrollNext(false);
|
|
84
|
+
if (!_preserveOverflowOnSuspend) {
|
|
85
|
+
setIsOverflow(false);
|
|
86
|
+
}
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
setIsOverflow(el.scrollWidth > el.clientWidth);
|
|
90
|
+
setShowScrollPrev(el.scrollLeft > 1);
|
|
91
|
+
setShowScrollNext(el.scrollWidth > el.clientWidth && el.scrollLeft + el.clientWidth < el.scrollWidth - 1);
|
|
92
|
+
}, [enabled, _preserveOverflowOnSuspend, _suspend]);
|
|
93
|
+
useEffect(() => {
|
|
94
|
+
const el = scrollRef.current;
|
|
95
|
+
if (!el || !enabled || _suspend) {
|
|
96
|
+
update();
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
update();
|
|
100
|
+
el.addEventListener('scroll', update);
|
|
101
|
+
window.addEventListener('resize', update);
|
|
102
|
+
const rafId = window.requestAnimationFrame(update);
|
|
103
|
+
return () => {
|
|
104
|
+
el.removeEventListener('scroll', update);
|
|
105
|
+
window.removeEventListener('resize', update);
|
|
106
|
+
window.cancelAnimationFrame(rafId);
|
|
107
|
+
};
|
|
108
|
+
}, [enabled, refreshKey, _suspend, update]);
|
|
109
|
+
return {
|
|
110
|
+
scrollRef,
|
|
111
|
+
isOverflow,
|
|
112
|
+
showScrollPrev,
|
|
113
|
+
showScrollNext,
|
|
114
|
+
updateScrollShadowVisible: update
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
|
|
45
118
|
const Line$1 = ({
|
|
46
119
|
list,
|
|
47
120
|
children
|
|
@@ -91,54 +164,20 @@ const FilterLines = ({
|
|
|
91
164
|
const hasMore = _list.length > _displayLine;
|
|
92
165
|
const mobileList = _list.reduce((result, item) => result.concat(Array.isArray(item) ? item : [item]), []);
|
|
93
166
|
const [isExpand, setIsExpand] = useState(false);
|
|
94
|
-
const
|
|
95
|
-
const
|
|
96
|
-
|
|
167
|
+
const isMobile = useMobile();
|
|
168
|
+
const {
|
|
169
|
+
scrollRef,
|
|
170
|
+
showScrollPrev,
|
|
171
|
+
showScrollNext
|
|
172
|
+
} = useHorizontalScrollShadows({
|
|
173
|
+
enabled: isMobile,
|
|
174
|
+
refreshKey: _list
|
|
175
|
+
});
|
|
97
176
|
const {
|
|
98
177
|
formatMessage
|
|
99
178
|
} = useIntl({
|
|
100
179
|
moduleName: 'Filter'
|
|
101
180
|
});
|
|
102
|
-
const updateScrollNextVisible = useCallback(() => {
|
|
103
|
-
const el = scrollRef.current;
|
|
104
|
-
if (!el) {
|
|
105
|
-
setShowScrollNext(false);
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
setShowScrollNext(el.scrollWidth > el.clientWidth && el.scrollLeft + el.clientWidth < el.scrollWidth - 1);
|
|
109
|
-
}, []);
|
|
110
|
-
useEffect(() => {
|
|
111
|
-
if (typeof window === 'undefined') return;
|
|
112
|
-
const mediaQuery = window.matchMedia('(max-width: 768px)');
|
|
113
|
-
const updateIsMobile = () => {
|
|
114
|
-
setIsMobile(mediaQuery.matches);
|
|
115
|
-
};
|
|
116
|
-
updateIsMobile();
|
|
117
|
-
mediaQuery.addEventListener ? mediaQuery.addEventListener('change', updateIsMobile) : mediaQuery.addListener(updateIsMobile);
|
|
118
|
-
return () => {
|
|
119
|
-
mediaQuery.removeEventListener ? mediaQuery.removeEventListener('change', updateIsMobile) : mediaQuery.removeListener(updateIsMobile);
|
|
120
|
-
};
|
|
121
|
-
}, []);
|
|
122
|
-
useEffect(() => {
|
|
123
|
-
if (!isMobile) {
|
|
124
|
-
setShowScrollNext(false);
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
const el = scrollRef.current;
|
|
128
|
-
if (!el) return;
|
|
129
|
-
updateScrollNextVisible();
|
|
130
|
-
const update = () => {
|
|
131
|
-
updateScrollNextVisible();
|
|
132
|
-
};
|
|
133
|
-
el.addEventListener('scroll', update);
|
|
134
|
-
window.addEventListener('resize', update);
|
|
135
|
-
const rafId = window.requestAnimationFrame(update);
|
|
136
|
-
return () => {
|
|
137
|
-
el.removeEventListener('scroll', update);
|
|
138
|
-
window.removeEventListener('resize', update);
|
|
139
|
-
window.cancelAnimationFrame(rafId);
|
|
140
|
-
};
|
|
141
|
-
}, [isMobile, _list, updateScrollNextVisible]);
|
|
142
181
|
const scrollToNext = useCallback(() => {
|
|
143
182
|
const el = scrollRef.current;
|
|
144
183
|
if (!el) return;
|
|
@@ -146,7 +185,7 @@ const FilterLines = ({
|
|
|
146
185
|
left: el.scrollLeft + el.clientWidth * 0.8,
|
|
147
186
|
behavior: 'smooth'
|
|
148
187
|
});
|
|
149
|
-
}, []);
|
|
188
|
+
}, [scrollRef]);
|
|
150
189
|
const scrollItemIntoView = useCallback(e => {
|
|
151
190
|
if (!isMobile) return;
|
|
152
191
|
const container = scrollRef.current;
|
|
@@ -157,7 +196,7 @@ const FilterLines = ({
|
|
|
157
196
|
block: 'nearest',
|
|
158
197
|
inline: 'center'
|
|
159
198
|
});
|
|
160
|
-
}, [isMobile]);
|
|
199
|
+
}, [isMobile, scrollRef]);
|
|
161
200
|
return /*#__PURE__*/jsxs(Fragment, {
|
|
162
201
|
children: [/*#__PURE__*/jsxs(Space, {
|
|
163
202
|
className: classnames(style$1['filter-title'], 'filter-title', className),
|
|
@@ -177,7 +216,9 @@ const FilterLines = ({
|
|
|
177
216
|
flex: 1,
|
|
178
217
|
children: /*#__PURE__*/jsxs("div", {
|
|
179
218
|
className: style$1['filter-list-scroll-wrap'],
|
|
180
|
-
children: [/*#__PURE__*/jsx("div", {
|
|
219
|
+
children: [isMobile && showScrollPrev ? /*#__PURE__*/jsx("div", {
|
|
220
|
+
className: style$1['filter-scroll-prev-shadow']
|
|
221
|
+
}) : null, /*#__PURE__*/jsx("div", {
|
|
181
222
|
className: style$1['filter-list-scroll'],
|
|
182
223
|
ref: scrollRef,
|
|
183
224
|
onClick: scrollItemIntoView,
|
|
@@ -347,6 +388,42 @@ const FilterValueDisplay = withLocale(({
|
|
|
347
388
|
} = useIntl({
|
|
348
389
|
moduleName: 'Filter'
|
|
349
390
|
});
|
|
391
|
+
const [isExpand, setIsExpand] = useState(false);
|
|
392
|
+
const isMobile = useMobile();
|
|
393
|
+
const {
|
|
394
|
+
scrollRef,
|
|
395
|
+
isOverflow,
|
|
396
|
+
showScrollPrev,
|
|
397
|
+
showScrollNext
|
|
398
|
+
} = useHorizontalScrollShadows({
|
|
399
|
+
enabled: isMobile,
|
|
400
|
+
suspend: isExpand,
|
|
401
|
+
preserveOverflowOnSuspend: true,
|
|
402
|
+
refreshKey: filterValue
|
|
403
|
+
});
|
|
404
|
+
const tags = filterValue.map(({
|
|
405
|
+
name,
|
|
406
|
+
label,
|
|
407
|
+
value
|
|
408
|
+
}, index) => {
|
|
409
|
+
const valueLabel = Array.isArray(value) ? value.map(item => item.label).join(',') : value == null ? void 0 : value.label;
|
|
410
|
+
return /*#__PURE__*/jsxs(Tag, {
|
|
411
|
+
closable: true,
|
|
412
|
+
className: style$1['filter-value-tag'],
|
|
413
|
+
onClose: () => {
|
|
414
|
+
const newValue = filterValue.slice(0);
|
|
415
|
+
newValue.splice(index, 1);
|
|
416
|
+
onChange(newValue);
|
|
417
|
+
},
|
|
418
|
+
children: [/*#__PURE__*/jsxs("span", {
|
|
419
|
+
className: style$1['filter-value-tag-label'],
|
|
420
|
+
children: [label, ":"]
|
|
421
|
+
}), /*#__PURE__*/jsx("span", {
|
|
422
|
+
className: style$1['filter-value-tag-content'],
|
|
423
|
+
children: valueLabel
|
|
424
|
+
})]
|
|
425
|
+
}, name);
|
|
426
|
+
});
|
|
350
427
|
return /*#__PURE__*/jsxs(Space, {
|
|
351
428
|
className: classnames(style$1['filter-title'], style$1['filter-value-display']),
|
|
352
429
|
align: "top",
|
|
@@ -356,31 +433,57 @@ const FilterValueDisplay = withLocale(({
|
|
|
356
433
|
children: formatMessage({
|
|
357
434
|
id: 'selectedText'
|
|
358
435
|
})
|
|
359
|
-
}), /*#__PURE__*/jsxs("div", {
|
|
360
|
-
className: style$1['filter-
|
|
361
|
-
children: [
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
436
|
+
}), isMobile ? /*#__PURE__*/jsxs("div", {
|
|
437
|
+
className: classnames(style$1['filter-value-display-content'], !isOverflow && style$1['is-not-overflow']),
|
|
438
|
+
children: [/*#__PURE__*/jsxs("div", {
|
|
439
|
+
className: classnames(style$1['filter-value-tags-wrap'], isExpand && style$1['is-expand']),
|
|
440
|
+
children: [showScrollPrev ? /*#__PURE__*/jsx("div", {
|
|
441
|
+
className: classnames(style$1['filter-scroll-prev-shadow'], style$1['filter-value-scroll-prev-shadow'])
|
|
442
|
+
}) : null, /*#__PURE__*/jsx("div", {
|
|
443
|
+
ref: scrollRef,
|
|
444
|
+
className: classnames(style$1['filter-line'], style$1['filter-value-tags'], isExpand && style$1['is-expand']),
|
|
445
|
+
children: tags
|
|
446
|
+
}), showScrollNext ? /*#__PURE__*/jsx("div", {
|
|
447
|
+
className: classnames(style$1['filter-value-scroll-next-shadow'])
|
|
448
|
+
}) : null]
|
|
449
|
+
}), /*#__PURE__*/jsxs("div", {
|
|
450
|
+
className: classnames(style$1['filter-value-actions'], isOverflow && style$1['is-overflow']),
|
|
451
|
+
children: [/*#__PURE__*/jsx("div", {
|
|
452
|
+
className: style$1['filter-value-action-right'],
|
|
453
|
+
children: /*#__PURE__*/jsxs(Space, {
|
|
454
|
+
size: 4,
|
|
455
|
+
children: [extraExpand, /*#__PURE__*/jsx(Button, {
|
|
456
|
+
size: "small",
|
|
457
|
+
onClick: () => {
|
|
458
|
+
onChange([]);
|
|
459
|
+
},
|
|
460
|
+
children: formatMessage({
|
|
461
|
+
id: 'clearAllText'
|
|
462
|
+
})
|
|
463
|
+
})]
|
|
464
|
+
})
|
|
465
|
+
}), isOverflow ? /*#__PURE__*/jsx(Button, {
|
|
466
|
+
type: "link",
|
|
467
|
+
size: "small",
|
|
468
|
+
className: style$1['filter-value-toggle'],
|
|
469
|
+
icon: isExpand ? /*#__PURE__*/jsx(UpOutlined, {}) : /*#__PURE__*/jsx(DownOutlined, {}),
|
|
470
|
+
onClick: () => {
|
|
471
|
+
setIsExpand(value => !value);
|
|
374
472
|
},
|
|
375
|
-
children:
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
children:
|
|
473
|
+
children: isExpand ? '收起' : '展开'
|
|
474
|
+
}) : null, /*#__PURE__*/jsxs("div", {
|
|
475
|
+
className: style$1['filter-value-action-placeholder'],
|
|
476
|
+
children: [extraExpand, /*#__PURE__*/jsx(Button, {
|
|
477
|
+
size: "small",
|
|
478
|
+
children: formatMessage({
|
|
479
|
+
id: 'clearAllText'
|
|
480
|
+
})
|
|
381
481
|
})]
|
|
382
|
-
}
|
|
383
|
-
})
|
|
482
|
+
})]
|
|
483
|
+
})]
|
|
484
|
+
}) : /*#__PURE__*/jsxs("div", {
|
|
485
|
+
className: style$1['filter-line'],
|
|
486
|
+
children: [tags, /*#__PURE__*/jsxs(Space, {
|
|
384
487
|
size: 4,
|
|
385
488
|
className: classnames(style$1['un-expand-shadow']),
|
|
386
489
|
children: [extraExpand, /*#__PURE__*/jsx(Button, {
|
|
@@ -548,7 +651,7 @@ const withFieldItem = (WrappedComponent, options = {}) => _ref => {
|
|
|
548
651
|
if (typeof document === 'undefined') return;
|
|
549
652
|
document.body.style.setProperty('--react-filter-field-mobile-height', `${metrics.height}px`);
|
|
550
653
|
document.body.style.setProperty('--react-filter-popover-mobile-height', `${metrics.height}px`);
|
|
551
|
-
document.body.style.setProperty('--react-filter-field-mobile-top', `${metrics.
|
|
654
|
+
document.body.style.setProperty('--react-filter-field-mobile-top', `${metrics.top}px`);
|
|
552
655
|
}, []);
|
|
553
656
|
const updatePopupMetrics = useCallback(() => {
|
|
554
657
|
if (typeof window === 'undefined' || !triggerRef.current) return;
|
|
@@ -556,7 +659,6 @@ const withFieldItem = (WrappedComponent, options = {}) => _ref => {
|
|
|
556
659
|
const top = Math.max(rect.bottom + MOBILE_POPUP_OFFSET$1, 0);
|
|
557
660
|
const metrics = {
|
|
558
661
|
top,
|
|
559
|
-
pageTop: top + window.scrollY,
|
|
560
662
|
height: Math.max(window.innerHeight - top, 0)
|
|
561
663
|
};
|
|
562
664
|
setPopupMetrics(metrics);
|
|
@@ -625,8 +727,8 @@ const withFieldItem = (WrappedComponent, options = {}) => _ref => {
|
|
|
625
727
|
const mobilePopupStyle = isMobile ? {
|
|
626
728
|
'--react-filter-field-mobile-height': `${popupMetrics.height}px`,
|
|
627
729
|
'--react-filter-popover-mobile-height': `${popupMetrics.height}px`,
|
|
628
|
-
'--react-filter-field-mobile-top': `${popupMetrics.
|
|
629
|
-
top: popupMetrics.
|
|
730
|
+
'--react-filter-field-mobile-top': `${popupMetrics.top}px`,
|
|
731
|
+
top: popupMetrics.top,
|
|
630
732
|
left: 0
|
|
631
733
|
} : undefined;
|
|
632
734
|
const mergePopupClassNames = classNames => {
|
|
@@ -647,31 +749,35 @@ const withFieldItem = (WrappedComponent, options = {}) => _ref => {
|
|
|
647
749
|
})
|
|
648
750
|
});
|
|
649
751
|
};
|
|
650
|
-
const renderChildren = otherProps =>
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
752
|
+
const renderChildren = otherProps => {
|
|
753
|
+
const inputValue = typeof (interceptor == null ? void 0 : interceptor.input) === 'function' ? interceptor.input(value) : value;
|
|
754
|
+
const fieldValue = options.forcePopup && inputValue == null ? props.single ? null : [] : inputValue;
|
|
755
|
+
return /*#__PURE__*/jsx(WrappedComponent, _extends({
|
|
756
|
+
allowClear: false
|
|
757
|
+
}, Object.assign({}, props, otherProps), {
|
|
758
|
+
className: style$1['filter-item-inner'],
|
|
759
|
+
value: fieldValue,
|
|
760
|
+
onChange: typeof (interceptor == null ? void 0 : interceptor.output) === 'function' ? (...args) => onChange(interceptor.output(...args)) : onChange,
|
|
761
|
+
valueType: "all",
|
|
762
|
+
onOpenChange: handleOpenChange,
|
|
763
|
+
onDropdownVisibleChange: handleOpenChange,
|
|
764
|
+
popupClassName: classnames(props.popupClassName, isMobile && style$1['field-item-mobile-popup'], isMobile && FIELD_MOBILE_POPUP_CLASS),
|
|
765
|
+
dropdownClassName: classnames(props.dropdownClassName, isMobile && style$1['field-item-mobile-popup'], isMobile && FIELD_MOBILE_POPUP_CLASS),
|
|
766
|
+
overlayClassName: classnames(props.overlayClassName, isMobile && style$1['field-item-mobile-popup'], isMobile && FIELD_MOBILE_POPUP_CLASS),
|
|
767
|
+
overlayStyle: Object.assign({}, props.overlayStyle, mobilePopupStyle),
|
|
768
|
+
popupStyle: Object.assign({}, props.popupStyle, mobilePopupStyle),
|
|
769
|
+
dropdownStyle: Object.assign({}, props.dropdownStyle, mobilePopupStyle),
|
|
770
|
+
classNames: mergePopupClassNames(props.classNames),
|
|
771
|
+
styles: mergePopupStyles(props.styles),
|
|
772
|
+
transitionName: isMobile ? '' : props.transitionName,
|
|
773
|
+
autoAdjustOverflow: isMobile ? false : props.autoAdjustOverflow,
|
|
774
|
+
align: isMobile ? {
|
|
775
|
+
offset: [0, 0]
|
|
776
|
+
} : props.align,
|
|
777
|
+
isPopup: options.forcePopup ? true : props.isPopup,
|
|
778
|
+
overlayWidth: isMobile && options.forcePopup ? typeof window === 'undefined' ? props.overlayWidth : window.innerWidth : props.overlayWidth
|
|
779
|
+
}));
|
|
780
|
+
};
|
|
675
781
|
return /*#__PURE__*/jsxs(Fragment, {
|
|
676
782
|
children: [renderMask && typeof document !== 'undefined' && /*#__PURE__*/createPortal(/*#__PURE__*/jsx("div", {
|
|
677
783
|
className: classnames(style$1['pop-util-mask'], maskClosing && style$1['pop-util-mask-leave']),
|
|
@@ -679,7 +785,10 @@ const withFieldItem = (WrappedComponent, options = {}) => _ref => {
|
|
|
679
785
|
top: popupMetrics.top,
|
|
680
786
|
height: popupMetrics.height
|
|
681
787
|
},
|
|
682
|
-
onClick: closeFieldItem
|
|
788
|
+
onClick: closeFieldItem,
|
|
789
|
+
onTouchMove: e => {
|
|
790
|
+
e.preventDefault();
|
|
791
|
+
}
|
|
683
792
|
}), document.body), /*#__PURE__*/jsx("span", {
|
|
684
793
|
ref: triggerRef,
|
|
685
794
|
children: /*#__PURE__*/jsx(FilterItem, {
|
|
@@ -749,7 +858,6 @@ const PopoverItem = withLocale(({
|
|
|
749
858
|
const top = Math.max(rect.bottom + MOBILE_POPUP_OFFSET, 0);
|
|
750
859
|
setPopupMetrics({
|
|
751
860
|
top,
|
|
752
|
-
pageTop: top + window.scrollY,
|
|
753
861
|
height: Math.max(window.innerHeight - top, 0)
|
|
754
862
|
});
|
|
755
863
|
}, []);
|
|
@@ -793,7 +901,7 @@ const PopoverItem = withLocale(({
|
|
|
793
901
|
}, [isMobile, onOpenChange, updatePopupMetrics, value]);
|
|
794
902
|
const mobileOverlayStyle = isMobile ? {
|
|
795
903
|
'--react-filter-popover-mobile-height': `${popupMetrics.height}px`,
|
|
796
|
-
top: popupMetrics.
|
|
904
|
+
top: popupMetrics.top,
|
|
797
905
|
left: 0
|
|
798
906
|
} : undefined;
|
|
799
907
|
const overlayContent = /*#__PURE__*/jsxs("div", {
|
|
@@ -813,7 +921,7 @@ const PopoverItem = withLocale(({
|
|
|
813
921
|
gutter: 8,
|
|
814
922
|
children: [/*#__PURE__*/jsx(Col, {
|
|
815
923
|
children: /*#__PURE__*/jsx(Button, {
|
|
816
|
-
size:
|
|
924
|
+
size: isMobile ? undefined : 'small',
|
|
817
925
|
onClick: closeDropdown,
|
|
818
926
|
children: formatMessage({
|
|
819
927
|
id: 'cancelText'
|
|
@@ -821,7 +929,7 @@ const PopoverItem = withLocale(({
|
|
|
821
929
|
})
|
|
822
930
|
}), /*#__PURE__*/jsx(Col, {
|
|
823
931
|
children: /*#__PURE__*/jsx(Button, {
|
|
824
|
-
size:
|
|
932
|
+
size: isMobile ? undefined : 'small',
|
|
825
933
|
type: "primary",
|
|
826
934
|
disabled: disabled,
|
|
827
935
|
onClick: () => {
|
|
@@ -842,7 +950,10 @@ const PopoverItem = withLocale(({
|
|
|
842
950
|
top: popupMetrics.top,
|
|
843
951
|
height: popupMetrics.height
|
|
844
952
|
},
|
|
845
|
-
onClick: closeDropdown
|
|
953
|
+
onClick: closeDropdown,
|
|
954
|
+
onTouchMove: e => {
|
|
955
|
+
e.preventDefault();
|
|
956
|
+
}
|
|
846
957
|
}), document.body), /*#__PURE__*/jsx(Dropdown, {
|
|
847
958
|
open: open,
|
|
848
959
|
trigger: ['click'],
|