@onehat/ui 0.3.37 → 0.3.38
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/package.json
CHANGED
|
@@ -150,7 +150,7 @@ function GridComponent(props) {
|
|
|
150
150
|
gridRef = useRef(),
|
|
151
151
|
gridContainerRef = useRef(),
|
|
152
152
|
isAddingRef = useRef(),
|
|
153
|
-
|
|
153
|
+
isRenderedRef = useRef(),
|
|
154
154
|
[isReady, setIsReady] = useState(false),
|
|
155
155
|
[isLoading, setIsLoading] = useState(false),
|
|
156
156
|
[localColumnsConfig, setLocalColumnsConfigRaw] = useState([]),
|
|
@@ -622,50 +622,49 @@ function GridComponent(props) {
|
|
|
622
622
|
}
|
|
623
623
|
setDragRowSlot(null);
|
|
624
624
|
},
|
|
625
|
-
|
|
626
|
-
|
|
625
|
+
adjustPageSizeToHeight = (e) => {
|
|
627
626
|
let doLoad = false;
|
|
628
|
-
if (!
|
|
629
|
-
|
|
627
|
+
if (!isRenderedRef.current) {
|
|
628
|
+
isRenderedRef.current = true;
|
|
630
629
|
if (loadOnRender && Repository && !Repository.isLoaded && !Repository.isLoading && !Repository.isAutoLoad) {
|
|
631
630
|
doLoad = true; // first time in onLayout only!
|
|
632
631
|
}
|
|
633
632
|
}
|
|
634
633
|
|
|
635
|
-
|
|
634
|
+
let adjustPageSizeToHeight = true;
|
|
635
|
+
if (disableAdjustingPageSizeToHeight || !Repository) {
|
|
636
|
+
adjustPageSizeToHeight = false;
|
|
637
|
+
}
|
|
636
638
|
if (adjustPageSizeToHeight) {
|
|
637
|
-
// this currently only works on web
|
|
638
639
|
const
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
// const
|
|
653
|
-
// rowHeight = firstRow.getBoundingClientRect().height,
|
|
654
|
-
// rowsPerContainer = Math.floor(scrollableNodeHeight / rowHeight);
|
|
655
|
-
// let pageSize = rowsPerContainer;
|
|
656
|
-
// if (showHeaders) {
|
|
657
|
-
// pageSize--;
|
|
658
|
-
// }
|
|
659
|
-
// if (pageSize !== Repository.pageSize) {
|
|
660
|
-
// Repository.setPageSize(pageSize);
|
|
661
|
-
// }
|
|
662
|
-
// }
|
|
640
|
+
containerHeight = e.nativeEvent.layout.height,
|
|
641
|
+
headerHeight = showHeaders ? 50 : 0,
|
|
642
|
+
footerHeight = !disablePagination ? 50 : 0,
|
|
643
|
+
height = containerHeight - headerHeight - footerHeight,
|
|
644
|
+
rowHeight = 48,
|
|
645
|
+
rowsPerContainer = Math.floor(height / rowHeight);
|
|
646
|
+
let pageSize = rowsPerContainer;
|
|
647
|
+
if (showHeaders) {
|
|
648
|
+
pageSize--;
|
|
649
|
+
}
|
|
650
|
+
if (pageSize !== Repository.pageSize) {
|
|
651
|
+
Repository.setPageSize(pageSize);
|
|
652
|
+
}
|
|
663
653
|
}
|
|
664
654
|
if (doLoad) {
|
|
665
655
|
Repository.load();
|
|
666
656
|
}
|
|
667
657
|
},
|
|
668
|
-
|
|
658
|
+
debouncedAdjustPageSizeToHeight = useCallback(_.debounce(adjustPageSizeToHeight, 200), []),
|
|
659
|
+
onLayout = (e) => {
|
|
660
|
+
if (!isRenderedRef.current) {
|
|
661
|
+
// first time, call this immediately
|
|
662
|
+
adjustPageSizeToHeight(e);
|
|
663
|
+
} else {
|
|
664
|
+
// debounce all subsequent calls
|
|
665
|
+
debouncedAdjustPageSizeToHeight(e);
|
|
666
|
+
}
|
|
667
|
+
};
|
|
669
668
|
|
|
670
669
|
useEffect(() => {
|
|
671
670
|
|
|
@@ -841,7 +840,7 @@ function GridComponent(props) {
|
|
|
841
840
|
bg={bg}
|
|
842
841
|
borderWidth={styles.GRID_BORDER_WIDTH}
|
|
843
842
|
borderColor={styles.GRID_BORDER_COLOR}
|
|
844
|
-
onLayout={
|
|
843
|
+
onLayout={onLayout}
|
|
845
844
|
{...sizeProps}
|
|
846
845
|
>
|
|
847
846
|
{topToolbar}
|