@trackunit/react-components 0.1.296 → 0.1.297

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/index.cjs.js CHANGED
@@ -4523,8 +4523,10 @@ const cvaVirtualizedListItem = cssClassVarianceUtilities.cvaMerge(["absolute", "
4523
4523
  * @property {RelayPagination | undefined} pagination - Pagination configuration for the list.
4524
4524
  * @property {separator} [separator="line"] - The separator style between items in the list.
4525
4525
  * @property {(index: number) => JSX.Element} children - A function that takes an index and returns the JSX element to be rendered at said index.
4526
+ * @property {loadingIndicator} [loadingIndicator="spinner"] - The type of loading indicator in the list.
4527
+ * @property {skeletonLinesHeight} [skeletonLinesHeight="2rem"] - The height of the skeleton lines.
4526
4528
  */
4527
- const VirtualizedList = ({ count, rowHeight = 40, pagination, children, className, dataTestId, separator = "none", }) => {
4529
+ const VirtualizedList = ({ count, rowHeight = 40, pagination, children, className, dataTestId, separator = "none", loadingIndicator = "spinner", skeletonLinesHeight = "2rem", }) => {
4528
4530
  var _a;
4529
4531
  const containerRef = React.useRef(null);
4530
4532
  const { fetchMoreOnBottomReached, getVirtualItems, getTotalSize, measureElement } = reactTablePagination.useInfiniteScroll({
@@ -4539,7 +4541,7 @@ const VirtualizedList = ({ count, rowHeight = 40, pagination, children, classNam
4539
4541
  const isLoaderRow = virtualRow.index > count - 1;
4540
4542
  return (jsxRuntime.jsx("li", { className: cvaVirtualizedListItem({ separator }), "data-index": virtualRow.index, ref: measureElement, style: {
4541
4543
  transform: `translateY(${virtualRow.start}px)`,
4542
- }, children: isLoaderRow ? ((pagination === null || pagination === void 0 ? void 0 : pagination.isLoading) ? (jsxRuntime.jsx(Spinner, { centering: "horizontally", containerClassName: "p-4" })) : null) : (children(virtualRow.index)) }, virtualRow.key));
4544
+ }, children: isLoaderRow ? ((pagination === null || pagination === void 0 ? void 0 : pagination.isLoading) ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [loadingIndicator === "spinner" && jsxRuntime.jsx(Spinner, { centering: "horizontally", containerClassName: "p-4" }), loadingIndicator === "skeletonLines" && (jsxRuntime.jsx(SkeletonLines, { height: skeletonLinesHeight, lines: 3, width: "full" }))] })) : null) : (children(virtualRow.index)) }, virtualRow.key));
4543
4545
  }) }) }));
4544
4546
  };
4545
4547
 
package/index.esm.js CHANGED
@@ -4492,8 +4492,10 @@ const cvaVirtualizedListItem = cvaMerge(["absolute", "top-0", "left-0", "w-full"
4492
4492
  * @property {RelayPagination | undefined} pagination - Pagination configuration for the list.
4493
4493
  * @property {separator} [separator="line"] - The separator style between items in the list.
4494
4494
  * @property {(index: number) => JSX.Element} children - A function that takes an index and returns the JSX element to be rendered at said index.
4495
+ * @property {loadingIndicator} [loadingIndicator="spinner"] - The type of loading indicator in the list.
4496
+ * @property {skeletonLinesHeight} [skeletonLinesHeight="2rem"] - The height of the skeleton lines.
4495
4497
  */
4496
- const VirtualizedList = ({ count, rowHeight = 40, pagination, children, className, dataTestId, separator = "none", }) => {
4498
+ const VirtualizedList = ({ count, rowHeight = 40, pagination, children, className, dataTestId, separator = "none", loadingIndicator = "spinner", skeletonLinesHeight = "2rem", }) => {
4497
4499
  var _a;
4498
4500
  const containerRef = useRef(null);
4499
4501
  const { fetchMoreOnBottomReached, getVirtualItems, getTotalSize, measureElement } = useInfiniteScroll({
@@ -4508,7 +4510,7 @@ const VirtualizedList = ({ count, rowHeight = 40, pagination, children, classNam
4508
4510
  const isLoaderRow = virtualRow.index > count - 1;
4509
4511
  return (jsx("li", { className: cvaVirtualizedListItem({ separator }), "data-index": virtualRow.index, ref: measureElement, style: {
4510
4512
  transform: `translateY(${virtualRow.start}px)`,
4511
- }, children: isLoaderRow ? ((pagination === null || pagination === void 0 ? void 0 : pagination.isLoading) ? (jsx(Spinner, { centering: "horizontally", containerClassName: "p-4" })) : null) : (children(virtualRow.index)) }, virtualRow.key));
4513
+ }, children: isLoaderRow ? ((pagination === null || pagination === void 0 ? void 0 : pagination.isLoading) ? (jsxs(Fragment, { children: [loadingIndicator === "spinner" && jsx(Spinner, { centering: "horizontally", containerClassName: "p-4" }), loadingIndicator === "skeletonLines" && (jsx(SkeletonLines, { height: skeletonLinesHeight, lines: 3, width: "full" }))] })) : null) : (children(virtualRow.index)) }, virtualRow.key));
4512
4514
  }) }) }));
4513
4515
  };
4514
4516
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-components",
3
- "version": "0.1.296",
3
+ "version": "0.1.297",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
@@ -4,12 +4,15 @@ import { RelayPagination } from "@trackunit/react-table-pagination";
4
4
  import { CommonProps } from "../../common/CommonProps";
5
5
  import { cvaVirtualizedListItem } from "./VirtualizedList.variants";
6
6
  type Separator = NonNullable<VariantProps<typeof cvaVirtualizedListItem>["separator"]>;
7
+ type LoadingIndicator = "spinner" | "skeletonLines";
7
8
  export interface VirtualizedListProps extends CommonProps {
8
9
  count: number;
9
10
  rowHeight?: number;
10
11
  pagination?: RelayPagination;
11
12
  children: (index: number) => JSX.Element;
12
13
  separator?: Separator;
14
+ loadingIndicator?: LoadingIndicator;
15
+ skeletonLinesHeight?: string;
13
16
  }
14
17
  /**
15
18
  * Render a performant virtualized list of items. Optionally with infinite scrolling.
@@ -19,6 +22,8 @@ export interface VirtualizedListProps extends CommonProps {
19
22
  * @property {RelayPagination | undefined} pagination - Pagination configuration for the list.
20
23
  * @property {separator} [separator="line"] - The separator style between items in the list.
21
24
  * @property {(index: number) => JSX.Element} children - A function that takes an index and returns the JSX element to be rendered at said index.
25
+ * @property {loadingIndicator} [loadingIndicator="spinner"] - The type of loading indicator in the list.
26
+ * @property {skeletonLinesHeight} [skeletonLinesHeight="2rem"] - The height of the skeleton lines.
22
27
  */
23
- export declare const VirtualizedList: ({ count, rowHeight, pagination, children, className, dataTestId, separator, }: VirtualizedListProps) => JSX.Element;
28
+ export declare const VirtualizedList: ({ count, rowHeight, pagination, children, className, dataTestId, separator, loadingIndicator, skeletonLinesHeight, }: VirtualizedListProps) => JSX.Element;
24
29
  export {};