@kne/react-filter 1.0.2 → 1.0.4
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 +134 -8
- 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.js
CHANGED
|
@@ -4,6 +4,7 @@ var antd = require('antd');
|
|
|
4
4
|
var reactIntl = require('@kne/react-intl');
|
|
5
5
|
var get = require('lodash/get');
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
var icons = require('@ant-design/icons');
|
|
7
8
|
var clone = require('lodash/clone');
|
|
8
9
|
var reactDom = require('react-dom');
|
|
9
10
|
var isNumber = require('lodash/isNumber');
|
|
@@ -45,12 +46,84 @@ function _objectWithoutPropertiesLoose(r, e) {
|
|
|
45
46
|
return t;
|
|
46
47
|
}
|
|
47
48
|
|
|
48
|
-
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"};
|
|
49
|
+
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"};
|
|
49
50
|
|
|
50
51
|
const context = /*#__PURE__*/react.createContext({});
|
|
51
52
|
const Provider = context.Provider;
|
|
52
53
|
const useContext = () => react.useContext(context);
|
|
53
54
|
|
|
55
|
+
const useMobile = () => {
|
|
56
|
+
const [isMobile, setIsMobile] = react.useState(false);
|
|
57
|
+
react.useEffect(() => {
|
|
58
|
+
if (typeof window === 'undefined') return;
|
|
59
|
+
const mediaQuery = window.matchMedia('(max-width: 768px)');
|
|
60
|
+
const updateIsMobile = () => {
|
|
61
|
+
setIsMobile(mediaQuery.matches);
|
|
62
|
+
};
|
|
63
|
+
updateIsMobile();
|
|
64
|
+
mediaQuery.addEventListener ? mediaQuery.addEventListener('change', updateIsMobile) : mediaQuery.addListener(updateIsMobile);
|
|
65
|
+
return () => {
|
|
66
|
+
mediaQuery.removeEventListener ? mediaQuery.removeEventListener('change', updateIsMobile) : mediaQuery.removeListener(updateIsMobile);
|
|
67
|
+
};
|
|
68
|
+
}, []);
|
|
69
|
+
return isMobile;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const useHorizontalScrollShadows = ({
|
|
73
|
+
enabled,
|
|
74
|
+
suspend = false,
|
|
75
|
+
preserveOverflowOnSuspend = false,
|
|
76
|
+
refreshKey
|
|
77
|
+
} = {}) => {
|
|
78
|
+
const scrollRef = react.useRef(null);
|
|
79
|
+
const [isOverflow, setIsOverflow] = react.useState(false);
|
|
80
|
+
const [showScrollPrev, setShowScrollPrev] = react.useState(false);
|
|
81
|
+
const [showScrollNext, setShowScrollNext] = react.useState(false);
|
|
82
|
+
const update = react.useCallback(() => {
|
|
83
|
+
const el = scrollRef.current;
|
|
84
|
+
if (!el || !enabled) {
|
|
85
|
+
setShowScrollPrev(false);
|
|
86
|
+
setShowScrollNext(false);
|
|
87
|
+
setIsOverflow(false);
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if (suspend) {
|
|
91
|
+
setShowScrollPrev(false);
|
|
92
|
+
setShowScrollNext(false);
|
|
93
|
+
if (!preserveOverflowOnSuspend) {
|
|
94
|
+
setIsOverflow(false);
|
|
95
|
+
}
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
setIsOverflow(el.scrollWidth > el.clientWidth);
|
|
99
|
+
setShowScrollPrev(el.scrollLeft > 1);
|
|
100
|
+
setShowScrollNext(el.scrollWidth > el.clientWidth && el.scrollLeft + el.clientWidth < el.scrollWidth - 1);
|
|
101
|
+
}, [enabled, preserveOverflowOnSuspend, suspend]);
|
|
102
|
+
react.useEffect(() => {
|
|
103
|
+
const el = scrollRef.current;
|
|
104
|
+
if (!el || !enabled || suspend) {
|
|
105
|
+
update();
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
update();
|
|
109
|
+
el.addEventListener('scroll', update);
|
|
110
|
+
window.addEventListener('resize', update);
|
|
111
|
+
const rafId = window.requestAnimationFrame(update);
|
|
112
|
+
return () => {
|
|
113
|
+
el.removeEventListener('scroll', update);
|
|
114
|
+
window.removeEventListener('resize', update);
|
|
115
|
+
window.cancelAnimationFrame(rafId);
|
|
116
|
+
};
|
|
117
|
+
}, [enabled, refreshKey, suspend, update]);
|
|
118
|
+
return {
|
|
119
|
+
scrollRef,
|
|
120
|
+
isOverflow,
|
|
121
|
+
showScrollPrev,
|
|
122
|
+
showScrollNext,
|
|
123
|
+
updateScrollShadowVisible: update
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
|
|
54
127
|
const Line$1 = _ref => {
|
|
55
128
|
let list = _ref.list,
|
|
56
129
|
children = _ref.children;
|
|
@@ -101,57 +174,18 @@ const FilterLines = _ref2 => {
|
|
|
101
174
|
const _useState = react.useState(false),
|
|
102
175
|
isExpand = _useState[0],
|
|
103
176
|
setIsExpand = _useState[1];
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
177
|
+
const isMobile = useMobile();
|
|
178
|
+
const _useHorizontalScrollS = useHorizontalScrollShadows({
|
|
179
|
+
enabled: isMobile,
|
|
180
|
+
refreshKey: list
|
|
181
|
+
}),
|
|
182
|
+
scrollRef = _useHorizontalScrollS.scrollRef,
|
|
183
|
+
showScrollPrev = _useHorizontalScrollS.showScrollPrev,
|
|
184
|
+
showScrollNext = _useHorizontalScrollS.showScrollNext;
|
|
111
185
|
const _useIntl = reactIntl.useIntl({
|
|
112
186
|
moduleName: 'Filter'
|
|
113
187
|
}),
|
|
114
188
|
formatMessage = _useIntl.formatMessage;
|
|
115
|
-
const updateScrollNextVisible = react.useCallback(() => {
|
|
116
|
-
const el = scrollRef.current;
|
|
117
|
-
if (!el) {
|
|
118
|
-
setShowScrollNext(false);
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
setShowScrollNext(el.scrollWidth > el.clientWidth && el.scrollLeft + el.clientWidth < el.scrollWidth - 1);
|
|
122
|
-
}, []);
|
|
123
|
-
react.useEffect(() => {
|
|
124
|
-
if (typeof window === 'undefined') return;
|
|
125
|
-
const mediaQuery = window.matchMedia('(max-width: 768px)');
|
|
126
|
-
const updateIsMobile = () => {
|
|
127
|
-
setIsMobile(mediaQuery.matches);
|
|
128
|
-
};
|
|
129
|
-
updateIsMobile();
|
|
130
|
-
mediaQuery.addEventListener ? mediaQuery.addEventListener('change', updateIsMobile) : mediaQuery.addListener(updateIsMobile);
|
|
131
|
-
return () => {
|
|
132
|
-
mediaQuery.removeEventListener ? mediaQuery.removeEventListener('change', updateIsMobile) : mediaQuery.removeListener(updateIsMobile);
|
|
133
|
-
};
|
|
134
|
-
}, []);
|
|
135
|
-
react.useEffect(() => {
|
|
136
|
-
if (!isMobile) {
|
|
137
|
-
setShowScrollNext(false);
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
const el = scrollRef.current;
|
|
141
|
-
if (!el) return;
|
|
142
|
-
updateScrollNextVisible();
|
|
143
|
-
const update = () => {
|
|
144
|
-
updateScrollNextVisible();
|
|
145
|
-
};
|
|
146
|
-
el.addEventListener('scroll', update);
|
|
147
|
-
window.addEventListener('resize', update);
|
|
148
|
-
const rafId = window.requestAnimationFrame(update);
|
|
149
|
-
return () => {
|
|
150
|
-
el.removeEventListener('scroll', update);
|
|
151
|
-
window.removeEventListener('resize', update);
|
|
152
|
-
window.cancelAnimationFrame(rafId);
|
|
153
|
-
};
|
|
154
|
-
}, [isMobile, list, updateScrollNextVisible]);
|
|
155
189
|
const scrollToNext = react.useCallback(() => {
|
|
156
190
|
const el = scrollRef.current;
|
|
157
191
|
if (!el) return;
|
|
@@ -159,7 +193,7 @@ const FilterLines = _ref2 => {
|
|
|
159
193
|
left: el.scrollLeft + el.clientWidth * 0.8,
|
|
160
194
|
behavior: 'smooth'
|
|
161
195
|
});
|
|
162
|
-
}, []);
|
|
196
|
+
}, [scrollRef]);
|
|
163
197
|
const scrollItemIntoView = react.useCallback(e => {
|
|
164
198
|
if (!isMobile) return;
|
|
165
199
|
const container = scrollRef.current;
|
|
@@ -170,7 +204,7 @@ const FilterLines = _ref2 => {
|
|
|
170
204
|
block: 'nearest',
|
|
171
205
|
inline: 'center'
|
|
172
206
|
});
|
|
173
|
-
}, [isMobile]);
|
|
207
|
+
}, [isMobile, scrollRef]);
|
|
174
208
|
return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
175
209
|
children: [/*#__PURE__*/jsxRuntime.jsxs(antd.Space, {
|
|
176
210
|
className: classnames__default["default"](style$1['filter-title'], 'filter-title', className),
|
|
@@ -190,7 +224,9 @@ const FilterLines = _ref2 => {
|
|
|
190
224
|
flex: 1,
|
|
191
225
|
children: /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
192
226
|
className: style$1['filter-list-scroll-wrap'],
|
|
193
|
-
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
227
|
+
children: [isMobile && showScrollPrev ? /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
228
|
+
className: style$1['filter-scroll-prev-shadow']
|
|
229
|
+
}) : null, /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
194
230
|
className: style$1['filter-list-scroll'],
|
|
195
231
|
ref: scrollRef,
|
|
196
232
|
onClick: scrollItemIntoView,
|
|
@@ -358,6 +394,42 @@ const FilterValueDisplay = withLocale(_ref => {
|
|
|
358
394
|
moduleName: 'Filter'
|
|
359
395
|
}),
|
|
360
396
|
formatMessage = _useIntl.formatMessage;
|
|
397
|
+
const _useState = react.useState(false),
|
|
398
|
+
isExpand = _useState[0],
|
|
399
|
+
setIsExpand = _useState[1];
|
|
400
|
+
const isMobile = useMobile();
|
|
401
|
+
const _useHorizontalScrollS = useHorizontalScrollShadows({
|
|
402
|
+
enabled: isMobile,
|
|
403
|
+
suspend: isExpand,
|
|
404
|
+
preserveOverflowOnSuspend: true,
|
|
405
|
+
refreshKey: filterValue
|
|
406
|
+
}),
|
|
407
|
+
scrollRef = _useHorizontalScrollS.scrollRef,
|
|
408
|
+
isOverflow = _useHorizontalScrollS.isOverflow,
|
|
409
|
+
showScrollPrev = _useHorizontalScrollS.showScrollPrev,
|
|
410
|
+
showScrollNext = _useHorizontalScrollS.showScrollNext;
|
|
411
|
+
const tags = filterValue.map((_ref2, index) => {
|
|
412
|
+
let name = _ref2.name,
|
|
413
|
+
label = _ref2.label,
|
|
414
|
+
value = _ref2.value;
|
|
415
|
+
const valueLabel = Array.isArray(value) ? value.map(item => item.label).join(',') : value == null ? void 0 : value.label;
|
|
416
|
+
return /*#__PURE__*/jsxRuntime.jsxs(antd.Tag, {
|
|
417
|
+
closable: true,
|
|
418
|
+
className: style$1['filter-value-tag'],
|
|
419
|
+
onClose: () => {
|
|
420
|
+
const newValue = filterValue.slice(0);
|
|
421
|
+
newValue.splice(index, 1);
|
|
422
|
+
onChange(newValue);
|
|
423
|
+
},
|
|
424
|
+
children: [/*#__PURE__*/jsxRuntime.jsxs("span", {
|
|
425
|
+
className: style$1['filter-value-tag-label'],
|
|
426
|
+
children: [label, ":"]
|
|
427
|
+
}), /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
428
|
+
className: style$1['filter-value-tag-content'],
|
|
429
|
+
children: valueLabel
|
|
430
|
+
})]
|
|
431
|
+
}, name);
|
|
432
|
+
});
|
|
361
433
|
return /*#__PURE__*/jsxRuntime.jsxs(antd.Space, {
|
|
362
434
|
className: classnames__default["default"](style$1['filter-title'], style$1['filter-value-display']),
|
|
363
435
|
align: "top",
|
|
@@ -367,30 +439,57 @@ const FilterValueDisplay = withLocale(_ref => {
|
|
|
367
439
|
children: formatMessage({
|
|
368
440
|
id: 'selectedText'
|
|
369
441
|
})
|
|
370
|
-
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
371
|
-
className: style$1['filter-
|
|
372
|
-
children: [
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
442
|
+
}), isMobile ? /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
443
|
+
className: classnames__default["default"](style$1['filter-value-display-content'], !isOverflow && style$1['is-not-overflow']),
|
|
444
|
+
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
445
|
+
className: classnames__default["default"](style$1['filter-value-tags-wrap'], isExpand && style$1['is-expand']),
|
|
446
|
+
children: [showScrollPrev ? /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
447
|
+
className: classnames__default["default"](style$1['filter-scroll-prev-shadow'], style$1['filter-value-scroll-prev-shadow'])
|
|
448
|
+
}) : null, /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
449
|
+
ref: scrollRef,
|
|
450
|
+
className: classnames__default["default"](style$1['filter-line'], style$1['filter-value-tags'], isExpand && style$1['is-expand']),
|
|
451
|
+
children: tags
|
|
452
|
+
}), showScrollNext ? /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
453
|
+
className: classnames__default["default"](style$1['filter-value-scroll-next-shadow'])
|
|
454
|
+
}) : null]
|
|
455
|
+
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
456
|
+
className: classnames__default["default"](style$1['filter-value-actions'], isOverflow && style$1['is-overflow']),
|
|
457
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
458
|
+
className: style$1['filter-value-action-right'],
|
|
459
|
+
children: /*#__PURE__*/jsxRuntime.jsxs(antd.Space, {
|
|
460
|
+
size: 4,
|
|
461
|
+
children: [extraExpand, /*#__PURE__*/jsxRuntime.jsx(antd.Button, {
|
|
462
|
+
size: "small",
|
|
463
|
+
onClick: () => {
|
|
464
|
+
onChange([]);
|
|
465
|
+
},
|
|
466
|
+
children: formatMessage({
|
|
467
|
+
id: 'clearAllText'
|
|
468
|
+
})
|
|
469
|
+
})]
|
|
470
|
+
})
|
|
471
|
+
}), isOverflow ? /*#__PURE__*/jsxRuntime.jsx(antd.Button, {
|
|
472
|
+
type: "link",
|
|
473
|
+
size: "small",
|
|
474
|
+
className: style$1['filter-value-toggle'],
|
|
475
|
+
icon: isExpand ? /*#__PURE__*/jsxRuntime.jsx(icons.UpOutlined, {}) : /*#__PURE__*/jsxRuntime.jsx(icons.DownOutlined, {}),
|
|
476
|
+
onClick: () => {
|
|
477
|
+
setIsExpand(value => !value);
|
|
384
478
|
},
|
|
385
|
-
children:
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
children:
|
|
479
|
+
children: isExpand ? '收起' : '展开'
|
|
480
|
+
}) : null, /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
481
|
+
className: style$1['filter-value-action-placeholder'],
|
|
482
|
+
children: [extraExpand, /*#__PURE__*/jsxRuntime.jsx(antd.Button, {
|
|
483
|
+
size: "small",
|
|
484
|
+
children: formatMessage({
|
|
485
|
+
id: 'clearAllText'
|
|
486
|
+
})
|
|
391
487
|
})]
|
|
392
|
-
}
|
|
393
|
-
})
|
|
488
|
+
})]
|
|
489
|
+
})]
|
|
490
|
+
}) : /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
491
|
+
className: style$1['filter-line'],
|
|
492
|
+
children: [tags, /*#__PURE__*/jsxRuntime.jsxs(antd.Space, {
|
|
394
493
|
size: 4,
|
|
395
494
|
className: classnames__default["default"](style$1['un-expand-shadow']),
|
|
396
495
|
children: [extraExpand, /*#__PURE__*/jsxRuntime.jsx(antd.Button, {
|
|
@@ -566,7 +665,7 @@ const withFieldItem = function (WrappedComponent, options) {
|
|
|
566
665
|
if (typeof document === 'undefined') return;
|
|
567
666
|
document.body.style.setProperty('--react-filter-field-mobile-height', metrics.height + "px");
|
|
568
667
|
document.body.style.setProperty('--react-filter-popover-mobile-height', metrics.height + "px");
|
|
569
|
-
document.body.style.setProperty('--react-filter-field-mobile-top', metrics.
|
|
668
|
+
document.body.style.setProperty('--react-filter-field-mobile-top', metrics.top + "px");
|
|
570
669
|
}, []);
|
|
571
670
|
const updatePopupMetrics = react.useCallback(() => {
|
|
572
671
|
if (typeof window === 'undefined' || !triggerRef.current) return;
|
|
@@ -574,7 +673,6 @@ const withFieldItem = function (WrappedComponent, options) {
|
|
|
574
673
|
const top = Math.max(rect.bottom + MOBILE_POPUP_OFFSET$1, 0);
|
|
575
674
|
const metrics = {
|
|
576
675
|
top,
|
|
577
|
-
pageTop: top + window.scrollY,
|
|
578
676
|
height: Math.max(window.innerHeight - top, 0)
|
|
579
677
|
};
|
|
580
678
|
setPopupMetrics(metrics);
|
|
@@ -643,8 +741,8 @@ const withFieldItem = function (WrappedComponent, options) {
|
|
|
643
741
|
const mobilePopupStyle = isMobile ? {
|
|
644
742
|
'--react-filter-field-mobile-height': popupMetrics.height + "px",
|
|
645
743
|
'--react-filter-popover-mobile-height': popupMetrics.height + "px",
|
|
646
|
-
'--react-filter-field-mobile-top': popupMetrics.
|
|
647
|
-
top: popupMetrics.
|
|
744
|
+
'--react-filter-field-mobile-top': popupMetrics.top + "px",
|
|
745
|
+
top: popupMetrics.top,
|
|
648
746
|
left: 0
|
|
649
747
|
} : undefined;
|
|
650
748
|
const mergePopupClassNames = classNames => {
|
|
@@ -665,33 +763,37 @@ const withFieldItem = function (WrappedComponent, options) {
|
|
|
665
763
|
})
|
|
666
764
|
});
|
|
667
765
|
};
|
|
668
|
-
const renderChildren = otherProps =>
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
766
|
+
const renderChildren = otherProps => {
|
|
767
|
+
const inputValue = typeof (interceptor == null ? void 0 : interceptor.input) === 'function' ? interceptor.input(value) : value;
|
|
768
|
+
const fieldValue = options.forcePopup && inputValue == null ? props.single ? null : [] : inputValue;
|
|
769
|
+
return /*#__PURE__*/jsxRuntime.jsx(WrappedComponent, _extends({
|
|
770
|
+
allowClear: false
|
|
771
|
+
}, Object.assign({}, props, otherProps), {
|
|
772
|
+
className: style$1['filter-item-inner'],
|
|
773
|
+
value: fieldValue,
|
|
774
|
+
onChange: typeof (interceptor == null ? void 0 : interceptor.output) === 'function' ? function () {
|
|
775
|
+
return onChange(interceptor.output(...[].slice.call(arguments)));
|
|
776
|
+
} : onChange,
|
|
777
|
+
valueType: "all",
|
|
778
|
+
onOpenChange: handleOpenChange,
|
|
779
|
+
onDropdownVisibleChange: handleOpenChange,
|
|
780
|
+
popupClassName: classnames__default["default"](props.popupClassName, isMobile && style$1['field-item-mobile-popup'], isMobile && FIELD_MOBILE_POPUP_CLASS),
|
|
781
|
+
dropdownClassName: classnames__default["default"](props.dropdownClassName, isMobile && style$1['field-item-mobile-popup'], isMobile && FIELD_MOBILE_POPUP_CLASS),
|
|
782
|
+
overlayClassName: classnames__default["default"](props.overlayClassName, isMobile && style$1['field-item-mobile-popup'], isMobile && FIELD_MOBILE_POPUP_CLASS),
|
|
783
|
+
overlayStyle: Object.assign({}, props.overlayStyle, mobilePopupStyle),
|
|
784
|
+
popupStyle: Object.assign({}, props.popupStyle, mobilePopupStyle),
|
|
785
|
+
dropdownStyle: Object.assign({}, props.dropdownStyle, mobilePopupStyle),
|
|
786
|
+
classNames: mergePopupClassNames(props.classNames),
|
|
787
|
+
styles: mergePopupStyles(props.styles),
|
|
788
|
+
transitionName: isMobile ? '' : props.transitionName,
|
|
789
|
+
autoAdjustOverflow: isMobile ? false : props.autoAdjustOverflow,
|
|
790
|
+
align: isMobile ? {
|
|
791
|
+
offset: [0, 0]
|
|
792
|
+
} : props.align,
|
|
793
|
+
isPopup: options.forcePopup ? true : props.isPopup,
|
|
794
|
+
overlayWidth: isMobile && options.forcePopup ? typeof window === 'undefined' ? props.overlayWidth : window.innerWidth : props.overlayWidth
|
|
795
|
+
}));
|
|
796
|
+
};
|
|
695
797
|
return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
696
798
|
children: [renderMask && typeof document !== 'undefined' && /*#__PURE__*/reactDom.createPortal(/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
697
799
|
className: classnames__default["default"](style$1['pop-util-mask'], maskClosing && style$1['pop-util-mask-leave']),
|
|
@@ -699,7 +801,10 @@ const withFieldItem = function (WrappedComponent, options) {
|
|
|
699
801
|
top: popupMetrics.top,
|
|
700
802
|
height: popupMetrics.height
|
|
701
803
|
},
|
|
702
|
-
onClick: closeFieldItem
|
|
804
|
+
onClick: closeFieldItem,
|
|
805
|
+
onTouchMove: e => {
|
|
806
|
+
e.preventDefault();
|
|
807
|
+
}
|
|
703
808
|
}), document.body), /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
704
809
|
ref: triggerRef,
|
|
705
810
|
children: /*#__PURE__*/jsxRuntime.jsx(FilterItem, {
|
|
@@ -781,7 +886,6 @@ const PopoverItem = withLocale(_ref => {
|
|
|
781
886
|
const top = Math.max(rect.bottom + MOBILE_POPUP_OFFSET, 0);
|
|
782
887
|
setPopupMetrics({
|
|
783
888
|
top,
|
|
784
|
-
pageTop: top + window.scrollY,
|
|
785
889
|
height: Math.max(window.innerHeight - top, 0)
|
|
786
890
|
});
|
|
787
891
|
}, []);
|
|
@@ -825,7 +929,7 @@ const PopoverItem = withLocale(_ref => {
|
|
|
825
929
|
}, [isMobile, onOpenChange, updatePopupMetrics, value]);
|
|
826
930
|
const mobileOverlayStyle = isMobile ? {
|
|
827
931
|
'--react-filter-popover-mobile-height': popupMetrics.height + "px",
|
|
828
|
-
top: popupMetrics.
|
|
932
|
+
top: popupMetrics.top,
|
|
829
933
|
left: 0
|
|
830
934
|
} : undefined;
|
|
831
935
|
const overlayContent = /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
@@ -845,7 +949,7 @@ const PopoverItem = withLocale(_ref => {
|
|
|
845
949
|
gutter: 8,
|
|
846
950
|
children: [/*#__PURE__*/jsxRuntime.jsx(antd.Col, {
|
|
847
951
|
children: /*#__PURE__*/jsxRuntime.jsx(antd.Button, {
|
|
848
|
-
size:
|
|
952
|
+
size: isMobile ? undefined : 'small',
|
|
849
953
|
onClick: closeDropdown,
|
|
850
954
|
children: formatMessage({
|
|
851
955
|
id: 'cancelText'
|
|
@@ -853,7 +957,7 @@ const PopoverItem = withLocale(_ref => {
|
|
|
853
957
|
})
|
|
854
958
|
}), /*#__PURE__*/jsxRuntime.jsx(antd.Col, {
|
|
855
959
|
children: /*#__PURE__*/jsxRuntime.jsx(antd.Button, {
|
|
856
|
-
size:
|
|
960
|
+
size: isMobile ? undefined : 'small',
|
|
857
961
|
type: "primary",
|
|
858
962
|
disabled: disabled,
|
|
859
963
|
onClick: () => {
|
|
@@ -874,7 +978,10 @@ const PopoverItem = withLocale(_ref => {
|
|
|
874
978
|
top: popupMetrics.top,
|
|
875
979
|
height: popupMetrics.height
|
|
876
980
|
},
|
|
877
|
-
onClick: closeDropdown
|
|
981
|
+
onClick: closeDropdown,
|
|
982
|
+
onTouchMove: e => {
|
|
983
|
+
e.preventDefault();
|
|
984
|
+
}
|
|
878
985
|
}), document.body), /*#__PURE__*/jsxRuntime.jsx(antd.Dropdown, {
|
|
879
986
|
open: open,
|
|
880
987
|
trigger: ['click'],
|