@trackunit/react-components 1.8.23 → 1.8.24

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
@@ -17,9 +17,9 @@ var reactRouter = require('@tanstack/react-router');
17
17
  var react$1 = require('@floating-ui/react');
18
18
  var omit = require('lodash/omit');
19
19
  var tailwindMerge = require('tailwind-merge');
20
+ var reactTablePagination = require('@trackunit/react-table-pagination');
20
21
  var reactHelmetAsync = require('react-helmet-async');
21
22
  var reactTabs = require('@radix-ui/react-tabs');
22
- var reactTablePagination = require('@trackunit/react-table-pagination');
23
23
 
24
24
  const docs = {
25
25
  source: {
@@ -3067,6 +3067,92 @@ const cvaCardBodyDensityContainer = cssClassVarianceUtilities.cvaMerge(["grid",
3067
3067
  },
3068
3068
  });
3069
3069
 
3070
+ const cvaListContainer = cssClassVarianceUtilities.cvaMerge(["h-full"], {
3071
+ variants: {
3072
+ parentControlledScrollable: {
3073
+ true: [""],
3074
+ false: ["overflow-auto"],
3075
+ },
3076
+ },
3077
+ defaultVariants: {
3078
+ parentControlledScrollable: false,
3079
+ },
3080
+ });
3081
+ const cvaList = cssClassVarianceUtilities.cvaMerge(["relative"]);
3082
+ const cvaListItem$1 = cssClassVarianceUtilities.cvaMerge(["absolute", "top-0", "left-0", "w-full"], {
3083
+ variants: {
3084
+ separator: {
3085
+ alternating: ["even:bg-slate-100"],
3086
+ line: ["[&:not(:last-child)]:border-b", "border-gray-200"],
3087
+ none: "",
3088
+ space: "[&:not(:last-child)]:pb-0.5",
3089
+ },
3090
+ },
3091
+ defaultVariants: {
3092
+ separator: "none",
3093
+ },
3094
+ });
3095
+
3096
+ /**
3097
+ * Render a performant virtualized list of items. Optionally with infinite scrolling.
3098
+ *
3099
+ * @property {number} count - The total number of items in the list.
3100
+ * @property {number} [rowHeight="40"] - The estimated height of each row in the list.
3101
+ * @property {RelayPagination | undefined} pagination - Pagination configuration for the list.
3102
+ * @property {separator} [separator="line"] - The separator style between items in the list.
3103
+ * @property {(index: number) =>ReactElement} children - A function that takes an index and returns the JSX element to be rendered at said index.
3104
+ * @property {loadingIndicator} [loadingIndicator="spinner"] - The type of loading indicator in the list.
3105
+ * @property {skeletonLinesHeight} [skeletonLinesHeight="2rem"] - The height of the skeleton lines.
3106
+ */
3107
+ const List = ({ count, rowHeight = 40, pagination, children, className, dataTestId, separator = "none", loadingIndicator = "spinner", skeletonLinesHeight = rowHeight + "px", onRowClick, scrollRef, }) => {
3108
+ const containerRef = react.useRef(null);
3109
+ const listRef = react.useRef(null);
3110
+ const [scrollParent, setScrollParent] = react.useState(null);
3111
+ const [parentControlledScrollable, setParentControlledScrollable] = react.useState(false);
3112
+ react.useEffect(() => {
3113
+ if (scrollRef?.current) {
3114
+ setParentControlledScrollable(true);
3115
+ setScrollParent(scrollRef.current);
3116
+ }
3117
+ else {
3118
+ setParentControlledScrollable(false);
3119
+ setScrollParent(containerRef.current);
3120
+ }
3121
+ }, [scrollRef]);
3122
+ const infiniteScrollProps = react.useMemo(() => {
3123
+ return {
3124
+ pagination: pagination || reactTablePagination.noPagination,
3125
+ containerRef: { current: scrollParent },
3126
+ rowSize: pagination !== undefined &&
3127
+ pagination.pageInfo !== undefined &&
3128
+ pagination.pageInfo.hasNextPage === true &&
3129
+ pagination.isLoading === true
3130
+ ? count + 1
3131
+ : count,
3132
+ rowHeight,
3133
+ };
3134
+ }, [pagination, scrollParent, count, rowHeight]);
3135
+ const { fetchMoreOnBottomReached, getVirtualItems, getTotalSize, measureElement } = reactTablePagination.useInfiniteScroll(infiniteScrollProps);
3136
+ react.useEffect(() => {
3137
+ if (scrollParent) {
3138
+ const handleScroll = () => {
3139
+ fetchMoreOnBottomReached(scrollParent);
3140
+ };
3141
+ scrollParent.addEventListener("scroll", handleScroll);
3142
+ return () => {
3143
+ scrollParent.removeEventListener("scroll", handleScroll);
3144
+ };
3145
+ }
3146
+ return undefined;
3147
+ }, [scrollParent, fetchMoreOnBottomReached]);
3148
+ return (jsxRuntime.jsx("div", { className: cvaListContainer({ parentControlledScrollable, className }), "data-testid": dataTestId, ref: containerRef, children: jsxRuntime.jsx("ul", { className: cvaList(), ref: listRef, style: { height: `${getTotalSize()}px`, outline: "none" }, children: getVirtualItems().map(virtualRow => {
3149
+ const isLoaderRow = virtualRow.index > count - 1;
3150
+ return (jsxRuntime.jsx("li", { className: cvaListItem$1({ separator }), "data-index": virtualRow.index, onClick: onRowClick !== undefined ? () => onRowClick(virtualRow.index) : undefined, ref: measureElement, style: {
3151
+ transform: `translateY(${virtualRow.start}px)`,
3152
+ }, tabIndex: -1, children: isLoaderRow ? (pagination?.isLoading === true ? (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));
3153
+ }) }) }));
3154
+ };
3155
+
3070
3156
  /**
3071
3157
  * Applies standardized interaction-related styles to an element.
3072
3158
  *
@@ -4285,92 +4371,6 @@ const ValueBar = ({ value, min = 0, max = 100, unit, size = "small", levelColors
4285
4371
  return (jsxRuntime.jsxs("span", { className: "relative flex items-center gap-2", "data-testid": dataTestId, children: [jsxRuntime.jsx("progress", { "aria-label": valueText, className: cvaValueBar({ className, size }), max: 100, style: { color: barFillColor }, value: score * 100 }), showValue && (size === "small" || size === "large") ? (jsxRuntime.jsx(Text, { className: cvaValueBarText({ size }), dataTestId: dataTestId ? `${dataTestId}-value` : undefined, children: jsxRuntime.jsx("span", { style: valueColor ? { color: valueColor } : undefined, children: valueText }) })) : null] }));
4286
4372
  };
4287
4373
 
4288
- const cvaVirtualizedListContainer = cssClassVarianceUtilities.cvaMerge(["h-full"], {
4289
- variants: {
4290
- parentControlledScrollable: {
4291
- true: [""],
4292
- false: ["overflow-auto"],
4293
- },
4294
- },
4295
- defaultVariants: {
4296
- parentControlledScrollable: false,
4297
- },
4298
- });
4299
- const cvaVirtualizedList = cssClassVarianceUtilities.cvaMerge(["relative"]);
4300
- const cvaVirtualizedListItem = cssClassVarianceUtilities.cvaMerge(["absolute", "top-0", "left-0", "w-full"], {
4301
- variants: {
4302
- separator: {
4303
- alternating: ["even:bg-slate-100"],
4304
- line: ["[&:not(:last-child)]:border-b", "border-gray-200"],
4305
- none: "",
4306
- space: "[&:not(:last-child)]:pb-0.5",
4307
- },
4308
- },
4309
- defaultVariants: {
4310
- separator: "none",
4311
- },
4312
- });
4313
-
4314
- /**
4315
- * Render a performant virtualized list of items. Optionally with infinite scrolling.
4316
- *
4317
- * @property {number} count - The total number of items in the list.
4318
- * @property {number} [rowHeight="40"] - The estimated height of each row in the list.
4319
- * @property {RelayPagination | undefined} pagination - Pagination configuration for the list.
4320
- * @property {separator} [separator="line"] - The separator style between items in the list.
4321
- * @property {(index: number) =>ReactElement} children - A function that takes an index and returns the JSX element to be rendered at said index.
4322
- * @property {loadingIndicator} [loadingIndicator="spinner"] - The type of loading indicator in the list.
4323
- * @property {skeletonLinesHeight} [skeletonLinesHeight="2rem"] - The height of the skeleton lines.
4324
- */
4325
- const VirtualizedList = ({ count, rowHeight = 40, pagination, children, className, dataTestId, separator = "none", loadingIndicator = "spinner", skeletonLinesHeight = rowHeight + "px", onRowClick, scrollRef, }) => {
4326
- const containerRef = react.useRef(null);
4327
- const listRef = react.useRef(null);
4328
- const [scrollParent, setScrollParent] = react.useState(null);
4329
- const [parentControlledScrollable, setParentControlledScrollable] = react.useState(false);
4330
- react.useEffect(() => {
4331
- if (scrollRef?.current) {
4332
- setParentControlledScrollable(true);
4333
- setScrollParent(scrollRef.current);
4334
- }
4335
- else {
4336
- setParentControlledScrollable(false);
4337
- setScrollParent(containerRef.current);
4338
- }
4339
- }, [scrollRef]);
4340
- const infiniteScrollProps = react.useMemo(() => {
4341
- return {
4342
- pagination: pagination || reactTablePagination.noPagination,
4343
- containerRef: { current: scrollParent },
4344
- rowSize: pagination !== undefined &&
4345
- pagination.pageInfo !== undefined &&
4346
- pagination.pageInfo.hasNextPage === true &&
4347
- pagination.isLoading === true
4348
- ? count + 1
4349
- : count,
4350
- rowHeight,
4351
- };
4352
- }, [pagination, scrollParent, count, rowHeight]);
4353
- const { fetchMoreOnBottomReached, getVirtualItems, getTotalSize, measureElement } = reactTablePagination.useInfiniteScroll(infiniteScrollProps);
4354
- react.useEffect(() => {
4355
- if (scrollParent) {
4356
- const handleScroll = () => {
4357
- fetchMoreOnBottomReached(scrollParent);
4358
- };
4359
- scrollParent.addEventListener("scroll", handleScroll);
4360
- return () => {
4361
- scrollParent.removeEventListener("scroll", handleScroll);
4362
- };
4363
- }
4364
- return undefined;
4365
- }, [scrollParent, fetchMoreOnBottomReached]);
4366
- return (jsxRuntime.jsx("div", { className: cvaVirtualizedListContainer({ parentControlledScrollable, className }), "data-testid": dataTestId, ref: containerRef, children: jsxRuntime.jsx("ul", { className: cvaVirtualizedList(), ref: listRef, style: { height: `${getTotalSize()}px`, outline: "none" }, children: getVirtualItems().map(virtualRow => {
4367
- const isLoaderRow = virtualRow.index > count - 1;
4368
- return (jsxRuntime.jsx("li", { className: cvaVirtualizedListItem({ separator }), "data-index": virtualRow.index, onClick: onRowClick !== undefined ? () => onRowClick(virtualRow.index) : undefined, ref: measureElement, style: {
4369
- transform: `translateY(${virtualRow.start}px)`,
4370
- }, tabIndex: -1, children: isLoaderRow ? (pagination?.isLoading === true ? (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));
4371
- }) }) }));
4372
- };
4373
-
4374
4374
  const cvaZStackContainer = cssClassVarianceUtilities.cvaMerge(["grid", "grid-cols-1", "grid-rows-1"]);
4375
4375
  const cvaZStackItem = cssClassVarianceUtilities.cvaMerge(["col-start-1", "col-end-1", "row-start-1", "row-end-2"]);
4376
4376
 
@@ -4441,6 +4441,7 @@ exports.IconButton = IconButton;
4441
4441
  exports.Indicator = Indicator;
4442
4442
  exports.KPI = KPI;
4443
4443
  exports.KPICard = KPICard;
4444
+ exports.List = List;
4444
4445
  exports.ListItem = ListItem;
4445
4446
  exports.MenuDivider = MenuDivider;
4446
4447
  exports.MenuItem = MenuItem;
@@ -4478,7 +4479,6 @@ exports.Text = Text;
4478
4479
  exports.ToggleGroup = ToggleGroup;
4479
4480
  exports.Tooltip = Tooltip;
4480
4481
  exports.ValueBar = ValueBar;
4481
- exports.VirtualizedList = VirtualizedList;
4482
4482
  exports.ZStack = ZStack;
4483
4483
  exports.cvaButton = cvaButton;
4484
4484
  exports.cvaButtonPrefixSuffix = cvaButtonPrefixSuffix;
@@ -4494,6 +4494,9 @@ exports.cvaIndicatorIconBackground = cvaIndicatorIconBackground;
4494
4494
  exports.cvaIndicatorLabel = cvaIndicatorLabel;
4495
4495
  exports.cvaIndicatorPing = cvaIndicatorPing;
4496
4496
  exports.cvaInteractableItem = cvaInteractableItem;
4497
+ exports.cvaList = cvaList;
4498
+ exports.cvaListContainer = cvaListContainer;
4499
+ exports.cvaListItem = cvaListItem$1;
4497
4500
  exports.cvaMenuItem = cvaMenuItem;
4498
4501
  exports.cvaMenuItemLabel = cvaMenuItemLabel;
4499
4502
  exports.cvaMenuItemPrefix = cvaMenuItemPrefix;
@@ -4507,9 +4510,6 @@ exports.cvaToggleGroupWithSlidingBackground = cvaToggleGroupWithSlidingBackgroun
4507
4510
  exports.cvaToggleItem = cvaToggleItem;
4508
4511
  exports.cvaToggleItemContent = cvaToggleItemContent;
4509
4512
  exports.cvaToggleItemText = cvaToggleItemText;
4510
- exports.cvaVirtualizedList = cvaVirtualizedList;
4511
- exports.cvaVirtualizedListContainer = cvaVirtualizedListContainer;
4512
- exports.cvaVirtualizedListItem = cvaVirtualizedListItem;
4513
4513
  exports.cvaZStackContainer = cvaZStackContainer;
4514
4514
  exports.cvaZStackItem = cvaZStackItem;
4515
4515
  exports.docs = docs;
package/index.esm.js CHANGED
@@ -15,9 +15,9 @@ import { Link, useBlocker } from '@tanstack/react-router';
15
15
  import { useFloating, autoUpdate, offset, flip, shift, size, useClick, useDismiss, useHover as useHover$1, useRole, useInteractions, FloatingPortal, useMergeRefs, FloatingFocusManager, arrow, useTransitionStatus, FloatingArrow } from '@floating-ui/react';
16
16
  import omit from 'lodash/omit';
17
17
  import { twMerge } from 'tailwind-merge';
18
- import { HelmetProvider, Helmet } from 'react-helmet-async';
19
- import { Trigger, Content, List, Root } from '@radix-ui/react-tabs';
20
18
  import { noPagination, useInfiniteScroll } from '@trackunit/react-table-pagination';
19
+ import { HelmetProvider, Helmet } from 'react-helmet-async';
20
+ import { Trigger, Content, List as List$1, Root } from '@radix-ui/react-tabs';
21
21
 
22
22
  const docs = {
23
23
  source: {
@@ -3065,6 +3065,92 @@ const cvaCardBodyDensityContainer = cvaMerge(["grid", "grid-cols-[1fr_auto]"], {
3065
3065
  },
3066
3066
  });
3067
3067
 
3068
+ const cvaListContainer = cvaMerge(["h-full"], {
3069
+ variants: {
3070
+ parentControlledScrollable: {
3071
+ true: [""],
3072
+ false: ["overflow-auto"],
3073
+ },
3074
+ },
3075
+ defaultVariants: {
3076
+ parentControlledScrollable: false,
3077
+ },
3078
+ });
3079
+ const cvaList = cvaMerge(["relative"]);
3080
+ const cvaListItem$1 = cvaMerge(["absolute", "top-0", "left-0", "w-full"], {
3081
+ variants: {
3082
+ separator: {
3083
+ alternating: ["even:bg-slate-100"],
3084
+ line: ["[&:not(:last-child)]:border-b", "border-gray-200"],
3085
+ none: "",
3086
+ space: "[&:not(:last-child)]:pb-0.5",
3087
+ },
3088
+ },
3089
+ defaultVariants: {
3090
+ separator: "none",
3091
+ },
3092
+ });
3093
+
3094
+ /**
3095
+ * Render a performant virtualized list of items. Optionally with infinite scrolling.
3096
+ *
3097
+ * @property {number} count - The total number of items in the list.
3098
+ * @property {number} [rowHeight="40"] - The estimated height of each row in the list.
3099
+ * @property {RelayPagination | undefined} pagination - Pagination configuration for the list.
3100
+ * @property {separator} [separator="line"] - The separator style between items in the list.
3101
+ * @property {(index: number) =>ReactElement} children - A function that takes an index and returns the JSX element to be rendered at said index.
3102
+ * @property {loadingIndicator} [loadingIndicator="spinner"] - The type of loading indicator in the list.
3103
+ * @property {skeletonLinesHeight} [skeletonLinesHeight="2rem"] - The height of the skeleton lines.
3104
+ */
3105
+ const List = ({ count, rowHeight = 40, pagination, children, className, dataTestId, separator = "none", loadingIndicator = "spinner", skeletonLinesHeight = rowHeight + "px", onRowClick, scrollRef, }) => {
3106
+ const containerRef = useRef(null);
3107
+ const listRef = useRef(null);
3108
+ const [scrollParent, setScrollParent] = useState(null);
3109
+ const [parentControlledScrollable, setParentControlledScrollable] = useState(false);
3110
+ useEffect(() => {
3111
+ if (scrollRef?.current) {
3112
+ setParentControlledScrollable(true);
3113
+ setScrollParent(scrollRef.current);
3114
+ }
3115
+ else {
3116
+ setParentControlledScrollable(false);
3117
+ setScrollParent(containerRef.current);
3118
+ }
3119
+ }, [scrollRef]);
3120
+ const infiniteScrollProps = useMemo(() => {
3121
+ return {
3122
+ pagination: pagination || noPagination,
3123
+ containerRef: { current: scrollParent },
3124
+ rowSize: pagination !== undefined &&
3125
+ pagination.pageInfo !== undefined &&
3126
+ pagination.pageInfo.hasNextPage === true &&
3127
+ pagination.isLoading === true
3128
+ ? count + 1
3129
+ : count,
3130
+ rowHeight,
3131
+ };
3132
+ }, [pagination, scrollParent, count, rowHeight]);
3133
+ const { fetchMoreOnBottomReached, getVirtualItems, getTotalSize, measureElement } = useInfiniteScroll(infiniteScrollProps);
3134
+ useEffect(() => {
3135
+ if (scrollParent) {
3136
+ const handleScroll = () => {
3137
+ fetchMoreOnBottomReached(scrollParent);
3138
+ };
3139
+ scrollParent.addEventListener("scroll", handleScroll);
3140
+ return () => {
3141
+ scrollParent.removeEventListener("scroll", handleScroll);
3142
+ };
3143
+ }
3144
+ return undefined;
3145
+ }, [scrollParent, fetchMoreOnBottomReached]);
3146
+ return (jsx("div", { className: cvaListContainer({ parentControlledScrollable, className }), "data-testid": dataTestId, ref: containerRef, children: jsx("ul", { className: cvaList(), ref: listRef, style: { height: `${getTotalSize()}px`, outline: "none" }, children: getVirtualItems().map(virtualRow => {
3147
+ const isLoaderRow = virtualRow.index > count - 1;
3148
+ return (jsx("li", { className: cvaListItem$1({ separator }), "data-index": virtualRow.index, onClick: onRowClick !== undefined ? () => onRowClick(virtualRow.index) : undefined, ref: measureElement, style: {
3149
+ transform: `translateY(${virtualRow.start}px)`,
3150
+ }, tabIndex: -1, children: isLoaderRow ? (pagination?.isLoading === true ? (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));
3151
+ }) }) }));
3152
+ };
3153
+
3068
3154
  /**
3069
3155
  * Applies standardized interaction-related styles to an element.
3070
3156
  *
@@ -3990,7 +4076,7 @@ const TabContent = ({ className, dataTestId, children, ...rest }) => {
3990
4076
  * Wrapper for radix tab list component.
3991
4077
  */
3992
4078
  const TabList = ({ className, dataTestId, children, ...rest }) => {
3993
- return (jsx(List, { className: cvaTabList({ className }), "data-testid": dataTestId, ...rest, children: children }));
4079
+ return (jsx(List$1, { className: cvaTabList({ className }), "data-testid": dataTestId, ...rest, children: children }));
3994
4080
  };
3995
4081
 
3996
4082
  /**
@@ -4283,92 +4369,6 @@ const ValueBar = ({ value, min = 0, max = 100, unit, size = "small", levelColors
4283
4369
  return (jsxs("span", { className: "relative flex items-center gap-2", "data-testid": dataTestId, children: [jsx("progress", { "aria-label": valueText, className: cvaValueBar({ className, size }), max: 100, style: { color: barFillColor }, value: score * 100 }), showValue && (size === "small" || size === "large") ? (jsx(Text, { className: cvaValueBarText({ size }), dataTestId: dataTestId ? `${dataTestId}-value` : undefined, children: jsx("span", { style: valueColor ? { color: valueColor } : undefined, children: valueText }) })) : null] }));
4284
4370
  };
4285
4371
 
4286
- const cvaVirtualizedListContainer = cvaMerge(["h-full"], {
4287
- variants: {
4288
- parentControlledScrollable: {
4289
- true: [""],
4290
- false: ["overflow-auto"],
4291
- },
4292
- },
4293
- defaultVariants: {
4294
- parentControlledScrollable: false,
4295
- },
4296
- });
4297
- const cvaVirtualizedList = cvaMerge(["relative"]);
4298
- const cvaVirtualizedListItem = cvaMerge(["absolute", "top-0", "left-0", "w-full"], {
4299
- variants: {
4300
- separator: {
4301
- alternating: ["even:bg-slate-100"],
4302
- line: ["[&:not(:last-child)]:border-b", "border-gray-200"],
4303
- none: "",
4304
- space: "[&:not(:last-child)]:pb-0.5",
4305
- },
4306
- },
4307
- defaultVariants: {
4308
- separator: "none",
4309
- },
4310
- });
4311
-
4312
- /**
4313
- * Render a performant virtualized list of items. Optionally with infinite scrolling.
4314
- *
4315
- * @property {number} count - The total number of items in the list.
4316
- * @property {number} [rowHeight="40"] - The estimated height of each row in the list.
4317
- * @property {RelayPagination | undefined} pagination - Pagination configuration for the list.
4318
- * @property {separator} [separator="line"] - The separator style between items in the list.
4319
- * @property {(index: number) =>ReactElement} children - A function that takes an index and returns the JSX element to be rendered at said index.
4320
- * @property {loadingIndicator} [loadingIndicator="spinner"] - The type of loading indicator in the list.
4321
- * @property {skeletonLinesHeight} [skeletonLinesHeight="2rem"] - The height of the skeleton lines.
4322
- */
4323
- const VirtualizedList = ({ count, rowHeight = 40, pagination, children, className, dataTestId, separator = "none", loadingIndicator = "spinner", skeletonLinesHeight = rowHeight + "px", onRowClick, scrollRef, }) => {
4324
- const containerRef = useRef(null);
4325
- const listRef = useRef(null);
4326
- const [scrollParent, setScrollParent] = useState(null);
4327
- const [parentControlledScrollable, setParentControlledScrollable] = useState(false);
4328
- useEffect(() => {
4329
- if (scrollRef?.current) {
4330
- setParentControlledScrollable(true);
4331
- setScrollParent(scrollRef.current);
4332
- }
4333
- else {
4334
- setParentControlledScrollable(false);
4335
- setScrollParent(containerRef.current);
4336
- }
4337
- }, [scrollRef]);
4338
- const infiniteScrollProps = useMemo(() => {
4339
- return {
4340
- pagination: pagination || noPagination,
4341
- containerRef: { current: scrollParent },
4342
- rowSize: pagination !== undefined &&
4343
- pagination.pageInfo !== undefined &&
4344
- pagination.pageInfo.hasNextPage === true &&
4345
- pagination.isLoading === true
4346
- ? count + 1
4347
- : count,
4348
- rowHeight,
4349
- };
4350
- }, [pagination, scrollParent, count, rowHeight]);
4351
- const { fetchMoreOnBottomReached, getVirtualItems, getTotalSize, measureElement } = useInfiniteScroll(infiniteScrollProps);
4352
- useEffect(() => {
4353
- if (scrollParent) {
4354
- const handleScroll = () => {
4355
- fetchMoreOnBottomReached(scrollParent);
4356
- };
4357
- scrollParent.addEventListener("scroll", handleScroll);
4358
- return () => {
4359
- scrollParent.removeEventListener("scroll", handleScroll);
4360
- };
4361
- }
4362
- return undefined;
4363
- }, [scrollParent, fetchMoreOnBottomReached]);
4364
- return (jsx("div", { className: cvaVirtualizedListContainer({ parentControlledScrollable, className }), "data-testid": dataTestId, ref: containerRef, children: jsx("ul", { className: cvaVirtualizedList(), ref: listRef, style: { height: `${getTotalSize()}px`, outline: "none" }, children: getVirtualItems().map(virtualRow => {
4365
- const isLoaderRow = virtualRow.index > count - 1;
4366
- return (jsx("li", { className: cvaVirtualizedListItem({ separator }), "data-index": virtualRow.index, onClick: onRowClick !== undefined ? () => onRowClick(virtualRow.index) : undefined, ref: measureElement, style: {
4367
- transform: `translateY(${virtualRow.start}px)`,
4368
- }, tabIndex: -1, children: isLoaderRow ? (pagination?.isLoading === true ? (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));
4369
- }) }) }));
4370
- };
4371
-
4372
4372
  const cvaZStackContainer = cvaMerge(["grid", "grid-cols-1", "grid-rows-1"]);
4373
4373
  const cvaZStackItem = cvaMerge(["col-start-1", "col-end-1", "row-start-1", "row-end-2"]);
4374
4374
 
@@ -4415,4 +4415,4 @@ const cvaClickable = cvaMerge([
4415
4415
  },
4416
4416
  });
4417
4417
 
4418
- export { ActionRenderer, Alert, Badge, Breadcrumb, BreadcrumbContainer, Button, Card, CardBody, CardFooter, CardHeader, Collapse, CompletionStatusIndicator, CopyableText, DetailsList, EmptyState, EmptyValue, ExternalLink, Heading, Highlight, Icon, IconButton, Indicator, KPI, KPICard, ListItem, MenuDivider, MenuItem, MenuList, MoreMenu, Notice, PackageNameStoryComponent, Page, PageContent, PageHeader, PageHeaderKpiMetrics, PageHeaderSecondaryActions, PageHeaderTitle, Pagination, Polygon, Popover, PopoverContent, PopoverTitle, PopoverTrigger, Portal, Prompt, ROLE_CARD, SectionHeader, Sidebar, SkeletonLines, Spacer, Spinner, StarButton, Tab, TabContent, TabList, Tabs, Tag, Text, ToggleGroup, Tooltip, ValueBar, VirtualizedList, ZStack, cvaButton, cvaButtonPrefixSuffix, cvaButtonSpinner, cvaButtonSpinnerContainer, cvaClickable, cvaContainerStyles, cvaIconButton, cvaImgStyles, cvaIndicator, cvaIndicatorIcon, cvaIndicatorIconBackground, cvaIndicatorLabel, cvaIndicatorPing, cvaInteractableItem, cvaMenuItem, cvaMenuItemLabel, cvaMenuItemPrefix, cvaMenuItemStyle, cvaMenuItemSuffix, cvaPageHeader, cvaPageHeaderContainer, cvaPageHeaderHeading, cvaToggleGroup, cvaToggleGroupWithSlidingBackground, cvaToggleItem, cvaToggleItemContent, cvaToggleItemText, cvaVirtualizedList, cvaVirtualizedListContainer, cvaVirtualizedListItem, cvaZStackContainer, cvaZStackItem, docs, getDevicePixelRatio, getValueBarColorByValue, iconColorNames, iconPalette, useClickOutside, useContainerBreakpoints, useContinuousTimeout, useDebounce, useDevicePixelRatio, useElevatedReducer, useElevatedState, useGeometry, useHover, useIsFirstRender, useIsFullscreen, useIsTextTruncated, useModifierKey, useOverflowItems, usePopoverContext, usePrompt, useResize, useScrollDetection, useSelfUpdatingRef, useTimeout, useViewportBreakpoints, useWatch, useWindowActivity };
4418
+ export { ActionRenderer, Alert, Badge, Breadcrumb, BreadcrumbContainer, Button, Card, CardBody, CardFooter, CardHeader, Collapse, CompletionStatusIndicator, CopyableText, DetailsList, EmptyState, EmptyValue, ExternalLink, Heading, Highlight, Icon, IconButton, Indicator, KPI, KPICard, List, ListItem, MenuDivider, MenuItem, MenuList, MoreMenu, Notice, PackageNameStoryComponent, Page, PageContent, PageHeader, PageHeaderKpiMetrics, PageHeaderSecondaryActions, PageHeaderTitle, Pagination, Polygon, Popover, PopoverContent, PopoverTitle, PopoverTrigger, Portal, Prompt, ROLE_CARD, SectionHeader, Sidebar, SkeletonLines, Spacer, Spinner, StarButton, Tab, TabContent, TabList, Tabs, Tag, Text, ToggleGroup, Tooltip, ValueBar, ZStack, cvaButton, cvaButtonPrefixSuffix, cvaButtonSpinner, cvaButtonSpinnerContainer, cvaClickable, cvaContainerStyles, cvaIconButton, cvaImgStyles, cvaIndicator, cvaIndicatorIcon, cvaIndicatorIconBackground, cvaIndicatorLabel, cvaIndicatorPing, cvaInteractableItem, cvaList, cvaListContainer, cvaListItem$1 as cvaListItem, cvaMenuItem, cvaMenuItemLabel, cvaMenuItemPrefix, cvaMenuItemStyle, cvaMenuItemSuffix, cvaPageHeader, cvaPageHeaderContainer, cvaPageHeaderHeading, cvaToggleGroup, cvaToggleGroupWithSlidingBackground, cvaToggleItem, cvaToggleItemContent, cvaToggleItemText, cvaZStackContainer, cvaZStackItem, docs, getDevicePixelRatio, getValueBarColorByValue, iconColorNames, iconPalette, useClickOutside, useContainerBreakpoints, useContinuousTimeout, useDebounce, useDevicePixelRatio, useElevatedReducer, useElevatedState, useGeometry, useHover, useIsFirstRender, useIsFullscreen, useIsTextTruncated, useModifierKey, useOverflowItems, usePopoverContext, usePrompt, useResize, useScrollDetection, useSelfUpdatingRef, useTimeout, useViewportBreakpoints, useWatch, useWindowActivity };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-components",
3
- "version": "1.8.23",
3
+ "version": "1.8.24",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
@@ -2,10 +2,10 @@ import { VariantProps } from "@trackunit/css-class-variance-utilities";
2
2
  import { RelayPagination } from "@trackunit/react-table-pagination";
3
3
  import { ReactElement, RefObject } from "react";
4
4
  import { CommonProps } from "../../common/CommonProps";
5
- import { cvaVirtualizedListItem } from "./VirtualizedList.variants";
6
- type Separator = NonNullable<VariantProps<typeof cvaVirtualizedListItem>["separator"]>;
5
+ import { cvaListItem } from "./List.variants";
6
+ type Separator = NonNullable<VariantProps<typeof cvaListItem>["separator"]>;
7
7
  type LoadingIndicator = "spinner" | "skeletonLines";
8
- export interface VirtualizedListProps extends CommonProps {
8
+ export interface ListProps extends CommonProps {
9
9
  count: number;
10
10
  rowHeight?: number;
11
11
  pagination?: RelayPagination;
@@ -30,5 +30,5 @@ export interface VirtualizedListProps extends CommonProps {
30
30
  * @property {loadingIndicator} [loadingIndicator="spinner"] - The type of loading indicator in the list.
31
31
  * @property {skeletonLinesHeight} [skeletonLinesHeight="2rem"] - The height of the skeleton lines.
32
32
  */
33
- export declare const VirtualizedList: ({ count, rowHeight, pagination, children, className, dataTestId, separator, loadingIndicator, skeletonLinesHeight, onRowClick, scrollRef, }: VirtualizedListProps) => ReactElement;
33
+ export declare const List: ({ count, rowHeight, pagination, children, className, dataTestId, separator, loadingIndicator, skeletonLinesHeight, onRowClick, scrollRef, }: ListProps) => ReactElement;
34
34
  export {};
@@ -1,7 +1,7 @@
1
- export declare const cvaVirtualizedListContainer: (props?: ({
1
+ export declare const cvaListContainer: (props?: ({
2
2
  parentControlledScrollable?: boolean | null | undefined;
3
3
  } & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
4
- export declare const cvaVirtualizedList: (props?: import("class-variance-authority/dist/types").ClassProp | undefined) => string;
5
- export declare const cvaVirtualizedListItem: (props?: ({
4
+ export declare const cvaList: (props?: import("class-variance-authority/dist/types").ClassProp | undefined) => string;
5
+ export declare const cvaListItem: (props?: ({
6
6
  separator?: "alternating" | "line" | "none" | "space" | null | undefined;
7
7
  } & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
@@ -17,6 +17,8 @@ export * from "./Icon/Icon";
17
17
  export * from "./Indicator";
18
18
  export * from "./KPI/KPI";
19
19
  export * from "./KPICard/KPICard";
20
+ export * from "./List/List";
21
+ export * from "./List/List.variants";
20
22
  export * from "./ListItem/ListItem";
21
23
  export * from "./Menu";
22
24
  export * from "./Notice";
@@ -44,7 +46,5 @@ export * from "./ToggleGroup/ToggleGroup";
44
46
  export * from "./ToggleGroup/ToggleGroup.variants";
45
47
  export * from "./Tooltip";
46
48
  export * from "./ValueBar";
47
- export * from "./VirtualizedList/VirtualizedList";
48
- export * from "./VirtualizedList/VirtualizedList.variants";
49
49
  export * from "./ZStack/ZStack";
50
50
  export * from "./ZStack/ZStack.variants";