@react-fabric/data 1.0.0-beta.51 → 1.0.0-beta.53

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.
Files changed (58) hide show
  1. package/dist/cjs/checklist/CheckList.js +23 -0
  2. package/dist/cjs/histogram/Histogram.js +28 -0
  3. package/dist/cjs/hooks/useFilteredList.js +20 -0
  4. package/dist/cjs/hooks/usePagination.js +20 -0
  5. package/dist/cjs/hooks/useSelectableList.js +29 -0
  6. package/dist/cjs/i18n/ar.json.js +8 -1
  7. package/dist/cjs/i18n/en.json.js +8 -1
  8. package/dist/cjs/json/JsonViewer.js +27 -0
  9. package/dist/cjs/pagination/Pagination.js +10 -0
  10. package/dist/cjs/table/Table.js +2 -2
  11. package/dist/cjs/table/types.js +29 -0
  12. package/dist/cjs/tree/TreeNode.js +1 -1
  13. package/dist/cjs/virtual/Gallery.js +35 -2
  14. package/dist/cjs/virtual/List.js +38 -1
  15. package/dist/esm/checklist/CheckList.js +23 -0
  16. package/dist/esm/histogram/Histogram.js +28 -0
  17. package/dist/esm/hooks/useFilteredList.js +20 -0
  18. package/dist/esm/hooks/usePagination.js +20 -0
  19. package/dist/esm/hooks/useSelectableList.js +29 -0
  20. package/dist/esm/i18n/ar.json.js +8 -2
  21. package/dist/esm/i18n/en.json.js +8 -2
  22. package/dist/esm/json/JsonViewer.js +27 -0
  23. package/dist/esm/pagination/Pagination.js +10 -0
  24. package/dist/esm/table/Table.js +2 -2
  25. package/dist/esm/table/types.js +29 -0
  26. package/dist/esm/tree/TreeNode.js +1 -1
  27. package/dist/esm/virtual/Gallery.js +35 -2
  28. package/dist/esm/virtual/List.js +38 -1
  29. package/dist/types/checklist/CheckList.d.ts +22 -0
  30. package/dist/types/histogram/Histogram.d.ts +28 -0
  31. package/dist/types/hooks/useFilteredList.d.ts +20 -2
  32. package/dist/types/hooks/usePagination.d.ts +19 -0
  33. package/dist/types/hooks/useSelectableList.d.ts +29 -0
  34. package/dist/types/json/JsonViewer.d.ts +27 -1
  35. package/dist/types/pagination/Pagination.d.ts +10 -1
  36. package/dist/types/table/Table.d.ts +14 -1
  37. package/dist/types/table/types.d.ts +28 -0
  38. package/dist/types/table/useVirtualTable.d.ts +1 -2
  39. package/dist/types/tree/TreePanel.d.ts +42 -1
  40. package/dist/types/tree/useTree.d.ts +2 -2
  41. package/dist/types/virtual/Gallery.d.ts +32 -0
  42. package/dist/types/virtual/List.d.ts +36 -0
  43. package/package.json +6 -6
  44. package/src/checklist/CheckList.tsx +22 -0
  45. package/src/histogram/Histogram.tsx +28 -0
  46. package/src/hooks/useFilteredList.tsx +19 -0
  47. package/src/hooks/usePagination.tsx +19 -0
  48. package/src/hooks/useSelectableList.ts +29 -0
  49. package/src/i18n/ar.json +5 -0
  50. package/src/i18n/en.json +5 -0
  51. package/src/json/JsonViewer.tsx +26 -0
  52. package/src/pagination/Pagination.tsx +10 -0
  53. package/src/table/Table.tsx +15 -2
  54. package/src/table/types.ts +28 -0
  55. package/src/tree/TreeNode.tsx +1 -1
  56. package/src/tree/TreePanel.tsx +41 -0
  57. package/src/virtual/Gallery.tsx +35 -2
  58. package/src/virtual/List.tsx +38 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-fabric/data",
