@balena/ui-shared-components 9.7.7 → 9.7.8

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.
@@ -2,7 +2,7 @@ import { __rest } from "tslib";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { createElement as _createElement } from "react";
4
4
  import { color } from '@balena/design-tokens';
5
- import { Autocomplete, Box, ListItemButton } from '@mui/material';
5
+ import { Autocomplete, Box, ListItemButton, Stack } from '@mui/material';
6
6
  import throttle from 'lodash/throttle';
7
7
  import * as React from 'react';
8
8
  import { VList } from 'virtua';
@@ -11,6 +11,7 @@ const ListboxComponent = (_a) => {
11
11
  const itemData = children.slice();
12
12
  const { itemCount, loadNextPage } = pagination;
13
13
  const [optionHeightsTotal, setOptionHeightsTotal] = React.useState(0);
14
+ const ref = React.useRef(null);
14
15
  React.useEffect(() => {
15
16
  if (!isNextPageLoading) {
16
17
  setOptionHeightsTotal(0);
@@ -26,14 +27,17 @@ const ListboxComponent = (_a) => {
26
27
  setOptionHeightsTotal(total);
27
28
  }
28
29
  }, [optionHeightsTotal]);
29
- return (_jsxs(Box, Object.assign({}, props, { style: Object.assign(Object.assign({}, style), { padding: 0, height: document.documentElement.clientHeight * 0.4 < optionHeightsTotal
30
+ return (_jsxs(Stack, Object.assign({}, props, { style: Object.assign(Object.assign({}, style), { padding: 0, height: document.documentElement.clientHeight * 0.4 < optionHeightsTotal
30
31
  ? '40vh'
31
- : optionHeightsTotal, display: 'flex', flexDirection: 'column' }), children: [_jsx(VList, { style: {
32
+ : optionHeightsTotal }), children: [_jsx(VList, { ref: ref, style: {
32
33
  flex: 1,
33
- }, onRangeChange: async (_, lastItemIndex) => {
34
+ }, onScroll: async () => {
35
+ if (!ref.current) {
36
+ return;
37
+ }
34
38
  if (itemCount != null &&
35
- lastItemIndex + 1 === itemData.length &&
36
- lastItemIndex + 1 < itemCount) {
39
+ itemData.length < itemCount &&
40
+ ref.current.findEndIndex() + 50 > itemCount) {
37
41
  await (loadNextPage === null || loadNextPage === void 0 ? void 0 : loadNextPage());
38
42
  }
39
43
  }, children: itemData.map((item, i) => (_createElement(Box, Object.assign({ component: ListItemButton }, item.props, (i < itemData.length - 1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@balena/ui-shared-components",
3
- "version": "9.7.7",
3
+ "version": "9.7.8",
4
4
  "main": "./dist/index.js",
5
5
  "sideEffects": false,
6
6
  "files": [
@@ -40,7 +40,7 @@
40
40
  "remark-gfm": "^4.0.0",
41
41
  "rimraf": "^6.0.0",
42
42
  "typescript": "^5.5.2",
43
- "virtua": "^0.36.0",
43
+ "virtua": "^0.37.3",
44
44
  "zxcvbn": "^4.4.2"
45
45
  },
46
46
  "devDependencies": {
@@ -114,6 +114,6 @@
114
114
  },
115
115
  "homepage": "https://github.com/balena-io/ui-shared-components#readme",
116
116
  "versionist": {
117
- "publishedAt": "2024-11-20T12:14:17.194Z"
117
+ "publishedAt": "2024-11-20T15:03:20.202Z"
118
118
  }
119
119
  }