@kne/react-filter 1.0.0 → 1.0.1
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.js +22 -9
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +22 -9
- package/dist/index.modern.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -562,16 +562,24 @@ const withFieldItem = function (WrappedComponent, options) {
|
|
|
562
562
|
popupMetrics = _useState5[0],
|
|
563
563
|
setPopupMetrics = _useState5[1];
|
|
564
564
|
const triggerRef = react.useRef(null);
|
|
565
|
+
const setMobilePopupVariables = react.useCallback(metrics => {
|
|
566
|
+
if (typeof document === 'undefined') return;
|
|
567
|
+
document.body.style.setProperty('--react-filter-field-mobile-height', metrics.height + "px");
|
|
568
|
+
document.body.style.setProperty('--react-filter-popover-mobile-height', metrics.height + "px");
|
|
569
|
+
document.body.style.setProperty('--react-filter-field-mobile-top', metrics.pageTop + "px");
|
|
570
|
+
}, []);
|
|
565
571
|
const updatePopupMetrics = react.useCallback(() => {
|
|
566
572
|
if (typeof window === 'undefined' || !triggerRef.current) return;
|
|
567
573
|
const rect = triggerRef.current.getBoundingClientRect();
|
|
568
574
|
const top = Math.max(rect.bottom + MOBILE_POPUP_OFFSET$1, 0);
|
|
569
|
-
|
|
575
|
+
const metrics = {
|
|
570
576
|
top,
|
|
571
577
|
pageTop: top + window.scrollY,
|
|
572
578
|
height: Math.max(window.innerHeight - top, 0)
|
|
573
|
-
}
|
|
574
|
-
|
|
579
|
+
};
|
|
580
|
+
setPopupMetrics(metrics);
|
|
581
|
+
setMobilePopupVariables(metrics);
|
|
582
|
+
}, [setMobilePopupVariables]);
|
|
575
583
|
react.useEffect(() => {
|
|
576
584
|
if (typeof window === 'undefined') return;
|
|
577
585
|
const mediaQuery = window.matchMedia('(max-width: 768px)');
|
|
@@ -595,16 +603,14 @@ const withFieldItem = function (WrappedComponent, options) {
|
|
|
595
603
|
};
|
|
596
604
|
}, [isMobile, open, updatePopupMetrics]);
|
|
597
605
|
react.useEffect(() => {
|
|
598
|
-
if (typeof document === 'undefined' || !isMobile) return;
|
|
599
|
-
|
|
600
|
-
document.body.style.setProperty('--react-filter-popover-mobile-height', popupMetrics.height + "px");
|
|
601
|
-
document.body.style.setProperty('--react-filter-field-mobile-top', popupMetrics.pageTop + "px");
|
|
606
|
+
if (typeof document === 'undefined' || !isMobile || popupMetrics.height <= 0) return;
|
|
607
|
+
setMobilePopupVariables(popupMetrics);
|
|
602
608
|
return () => {
|
|
603
609
|
document.body.style.removeProperty('--react-filter-field-mobile-height');
|
|
604
610
|
document.body.style.removeProperty('--react-filter-popover-mobile-height');
|
|
605
611
|
document.body.style.removeProperty('--react-filter-field-mobile-top');
|
|
606
612
|
};
|
|
607
|
-
}, [isMobile, popupMetrics
|
|
613
|
+
}, [isMobile, popupMetrics, setMobilePopupVariables]);
|
|
608
614
|
react.useEffect(() => {
|
|
609
615
|
if (open && isMobile) {
|
|
610
616
|
setRenderMask(true);
|
|
@@ -637,7 +643,9 @@ const withFieldItem = function (WrappedComponent, options) {
|
|
|
637
643
|
const mobilePopupStyle = isMobile ? {
|
|
638
644
|
'--react-filter-field-mobile-height': popupMetrics.height + "px",
|
|
639
645
|
'--react-filter-popover-mobile-height': popupMetrics.height + "px",
|
|
640
|
-
'--react-filter-field-mobile-top': popupMetrics.pageTop + "px"
|
|
646
|
+
'--react-filter-field-mobile-top': popupMetrics.pageTop + "px",
|
|
647
|
+
top: popupMetrics.pageTop,
|
|
648
|
+
left: 0
|
|
641
649
|
} : undefined;
|
|
642
650
|
const mergePopupClassNames = classNames => {
|
|
643
651
|
var _classNames$popup;
|
|
@@ -671,11 +679,16 @@ const withFieldItem = function (WrappedComponent, options) {
|
|
|
671
679
|
popupClassName: classnames__default["default"](props.popupClassName, isMobile && style$1['field-item-mobile-popup'], isMobile && FIELD_MOBILE_POPUP_CLASS),
|
|
672
680
|
dropdownClassName: classnames__default["default"](props.dropdownClassName, isMobile && style$1['field-item-mobile-popup'], isMobile && FIELD_MOBILE_POPUP_CLASS),
|
|
673
681
|
overlayClassName: classnames__default["default"](props.overlayClassName, isMobile && style$1['field-item-mobile-popup'], isMobile && FIELD_MOBILE_POPUP_CLASS),
|
|
682
|
+
overlayStyle: Object.assign({}, props.overlayStyle, mobilePopupStyle),
|
|
674
683
|
popupStyle: Object.assign({}, props.popupStyle, mobilePopupStyle),
|
|
675
684
|
dropdownStyle: Object.assign({}, props.dropdownStyle, mobilePopupStyle),
|
|
676
685
|
classNames: mergePopupClassNames(props.classNames),
|
|
677
686
|
styles: mergePopupStyles(props.styles),
|
|
678
687
|
transitionName: isMobile ? '' : props.transitionName,
|
|
688
|
+
autoAdjustOverflow: isMobile ? false : props.autoAdjustOverflow,
|
|
689
|
+
align: isMobile ? {
|
|
690
|
+
offset: [0, 0]
|
|
691
|
+
} : props.align,
|
|
679
692
|
isPopup: options.forcePopup ? true : props.isPopup,
|
|
680
693
|
overlayWidth: isMobile && options.forcePopup ? typeof window === 'undefined' ? props.overlayWidth : window.innerWidth : props.overlayWidth
|
|
681
694
|
}));
|