3
- "version": "1.0.0-beta.51",
3
+ "version": "1.0.0-beta.53",
4
4
  "description": "RUF: Data package",
5
5
  "author": "Adarsh Pastakia <adarshpastakia@outlook.com>",
6
6
  "license": "MIT",
@@ -35,10 +35,10 @@
35
35
  "watch": "npm-run-all -p watch:rollup watch:dts"
36
36
  },
37
37
  "dependencies": {
38
- "@react-fabric/core": "^1.0.0-beta.51",
39
- "@react-fabric/date": "^1.0.0-beta.51",
40
- "@react-fabric/form": "^1.0.0-beta.51",
41
- "@react-fabric/utilities": "^1.0.0-beta.50",
38
+ "@react-fabric/core": "^1.0.0-beta.53",
39
+ "@react-fabric/date": "^1.0.0-beta.53",
40
+ "@react-fabric/form": "^1.0.0-beta.53",
41
+ "@react-fabric/utilities": "^1.0.0-beta.52",
42
42
  "@tanstack/react-virtual": "^3.13.9",
43
43
  "classnames": "^2.5.1",
44
44
  "color": "^4.2.3",
@@ -54,5 +54,5 @@
54
54
  "node": ">=18.12.0",
55
55
  "npm": ">=8.19.0"
56
56
  },
57
- "gitHead": "a1b04de4663045f82992bff2aef8db26608eac74"
57
+ "gitHead": "1042327831f9c908912c552d5c2704b765a6f9c2"
58
58
  }
@@ -149,6 +149,28 @@ const CheckItem: FC<
149
149
  );
150
150
  };
151
151
 
