@maxio-com/react-ui-components 9.24.1 → 9.25.0
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.esm.js +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/skills/maxio-react/references/components-listbox.md +53 -0
- package/dist/temporary-typings/src/components/ListBox/ListBox.d.ts +1 -1
- package/dist/temporary-typings/src/components/ListBox/ListBox.d.ts.map +1 -1
- package/dist/temporary-typings/src/components/ListBox/types.d.ts +4 -1
- package/dist/temporary-typings/src/components/ListBox/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/typings/index.d.ts +5 -2
|
@@ -99,6 +99,19 @@ selection when all options are selected, and updates controlled and uncontrolled
|
|
|
99
99
|
state through the same `onSelectionChange` API. When `disallowEmptySelection` is
|
|
100
100
|
set, the toggle is disabled after all options are selected.
|
|
101
101
|
|
|
102
|
+
## Async Loading
|
|
103
|
+
|
|
104
|
+
Set `onLoadMore` on `ListBox` to load another page when the user scrolls near the
|
|
105
|
+
bottom, and set `isLoading` while options are loading. ListBox manages the loading
|
|
106
|
+
item internally and displays a small spinner for both initial loading and
|
|
107
|
+
pagination. Use `scrollOffset` to adjust how early the next page loads.
|
|
108
|
+
|
|
109
|
+
Pass options through `items` with a child render function, or use static children.
|
|
110
|
+
Give the listbox a bounded height with scrolling, as shown in the **Async Loading**
|
|
111
|
+
story. Omit `onLoadMore` when no pages remain, or use a pagination callback that
|
|
112
|
+
stops requesting pages at the end (as `useAsyncList` does). `renderEmptyState`
|
|
113
|
+
provides the message when loading finishes without results.
|
|
114
|
+
|
|
102
115
|
## Imports
|
|
103
116
|
|
|
104
117
|
```tsx
|
|
@@ -217,3 +230,43 @@ const EmptyState = () => (
|
|
|
217
230
|
</ListBox>
|
|
218
231
|
);
|
|
219
232
|
```
|
|
233
|
+
|
|
234
|
+
### Async Loading
|
|
235
|
+
|
|
236
|
+
Load options in pages as users scroll. This example simulates a delayed API
|
|
237
|
+
with 60 options, loading 20 at a time without an external network request.
|
|
238
|
+
|
|
239
|
+
```tsx
|
|
240
|
+
const AsyncLoading = () => {
|
|
241
|
+
const list = useAsyncList<{ id: number; name: string }>({
|
|
242
|
+
async load({ cursor }) {
|
|
243
|
+
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
244
|
+
|
|
245
|
+
const start = Number(cursor ?? 0);
|
|
246
|
+
const end = start + 20;
|
|
247
|
+
|
|
248
|
+
return {
|
|
249
|
+
items: Array.from({ length: 20 }, (_, index) => ({
|
|
250
|
+
id: start + index + 1,
|
|
251
|
+
name: `Option ${start + index + 1}`,
|
|
252
|
+
})),
|
|
253
|
+
cursor: end < 60 ? String(end) : undefined,
|
|
254
|
+
};
|
|
255
|
+
},
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
return (
|
|
259
|
+
<ListBox
|
|
260
|
+
aria-label="Async options"
|
|
261
|
+
selectionMode="single"
|
|
262
|
+
items={list.items}
|
|
263
|
+
isLoading={list.isLoading}
|
|
264
|
+
onLoadMore={list.loadMore}
|
|
265
|
+
style={{ height: 240, width: 280, overflow: 'auto' }}
|
|
266
|
+
renderEmptyState={() => 'No results found.'}
|
|
267
|
+
>
|
|
268
|
+
{(item) => <ListBox.Item id={item.id}>{item.name}</ListBox.Item>}
|
|
269
|
+
</ListBox>
|
|
270
|
+
);
|
|
271
|
+
};
|
|
272
|
+
```
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { ListBoxHeaderProps, ListBoxItemProps, ListBoxProps, ListBoxSectionProps } from './types';
|
|
3
3
|
declare const ListBoxRoot: {
|
|
4
|
-
({ className, render, showSelectAll, ...props }: ListBoxProps): React.JSX.Element;
|
|
4
|
+
<T extends object>({ className, children, items, render, renderEmptyState, isLoading, onLoadMore, scrollOffset, showSelectAll, ...props }: ListBoxProps<T>): React.JSX.Element;
|
|
5
5
|
displayName: string;
|
|
6
6
|
};
|
|
7
7
|
declare const ListBoxItem: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListBox.d.ts","sourceRoot":"","sources":["../../../../../src/components/ListBox/ListBox.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ListBox.d.ts","sourceRoot":"","sources":["../../../../../src/components/ListBox/ListBox.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAgB1B,OAAO,KAAK,EACV,kBAAkB,EAClB,gBAAgB,EAChB,YAAY,EACZ,mBAAmB,EACpB,MAAM,SAAS,CAAC;AAGjB,QAAA,MAAM,WAAW;KAAI,CAAC,SAAS,MAAM,0HAWlC,YAAY,CAAC,CAAC,CAAC;;CA0EjB,CAAC;AAKF,QAAA,MAAM,WAAW;8BAA6B,gBAAgB;;CAyB7D,CAAC;AAKF,QAAA,MAAM,cAAc;8BAA6B,mBAAmB;;CAKnE,CAAC;AAKF,QAAA,MAAM,aAAa;8BAA6B,kBAAkB;;CAEjE,CAAC;AAIF,MAAM,MAAM,gBAAgB,GAAG,OAAO,WAAW,GAAG;IAClD,IAAI,EAAE,OAAO,WAAW,CAAC;IACzB,OAAO,EAAE,OAAO,cAAc,CAAC;IAC/B,MAAM,EAAE,OAAO,aAAa,CAAC;CAC9B,CAAC;AAEF,QAAA,MAAM,OAAO,EAIP,gBAAgB,CAAC;AAEvB,eAAe,OAAO,CAAC"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import type { HeaderProps as AriaHeaderProps, ListBoxItemProps as AriaListBoxItemProps, ListBoxProps as AriaListBoxProps, ListBoxSectionProps as AriaListBoxSectionProps } from 'react-aria-components';
|
|
1
|
+
import type { HeaderProps as AriaHeaderProps, ListBoxItemProps as AriaListBoxItemProps, ListBoxLoadMoreItemProps as AriaListBoxLoadMoreItemProps, ListBoxProps as AriaListBoxProps, ListBoxSectionProps as AriaListBoxSectionProps } from 'react-aria-components';
|
|
2
2
|
export type ListBoxProps<T extends object = object> = AriaListBoxProps<T> & {
|
|
3
3
|
showSelectAll?: boolean;
|
|
4
|
+
isLoading?: boolean;
|
|
5
|
+
onLoadMore?: AriaListBoxLoadMoreItemProps['onLoadMore'];
|
|
6
|
+
scrollOffset?: AriaListBoxLoadMoreItemProps['scrollOffset'];
|
|
4
7
|
};
|
|
5
8
|
export type ListBoxItemProps = AriaListBoxItemProps;
|
|
6
9
|
export type ListBoxSectionProps<T extends object = object> = AriaListBoxSectionProps<T>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/components/ListBox/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,IAAI,eAAe,EAC9B,gBAAgB,IAAI,oBAAoB,EACxC,YAAY,IAAI,gBAAgB,EAChC,mBAAmB,IAAI,uBAAuB,EAC/C,MAAM,uBAAuB,CAAC;AAE/B,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI,gBAAgB,CAAC,CAAC,CAAC,GAAG;IAM1E,aAAa,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/components/ListBox/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,IAAI,eAAe,EAC9B,gBAAgB,IAAI,oBAAoB,EACxC,wBAAwB,IAAI,4BAA4B,EACxD,YAAY,IAAI,gBAAgB,EAChC,mBAAmB,IAAI,uBAAuB,EAC/C,MAAM,uBAAuB,CAAC;AAE/B,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI,gBAAgB,CAAC,CAAC,CAAC,GAAG;IAM1E,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB,UAAU,CAAC,EAAE,4BAA4B,CAAC,YAAY,CAAC,CAAC;IAExD,YAAY,CAAC,EAAE,4BAA4B,CAAC,cAAc,CAAC,CAAC;CAC7D,CAAC;AACF,MAAM,MAAM,gBAAgB,GAAG,oBAAoB,CAAC;AACpD,MAAM,MAAM,mBAAmB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IACvD,uBAAuB,CAAC,CAAC,CAAC,CAAC;AAC7B,MAAM,MAAM,kBAAkB,GAAG,eAAe,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maxio-com/react-ui-components",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.25.0",
|
|
4
4
|
"description": "React UI components",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -65,5 +65,5 @@
|
|
|
65
65
|
"publishConfig": {
|
|
66
66
|
"access": "public"
|
|
67
67
|
},
|
|
68
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "ad1647de4f704ba3bee3e22932056ebb46dd6b76"
|
|
69
69
|
}
|
package/typings/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React$1, { ReactNode, HTMLAttributes, LiHTMLAttributes, ButtonHTMLAttributes, AnchorHTMLAttributes, RefObject, FC, ElementType, InputHTMLAttributes } from 'react';
|
|
2
2
|
import { RowData, Row, Table, ExpandedState, RowSelectionState, SortingState, TableOptions } from '@tanstack/react-table';
|
|
3
3
|
export { createColumnHelper } from '@tanstack/react-table';
|
|
4
|
-
import { PopoverProps as PopoverProps$1, ToggleButtonGroupProps, ToggleButtonProps, ListBoxProps as ListBoxProps$1, ListBoxItemProps as ListBoxItemProps$1, ListBoxSectionProps as ListBoxSectionProps$1, HeaderProps, ComboBoxProps as ComboBoxProps$1, ValidationResult, TextFieldProps as TextFieldProps$1, DateValue, CalendarProps as CalendarProps$1, RangeCalendarProps as RangeCalendarProps$1 } from 'react-aria-components';
|
|
4
|
+
import { PopoverProps as PopoverProps$1, ToggleButtonGroupProps, ToggleButtonProps, ListBoxProps as ListBoxProps$1, ListBoxLoadMoreItemProps, ListBoxItemProps as ListBoxItemProps$1, ListBoxSectionProps as ListBoxSectionProps$1, HeaderProps, ComboBoxProps as ComboBoxProps$1, ValidationResult, TextFieldProps as TextFieldProps$1, DateValue, CalendarProps as CalendarProps$1, RangeCalendarProps as RangeCalendarProps$1 } from 'react-aria-components';
|
|
5
5
|
export { DialogTrigger, Pressable } from 'react-aria-components';
|
|
6
6
|
import * as _floating_ui_react_dom_interactions from '@floating-ui/react-dom-interactions';
|
|
7
7
|
import { MotionProps } from 'framer-motion';
|
|
@@ -693,13 +693,16 @@ declare const CheckboxGroup: ({ helperText, className, errorMessage, children, d
|
|
|
693
693
|
|
|
694
694
|
type ListBoxProps<T extends object = object> = ListBoxProps$1<T> & {
|
|
695
695
|
showSelectAll?: boolean;
|
|
696
|
+
isLoading?: boolean;
|
|
697
|
+
onLoadMore?: ListBoxLoadMoreItemProps['onLoadMore'];
|
|
698
|
+
scrollOffset?: ListBoxLoadMoreItemProps['scrollOffset'];
|
|
696
699
|
};
|
|
697
700
|
type ListBoxItemProps = ListBoxItemProps$1;
|
|
698
701
|
type ListBoxSectionProps<T extends object = object> = ListBoxSectionProps$1<T>;
|
|
699
702
|
type ListBoxHeaderProps = HeaderProps;
|
|
700
703
|
|
|
701
704
|
declare const ListBoxRoot: {
|
|
702
|
-
({ className, render, showSelectAll, ...props }: ListBoxProps): React$1.JSX.Element;
|
|
705
|
+
<T extends object>({ className, children, items, render, renderEmptyState, isLoading, onLoadMore, scrollOffset, showSelectAll, ...props }: ListBoxProps<T>): React$1.JSX.Element;
|
|
703
706
|
displayName: string;
|
|
704
707
|
};
|
|
705
708
|
declare const ListBoxItem: {
|