@kne/react-filter 1.0.9 → 1.0.10
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 +48 -40
- package/dist/index.css.map +1 -1
- package/dist/index.js +69 -40
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +65 -36
- package/dist/index.modern.js.map +1 -1
- package/package.json +1 -1
package/dist/index.modern.js
CHANGED
|
@@ -3,7 +3,7 @@ import { useContext as useContext$1, createContext, useEffect, useRef, useState,
|
|
|
3
3
|
import { Space, Row, Col, Tag, Button, Dropdown, Input, InputNumber, DatePicker, Flex, Select, App } from 'antd';
|
|
4
4
|
import { useIntl, createWithIntlProvider } from '@kne/react-intl';
|
|
5
5
|
import get from 'lodash/get';
|
|
6
|
-
import { useResponsiveContext, useMediaQuery, IS_MOBILE_QUERY, MOBILE_BREAKPOINT, useScrollElement, resetViewportCssVars, applyViewportCssVars,
|
|
6
|
+
import { useResponsiveContext, useMediaQuery, IS_MOBILE_QUERY, MOBILE_BREAKPOINT, useScrollElement, resetViewportCssVars, applyViewportCssVars, usePopupContainer } from '@kne/responsive-utils';
|
|
7
7
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
8
8
|
import { UpOutlined, DownOutlined } from '@ant-design/icons';
|
|
9
9
|
import clone from 'lodash/clone';
|
|
@@ -37,7 +37,7 @@ function _objectWithoutPropertiesLoose(r, e) {
|
|
|
37
37
|
return t;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
var style$1 = {"kne-responsive-boundary":"kne-react-filter_gh14z","kne-responsive-scroll":"kne-react-filter_Kfn6L","filter":"kne-react-filter_b3gMw","filter-item-icon":"kne-react-filter_e3V6h","filter-item-option-icon":"kne-react-filter_dLoYj","filter-title":"kne-react-filter_khFt2","filter-title-hidden":"kne-react-filter_j2mP1","ad-filter-title":"kne-react-filter_HptIY","ad-filter-line":"kne-react-filter_7Ob6-","filter-line":"kne-react-filter_Y9XTa","clean-btn":"kne-react-filter_CJ935","filter-item":"kne-react-filter_JpaMr","un-expand":"kne-react-filter_LfQME","ad-filter-selected":"kne-react-filter_pBsaE","filter-label":"kne-react-filter_Bx3s8","filter-line-nowrap":"kne-react-filter_Ccx24","filter-line-measure":"kne-react-filter_uMXzo","filter-item-wrap":"kne-react-filter_Co4Pg","option":"kne-react-filter_G1cRp","is-active":"kne-react-filter_Aab98","is-visited":"kne-react-filter_Ww12R","un-expand-shadow":"kne-react-filter_2ExqW","filter-item-label":"kne-react-filter_JAmeE","filter-item-field":"kne-react-filter_WvRvl","filter-drop-tag":"kne-react-filter_dG8rq","filter-list":"kne-react-filter_qlWu6","filter-list-scroll-wrap":"kne-react-filter_oaIF4","filter-list-constrained":"kne-react-filter_3gXxO","filter-list-scroll":"kne-react-filter_Jq43Q","filter-scroll-next":"kne-react-filter_BdfSI","filter-list-tag":"kne-react-filter_LV2VI","filter-tag":"kne-react-filter_yyR3u","filter-tag-value":"kne-react-filter_8nm8n","filter-value-tag":"kne-react-filter_tWyCr","filter-value-tag-label":"kne-react-filter_XPzrL","filter-value-tag-content":"kne-react-filter_6e79l","filter-value-display-content":"kne-react-filter_v2dnw","filter-value-display":"kne-react-filter_8-R34","is-hide-label":"kne-react-filter_zpGJE","is-flush":"kne-react-filter_z8bDM","filter-value-tags-wrap":"kne-react-filter_J1wBU","filter-value-tags":"kne-react-filter_rRhFE","filter-value-actions":"kne-react-filter_-Brt9","filter-value-toggle":"kne-react-filter_WuL0c","pop-util-content":"kne-react-filter_g-hXk","pop-util-body":"kne-react-filter_4n4MP","date-range-picker-popup":"kne-react-filter_6Zx60","pop-util-overlay":"kne-react-filter_m7Csi","
|
|
40
|
+
var style$1 = {"kne-responsive-boundary":"kne-react-filter_gh14z","kne-responsive-scroll":"kne-react-filter_Kfn6L","filter":"kne-react-filter_b3gMw","filter-item-icon":"kne-react-filter_e3V6h","filter-item-option-icon":"kne-react-filter_dLoYj","filter-title":"kne-react-filter_khFt2","filter-title-hidden":"kne-react-filter_j2mP1","ad-filter-title":"kne-react-filter_HptIY","ad-filter-line":"kne-react-filter_7Ob6-","filter-line":"kne-react-filter_Y9XTa","clean-btn":"kne-react-filter_CJ935","filter-item":"kne-react-filter_JpaMr","un-expand":"kne-react-filter_LfQME","ad-filter-selected":"kne-react-filter_pBsaE","filter-label":"kne-react-filter_Bx3s8","filter-line-nowrap":"kne-react-filter_Ccx24","filter-line-measure":"kne-react-filter_uMXzo","filter-item-wrap":"kne-react-filter_Co4Pg","option":"kne-react-filter_G1cRp","is-active":"kne-react-filter_Aab98","is-visited":"kne-react-filter_Ww12R","un-expand-shadow":"kne-react-filter_2ExqW","filter-item-label":"kne-react-filter_JAmeE","filter-item-field":"kne-react-filter_WvRvl","filter-drop-tag":"kne-react-filter_dG8rq","filter-list":"kne-react-filter_qlWu6","filter-list-scroll-wrap":"kne-react-filter_oaIF4","filter-list-constrained":"kne-react-filter_3gXxO","filter-list-scroll":"kne-react-filter_Jq43Q","filter-scroll-next":"kne-react-filter_BdfSI","filter-list-tag":"kne-react-filter_LV2VI","filter-tag":"kne-react-filter_yyR3u","filter-tag-value":"kne-react-filter_8nm8n","filter-value-tag":"kne-react-filter_tWyCr","filter-value-tag-label":"kne-react-filter_XPzrL","filter-value-tag-content":"kne-react-filter_6e79l","filter-value-display-content":"kne-react-filter_v2dnw","filter-value-display":"kne-react-filter_8-R34","is-hide-label":"kne-react-filter_zpGJE","is-flush":"kne-react-filter_z8bDM","filter-value-tags-wrap":"kne-react-filter_J1wBU","filter-value-tags":"kne-react-filter_rRhFE","filter-value-actions":"kne-react-filter_-Brt9","filter-value-toggle":"kne-react-filter_WuL0c","pop-util-content":"kne-react-filter_g-hXk","pop-util-body":"kne-react-filter_4n4MP","date-range-picker-popup":"kne-react-filter_6Zx60","pop-util-overlay":"kne-react-filter_m7Csi","is-viewport":"kne-react-filter_3Wr-x","is-boundary":"kne-react-filter_pPiQ8","pop-util-footer":"kne-react-filter_iqe8W","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-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"};
|
|
41
41
|
|
|
42
42
|
const context = /*#__PURE__*/createContext({});
|
|
43
43
|
const {
|
|
@@ -919,7 +919,7 @@ const FilterOuter = _ref => {
|
|
|
919
919
|
return /*#__PURE__*/jsx(FilterProvider, _extends({}, props, {
|
|
920
920
|
children: context => /*#__PURE__*/jsx("div", {
|
|
921
921
|
ref: boundaryRef,
|
|
922
|
-
className: classnames(style$1['filter'], 'filter',
|
|
922
|
+
className: classnames(style$1['filter'], 'filter', isMobile && style$1['is-mobile'], className),
|
|
923
923
|
children: children(_extends({}, context, {
|
|
924
924
|
props
|
|
925
925
|
}))
|
|
@@ -975,6 +975,43 @@ const useMobileFixedMode = () => {
|
|
|
975
975
|
};
|
|
976
976
|
};
|
|
977
977
|
|
|
978
|
+
/**
|
|
979
|
+
* Filter Item 弹窗挂载(不使用 RESPONSIVE_BOUNDARY_CLASS,避免劫持全局 pop):
|
|
980
|
+
* - useBoundaryMount(example container / 手机预览):ResponsiveProvider 的 boundary
|
|
981
|
+
* - 真实移动端 viewport:document.body
|
|
982
|
+
* - 桌面端:页面级 boundary(usePopupContainer)
|
|
983
|
+
*/
|
|
984
|
+
const resolveFilterPopupContainer = ({
|
|
985
|
+
isMobile,
|
|
986
|
+
useBoundaryMount,
|
|
987
|
+
getBoundaryElement
|
|
988
|
+
}) => {
|
|
989
|
+
if (!isMobile || useBoundaryMount) {
|
|
990
|
+
return typeof getBoundaryElement === 'function' ? getBoundaryElement() : null;
|
|
991
|
+
}
|
|
992
|
+
return typeof document !== 'undefined' ? document.body : null;
|
|
993
|
+
};
|
|
994
|
+
|
|
995
|
+
const useFilterPopupContainer = () => {
|
|
996
|
+
const getBoundaryElement = usePopupContainer();
|
|
997
|
+
const {
|
|
998
|
+
isMobile,
|
|
999
|
+
useBoundaryMount
|
|
1000
|
+
} = useMobileFixedMode();
|
|
1001
|
+
const getMountNode = useCallback(() => resolveFilterPopupContainer({
|
|
1002
|
+
isMobile,
|
|
1003
|
+
useBoundaryMount,
|
|
1004
|
+
getBoundaryElement
|
|
1005
|
+
}), [getBoundaryElement, isMobile, useBoundaryMount]);
|
|
1006
|
+
const getPopupContainer = useCallback(() => getMountNode(), [getMountNode]);
|
|
1007
|
+
return {
|
|
1008
|
+
isMobile,
|
|
1009
|
+
useBoundaryMount,
|
|
1010
|
+
getMountNode,
|
|
1011
|
+
getPopupContainer
|
|
1012
|
+
};
|
|
1013
|
+
};
|
|
1014
|
+
|
|
978
1015
|
const FilterItem = withLocale(({
|
|
979
1016
|
open,
|
|
980
1017
|
active,
|
|
@@ -1069,8 +1106,10 @@ const withFieldItem = (WrappedComponent, options = {}) => _ref => {
|
|
|
1069
1106
|
const [open, setOpen] = useState(false);
|
|
1070
1107
|
const {
|
|
1071
1108
|
isMobile,
|
|
1072
|
-
useBoundaryMount
|
|
1073
|
-
|
|
1109
|
+
useBoundaryMount,
|
|
1110
|
+
getMountNode,
|
|
1111
|
+
getPopupContainer
|
|
1112
|
+
} = useFilterPopupContainer();
|
|
1074
1113
|
const fixedModeClass = useBoundaryMount ? style$1['is-boundary'] : style$1['is-viewport'];
|
|
1075
1114
|
const [renderMask, setRenderMask] = useState(false);
|
|
1076
1115
|
const [maskClosing, setMaskClosing] = useState(false);
|
|
@@ -1080,7 +1119,6 @@ const withFieldItem = (WrappedComponent, options = {}) => _ref => {
|
|
|
1080
1119
|
height: 0
|
|
1081
1120
|
});
|
|
1082
1121
|
const triggerRef = useRef(null);
|
|
1083
|
-
const getBoundaryElement = usePopupContainer();
|
|
1084
1122
|
const getScrollElement = useScrollElement();
|
|
1085
1123
|
const resolveGetPopupContainer = useCallback(triggerNode => {
|
|
1086
1124
|
if (typeof props.getPopupContainer === 'function') {
|
|
@@ -1089,15 +1127,9 @@ const withFieldItem = (WrappedComponent, options = {}) => _ref => {
|
|
|
1089
1127
|
return customContainer;
|
|
1090
1128
|
}
|
|
1091
1129
|
}
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
if (useBoundaryMount) {
|
|
1096
|
-
return getBoundaryElement();
|
|
1097
|
-
}
|
|
1098
|
-
return typeof document !== 'undefined' ? document.body : null;
|
|
1099
|
-
}, [getBoundaryElement, isMobile, props.getPopupContainer, useBoundaryMount]);
|
|
1100
|
-
const popupMountNode = typeof document !== 'undefined' ? isMobile ? useBoundaryMount ? getBoundaryElement() || document.body : document.body : getBoundaryElement() || document.body : null;
|
|
1130
|
+
return getPopupContainer(triggerNode);
|
|
1131
|
+
}, [getPopupContainer, props.getPopupContainer]);
|
|
1132
|
+
const popupMountNode = typeof document !== 'undefined' ? getMountNode() || document.body : null;
|
|
1101
1133
|
const setMobilePopupVariables = useCallback(metrics => {
|
|
1102
1134
|
if (typeof document === 'undefined') return;
|
|
1103
1135
|
document.body.style.setProperty('--react-filter-field-mobile-height', `${metrics.height}px`);
|
|
@@ -1108,13 +1140,13 @@ const withFieldItem = (WrappedComponent, options = {}) => _ref => {
|
|
|
1108
1140
|
if (typeof window === 'undefined' || !triggerRef.current) return;
|
|
1109
1141
|
const metrics = getMobilePopupMetrics(triggerRef.current, {
|
|
1110
1142
|
scrollEl: getScrollElement(),
|
|
1111
|
-
boundaryEl:
|
|
1143
|
+
boundaryEl: getMountNode(),
|
|
1112
1144
|
useBoundaryMount,
|
|
1113
1145
|
offset: MOBILE_POPUP_OFFSET$1
|
|
1114
1146
|
});
|
|
1115
1147
|
setPopupMetrics(metrics);
|
|
1116
1148
|
setMobilePopupVariables(metrics);
|
|
1117
|
-
}, [
|
|
1149
|
+
}, [getMountNode, getScrollElement, setMobilePopupVariables, useBoundaryMount]);
|
|
1118
1150
|
useResponsiveScrollListener(updatePopupMetrics, open && isMobile);
|
|
1119
1151
|
useEffect(() => {
|
|
1120
1152
|
if (typeof document === 'undefined' || !isMobile || popupMetrics.height <= 0) return;
|
|
@@ -1210,7 +1242,7 @@ const withFieldItem = (WrappedComponent, options = {}) => _ref => {
|
|
|
1210
1242
|
zIndex: isMobile ? MOBILE_POPUP_Z_INDEX : props.zIndex,
|
|
1211
1243
|
overlayWidth: isMobile && options.forcePopup ? typeof window === 'undefined' ? props.overlayWidth : getMobilePopupMetrics(triggerRef.current, {
|
|
1212
1244
|
scrollEl: getScrollElement(),
|
|
1213
|
-
boundaryEl:
|
|
1245
|
+
boundaryEl: getMountNode(),
|
|
1214
1246
|
useBoundaryMount
|
|
1215
1247
|
}).width || window.innerWidth : props.overlayWidth
|
|
1216
1248
|
}));
|
|
@@ -1265,10 +1297,11 @@ const PopoverItem = withLocale(({
|
|
|
1265
1297
|
const [open, setOpen] = useState(false);
|
|
1266
1298
|
const {
|
|
1267
1299
|
isMobile,
|
|
1268
|
-
useBoundaryMount
|
|
1269
|
-
|
|
1300
|
+
useBoundaryMount,
|
|
1301
|
+
getMountNode,
|
|
1302
|
+
getPopupContainer
|
|
1303
|
+
} = useFilterPopupContainer();
|
|
1270
1304
|
const fixedModeClass = useBoundaryMount ? style$1['is-boundary'] : style$1['is-viewport'];
|
|
1271
|
-
const getBoundaryElement = usePopupContainer();
|
|
1272
1305
|
const getScrollElement = useScrollElement();
|
|
1273
1306
|
const resolveGetPopupContainer = useCallback(triggerNode => {
|
|
1274
1307
|
if (typeof customGetPopupContainer === 'function') {
|
|
@@ -1277,15 +1310,8 @@ const PopoverItem = withLocale(({
|
|
|
1277
1310
|
return customContainer;
|
|
1278
1311
|
}
|
|
1279
1312
|
}
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
}
|
|
1283
|
-
if (useBoundaryMount) {
|
|
1284
|
-
return getBoundaryElement();
|
|
1285
|
-
}
|
|
1286
|
-
return typeof document !== 'undefined' ? document.body : null;
|
|
1287
|
-
}, [customGetPopupContainer, getBoundaryElement, isMobile, useBoundaryMount]);
|
|
1288
|
-
const popupMountNode = typeof document !== 'undefined' ? isMobile ? useBoundaryMount ? getBoundaryElement() || document.body : document.body : getBoundaryElement() || document.body : null;
|
|
1313
|
+
return getPopupContainer(triggerNode);
|
|
1314
|
+
}, [customGetPopupContainer, getPopupContainer]);
|
|
1289
1315
|
const [renderMask, setRenderMask] = useState(false);
|
|
1290
1316
|
const [maskClosing, setMaskClosing] = useState(false);
|
|
1291
1317
|
const [popupMetrics, setPopupMetrics] = useState({
|
|
@@ -1294,6 +1320,7 @@ const PopoverItem = withLocale(({
|
|
|
1294
1320
|
height: 0
|
|
1295
1321
|
});
|
|
1296
1322
|
const triggerRef = useRef(null);
|
|
1323
|
+
const popupMountNode = typeof document !== 'undefined' ? getMountNode() || document.body : null;
|
|
1297
1324
|
const disabled = useMemo(() => {
|
|
1298
1325
|
return onValidate && !onValidate(state);
|
|
1299
1326
|
}, [onValidate, state]);
|
|
@@ -1306,12 +1333,12 @@ const PopoverItem = withLocale(({
|
|
|
1306
1333
|
if (typeof window === 'undefined' || !triggerRef.current) return;
|
|
1307
1334
|
const metrics = getMobilePopupMetrics(triggerRef.current, {
|
|
1308
1335
|
scrollEl: getScrollElement(),
|
|
1309
|
-
boundaryEl:
|
|
1336
|
+
boundaryEl: getMountNode(),
|
|
1310
1337
|
useBoundaryMount,
|
|
1311
1338
|
offset: MOBILE_POPUP_OFFSET
|
|
1312
1339
|
});
|
|
1313
1340
|
setPopupMetrics(metrics);
|
|
1314
|
-
}, [
|
|
1341
|
+
}, [getMountNode, getScrollElement, useBoundaryMount]);
|
|
1315
1342
|
useResponsiveScrollListener(updatePopupMetrics, open && isMobile);
|
|
1316
1343
|
useEffect(() => {
|
|
1317
1344
|
if (open && isMobile) {
|
|
@@ -1658,11 +1685,11 @@ const TypeDateRangePickerField = _ref => {
|
|
|
1658
1685
|
} = useIntl({
|
|
1659
1686
|
moduleName: 'Filter'
|
|
1660
1687
|
});
|
|
1661
|
-
const getPopupContainer = usePopupContainer();
|
|
1662
1688
|
const {
|
|
1663
1689
|
isMobile,
|
|
1664
|
-
useBoundaryMount
|
|
1665
|
-
|
|
1690
|
+
useBoundaryMount,
|
|
1691
|
+
getPopupContainer
|
|
1692
|
+
} = useFilterPopupContainer();
|
|
1666
1693
|
const fixedModeClass = useBoundaryMount ? style['is-boundary'] : style['is-viewport'];
|
|
1667
1694
|
const nestedPopupClassName = classnames(style['field-item-mobile-popup'], FIELD_MOBILE_POPUP_CLASS, fixedModeClass);
|
|
1668
1695
|
const nestedPopupStyle = isMobile ? {
|
|
@@ -2761,7 +2788,9 @@ const CityFilterItemInner = _ref => {
|
|
|
2761
2788
|
const {
|
|
2762
2789
|
message
|
|
2763
2790
|
} = App.useApp();
|
|
2764
|
-
const
|
|
2791
|
+
const {
|
|
2792
|
+
getPopupContainer
|
|
2793
|
+
} = useFilterPopupContainer();
|
|
2765
2794
|
const {
|
|
2766
2795
|
locale
|
|
2767
2796
|
} = useIntl();
|