152
+ /**
153
+ * CheckList component to display a list of selectable items with checkboxes.
154
+ * It supports selection, deselection, and allows for negative selections.
155
+ *
156
+ * @param {CheckListProps} props - The properties for the CheckList component.
157
+ * @returns {JSX.Element} The rendered CheckList component.
158
+ *
159
+ * @example
160
+ * ```jsx
161
+ * <CheckList
162
+ * items={[
163
+ * { id: "1", label: "Item 1", icon: "icon1" },
164
+ * { id: "2", label: "Item 2", icon: "icon2", badge: { text: "New" } },
165
+ * ]}
166
+ * maxCount={5}
167
+ * allowNegative={true}
168
+ * emptyMessage="No items available"
169
+ * onChange={(selectedItems) => console.log(selectedItems)}
170
+ * onClick={(itemId, isNegative) => console.log(itemId, isNegative)}
171
+ * />
172
+ * ```
173
+ */
152
174
  export const CheckList: FC<CheckListProps> = ({
153
175
  items = [],
154
176
  maxCount = 0,
@@ -80,6 +80,34 @@ export interface HistogramProps extends TestProps {
80
80
  onClick?: (id: string, negative?: true) => void;
81
81
  }
82
82
 
83
+ /**
84
+ * Histogram component displays a bar chart of items with counts.
85
+ * It allows users to visualize the distribution of counts across different items.
86
+ * The component supports sorting, custom colors, and click handling for each item.
87
+ * It also provides an empty state when there are no items to display.
88
+ *
89
+ * @param {HistogramProps} props - The properties for the Histogram component.
90
+ * @returns {JSX.Element} - The rendered Histogram component.
91
+ *
92
+ * @example
93
+ * ```jsx
94
+ * <Histogram
95
+ * items={[
96
+ * { id: "1", label: "Item 1", count: 10 },
97
+ * { id: "2", label: "Item 2", count: 20 },
98
+ * { id: "3", label: "Item 3", count: 5, disabled: true },
99
+ * ]}
100
+ * total={30}
101
+ * color="primary-500"
102
+ * sortBy="count"
103
+ * emptyTitle="No Data Available"
104
+ * emptyMessage="Please check back later."
105
+ * onClick={(id, negative) => console.log(`Clicked on ${id}`, negative ? "Negative" : "Positive")}
106
+ * />
107
+ * ```
108
+ *
109
+ * @see {@link https://adarshpastakia.github.io/react-fabric/?path=/docs/data-histogram--docs}
110
+ */
83
111
  export const Histogram = ({
84
112
  items = [],
85
113
  total,
@@ -51,6 +51,25 @@ const filterList = (
51
51
  return newList;
52
52
  };
53
53
 
54
+ /**
55
+ * Custom hook to filter a list of items based on a query.
56
+ * It provides a way to search through the items and returns the filtered list.
57
+ * The hook uses a deferred value to optimize performance during transitions.
58
+ * It also allows for a custom matcher function to define how items should be matched against the query.
59
+ *
60
+ * @param items - The list of items to filter.
61
+ * @param matcher - An optional function to match items against the query.
62
+ * @returns An object containing the search function, current query, filtered list, and a boolean indicating if a search is in progress.
63
+ *
64
+ * @example
65
+ * ```jsx
66
+ * useFilteredList(items, (item, query) => {
67
+ * return item.name.includes(query);
68
+ * });
69
+ * ```
70
+ *
71
+ * @see {@link https://adarshpastakia.github.io/react-fabric/?path=/docs/data-usefilteredlist--docs}
72
+ */
54
73
  export const useFilteredList = <
55
74
  T extends AnyObject = KeyValue,
56
75
  Q extends AnyObject = string,
@@ -57,6 +57,25 @@ const makeRange = (start: number, end: number) => {
57
57
  return Array.from({ length }, (_: AnyObject, idx: number) => idx + start);
58
58
  };
59
59
 
60
+ /**
61
+ * Custom hook to manage pagination state and logic.
62
+ * It calculates the total number of pages, generates page ranges,
63
+ * and provides a way to change the current page.
64
+ * It also handles the transition of page changes to optimize performance.
65
+ *
66
+ * @param options - The pagination options including total records, current page, records per page, and change handler.
67
+ * @returns An object containing the current page, total pages, head label, ranges for pagination pills, and a function to change the page.
68
+ *
69
+ * @example
70
+ * ```jsx
71
+ * const { page, totalPages, headLabel, ranges, onPageChange } = usePagination({
72
+ * totalRecords: 100,
73
+ * currentPage: 0,
74
+ * perPage: 10,
75
+ * onChange: (newPage) => console.log("Page changed to:", newPage),
76
+ * });
77
+ * ```
78
+ */
60
79
  export const usePagination = ({
61
80
  totalRecords,
62
81
  currentPage = 0,
@@ -46,6 +46,35 @@ export interface SelectableProps {
46
46
  onClick?: (id: string, isNegative: boolean) => void;
47
47
  }
48
48
 
49
+ /**
50
+ * Custom hook to manage selection of items in a list.
51
+ * It allows toggling selection state of items, handling both selected and non-selected states.
52
+ * The hook maintains a selection state and provides a function to toggle the selection of items.
53
+ * It also supports callbacks for when the selection changes or when an item is clicked.
54
+ *
55
+ * @param items - The list of items to manage selection for.
56
+ * @param selected - An array of item IDs that are currently selected.
57
+ * @param nonselected - An array of item IDs that are currently non-selected.
58
+ * @param onChange - Callback function that is called when the selection changes.
59
+ * @param onClick - Callback function that is called when an item is clicked.
60
+ * @returns An object containing the current selection state and a function to toggle selection of items.
61
+ *
62
+ * @example
63
+ * ```jsx
64
+ * const { selection, toggleSelection } = useSelectableList({
65
+ * items: [{ id: '1', label: 'Item 1' }, { id: '2', label: 'Item 2' }],
66
+ * selected: ['1'],
67
+ * nonselected: ['2'],
68
+ * onChange: (selectedIds, nonSelectedIds) => {
69
+ * console.log('Selected:', selectedIds);
70
+ * console.log('Non-selected:', nonSelectedIds);
71
+ * },
72
+ * onClick: (id, isNegative) => {
73
+ * console.log(`Item ${id} clicked, isNegative: ${isNegative}`);
74
+ * },
75
+ * });
76
+ * ```
77
+ */
49
78
  export const useSelectableList = ({
50
79
  items,
51
80
  selected,
package/src/i18n/ar.json CHANGED
@@ -32,5 +32,10 @@
32
32
  "uncheckAll": "الغاءالكل",
33
33
  "addFilter": "أضف عامل تصفية",
34
34
  "addFilterNot": "إضافة لا تصفية"
35
+ },
36
+ "data": {
37
+ "tree": {
38
+ "noItems": "لا توجد عناصر شجرة متوفرة"
39
+ }
35
40
  }
36
41
  }
package/src/i18n/en.json CHANGED
@@ -32,5 +32,10 @@
32
32
  "uncheckAll": "Uncheck All",
33
33
  "addFilter": "Add Filter",
34
34
  "addFilterNot": "Add not Filter"
35
+ },
36
+ "data": {
37
+ "tree": {
38
+ "noItems": "No tree items available"
39
+ }
35
40
  }
36
41
  }
@@ -346,6 +346,32 @@ const JsonEntry = ({
346
346
  );
347
347
  };
348
348
 
349
+ /**
350
+ * JsonViewer component to display JSON data in a structured format.
351
+ * It supports inline display, property filtering, and custom formatting.
352
+ * The component can handle nested objects and arrays, displaying them in a tree-like structure.
353
+ * It also provides options for copying values and filtering properties.
354
+ *
355
+ * @param {JsonViewProps<T>} props - The properties for the JsonViewer component.
356
+ * @returns {JSX.Element} The rendered JsonViewer component.
357
+ *
358
+ * @example
359
+ * ```jsx
360
+ * <JsonViewer
361
+ * json={{ name: "John", age: 30, address: { city: "New York", zip: "10001" } }}
362
+ * copy={true}
363
+ * filters={true}
364
+ * propertyScheme={{ date: ["createdAt"], phone: ["contact"] }}
365
+ * inline={true}
366
+ * labelWidth="25%"
367
+ * formatter={(path, value) => (path === "age" ? `${value} years` : value)}
368
+ * labeler={(path) => path.replace(/_/g, " ").toUpperCase()}
369
+ * onFilter={(path, value, negate) => console.log(`Filter ${negate ? "negate" : ""} on ${path}:`, value)}
370
+ * />
371
+ * ```
372
+ *
373
+ * @see {@link https://adarshpastakia.github.io/react-fabric/?path=/docs/data-jsonviewer--docs}
374
+ */
349
375
  export const JsonViewer = <T extends KeyValue = KeyValue>({
350
376
  className,
351
377
  json,
@@ -48,6 +48,16 @@ export interface PaginationProps {
48
48
  onPageChange: (page: number) => void;
49
49
  }
50
50
 
51
+ /**
52
+ * Pagination component to navigate through pages of data.
53
+ * It displays buttons for navigating to the first, previous, next, and last pages,
54
+ * as well as buttons for specific page numbers based on the provided ranges.
55
+ * The component supports a minimal view that shows the current page and total pages.
56
+ * It uses memoization to optimize rendering performance.
57
+ *
58
+ * @param {PaginationProps} props - The properties for the Pagination component.
59
+ * @returns {JSX.Element} The rendered Pagination component.
60
+ */
51
61
  export const Pagination = memo(
52
62
  ({ page, ranges, totalPages, minimal, onPageChange }: PaginationProps) => {
53
63
  const [start, mid, last] = ranges;
@@ -48,6 +48,19 @@ import { type TableProps } from "./types";
48
48
  import { useTableColumns } from "./useTableColumns";
49
49
  import { useVirtualTable } from "./useVirtualTable";
50
50
 
51
+ /**
52
+ * Table component for displaying data in a tabular format with features like sorting, filtering, and virtual scrolling.
53
+ * It supports expandable rows, checkable rows, and customizable columns.
54
+ * The component is designed to handle large datasets efficiently by rendering only the visible rows.
55
+ * It also provides a way to manage column visibility and allows for custom rendering of group headers.
56
+ * Uses TanStack's `useVirtual` for virtualization and React's `useMemo` for performance optimization.
57
+ *
58
+ * @param {TableProps<T>} props - The properties for the Table component.
59
+ * @returns {JSX.Element} The rendered Table component.
60
+ *
61
+ * @see {@link https://adarshpastakia.github.io/react-fabric/?path=/story/data-table--table}
62
+ * @see {@link https://tanstack.com/table/v8/docs/api/virtual}
63
+ */
51
64
  export const Table = <T extends KeyValue = KeyValue>({
52
65
  ref,
53
66
  data,
@@ -166,7 +179,7 @@ export const Table = <T extends KeyValue = KeyValue>({
166
179
  >
167
180
  <div
168
181
  data-ref="tableHeader"
169
- className="bg-base font-medium sticky top-0 h-8 area-head border-b select-none flex flex-nowrap z-5"
182
+ className="bg-base font-medium sticky top-0 h-8 area-head border-b select-none flex flex-nowrap z-2"
170
183
  >
171
184
  <div className={wrapperStart}>
172
185
  {canExpand && <div className="w-6" />}
@@ -234,7 +247,7 @@ export const Table = <T extends KeyValue = KeyValue>({
234
247
  ref={measureElement}
235
248
  data-index={index}
236
249
  className={classNames(
237
- "px-2 py-1 text-md bg-base border-y border-tint-100 cursor-pointer flex items-center gap-1 z-3",
250
+ "px-2 py-1 text-md bg-base border-y border-tint-100 cursor-pointer flex items-center gap-1 z-1",
238
251
  isActiveSticky(index) && "sticky top-8",
239
252
  )}
240
253
  role="none"
@@ -34,6 +34,34 @@ export const COL_MIN_WIDTH = "3rem";
34
34
  export const COL_MAX_WIDTH = "64rem";
35
35
  export const COL_DEFAULT_WIDTH = "12rem";
36
36
 
37
+ /**
38
+ * TableColumn interface defines the structure of a column in a table.
39
+ * It includes properties for column identification, display options, alignment,
40
+ * visibility, resizing, sorting, filtering, and rendering.
41
+ *
42
+ * @template T - The type of data the column will represent, defaulting to KeyValue.
43
+ * @property {keyof T | string} id - Unique identifier for the column.
44
+ * @property {"string" | "number" | "boolean" | "datetime" | "date" | "time" | "unknown"} [dataType] - Data type of the column values.
45
+ * @property {string} [label] - Display label for the column header.
46
+ * @property {string} [tooltip] - Tooltip text for the column header.
47
+ * @property {string} [format] - Format string for displaying the column values.
48
+ * @property {"start" | "center" | "end"} [align] - Text alignment within the column.
49
+ * @property {"start" | "end"} [locked] - Indicates if the column is locked at the start or end.
50
+ * @property {boolean} [hidden] - Whether the column is hidden.
51
+ * @property {boolean} [truncate] - Whether to truncate the text in the column.
52
+ * @property {boolean} [hideable] - Whether the column can be hidden by the user.
53
+ * @property {boolean} [resizable] - Whether the column can be resized by the user.
54
+ * @property {boolean} [sortable] - Whether the column can be sorted.
55
+ * @property {boolean} [filterable] - Whether the column can be filtered.
56
+ * @property {AnyObject} [filter] - Filter criteria for the column.
57
+ * @property {ReactElement[]} [actions] - Array of action elements to be displayed in the column.
58
+ * @property {AnyObject[]} [filterOptions] - Options for filtering the column.
59
+ * @property {string | number} [width] - Width of the column.
60
+ * @property {string | number} [minWidth] - Minimum width of the column.
61
+ * @property {string | number} [maxWidth] - Maximum width of the column.
62
+ * @property {KeyValue} [valueMap] - Mapping of values for the column.
63
+ * @property {(value: AnyObject, data: T, index: number) => Elements<AnyObject>} [renderer] - Custom renderer function for the column values.
64
+ */
37
65
  export interface TableColumn<T = KeyValue>
38
66
  extends CssProp,
39
67
  IconProps,
@@ -166,7 +166,7 @@ export const TreeNode = ({
166
166
  }
167
167
  >
168
168
  {nodeIcon && (
169
- <div className="flex-content w-6 self-center leading-none">
169
+ <div className="flex-content max-w-6 me-1 self-center leading-none">
170
170
  {isValidElement(nodeIcon) && nodeIcon}
171
171
  {isString(nodeIcon) && (
172
172
  <Icon
@@ -38,6 +38,47 @@ import { useTree } from "./useTree";
38
38
 
39
39
  // TODO: implement keyboard handler for navigating tree
40
40
 
41
+ /**
42
+ * TreePanel component renders a virtualized tree structure with support for
43
+ * selection, expansion, and filtering. It allows for custom rendering of tree
44
+ * nodes and supports checkable nodes.
45
+ *
46
+ * @param {TreePanelProps<T>} props - The properties for the TreePanel component.
47
+ * @returns {JSX.Element} The rendered TreePanel component.
48
+ * @template T - The type of items in the tree, extending KeyValue.
49
+ *
50
+ * @example
51
+ * ```jsx
52
+ * <TreePanel
53
+ * items={items}
54
+ * selected={selectedItem}
55
+ * checked={checkedItems}
56
+ * checkable={true}
57
+ * renderer={(item) => <span>{item.name}</span>}
58
+ * searchable={true}
59
+ * selectable={true}
60
+ * matcher={(item, query) => item.name.toLowerCase().includes(query.toLowerCase())}
61
+ * filterPlaceholder="Search..."
62
+ * defaultLeafIcon={<Icon icon={CoreIcons.file} />}
63
+ * defaultNodeIcon={<Icon icon={CoreIcons.folder} />}
64
+ * expander="caret"
65
+ * onChecked={(checkedItems) => console.log(checkedItems)}
66
+ * onLoad={(id) => console.log(`Load children for ${id}`)}
67
+ * onQuery={(query) => console.log(`Query: ${query}`)}
68
+ * onSelect={(selectedItem) => console.log(selectedItem)}
69
+ * onClick={(item) => console.log(`Clicked on ${item.id}`)}
70
+ * sorter={(a, b) => a.label.localeCompare(b.label)}
71
+ * makeLabel={(item) => item.name}
72
+ * makeIcon={(item) => item.icon ? <Icon icon={item.icon} /> : null}
73
+ * defaultExpanded={["root"]}
74
+ * onExpandToggle={(id, expanded) => console.log(`Toggle expand for ${id}: ${expanded}`)}
75
+ * leafClassName="leaf-node"
76
+ * nodeClassName="tree-node"
77
+ * />
78
+ * ```
79
+ *
80
+ * @see {@link https://adarshpastakia.github.io/react-fabric/?path=/docs/data-treepanel--docs}
81
+ */
41
82
  export const TreePanel = <T extends KeyValue>({
42
83
  ref,
43
84
  items,
@@ -294,7 +294,7 @@ const _VirtualGallery = <T extends AnyObject>({
294
294
  >
295
295
  <div
296
296
  className={classNames(
297
- "inline-flex flex-nowrap gap-2 justify-center min-h-full min-w-full",
297
+ "flex flex-nowrap justify-center gap-2 min-h-full",
298
298
  )}
299
299
  >
300
300
  <div
@@ -318,7 +318,7 @@ const _VirtualGallery = <T extends AnyObject>({
318
318
  <div style={{ height: virtualItems[0]?.start }} />
319
319
  {virtualItems.map(({ key, index }) => (
320
320
  <div
321
- className="flex justify-center"
321
+ className="flex"
322
322
  key={key}
323
323
  data-index={index}
324
324
  ref={virtualizer.measureElement}
@@ -367,4 +367,37 @@ const _VirtualGallery = <T extends AnyObject>({
367
367
  _VirtualGallery.displayName = "VirtualGallery";
368
368
 
369
369
  const GenericMemo: <T>(c: T) => T = memo;
370
+
371
+ /**
372
+ * VirtualGallery component provides a virtualized gallery view for displaying a large list of items efficiently.
373
+ * It supports features like fixed columns, loading states, and customizable item rendering.
374
+ * The component uses virtualization to render only the visible items, improving performance for large datasets.
375
+ * It also provides a scroller for easy navigation through the items.
376
+ *
377
+ * @param {VirtualGalleryProps<T>} props - The properties for the VirtualGallery component.
378
+ * @returns {JSX.Element} The rendered VirtualGallery component.
379
+ *
380
+ * @example
381
+ * ```jsx
382
+ * <VirtualGallery
383
+ * items={items}
384
+ * columns={3}
385
+ * defaultHeight={100}
386
+ * defaultWidth={100}
387
+ * fullWidth={true}
388
+ * onLoadMore={(lastIndex) => console.log("Load more items from index:", lastIndex)}
389
+ * onScroll={(top) => console.log("Scrolled to top:", top)}
390
+ * >
391
+ * {({ item, index, isLast }) => (
392
+ * <div className="gallery-item" key={item.id}>
393
+ * <img src={item.image} alt={item.label} />
394
+ * <p>{item.label}</p>
395
+ * </div>
396
+ * )}
397
+ * </VirtualGallery>
398
+ * ```
399
+ *
400
+ * @see {@link https://adarshpastakia.github.io/react-fabric/?path=/docs/data-virtualgallery--docs}
401
+ * @see {@link https://tanstack.com/docs/react-virtual/latest/overview}
402
+ */
370
403
  export const VirtualGallery = GenericMemo(_VirtualGallery);
@@ -269,7 +269,7 @@ const _VirtualList = <T extends AnyObject>({
269
269
  >
270
270
  <div
271
271
  className={classNames(
272
- "inline-flex flex-nowrap gap-2 justify-center min-h-full min-w-full",
272
+ "flex flex-nowrap gap-2 justify-center min-h-full min-w-full",
273
273
  orientation === "horizontal" && "flex-col",
274
274
  )}
275
275
  >
@@ -360,4 +360,41 @@ const _VirtualList = <T extends AnyObject>({
360
360
  _VirtualList.displayName = "VirtualList";
361
361
 
362
362
  const GenericMemo: <T>(c: T) => T = memo;
363
+
364
+ /**
365
+ * VirtualList component for rendering large lists efficiently using virtualization.
366
+ * It supports horizontal and vertical orientations, custom item heights and widths,
367
+ * and provides a scroller for navigating through the list.
368
+ * It also supports loading more items on scroll and provides a way to hilight items.
369
+ * It can be used with a ref to control scrolling and hilighting of items.
370
+ *
371
+ * @param {VirtualListProps<T>} props - The properties for the VirtualList component.
372
+ * @returns {JSX.Element} The rendered VirtualList component.
373
+ * @template T - The type of items in the list, extending AnyObject.
374
+ *
375
+ * @example
376
+ * ```jsx
377
+ * <VirtualList
378
+ * items={items}
379
+ * children={({ item, index, isLast }) => (
380
+ * <div key={index} className="item">
381
+ * {item.label}
382
+ * </div>
383
+ * )}
384
+ * fullWidth={true}
385
+ * orientation="vertical"
386
+ * defaultHeight={50}
387
+ * onLoadMore={(lastIndex) => console.log("Load more items from index:", lastIndex)}
388
+ * onScroll={(top) => console.log("Scrolled to top:", top)}
389
+ * listRef={virtualListRef}
390
+ * >
391
+ * {({ item, index, isLast }) => (
392
+ * <div className="gallery-item" key={item.id}>
393
+ * <img src={item.image} alt={item.label} />
394
+ * <p>{item.label}</p>
395
+ * </div>
396
+ * )}
397
+ * </VirtualList>
398
+ * ```
399
+ */
363
400
  export const VirtualList = GenericMemo(_VirtualList);