@trackunit/react-components 2.1.65 → 2.2.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/index.cjs.js CHANGED
@@ -5733,14 +5733,17 @@ const ListLoadingIndicator = ({ type, hasThumbnail, thumbnailShape, hasDescripti
5733
5733
  */
5734
5734
  const List = ({ children, className, "data-testid": dataTestId, style, ref,
5735
5735
  // UseListResult properties
5736
- containerRef, listRef, rows, getListItemProps, header, loadingIndicator, shouldShowLoaderAtIndex, count, isScrolling, separator, topSeparatorOnScroll, isAtTop, contentFillsContainer,
5736
+ containerRef, listRef, listContainerRef, rows, getListItemProps, header, loadingIndicator, shouldShowLoaderAtIndex, count, isScrolling, separator, topSeparatorOnScroll, isAtTop, contentFillsContainer,
5737
5737
  // Unused but part of UseListResult interface (can be used from parent)
5738
5738
  scrollOffset: _scrollOffset, getTotalSize: _getTotalSize, getVirtualItems: _getVirtualItems, scrollToOffset: _scrollToOffset, scrollToIndex: _scrollToIndex, measure: _measure, }) => {
5739
5739
  const mergedContainerRef = useMergeRefs([containerRef, ref]);
5740
+ // The virtualizer owns the `<ul>` height + item positions via directDomUpdates,
5741
+ // so its container callback must be attached to the `<ul>` (alongside listRef).
5742
+ const mergedListRef = useMergeRefs([listRef, listContainerRef]);
5740
5743
  return (jsxRuntime.jsx("div", { className: cvaListContainer({
5741
5744
  withTopSeparator: topSeparatorOnScroll && !isAtTop,
5742
5745
  className,
5743
- }), "data-is-scrolling": isScrolling, "data-testid": dataTestId, ref: mergedContainerRef, style: style, children: jsxRuntime.jsx("ul", { className: cvaList(), ref: listRef, children: rows.map(row => {
5746
+ }), "data-is-scrolling": isScrolling, "data-testid": dataTestId, ref: mergedContainerRef, style: style, children: jsxRuntime.jsx("ul", { className: cvaList(), ref: mergedListRef, children: rows.map(row => {
5744
5747
  // Generate list item props with clean separator styling
5745
5748
  const listItemProps = getListItemProps(row, {
5746
5749
  className: cvaListItem$1({
@@ -5794,7 +5797,7 @@ const DEFAULT_ROW_HEIGHT$1 = 50;
5794
5797
  * @param props.overscan - Optional number of items to render outside the visible area.
5795
5798
  * @param props.onChange - Optional callback when virtualizer changes.
5796
5799
  * @param props.skip - Whether to skip automatic loading of more data (default: false).
5797
- * @returns {Virtualizer} The virtualizer instance with all its properties and methods.
5800
+ * @returns {ReactVirtualizer} The virtualizer instance with all its properties and methods, including `containerRef` for direct DOM positioning.
5798
5801
  * @description
5799
5802
  * This hook is used to implement infinite scrolling in a table. It uses TanStack Virtual's
5800
5803
  * built-in capabilities for virtualization and automatically loads more data when scrolling
@@ -5808,12 +5811,14 @@ const DEFAULT_ROW_HEIGHT$1 = 50;
5808
5811
  * });
5809
5812
  */
5810
5813
  const useInfiniteScroll = ({ pagination, scrollElementRef, count, estimateSize, overscan, onChange, skip = false, }) => {
5811
- "use no memo"; //! TODO: remove this once Tanstack Virtual is updated to support React Compiler
5812
5814
  const handleChange = react.useCallback((virtualizer) => {
5813
5815
  onChange?.(virtualizer);
5814
5816
  }, [onChange]);
5815
5817
  const handleEstimateSize = react.useCallback((index) => estimateSize?.(index) ?? DEFAULT_ROW_HEIGHT$1, [estimateSize]);
5816
- //! TODO: remove this once Tanstack Virtual is updated to support React Compiler
5818
+ // eslint-plugin-react-hooks hardcodes `useVirtualizer` as a known-incompatible
5819
+ // API (its returned functions can't be memoized), so this warning is emitted
5820
+ // regardless of the installed version. The React Compiler already auto-skips
5821
+ // memoizing this hook, so the behaviour is safe.
5817
5822
  // eslint-disable-next-line react-hooks/incompatible-library
5818
5823
  const rowVirtualizer = reactVirtual.useVirtualizer({
5819
5824
  count,
@@ -5824,6 +5829,12 @@ const useInfiniteScroll = ({ pagination, scrollElementRef, count, estimateSize,
5824
5829
  // This option enables wrapping ResizeObserver measurements in requestAnimationFrame for smoother updates and reduced layout thrashing.
5825
5830
  // It helps prevent the "ResizeObserver loop completed with undelivered notifications" error by ensuring that measurements align with the rendering cycle
5826
5831
  useAnimationFrameWithResizeObserver: true,
5832
+ // Let the virtualizer write item positions and container size straight to
5833
+ // the DOM, only re-rendering when the visible index range changes. This
5834
+ // removes the imperative transform/height races that made scrolling jumpy.
5835
+ directDomUpdates: true,
5836
+ directDomUpdatesMode: "transform",
5837
+ useFlushSync: false,
5827
5838
  });
5828
5839
  const virtualItems = rowVirtualizer.getVirtualItems();
5829
5840
  // Auto-load more data based on scroll position and content height
@@ -5883,7 +5894,7 @@ const DEFAULT_LOADING_INDICATOR_CONFIG = {
5883
5894
  *
5884
5895
  * return (
5885
5896
  * <div ref={list.containerRef}>
5886
- * <ul style={{ height: `${list.getTotalSize()}px` }}>
5897
+ * <ul ref={list.listContainerRef} className="relative">
5887
5898
  * {list.rows.map(row => {
5888
5899
  * const props = list.getListItemProps(row, { className: 'list-item' });
5889
5900
  * return <li {...props}>{row.item?.title}</li>;
@@ -5896,7 +5907,6 @@ const DEFAULT_LOADING_INDICATOR_CONFIG = {
5896
5907
  const useList = ({ count, pagination, header, getItem, loadingIndicator = DEFAULT_LOADING_INDICATOR_CONFIG, onRowClick, onChange, estimateItemSize, estimateHeaderSize, overscan, separator = "line", topSeparatorOnScroll = false, }) => {
5897
5908
  const containerRef = react.useRef(null);
5898
5909
  const listRef = react.useRef(null);
5899
- const rowRefsMap = react.useRef(new Map());
5900
5910
  const virtualizerRef = react.useRef(null);
5901
5911
  const hasMeasuredOnMount = react.useRef(false);
5902
5912
  // Resolve loading indicator once to avoid unnecessary re-renders
@@ -5988,19 +5998,10 @@ const useList = ({ count, pagination, header, getItem, loadingIndicator = DEFAUL
5988
5998
  count: totalRowCount,
5989
5999
  estimateSize,
5990
6000
  overscan,
5991
- onChange: instance => {
5992
- if (listRef.current) {
5993
- listRef.current.style.height = `${instance.getTotalSize()}px`;
5994
- }
5995
- // Apply transforms to all virtual items
5996
- instance.getVirtualItems().forEach(virtualRow => {
5997
- const rowRef = rowRefsMap.current.get(virtualRow.index);
5998
- if (rowRef) {
5999
- rowRef.style.transform = `translateY(${virtualRow.start}px)`;
6000
- }
6001
- });
6002
- onChange?.(instance);
6003
- },
6001
+ // Item positions and the `<ul>` size are written directly to the DOM by
6002
+ // the virtualizer (directDomUpdates), so this callback only forwards the
6003
+ // change to consumers.
6004
+ onChange,
6004
6005
  });
6005
6006
  // Keep ref updated with latest virtualizer instance
6006
6007
  react.useEffect(() => {
@@ -6024,9 +6025,9 @@ const useList = ({ count, pagination, header, getItem, loadingIndicator = DEFAUL
6024
6025
  }
6025
6026
  previousCountRef.current = currentCount;
6026
6027
  }, [virtualizer, pagination?.pageInfo?.count]);
6028
+ const virtualItems = virtualizer.getVirtualItems();
6027
6029
  // Transform virtual items into typed rows
6028
6030
  const rows = react.useMemo(() => {
6029
- const virtualItems = virtualizer.getVirtualItems();
6030
6031
  return virtualItems.map((virtualRow) => {
6031
6032
  const { index } = virtualRow;
6032
6033
  // Determine row type
@@ -6056,8 +6057,7 @@ const useList = ({ count, pagination, header, getItem, loadingIndicator = DEFAUL
6056
6057
  dataIndex,
6057
6058
  };
6058
6059
  });
6059
- // Call getVirtualItems() fresh each time to get updated measurements after virtualizer state changes
6060
- }, [virtualizer, totalDataRows, hasHeader, dataStartIndex, getItem]);
6060
+ }, [virtualItems, totalDataRows, hasHeader, dataStartIndex, getItem]);
6061
6061
  // Helper to create list item props
6062
6062
  const getListItemProps = react.useCallback((row, options) => {
6063
6063
  const { type, item, dataIndex } = row;
@@ -6072,17 +6072,9 @@ const useList = ({ count, pagination, header, getItem, loadingIndicator = DEFAUL
6072
6072
  className: options.className,
6073
6073
  "data-index": row.virtualRow.index,
6074
6074
  onClick,
6075
- ref: el => {
6076
- if (el) {
6077
- virtualizer.measureElement(el);
6078
- rowRefsMap.current.set(row.virtualRow.index, el);
6079
- // Apply transform immediately when element is added to map
6080
- const virtualRow = virtualizer.getVirtualItems().find(vr => vr.index === row.virtualRow.index);
6081
- if (virtualRow) {
6082
- el.style.transform = `translateY(${virtualRow.start}px)`;
6083
- }
6084
- }
6085
- },
6075
+ // The virtualizer positions rows itself (directDomUpdates); the ref
6076
+ // only needs to register the element for dynamic height measurement.
6077
+ ref: virtualizer.measureElement,
6086
6078
  tabIndex: -1,
6087
6079
  };
6088
6080
  }, [onRowClick, virtualizer]);
@@ -6096,7 +6088,11 @@ const useList = ({ count, pagination, header, getItem, loadingIndicator = DEFAUL
6096
6088
  }, [totalSize]);
6097
6089
  return react.useMemo(() => ({
6098
6090
  ...virtualizer,
6091
+ // `containerRef` (scroll element) intentionally overrides the spread
6092
+ // `virtualizer.containerRef`; the latter is re-exposed as
6093
+ // `listContainerRef` for the inner `<ul>` size container.
6099
6094
  containerRef,
6095
+ listContainerRef: virtualizer.containerRef,
6100
6096
  listRef,
6101
6097
  rows,
6102
6098
  getListItemProps,
@@ -12124,8 +12120,7 @@ const DEFAULT_ROW_HEIGHT = 50;
12124
12120
  * scroll position at both ends and triggers the appropriate pagination
12125
12121
  * direction.
12126
12122
  */
12127
- const useBidirectionalScroll = ({ pagination, scrollElementRef, count, estimateSize, overscan, onChange, skip = false, onTopItemChange, }) => {
12128
- "use no memo"; //! TODO: remove this once Tanstack Virtual is updated to support React Compiler
12123
+ const useBidirectionalScroll = ({ pagination, scrollElementRef, count, estimateSize, overscan, onChange, skip = false, onTopItemChange, getItemKey, }) => {
12129
12124
  const onTopItemChangeRef = react.useRef(onTopItemChange);
12130
12125
  react.useEffect(() => {
12131
12126
  onTopItemChangeRef.current = onTopItemChange;
@@ -12141,7 +12136,10 @@ const useBidirectionalScroll = ({ pagination, scrollElementRef, count, estimateS
12141
12136
  }
12142
12137
  }, [onChange]);
12143
12138
  const handleEstimateSize = react.useCallback((index) => estimateSize?.(index) ?? DEFAULT_ROW_HEIGHT, [estimateSize]);
12144
- //! TODO: remove this once Tanstack Virtual is updated to support React Compiler
12139
+ // eslint-plugin-react-hooks hardcodes `useVirtualizer` as a known-incompatible
12140
+ // API (its returned functions can't be memoized), so this warning is emitted
12141
+ // regardless of the installed version. The React Compiler already auto-skips
12142
+ // memoizing this hook, so the behaviour is safe.
12145
12143
  // eslint-disable-next-line react-hooks/incompatible-library
12146
12144
  const rowVirtualizer = reactVirtual.useVirtualizer({
12147
12145
  count,
@@ -12149,7 +12147,14 @@ const useBidirectionalScroll = ({ pagination, scrollElementRef, count, estimateS
12149
12147
  estimateSize: handleEstimateSize,
12150
12148
  overscan: overscan ?? OVERSCAN,
12151
12149
  onChange: handleChange,
12150
+ getItemKey,
12152
12151
  useAnimationFrameWithResizeObserver: true,
12152
+ // Let the virtualizer write item positions and container size straight to
12153
+ // the DOM, only re-rendering when the visible index range changes. This
12154
+ // removes the imperative transform/height races that made scrolling jumpy.
12155
+ directDomUpdates: true,
12156
+ directDomUpdatesMode: "transform",
12157
+ useFlushSync: false,
12153
12158
  });
12154
12159
  const virtualItems = rowVirtualizer.getVirtualItems();
12155
12160
  // Track count before backward fetch so we can offset scroll position
package/index.esm.js CHANGED
@@ -5731,14 +5731,17 @@ const ListLoadingIndicator = ({ type, hasThumbnail, thumbnailShape, hasDescripti
5731
5731
  */
5732
5732
  const List = ({ children, className, "data-testid": dataTestId, style, ref,
5733
5733
  // UseListResult properties
5734
- containerRef, listRef, rows, getListItemProps, header, loadingIndicator, shouldShowLoaderAtIndex, count, isScrolling, separator, topSeparatorOnScroll, isAtTop, contentFillsContainer,
5734
+ containerRef, listRef, listContainerRef, rows, getListItemProps, header, loadingIndicator, shouldShowLoaderAtIndex, count, isScrolling, separator, topSeparatorOnScroll, isAtTop, contentFillsContainer,
5735
5735
  // Unused but part of UseListResult interface (can be used from parent)
5736
5736
  scrollOffset: _scrollOffset, getTotalSize: _getTotalSize, getVirtualItems: _getVirtualItems, scrollToOffset: _scrollToOffset, scrollToIndex: _scrollToIndex, measure: _measure, }) => {
5737
5737
  const mergedContainerRef = useMergeRefs([containerRef, ref]);
5738
+ // The virtualizer owns the `<ul>` height + item positions via directDomUpdates,
5739
+ // so its container callback must be attached to the `<ul>` (alongside listRef).
5740
+ const mergedListRef = useMergeRefs([listRef, listContainerRef]);
5738
5741
  return (jsx("div", { className: cvaListContainer({
5739
5742
  withTopSeparator: topSeparatorOnScroll && !isAtTop,
5740
5743
  className,
5741
- }), "data-is-scrolling": isScrolling, "data-testid": dataTestId, ref: mergedContainerRef, style: style, children: jsx("ul", { className: cvaList(), ref: listRef, children: rows.map(row => {
5744
+ }), "data-is-scrolling": isScrolling, "data-testid": dataTestId, ref: mergedContainerRef, style: style, children: jsx("ul", { className: cvaList(), ref: mergedListRef, children: rows.map(row => {
5742
5745
  // Generate list item props with clean separator styling
5743
5746
  const listItemProps = getListItemProps(row, {
5744
5747
  className: cvaListItem$1({
@@ -5792,7 +5795,7 @@ const DEFAULT_ROW_HEIGHT$1 = 50;
5792
5795
  * @param props.overscan - Optional number of items to render outside the visible area.
5793
5796
  * @param props.onChange - Optional callback when virtualizer changes.
5794
5797
  * @param props.skip - Whether to skip automatic loading of more data (default: false).
5795
- * @returns {Virtualizer} The virtualizer instance with all its properties and methods.
5798
+ * @returns {ReactVirtualizer} The virtualizer instance with all its properties and methods, including `containerRef` for direct DOM positioning.
5796
5799
  * @description
5797
5800
  * This hook is used to implement infinite scrolling in a table. It uses TanStack Virtual's
5798
5801
  * built-in capabilities for virtualization and automatically loads more data when scrolling
@@ -5806,12 +5809,14 @@ const DEFAULT_ROW_HEIGHT$1 = 50;
5806
5809
  * });
5807
5810
  */
5808
5811
  const useInfiniteScroll = ({ pagination, scrollElementRef, count, estimateSize, overscan, onChange, skip = false, }) => {
5809
- "use no memo"; //! TODO: remove this once Tanstack Virtual is updated to support React Compiler
5810
5812
  const handleChange = useCallback((virtualizer) => {
5811
5813
  onChange?.(virtualizer);
5812
5814
  }, [onChange]);
5813
5815
  const handleEstimateSize = useCallback((index) => estimateSize?.(index) ?? DEFAULT_ROW_HEIGHT$1, [estimateSize]);
5814
- //! TODO: remove this once Tanstack Virtual is updated to support React Compiler
5816
+ // eslint-plugin-react-hooks hardcodes `useVirtualizer` as a known-incompatible
5817
+ // API (its returned functions can't be memoized), so this warning is emitted
5818
+ // regardless of the installed version. The React Compiler already auto-skips
5819
+ // memoizing this hook, so the behaviour is safe.
5815
5820
  // eslint-disable-next-line react-hooks/incompatible-library
5816
5821
  const rowVirtualizer = useVirtualizer({
5817
5822
  count,
@@ -5822,6 +5827,12 @@ const useInfiniteScroll = ({ pagination, scrollElementRef, count, estimateSize,
5822
5827
  // This option enables wrapping ResizeObserver measurements in requestAnimationFrame for smoother updates and reduced layout thrashing.
5823
5828
  // It helps prevent the "ResizeObserver loop completed with undelivered notifications" error by ensuring that measurements align with the rendering cycle
5824
5829
  useAnimationFrameWithResizeObserver: true,
5830
+ // Let the virtualizer write item positions and container size straight to
5831
+ // the DOM, only re-rendering when the visible index range changes. This
5832
+ // removes the imperative transform/height races that made scrolling jumpy.
5833
+ directDomUpdates: true,
5834
+ directDomUpdatesMode: "transform",
5835
+ useFlushSync: false,
5825
5836
  });
5826
5837
  const virtualItems = rowVirtualizer.getVirtualItems();
5827
5838
  // Auto-load more data based on scroll position and content height
@@ -5881,7 +5892,7 @@ const DEFAULT_LOADING_INDICATOR_CONFIG = {
5881
5892
  *
5882
5893
  * return (
5883
5894
  * <div ref={list.containerRef}>
5884
- * <ul style={{ height: `${list.getTotalSize()}px` }}>
5895
+ * <ul ref={list.listContainerRef} className="relative">
5885
5896
  * {list.rows.map(row => {
5886
5897
  * const props = list.getListItemProps(row, { className: 'list-item' });
5887
5898
  * return <li {...props}>{row.item?.title}</li>;
@@ -5894,7 +5905,6 @@ const DEFAULT_LOADING_INDICATOR_CONFIG = {
5894
5905
  const useList = ({ count, pagination, header, getItem, loadingIndicator = DEFAULT_LOADING_INDICATOR_CONFIG, onRowClick, onChange, estimateItemSize, estimateHeaderSize, overscan, separator = "line", topSeparatorOnScroll = false, }) => {
5895
5906
  const containerRef = useRef(null);
5896
5907
  const listRef = useRef(null);
5897
- const rowRefsMap = useRef(new Map());
5898
5908
  const virtualizerRef = useRef(null);
5899
5909
  const hasMeasuredOnMount = useRef(false);
5900
5910
  // Resolve loading indicator once to avoid unnecessary re-renders
@@ -5986,19 +5996,10 @@ const useList = ({ count, pagination, header, getItem, loadingIndicator = DEFAUL
5986
5996
  count: totalRowCount,
5987
5997
  estimateSize,
5988
5998
  overscan,
5989
- onChange: instance => {
5990
- if (listRef.current) {
5991
- listRef.current.style.height = `${instance.getTotalSize()}px`;
5992
- }
5993
- // Apply transforms to all virtual items
5994
- instance.getVirtualItems().forEach(virtualRow => {
5995
- const rowRef = rowRefsMap.current.get(virtualRow.index);
5996
- if (rowRef) {
5997
- rowRef.style.transform = `translateY(${virtualRow.start}px)`;
5998
- }
5999
- });
6000
- onChange?.(instance);
6001
- },
5999
+ // Item positions and the `<ul>` size are written directly to the DOM by
6000
+ // the virtualizer (directDomUpdates), so this callback only forwards the
6001
+ // change to consumers.
6002
+ onChange,
6002
6003
  });
6003
6004
  // Keep ref updated with latest virtualizer instance
6004
6005
  useEffect(() => {
@@ -6022,9 +6023,9 @@ const useList = ({ count, pagination, header, getItem, loadingIndicator = DEFAUL
6022
6023
  }
6023
6024
  previousCountRef.current = currentCount;
6024
6025
  }, [virtualizer, pagination?.pageInfo?.count]);
6026
+ const virtualItems = virtualizer.getVirtualItems();
6025
6027
  // Transform virtual items into typed rows
6026
6028
  const rows = useMemo(() => {
6027
- const virtualItems = virtualizer.getVirtualItems();
6028
6029
  return virtualItems.map((virtualRow) => {
6029
6030
  const { index } = virtualRow;
6030
6031
  // Determine row type
@@ -6054,8 +6055,7 @@ const useList = ({ count, pagination, header, getItem, loadingIndicator = DEFAUL
6054
6055
  dataIndex,
6055
6056
  };
6056
6057
  });
6057
- // Call getVirtualItems() fresh each time to get updated measurements after virtualizer state changes
6058
- }, [virtualizer, totalDataRows, hasHeader, dataStartIndex, getItem]);
6058
+ }, [virtualItems, totalDataRows, hasHeader, dataStartIndex, getItem]);
6059
6059
  // Helper to create list item props
6060
6060
  const getListItemProps = useCallback((row, options) => {
6061
6061
  const { type, item, dataIndex } = row;
@@ -6070,17 +6070,9 @@ const useList = ({ count, pagination, header, getItem, loadingIndicator = DEFAUL
6070
6070
  className: options.className,
6071
6071
  "data-index": row.virtualRow.index,
6072
6072
  onClick,
6073
- ref: el => {
6074
- if (el) {
6075
- virtualizer.measureElement(el);
6076
- rowRefsMap.current.set(row.virtualRow.index, el);
6077
- // Apply transform immediately when element is added to map
6078
- const virtualRow = virtualizer.getVirtualItems().find(vr => vr.index === row.virtualRow.index);
6079
- if (virtualRow) {
6080
- el.style.transform = `translateY(${virtualRow.start}px)`;
6081
- }
6082
- }
6083
- },
6073
+ // The virtualizer positions rows itself (directDomUpdates); the ref
6074
+ // only needs to register the element for dynamic height measurement.
6075
+ ref: virtualizer.measureElement,
6084
6076
  tabIndex: -1,
6085
6077
  };
6086
6078
  }, [onRowClick, virtualizer]);
@@ -6094,7 +6086,11 @@ const useList = ({ count, pagination, header, getItem, loadingIndicator = DEFAUL
6094
6086
  }, [totalSize]);
6095
6087
  return useMemo(() => ({
6096
6088
  ...virtualizer,
6089
+ // `containerRef` (scroll element) intentionally overrides the spread
6090
+ // `virtualizer.containerRef`; the latter is re-exposed as
6091
+ // `listContainerRef` for the inner `<ul>` size container.
6097
6092
  containerRef,
6093
+ listContainerRef: virtualizer.containerRef,
6098
6094
  listRef,
6099
6095
  rows,
6100
6096
  getListItemProps,
@@ -12122,8 +12118,7 @@ const DEFAULT_ROW_HEIGHT = 50;
12122
12118
  * scroll position at both ends and triggers the appropriate pagination
12123
12119
  * direction.
12124
12120
  */
12125
- const useBidirectionalScroll = ({ pagination, scrollElementRef, count, estimateSize, overscan, onChange, skip = false, onTopItemChange, }) => {
12126
- "use no memo"; //! TODO: remove this once Tanstack Virtual is updated to support React Compiler
12121
+ const useBidirectionalScroll = ({ pagination, scrollElementRef, count, estimateSize, overscan, onChange, skip = false, onTopItemChange, getItemKey, }) => {
12127
12122
  const onTopItemChangeRef = useRef(onTopItemChange);
12128
12123
  useEffect(() => {
12129
12124
  onTopItemChangeRef.current = onTopItemChange;
@@ -12139,7 +12134,10 @@ const useBidirectionalScroll = ({ pagination, scrollElementRef, count, estimateS
12139
12134
  }
12140
12135
  }, [onChange]);
12141
12136
  const handleEstimateSize = useCallback((index) => estimateSize?.(index) ?? DEFAULT_ROW_HEIGHT, [estimateSize]);
12142
- //! TODO: remove this once Tanstack Virtual is updated to support React Compiler
12137
+ // eslint-plugin-react-hooks hardcodes `useVirtualizer` as a known-incompatible
12138
+ // API (its returned functions can't be memoized), so this warning is emitted
12139
+ // regardless of the installed version. The React Compiler already auto-skips
12140
+ // memoizing this hook, so the behaviour is safe.
12143
12141
  // eslint-disable-next-line react-hooks/incompatible-library
12144
12142
  const rowVirtualizer = useVirtualizer({
12145
12143
  count,
@@ -12147,7 +12145,14 @@ const useBidirectionalScroll = ({ pagination, scrollElementRef, count, estimateS
12147
12145
  estimateSize: handleEstimateSize,
12148
12146
  overscan: overscan ?? OVERSCAN,
12149
12147
  onChange: handleChange,
12148
+ getItemKey,
12150
12149
  useAnimationFrameWithResizeObserver: true,
12150
+ // Let the virtualizer write item positions and container size straight to
12151
+ // the DOM, only re-rendering when the visible index range changes. This
12152
+ // removes the imperative transform/height races that made scrolling jumpy.
12153
+ directDomUpdates: true,
12154
+ directDomUpdatesMode: "transform",
12155
+ useFlushSync: false,
12151
12156
  });
12152
12157
  const virtualItems = rowVirtualizer.getVirtualItems();
12153
12158
  // Track count before backward fetch so we can offset scroll position
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-components",
3
- "version": "2.1.65",
3
+ "version": "2.2.0",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "migrations": "./migrations.json",
@@ -14,17 +14,17 @@
14
14
  "@floating-ui/react": "^0.26.25",
15
15
  "string-ts": "^2.0.0",
16
16
  "tailwind-merge": "^2.0.0",
17
- "@trackunit/ui-design-tokens": "1.13.57",
18
- "@trackunit/css-class-variance-utilities": "1.13.58",
19
- "@trackunit/shared-utils": "1.15.61",
20
- "@trackunit/ui-icons": "1.13.59",
17
+ "@trackunit/ui-design-tokens": "1.13.58",
18
+ "@trackunit/css-class-variance-utilities": "1.13.59",
19
+ "@trackunit/shared-utils": "1.15.62",
20
+ "@trackunit/ui-icons": "1.13.60",
21
21
  "es-toolkit": "^1.39.10",
22
- "@tanstack/react-virtual": "3.13.12",
22
+ "@tanstack/react-virtual": "^3.14.3",
23
23
  "dequal": "^2.0.3",
24
24
  "fflate": "^0.8.2",
25
25
  "superjson": "^2.2.6",
26
26
  "zod": "^3.25.76",
27
- "@trackunit/i18n-library-translation": "2.0.63"
27
+ "@trackunit/i18n-library-translation": "2.1.0"
28
28
  },
29
29
  "peerDependencies": {
30
30
  "react": "^19.0.0",
@@ -93,4 +93,4 @@ export interface ListProps<TItem = unknown> extends CommonProps, Styleable, Refa
93
93
  * );
94
94
  * ```
95
95
  */
96
- export declare const List: <TItem = unknown>({ children, className, "data-testid": dataTestId, style, ref, containerRef, listRef, rows, getListItemProps, header, loadingIndicator, shouldShowLoaderAtIndex, count, isScrolling, separator, topSeparatorOnScroll, isAtTop, contentFillsContainer, scrollOffset: _scrollOffset, getTotalSize: _getTotalSize, getVirtualItems: _getVirtualItems, scrollToOffset: _scrollToOffset, scrollToIndex: _scrollToIndex, measure: _measure, }: ListProps<TItem>) => ReactElement;
96
+ export declare const List: <TItem = unknown>({ children, className, "data-testid": dataTestId, style, ref, containerRef, listRef, listContainerRef, rows, getListItemProps, header, loadingIndicator, shouldShowLoaderAtIndex, count, isScrolling, separator, topSeparatorOnScroll, isAtTop, contentFillsContainer, scrollOffset: _scrollOffset, getTotalSize: _getTotalSize, getVirtualItems: _getVirtualItems, scrollToOffset: _scrollToOffset, scrollToIndex: _scrollToIndex, measure: _measure, }: ListProps<TItem>) => ReactElement;
@@ -28,13 +28,13 @@ type CustomLoadingIndicator = {
28
28
  /**
29
29
  * Number of loading indicators to show on initial load
30
30
  *
31
- * @default 3
31
+ * @default 10
32
32
  */
33
33
  initialLoadingCount?: number;
34
34
  /**
35
35
  * Number of loading indicators to show when loading more items during scroll
36
36
  *
37
- * @default 10
37
+ * @default 3
38
38
  */
39
39
  scrollLoadingCount?: number;
40
40
  hasThumbnail?: never;
@@ -54,13 +54,13 @@ type SkeletonLoadingIndicator = {
54
54
  /**
55
55
  * Number of loading indicators to show on initial load
56
56
  *
57
- * @default 3
57
+ * @default 10
58
58
  */
59
59
  initialLoadingCount?: number;
60
60
  /**
61
61
  * Number of loading indicators to show when loading more items during scroll
62
62
  *
63
- * @default 10
63
+ * @default 3
64
64
  */
65
65
  scrollLoadingCount?: number;
66
66
  };
@@ -132,6 +132,13 @@ export interface UseListResult<TItem> extends Pick<Virtualizer<HTMLDivElement, H
132
132
  containerRef: RefObject<HTMLDivElement | null>;
133
133
  /** Reference to attach to the list */
134
134
  listRef: RefObject<HTMLUListElement | null>;
135
+ /**
136
+ * Callback ref for the inner size container (`<ul>`). The virtualizer writes
137
+ * the container's height and item positions directly to the DOM
138
+ * (directDomUpdates), so this MUST be attached to the `<ul>` and the `<ul>`
139
+ * must not set its own height.
140
+ */
141
+ listContainerRef: (node: HTMLElement | null) => void;
135
142
  /** Array of row data to render */
136
143
  readonly rows: ReadonlyArray<ListRow<TItem>>;
137
144
  /** Helper to create list item props for a given row */
@@ -178,7 +185,7 @@ export interface UseListResult<TItem> extends Pick<Virtualizer<HTMLDivElement, H
178
185
  *
179
186
  * return (
180
187
  * <div ref={list.containerRef}>
181
- * <ul style={{ height: `${list.getTotalSize()}px` }}>
188
+ * <ul ref={list.listContainerRef} className="relative">
182
189
  * {list.rows.map(row => {
183
190
  * const props = list.getListItemProps(row, { className: 'list-item' });
184
191
  * return <li {...props}>{row.item?.title}</li>;
@@ -1,4 +1,4 @@
1
- import { type Virtualizer } from "@tanstack/react-virtual";
1
+ import { type ReactVirtualizer, type Virtualizer } from "@tanstack/react-virtual";
2
2
  import { type RefObject } from "react";
3
3
  import type { RelayPagination } from "./useRelayPagination";
4
4
  interface BidirectionalScrollProps<TScrollElement extends Element, TItemElement extends Element> {
@@ -10,6 +10,15 @@ interface BidirectionalScrollProps<TScrollElement extends Element, TItemElement
10
10
  readonly onChange?: (virtualizer: Virtualizer<TScrollElement, TItemElement>) => void;
11
11
  readonly skip?: boolean;
12
12
  readonly onTopItemChange?: (index: number) => void;
13
+ /**
14
+ * Derives a stable per-item key from the index. Must agree with the React
15
+ * `key` used by the consumer's rendered items, otherwise the virtualizer's
16
+ * `elementsCache` (keyed by this value) and React's reconciliation (keyed
17
+ * by the rendered `key`) can disagree when indexes shift without a remount
18
+ * (e.g. sorting, filtering, or prepending pages), causing `directDomUpdates`
19
+ * to position rows incorrectly. Defaults to the item index.
20
+ */
21
+ readonly getItemKey?: (index: number) => string | number;
13
22
  }
14
23
  /**
15
24
  * Bidirectional infinite scroll hook that supports both forward (nextPage)
@@ -19,5 +28,5 @@ interface BidirectionalScrollProps<TScrollElement extends Element, TItemElement
19
28
  * scroll position at both ends and triggers the appropriate pagination
20
29
  * direction.
21
30
  */
22
- export declare const useBidirectionalScroll: <TScrollElement extends Element, TItemElement extends Element>({ pagination, scrollElementRef, count, estimateSize, overscan, onChange, skip, onTopItemChange, }: BidirectionalScrollProps<TScrollElement, TItemElement>) => Virtualizer<TScrollElement, TItemElement>;
31
+ export declare const useBidirectionalScroll: <TScrollElement extends Element, TItemElement extends Element>({ pagination, scrollElementRef, count, estimateSize, overscan, onChange, skip, onTopItemChange, getItemKey, }: BidirectionalScrollProps<TScrollElement, TItemElement>) => ReactVirtualizer<TScrollElement, TItemElement>;
23
32
  export {};
@@ -1,4 +1,4 @@
1
- import { type Virtualizer } from "@tanstack/react-virtual";
1
+ import { type ReactVirtualizer, type Virtualizer } from "@tanstack/react-virtual";
2
2
  import { RefObject } from "react";
3
3
  import { RelayPagination } from "./useRelayPagination";
4
4
  interface InfiniteScrollProps<TScrollElement extends Element, TItemElement extends Element> {
@@ -21,7 +21,7 @@ interface InfiniteScrollProps<TScrollElement extends Element, TItemElement exten
21
21
  * @param props.overscan - Optional number of items to render outside the visible area.
22
22
  * @param props.onChange - Optional callback when virtualizer changes.
23
23
  * @param props.skip - Whether to skip automatic loading of more data (default: false).
24
- * @returns {Virtualizer} The virtualizer instance with all its properties and methods.
24
+ * @returns {ReactVirtualizer} The virtualizer instance with all its properties and methods, including `containerRef` for direct DOM positioning.
25
25
  * @description
26
26
  * This hook is used to implement infinite scrolling in a table. It uses TanStack Virtual's
27
27
  * built-in capabilities for virtualization and automatically loads more data when scrolling
@@ -34,5 +34,5 @@ interface InfiniteScrollProps<TScrollElement extends Element, TItemElement exten
34
34
  * estimateSize: () => 35,
35
35
  * });
36
36
  */
37
- export declare const useInfiniteScroll: <TScrollElement extends Element, TItemElement extends Element>({ pagination, scrollElementRef, count, estimateSize, overscan, onChange, skip, }: InfiniteScrollProps<TScrollElement, TItemElement>) => Virtualizer<TScrollElement, TItemElement>;
37
+ export declare const useInfiniteScroll: <TScrollElement extends Element, TItemElement extends Element>({ pagination, scrollElementRef, count, estimateSize, overscan, onChange, skip, }: InfiniteScrollProps<TScrollElement, TItemElement>) => ReactVirtualizer<TScrollElement, TItemElement>;
38
38
  export {};
@@ -1 +0,0 @@
1
- {"version":3,"file":"entry.js","sourceRoot":"","sources":["../../../../../libs/react/components/migrations/entry.ts"],"names":[],"mappings":"","sourcesContent":["// Migration entry point for @nx/js:tsc build target.\n// Migrations are registered in ../migrations.json and resolved by NX at runtime.\nexport {};\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"jsx-utils.js","sourceRoot":"","sources":["../../../../../../libs/react/components/migrations/utils/jsx-utils.ts"],"names":[],"mappings":";;;;AAAA,uCAAqE;AACrE,uDAAoD;AA8L3C,wFA9LA,iBAAO,OA8LA;AA7LhB,uDAAiC;AAEjC,MAAM,cAAc,GAAG,CAAC,MAAM,EAAE,MAAM,CAAU,CAAC;AACjD,MAAM,aAAa,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAU,CAAC;AAEvD,MAA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pD,OAAO;IACT,CAAC;IACD,MAAM,YAAY,GAChB,kBAAkB,KAAK,SAAS,IAAI,kBAAkB,GAAG,CAAC;QACxD,CAAC,CAAC,KAAK,kBAAkB,kCAAkC;QAC3D,CAAC,CAAC,EAAE,CAAC;IACT,eAAM,CAAC,IAAI,CAAC,KAAK,aAAa,aAAa,OAAO,WAAW,YAAY,EAAE,CAAC,CAAC;AAC/E,CAAC,CAAC;AAVW,QAAA,UAAU,cAUrB;AAEF;;;;;;GAMG;AACI,MAAM,6BAA6B,GAAG,CAC3C,OAAe,EACf,cAA+D,EAC/D,aAAqB,EACb,EAAE;IACV,MAAM,OAAO,GAAG,cAAc,CAAC,OAAO,CAAC;IACvC,MAAM,SAAS,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IACnC,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,GAAG,IAAI,aAAa,EAAE,GAAG,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;AACtF,CAAC,CAAC;AARW,QAAA,6BAA6B,iCAQxC","sourcesContent":["import { logger, type Tree, visitNotIgnoredFiles } from \"@nx/devkit\";\nimport { tsquery } from \"@phenomnomnominal/tsquery\";\nimport * as ts from \"typescript\";\n\nconst TSX_EXTENSIONS = [\".tsx\", \".jsx\"] as const;\nconst TS_EXTENSIONS = [\".ts\", \".tsx\", \".jsx\"] as const;\n\nconst isTsxFile = (filePath: string): boolean => TSX_EXTENSIONS.some(ext => filePath.endsWith(ext));\nconst isTsFile = (filePath: string): boolean => TS_EXTENSIONS.some(ext => filePath.endsWith(ext));\n\nconst isUnderNodeModules = (filePath: string): boolean =>\n filePath.includes(\"/node_modules/\") || filePath.startsWith(\"node_modules/\");\n\nconst isUnderDist = (filePath: string): boolean =>\n filePath.includes(\"/dist/\") || filePath.startsWith(\"dist/\") || filePath.includes(\"/.nx/\");\n\n/**\n * Visits every `.tsx`/`.jsx` file under the workspace root and invokes the\n * callback with the file path and its current contents. Files that don't\n * include the marker substring are skipped, which makes large workspaces\n * cheap to scan.\n */\nexport const visitTsxFiles = (\n tree: Tree,\n marker: string,\n callback: (filePath: string, content: string) => string | null | undefined\n): number => {\n let touched = 0;\n visitNotIgnoredFiles(tree, \"/\", filePath => {\n if (!isTsxFile(filePath)) return;\n if (isUnderNodeModules(filePath) || isUnderDist(filePath)) return;\n const content = tree.read(filePath, \"utf-8\");\n if (content === null) return;\n if (!content.includes(marker)) return;\n const updated = callback(filePath, content);\n if (updated !== null && updated !== undefined && updated !== content) {\n tree.write(filePath, updated);\n touched += 1;\n }\n });\n return touched;\n};\n\n/**\n * Same as {@link visitTsxFiles} but also includes plain `.ts` files. Use this\n * when the codemod also rewrites non-JSX files such as helpers or hooks.\n */\nexport const visitTsFiles = (\n tree: Tree,\n marker: string,\n callback: (filePath: string, content: string) => string | null | undefined\n): number => {\n let touched = 0;\n visitNotIgnoredFiles(tree, \"/\", filePath => {\n if (!isTsFile(filePath)) return;\n if (isUnderNodeModules(filePath) || isUnderDist(filePath)) return;\n const content = tree.read(filePath, \"utf-8\");\n if (content === null) return;\n if (!content.includes(marker)) return;\n const updated = callback(filePath, content);\n if (updated !== null && updated !== undefined && updated !== content) {\n tree.write(filePath, updated);\n touched += 1;\n }\n });\n return touched;\n};\n\n/**\n * Mapping of imported component aliases to their original names for a given\n * package. For `import { IconButton as Btn } from \"@trackunit/react-components\"`\n * this returns `{ Btn: \"IconButton\" }`.\n *\n * Returns `null` when the file imports nothing from the package, which lets\n * callers short-circuit before parsing JSX.\n */\nexport const getImportedAliases = (sourceFile: ts.SourceFile, packageName: string): Record<string, string> | null => {\n const result: Record<string, string> = {};\n let found = false;\n\n for (const stmt of sourceFile.statements) {\n if (!ts.isImportDeclaration(stmt)) continue;\n const moduleSpecifier = stmt.moduleSpecifier;\n if (!ts.isStringLiteral(moduleSpecifier)) continue;\n if (moduleSpecifier.text !== packageName) continue;\n\n const namedBindings = stmt.importClause?.namedBindings;\n if (namedBindings === undefined || !ts.isNamedImports(namedBindings)) continue;\n\n for (const element of namedBindings.elements) {\n const localName = element.name.text;\n const importedName = element.propertyName?.text ?? localName;\n result[localName] = importedName;\n found = true;\n }\n }\n\n return found ? result : null;\n};\n\n/**\n * Returns the local alias used in this file for `originalName` when imported\n * from `packageName`, or `null` if the component is not imported.\n */\nexport const getLocalAliasFor = (\n sourceFile: ts.SourceFile,\n packageName: string,\n originalName: string\n): string | null => {\n const aliases = getImportedAliases(sourceFile, packageName);\n if (aliases === null) return null;\n for (const [local, original] of Object.entries(aliases)) {\n if (original === originalName) return local;\n }\n return null;\n};\n\nexport type JsxElementMatch = {\n /** The opening JSX element (the one carrying the attributes). */\n openingElement: ts.JsxOpeningElement | ts.JsxSelfClosingElement;\n /** The full element including children, or the self-closing element. */\n element: ts.JsxElement | ts.JsxSelfClosingElement;\n};\n\n/**\n * Finds every JSX element whose tag name resolves to one of `tagNames`\n * (typically the local aliases returned by {@link getImportedAliases}).\n *\n * The result intentionally includes both opening and full elements so callers\n * can manipulate attributes (via `openingElement`) or wrap/replace the whole\n * element (via `element`).\n */\nexport const findJsxElements = (\n sourceFile: ts.SourceFile,\n tagNames: ReadonlyArray<string>\n): ReadonlyArray<JsxElementMatch> => {\n const matches: Array<JsxElementMatch> = [];\n const tagSet = new Set(tagNames);\n\n const visit = (node: ts.Node): void => {\n if (ts.isJsxSelfClosingElement(node)) {\n if (ts.isIdentifier(node.tagName) && tagSet.has(node.tagName.text)) {\n matches.push({ openingElement: node, element: node });\n }\n } else if (ts.isJsxElement(node)) {\n const opening = node.openingElement;\n if (ts.isIdentifier(opening.tagName) && tagSet.has(opening.tagName.text)) {\n matches.push({ openingElement: opening, element: node });\n }\n }\n ts.forEachChild(node, visit);\n };\n\n visit(sourceFile);\n return matches;\n};\n\n/**\n * Looks up a named JSX attribute on the opening element. Returns `null` when\n * the attribute is missing or part of a spread attribute (which we cannot\n * statically inspect).\n */\nexport const findJsxAttribute = (\n openingElement: ts.JsxOpeningElement | ts.JsxSelfClosingElement,\n attributeName: string\n): ts.JsxAttribute | null => {\n for (const attr of openingElement.attributes.properties) {\n if (!ts.isJsxAttribute(attr)) continue;\n if (!ts.isIdentifier(attr.name)) continue;\n if (attr.name.text === attributeName) return attr;\n }\n return null;\n};\n\n/**\n * `true` when the element forwards a spread expression such as `{...rest}`,\n * which means we can't be sure which attributes are actually set.\n */\nexport const hasSpreadAttribute = (openingElement: ts.JsxOpeningElement | ts.JsxSelfClosingElement): boolean => {\n return openingElement.attributes.properties.some(prop => ts.isJsxSpreadAttribute(prop));\n};\n\n/**\n * Parses the file as TSX so JSX is recognised. We do not need a full program\n * here; tsquery's `ast` helper produces a script-kind source file which loses\n * JSX context, so we go through `createSourceFile` directly.\n */\nexport const parseTsx = (content: string, fileName = \"file.tsx\"): ts.SourceFile =>\n ts.createSourceFile(fileName, content, ts.ScriptTarget.Latest, true, ts.ScriptKind.TSX);\n\n/** Re-exported for codemods that need direct AST queries. */\nexport { tsquery };\n\n/**\n * Helper for codemods to log a one-line summary at the end of a run. Migration\n * runners aggregate logs per migration, so this keeps output focused.\n */\nexport const logSummary = (migrationName: string, touched: number, manualReviewNeeded?: number): void => {\n if (touched === 0) {\n logger.info(` ${migrationName}: no files changed`);\n return;\n }\n const reviewSuffix =\n manualReviewNeeded !== undefined && manualReviewNeeded > 0\n ? ` (${manualReviewNeeded} location(s) need manual review)`\n : \"\";\n logger.info(` ${migrationName}: updated ${touched} file(s)${reviewSuffix}`);\n};\n\n/**\n * Inserts an attribute string immediately after the tag name (so the new\n * attribute appears first). Returns the resulting source content.\n *\n * The added attribute is rendered verbatim, so callers are responsible for\n * including the leading space (e.g. ` title=\"Close\"`).\n */\nexport const insertAttributeIntoOpeningTag = (\n content: string,\n openingElement: ts.JsxOpeningElement | ts.JsxSelfClosingElement,\n attributeText: string\n): string => {\n const tagName = openingElement.tagName;\n const insertPos = tagName.getEnd();\n return content.slice(0, insertPos) + ` ${attributeText}` + content.slice(insertPos);\n};\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"breadcrumb-remove-deprecated-props.js","sourceRoot":"","sources":["../../../../../../libs/react/components/migrations/v2-0-0/breadcrumb-remove-deprecated-props.ts"],"names":[],"mappings":";;;AAAA,uCAA+C;AAC/C,kDAO4B;AAE5B,MAAM,YAAY,GAAG,6BAA6B,CAAC;AACnD,MAAM,eAAe,GAAG,CAAC,YAAY,EAAE,qBAAqB,EAAE,2BAA2B,CAAU,CAAC;AACpG,MAAM,eAAe,GAAG,CAAC,iBAAiB,EAAE,2BAA2B,CAAU,CAAC;AAElF,MAAM,oBAAoB,GAAG,CAAC,QAAgB,EAAE,OAAe,EAAiB,EAAE;IAChF,MAAM,UAAU,GAAG,IAAA,oBAAQ,EAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAE/C,MAAM,OAAO,GAAG,IAAA,8BAAkB,EAAC,UAAU,EAAE,YAAY,CAAC,CAAC;IAC7D,IAAI,OAAO,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAElC,MAAM,aAAa,GAAkB,EAAE,CAAC;IACxC,KAAK,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACxD,IAAI,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,KAAK,QAAQ,CAAC,EAAE,CAAC;YACpD,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC;IACD,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAE5C,MAAM,OAAO,GAAG,IAAA,2BAAe,EAAC,UAAU,EAAE,aAAa,CAAC,CAAC;IAC3D,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAEtC,yEAAyE;IACzE,yDAAyD;IACzD,MAAM,MAAM,GAA0C,EAAE,CAAC;IACzD,KAAK,MAAM,EAAE,cAAc,EAAE,IAA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AC1D,eAAM,CAAC,IAAI,CACT,kJAAkJ,CACnJ,CAAC;AACJ,CAAC,CAAC;AANW,QAAA,+BAA+B,mCAM1C;AAEF,kBAAe,uCAA+B,CAAC","sourcesContent":["import { type Tree, logger } from \"@nx/devkit\";\nimport {\n findJsxAttribute,\n findJsxElements,\n getImportedAliases,\n logSummary,\n parseTsx,\n visitTsxFiles,\n} from \"../utils/jsx-utils\";\n\nconst PACKAGE_NAME = \"@trackunit/react-components\";\nconst COMPONENT_NAMES = [\"Breadcrumb\", \"BreadcrumbContainer\", \"BreadcrumbForMediumScreen\"] as const;\nconst PROPS_TO_REMOVE = [\"backButtonTitle\", \"expandCollapsedItemsTitle\"] as const;\n\nconst stripDeprecatedProps = (filePath: string, content: string): string | null => {\n const sourceFile = parseTsx(content, filePath);\n\n const aliases = getImportedAliases(sourceFile, PACKAGE_NAME);\n if (aliases === null) return null;\n\n const localTagNames: Array<string> = [];\n for (const [local, original] of Object.entries(aliases)) {\n if (COMPONENT_NAMES.some(name => name === original)) {\n localTagNames.push(local);\n }\n }\n if (localTagNames.length === 0) return null;\n\n const matches = findJsxElements(sourceFile, localTagNames);\n if (matches.length === 0) return null;\n\n // Collect every (start, end) range we want to delete. We process them in\n // reverse so earlier offsets stay valid while we splice.\n const ranges: Array<{ start: number; end: number }> = [];\n for (const { openingElement } of matches) {\n for (const propName of PROPS_TO_REMOVE) {\n const attr = findJsxAttribute(openingElement, propName);\n if (attr === null) continue;\n\n // Drop trailing whitespace + the attribute itself so we don't leave a\n // dangling space inside the opening tag. e.g. `<X foo=\"a\" bar=\"b\" />`\n // becomes `<X foo=\"a\" />` and `<X bar=\"b\" />` becomes `<X />`.\n let start = attr.getFullStart();\n const end = attr.getEnd();\n // getFullStart includes leading whitespace which is what we want.\n // Guard against negative ranges if multiple props collapse later.\n if (start < 0) start = attr.getStart();\n ranges.push({ start, end });\n }\n }\n\n if (ranges.length === 0) return null;\n\n ranges.sort((a, b) => b.start - a.start);\n\n let updated = content;\n for (const { start, end } of ranges) {\n updated = updated.slice(0, start) + updated.slice(end);\n }\n\n return updated;\n};\n\n/**\n * Removes the no-longer-supported `backButtonTitle` and\n * `expandCollapsedItemsTitle` props from `<Breadcrumb>`,\n * `<BreadcrumbContainer>`, and `<BreadcrumbForMediumScreen>`. Their accessible\n * names are now sourced from the `react-components` library translations.\n */\nexport const breadcrumbRemoveDeprecatedProps = (tree: Tree): void => {\n const touched = visitTsxFiles(tree, \"Breadcrumb\", stripDeprecatedProps);\n logSummary(\"breadcrumb-remove-deprecated-props\", touched);\n logger.info(\n \" Ensure the host application registers the @trackunit/react-components library translations so the back/expand buttons render localized labels.\"\n );\n};\n\nexport default breadcrumbRemoveDeprecatedProps;\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"cardheader-onclickclose-to-actions.js","sourceRoot":"","sources":["../../../../../../libs/react/components/migrations/v2-0-0/cardheader-onclickclose-to-actions.ts"],"names":[],"mappings":";;;;AACA,uDAAiC;AACjC,kDAO4B;AAE5B,MAAM,YAAY,GAAG,6BAA6B,CAAC;AACnD,MAAM,cAAc,GAAG,YAAY,CAAC;AAEpC,MAAM,kBAAkB,GAAG,CAAC,YAAY,EAAE,MAAM,CAAU,CAAC;AAE3D,MAAM,iBAAiB,GAAG,CAAC,WAAmB,EAAE,SAAiB,EAAE,eAAuB,EAAU,EAAE,CACpG,IAAI,eAAe,WAAW,SAAS,2CAA2C,WAAW,4CAA4C,CAAC;AAE5I,MAAM,iBAAiB,GAAG,CAAC,OAAe,EAAE,WAAmB,EAAE,UAAiC,EAAU,EAAE;IAC5G,MAAM,UAAU,GAAG,IAAA,oBAAQ,EAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IACnD,MAAM,OAAO,GAAG,IAAA,8BAAkB,EAAC,UAAU,EAAE,WAAW,CAAC,IAAI,EAAE,CAAC;IAElE,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,CA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,CAAC,CAAC;IAC5E,IAAA,sBAAU,EAAC,oCAAoC,EAAE,OAAO,CAAC,CAAC;AAC5D,CAAC,CAAC;AAHW,QAAA,+BAA+B,mCAG1C;AAEF,kBAAe,uCAA+B,CAAC","sourcesContent":["import { type Tree } from \"@nx/devkit\";\nimport * as ts from \"typescript\";\nimport {\n findJsxAttribute,\n findJsxElements,\n getImportedAliases,\n logSummary,\n parseTsx,\n visitTsxFiles,\n} from \"../utils/jsx-utils\";\n\nconst PACKAGE_NAME = \"@trackunit/react-components\";\nconst COMPONENT_NAME = \"CardHeader\";\n\nconst CLOSE_BUTTON_NAMES = [\"IconButton\", \"Icon\"] as const;\n\nconst renderCloseButton = (handlerExpr: string, iconAlias: string, iconButtonAlias: string): string =>\n `<${iconButtonAlias} icon={<${iconAlias} name=\"XMark\" size=\"small\" />} onClick={${handlerExpr}} title=\"Close\" variant=\"ghost-neutral\" />`;\n\nconst ensureNamedImport = (content: string, packageName: string, namesToAdd: ReadonlyArray<string>): string => {\n const sourceFile = parseTsx(content, \"source.tsx\");\n const aliases = getImportedAliases(sourceFile, packageName) ?? {};\n\n const missing = namesToAdd.filter(name => !Object.values(aliases).includes(name));\n if (missing.length === 0) return content;\n\n for (const stmt of sourceFile.statements) {\n if (!ts.isImportDeclaration(stmt)) continue;\n const moduleSpecifier = stmt.moduleSpecifier;\n if (!ts.isStringLiteral(moduleSpecifier) || moduleSpecifier.text !== packageName) continue;\n\n const namedBindings = stmt.importClause?.namedBindings;\n if (namedBindings === undefined || !ts.isNamedImports(namedBindings)) continue;\n\n const elementsText = namedBindings.elements.map(el => el.getText()).join(\", \");\n const merged = [elementsText, ...missing].join(\", \");\n const before = content.slice(0, namedBindings.getStart());\n const after = content.slice(namedBindings.getEnd());\n return `${before}{ ${merged} }${after}`;\n }\n\n // No existing import from the package; add a fresh line near the top.\n const importLine = `import { ${missing.join(\", \")} } from \"${packageName}\";\\n`;\n return importLine + content;\n};\n\nconst transformCardHeaderUsage = (filePath: string, content: string): string | null => {\n const sourceFile = parseTsx(content, filePath);\n\n const aliases = getImportedAliases(sourceFile, PACKAGE_NAME);\n if (aliases === null) return null;\n\n const cardHeaderAlias = Object.entries(aliases).find(([, name]) => name === COMPONENT_NAME)?.[0];\n if (cardHeaderAlias === undefined) return null;\n\n const matches = findJsxElements(sourceFile, [cardHeaderAlias]);\n if (matches.length === 0) return null;\n\n type Edit = { start: number; end: number; replacement: string };\n const edits: Array<Edit> = [];\n\n for (const { openingElement } of matches) {\n const onClickCloseAttr = findJsxAttribute(openingElement, \"onClickClose\");\n if (onClickCloseAttr === null) continue;\n\n const initializer = onClickCloseAttr.initializer;\n if (initializer === undefined) continue;\n\n let handlerExpr: string;\n if (ts.isJsxExpression(initializer) && initializer.expression !== undefined) {\n handlerExpr = initializer.expression.getText();\n } else if (ts.isStringLiteral(initializer)) {\n handlerExpr = `\"${initializer.text}\"`;\n } else {\n continue;\n }\n\n const actionsAttr = findJsxAttribute(openingElement, \"actions\");\n if (actionsAttr !== null) {\n // Don't try to merge with an existing actions prop; flag and skip.\n continue;\n }\n\n const replacement = `actions={${renderCloseButton(handlerExpr, \"Icon\", \"IconButton\")}}`;\n edits.push({\n start: onClickCloseAttr.getStart(),\n end: onClickCloseAttr.getEnd(),\n replacement,\n });\n }\n\n if (edits.length === 0) return null;\n\n edits.sort((a, b) => b.start - a.start);\n\n let updated = content;\n for (const { start, end, replacement } of edits) {\n updated = updated.slice(0, start) + replacement + updated.slice(end);\n }\n\n updated = ensureNamedImport(updated, PACKAGE_NAME, [...CLOSE_BUTTON_NAMES]);\n\n return updated;\n};\n\n/**\n * Replaces the removed `onClickClose` prop on `<CardHeader>` with the\n * equivalent action rendered through the `actions` slot using `IconButton` +\n * the `XMark` icon.\n *\n * Cards that already declared `actions` are skipped to avoid clobbering\n * existing markup.\n */\nexport const cardHeaderOnClickCloseToActions = (tree: Tree): void => {\n const touched = visitTsxFiles(tree, \"CardHeader\", transformCardHeaderUsage);\n logSummary(\"cardheader-onclickclose-to-actions\", touched);\n};\n\nexport default cardHeaderOnClickCloseToActions;\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"iconbutton-add-required-name.js","sourceRoot":"","sources":["../../../../../../libs/react/components/migrations/v2-0-0/iconbutton-add-required-name.ts"],"names":[],"mappings":";;;AAAA,uCAA+C;AAC/C,kDAQ4B;AAE5B,MAAM,YAAY,GAAG,6BAA6B,CAAC;AACnD,MAAM,cAAc,GAAG,YAAY,CAAC;AAEpC,MAAM,iBAAiB,GAAG,0CAA0C,CAAC;AAErE,MAAM,wBAAwB,GAAG,CAAC,QAAgB,EAAE,OAAe,EAAiB,EAAE;IACpF,MAAM,UAAU,GAAG,IAAA,oBAAQ,EAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAE/C,MAAM,OAAO,GAAG,IAAA,8BAAkB,EAAC,UAAU,EAAE,YAAY,CAAC,CAAC;IAC7D,IAAI,OAAO,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAElC,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,IAAI,KAAK,cAAc,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAC5F,IAAI,UAAU,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IAE1C,MAAM,OAAO,GAAG,IAAA,2BAAe,EAAC,UAAU,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;IAC1D,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAGtC,MAAM,KAAK,GAAgB,EAAE,CAAC;IAE9B,KAAK,MAAM,EAAE,cAAc,EAAE,IAAI,OAAO,EAAE,CAAC;QACzC,IAAI,IAAA,8BAAkB,EAAC,cAAc,CAAC;YAAE,SAAS;QAEjD,MAAM,QAAQ,GAAG,IAAA,4BAAgB,EAAC,cAAc,EAAE,OAAO,CAAC,KAAK,IAAI,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yBAAyB,6BAQpC;AAEF,kBAAe,iCAAyB,CAAC","sourcesContent":["import { type Tree, logger } from \"@nx/devkit\";\nimport {\n findJsxAttribute,\n findJsxElements,\n getImportedAliases,\n hasSpreadAttribute,\n logSummary,\n parseTsx,\n visitTsxFiles,\n} from \"../utils/jsx-utils\";\n\nconst PACKAGE_NAME = \"@trackunit/react-components\";\nconst COMPONENT_NAME = \"IconButton\";\n\nconst PLACEHOLDER_TITLE = \"TODO Replace with localized button title\";\n\nconst transformIconButtonUsage = (filePath: string, content: string): string | null => {\n const sourceFile = parseTsx(content, filePath);\n\n const aliases = getImportedAliases(sourceFile, PACKAGE_NAME);\n if (aliases === null) return null;\n\n const localAlias = Object.entries(aliases).find(([, name]) => name === COMPONENT_NAME)?.[0];\n if (localAlias === undefined) return null;\n\n const matches = findJsxElements(sourceFile, [localAlias]);\n if (matches.length === 0) return null;\n\n type Edit = { offset: number; text: string };\n const edits: Array<Edit> = [];\n\n for (const { openingElement } of matches) {\n if (hasSpreadAttribute(openingElement)) continue;\n\n const hasTitle = findJsxAttribute(openingElement, \"title\") !== null;\n const hasAriaLabel = findJsxAttribute(openingElement, \"ariaLabel\") !== null;\n if (hasTitle || hasAriaLabel) continue;\n\n edits.push({\n offset: openingElement.tagName.getEnd(),\n text: ` title=\"${PLACEHOLDER_TITLE}\"`,\n });\n }\n\n if (edits.length === 0) return null;\n\n edits.sort((a, b) => (a.offset === b.offset ? 0 : b.offset - a.offset));\n\n let updated = content;\n for (const { offset, text } of edits) {\n updated = updated.slice(0, offset) + text + updated.slice(offset);\n }\n return updated;\n};\n\n/**\n * Adds a placeholder `title` to `<IconButton>` usages that don't already\n * provide either `title` or `ariaLabel`. The new accessible name requirement\n * means every icon button must carry one of these two props.\n *\n * Usages with a spread attribute (e.g. `<IconButton {...props} />`) are\n * skipped because we cannot tell whether `title`/`ariaLabel` is forwarded.\n */\nexport const iconButtonAddRequiredName = (tree: Tree): void => {\n const touched = visitTsxFiles(tree, \"IconButton\", transformIconButtonUsage);\n logSummary(\"iconbutton-add-required-name\", touched);\n if (touched > 0) {\n logger.info(\n ` Replace the placeholder \"${PLACEHOLDER_TITLE}\" titles with localized strings (or switch to ariaLabel where appropriate).`\n );\n }\n};\n\nexport default iconButtonAddRequiredName;\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"kpi-tooltiplabel-to-wrapper.js","sourceRoot":"","sources":["../../../../../../libs/react/components/migrations/v2-0-0/kpi-tooltiplabel-to-wrapper.ts"],"names":[],"mappings":";;;;AACA,uDAAiC;AACjC,kDAO4B;AAE5B,MAAM,YAAY,GAAG,6BAA6B,CAAC;AACnD,MAAM,cAAc,GAAG,KAAK,CAAC;AAE7B,MAAM,mBAAmB,GAAG,CAAC,OAAe,EAAU,EAAE;IACtD,MAAM,UAAU,GAAG,IAAA,oBAAQ,EAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IACnD,MAAM,OAAO,GAAG,IAAA,8BAAkB,EAAC,UAAU,EAAE,YAAY,CAAC,CAAC;IAC7D,IAAI,OAAO,KAAK,IAAI,IAAI,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC;QAAE,OAAO,OAAO,CAAC;IAEnF,KAAK,MAAM,IAAI,IAAI,UAAU,CAAC,UAAU,EAAE,CAAC;QACzC,IAAI,CAAC,EAAE,CAAC,mBAAmB,CAAC,IAAI,CAAC;YAAE,SAAS;QAC5C,MAAM,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC;QAC7C,IAAI,CAAC,EAAE,CAAC,eAAe,CAAC,eAAe,CAAC,IAAI,eAAe,CAAC,IAAI,KAAK,YAAY;YAAE,SAAS;QAE5F,MAAM,aAAa,GAAG,IAAI,CAAC,YAAY,EAAE,aAAa,CAAC;QACvD,IAAI,aAAa,KAAK,SAAS,IAAI,CAAC,EAAE,CAAC,cAAc,CAAC,aAAa,CAAC;YAAE,SAAS;QAE/E,MAAM,YAAY,GAAG,aAAa,CAAC,QAAQ,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O,GAAG,OAAO,CAAC;IACtB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,qEAAqE;QACrE,MAAM,kBAAkB,GACtB,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,YAAY,CAAC;YAC7D,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC;QAC3D,MAAM,OAAO,GAAG,kBAAkB,uBAAuB,CAAC,IAAI,CAAC,KAAK,CAAC,uBAAuB,kBAAkB,YAAY,CAAC;QAC3H,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,YAAY,CAAC,GAAG,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC3F,CAAC;IAED,OAAO,GAAG,mBAAmB,CAAC,OAAO,CAAC,CAAC;IAEvC,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF;;;;GAIG;AACI,MAAM,wBAAwB,GAAG,CAAC,IAAU,EAAQ,EAAE;IAC3D,MAAM,OAAO,GAAG,IAAA,yBAAa,EAAC,IAAI,EAAE,cAAc,EAAE,iBAAiB,CAAC,CAAC;IACvE,IAAA,sBAAU,EAAC,6BAA6B,EAAE,OAAO,CAAC,CAAC;AACrD,CAAC,CAAC;AAHW,QAAA,wBAAwB,4BAGnC;AAEF,kBAAe,gCAAwB,CAAC","sourcesContent":["import { type Tree } from \"@nx/devkit\";\nimport * as ts from \"typescript\";\nimport {\n findJsxAttribute,\n findJsxElements,\n getImportedAliases,\n logSummary,\n parseTsx,\n visitTsxFiles,\n} from \"../utils/jsx-utils\";\n\nconst PACKAGE_NAME = \"@trackunit/react-components\";\nconst COMPONENT_NAME = \"KPI\";\n\nconst ensureTooltipImport = (content: string): string => {\n const sourceFile = parseTsx(content, \"source.tsx\");\n const aliases = getImportedAliases(sourceFile, PACKAGE_NAME);\n if (aliases !== null && Object.values(aliases).includes(\"Tooltip\")) return content;\n\n for (const stmt of sourceFile.statements) {\n if (!ts.isImportDeclaration(stmt)) continue;\n const moduleSpecifier = stmt.moduleSpecifier;\n if (!ts.isStringLiteral(moduleSpecifier) || moduleSpecifier.text !== PACKAGE_NAME) continue;\n\n const namedBindings = stmt.importClause?.namedBindings;\n if (namedBindings === undefined || !ts.isNamedImports(namedBindings)) continue;\n\n const elementsText = namedBindings.elements.map(el => el.getText()).join(\", \");\n const merged = `${elementsText}, Tooltip`;\n const before = content.slice(0, namedBindings.getStart());\n const after = content.slice(namedBindings.getEnd());\n return `${before}{ ${merged} }${after}`;\n }\n\n return `import { Tooltip } from \"${PACKAGE_NAME}\";\\n${content}`;\n};\n\nconst renderTooltipExpression = (label: string): string => label;\n\nconst transformKpiUsage = (filePath: string, content: string): string | null => {\n const sourceFile = parseTsx(content, filePath);\n\n const aliases = getImportedAliases(sourceFile, PACKAGE_NAME);\n if (aliases === null) return null;\n\n const localAlias = Object.entries(aliases).find(([, name]) => name === COMPONENT_NAME)?.[0];\n if (localAlias === undefined) return null;\n\n const matches = findJsxElements(sourceFile, [localAlias]);\n if (matches.length === 0) return null;\n\n type Edit = {\n elementStart: number;\n elementEnd: number;\n attrStart: number;\n attrEnd: number;\n label: string;\n elementText: string;\n };\n const edits: Array<Edit> = [];\n\n for (const { openingElement, element } of matches) {\n const tooltipLabelAttr = findJsxAttribute(openingElement, \"tooltipLabel\");\n if (tooltipLabelAttr === null) continue;\n\n const initializer = tooltipLabelAttr.initializer;\n if (initializer === undefined) continue;\n\n let label: string;\n if (ts.isStringLiteral(initializer)) {\n label = `\"${initializer.text}\"`;\n } else if (ts.isJsxExpression(initializer) && initializer.expression !== undefined) {\n label = `{${initializer.expression.getText()}}`;\n } else {\n continue;\n }\n\n edits.push({\n elementStart: element.getStart(),\n elementEnd: element.getEnd(),\n attrStart: tooltipLabelAttr.getFullStart(),\n attrEnd: tooltipLabelAttr.getEnd(),\n label,\n elementText: content.slice(element.getStart(), element.getEnd()),\n });\n }\n\n if (edits.length === 0) return null;\n\n edits.sort((a, b) => b.elementStart - a.elementStart);\n\n let updated = content;\n for (const edit of edits) {\n // Remove the tooltipLabel attribute first (it's inside the element).\n const elementWithoutAttr =\n edit.elementText.slice(0, edit.attrStart - edit.elementStart) +\n edit.elementText.slice(edit.attrEnd - edit.elementStart);\n const wrapped = `<Tooltip label=${renderTooltipExpression(edit.label)} placement=\"bottom\">${elementWithoutAttr}</Tooltip>`;\n updated = updated.slice(0, edit.elementStart) + wrapped + updated.slice(edit.elementEnd);\n }\n\n updated = ensureTooltipImport(updated);\n\n return updated;\n};\n\n/**\n * Replaces the removed `tooltipLabel` prop on `<KPI>` with an explicit\n * `<Tooltip>` wrapper. The `KPICard` variant is intentionally not touched\n * because it still owns its own `tooltipLabel` prop.\n */\nexport const kpiTooltipLabelToWrapper = (tree: Tree): void => {\n const touched = visitTsxFiles(tree, \"tooltipLabel\", transformKpiUsage);\n logSummary(\"kpi-tooltiplabel-to-wrapper\", touched);\n};\n\nexport default kpiTooltipLabelToWrapper;\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"notice-tooltiplabel-to-wrapper.js","sourceRoot":"","sources":["../../../../../../libs/react/components/migrations/v2-0-0/notice-tooltiplabel-to-wrapper.ts"],"names":[],"mappings":";;;;AACA,uDAAiC;AACjC,kDAO4B;AAE5B,MAAM,YAAY,GAAG,6BAA6B,CAAC;AACnD,MAAM,cAAc,GAAG,QAAQ,CAAC;AAEhC,MAAM,mBAAmB,GAAG,CAAC,OAAe,EAAU,EAAE;IACtD,MAAM,UAAU,GAAG,IAAA,oBAAQ,EAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IACnD,MAAM,OAAO,GAAG,IAAA,8BAAkB,EAAC,UAAU,EAAE,YAAY,CAAC,CAAC;IAC7D,IAAI,OAAO,KAAK,IAAI,IAAI,MAAM,CAAC,MAAM,CAAC,OAAO,CAA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sxAttribute,\n findJsxElements,\n getImportedAliases,\n logSummary,\n parseTsx,\n visitTsxFiles,\n} from \"../utils/jsx-utils\";\n\nconst PACKAGE_NAME = \"@trackunit/react-components\";\nconst COMPONENT_NAME = \"Notice\";\n\nconst ensureTooltipImport = (content: string): string => {\n const sourceFile = parseTsx(content, \"source.tsx\");\n const aliases = getImportedAliases(sourceFile, PACKAGE_NAME);\n if (aliases !== null && Object.values(aliases).includes(\"Tooltip\")) return content;\n\n for (const stmt of sourceFile.statements) {\n if (!ts.isImportDeclaration(stmt)) continue;\n const moduleSpecifier = stmt.moduleSpecifier;\n if (!ts.isStringLiteral(moduleSpecifier) || moduleSpecifier.text !== PACKAGE_NAME) continue;\n\n const namedBindings = stmt.importClause?.namedBindings;\n if (namedBindings === undefined || !ts.isNamedImports(namedBindings)) continue;\n\n const elementsText = namedBindings.elements.map(el => el.getText()).join(\", \");\n const merged = `${elementsText}, Tooltip`;\n const before = content.slice(0, namedBindings.getStart());\n const after = content.slice(namedBindings.getEnd());\n return `${before}{ ${merged} }${after}`;\n }\n\n return `import { Tooltip } from \"${PACKAGE_NAME}\";\\n${content}`;\n};\n\nconst transformNoticeUsage = (filePath: string, content: string): string | null => {\n const sourceFile = parseTsx(content, filePath);\n\n const aliases = getImportedAliases(sourceFile, PACKAGE_NAME);\n if (aliases === null) return null;\n\n const localAlias = Object.entries(aliases).find(([, name]) => name === COMPONENT_NAME)?.[0];\n if (localAlias === undefined) return null;\n\n const matches = findJsxElements(sourceFile, [localAlias]);\n if (matches.length === 0) return null;\n\n type Edit = {\n elementStart: number;\n elementEnd: number;\n elementText: string;\n label: string | null;\n attrEdits: Array<{ start: number; end: number }>;\n };\n const edits: Array<Edit> = [];\n\n for (const { openingElement, element } of matches) {\n const tooltipLabelAttr = findJsxAttribute(openingElement, \"tooltipLabel\");\n const withTooltipAttr = findJsxAttribute(openingElement, \"withTooltip\");\n if (tooltipLabelAttr === null && withTooltipAttr === null) continue;\n\n let label: string | null = null;\n if (tooltipLabelAttr !== null) {\n const initializer = tooltipLabelAttr.initializer;\n if (initializer !== undefined) {\n if (ts.isStringLiteral(initializer)) {\n label = `\"${initializer.text}\"`;\n } else if (ts.isJsxExpression(initializer) && initializer.expression !== undefined) {\n label = `{${initializer.expression.getText()}}`;\n }\n }\n }\n\n const attrEdits: Array<{ start: number; end: number }> = [];\n for (const attr of [tooltipLabelAttr, withTooltipAttr]) {\n if (attr === null) continue;\n attrEdits.push({ start: attr.getFullStart(), end: attr.getEnd() });\n }\n\n edits.push({\n elementStart: element.getStart(),\n elementEnd: element.getEnd(),\n elementText: content.slice(element.getStart(), element.getEnd()),\n label,\n attrEdits,\n });\n }\n\n if (edits.length === 0) return null;\n\n edits.sort((a, b) => b.elementStart - a.elementStart);\n\n let updated = content;\n let needsTooltipImport = false;\n\n for (const edit of edits) {\n // Remove the tooltipLabel/withTooltip attributes from the element first.\n let elementWithoutAttrs = edit.elementText;\n const sortedAttrEdits = [...edit.attrEdits].sort((a, b) => b.start - a.start);\n for (const { start, end } of sortedAttrEdits) {\n elementWithoutAttrs =\n elementWithoutAttrs.slice(0, start - edit.elementStart) + elementWithoutAttrs.slice(end - edit.elementStart);\n }\n\n if (edit.label !== null) {\n const wrapped = `<Tooltip label=${edit.label} placement=\"bottom\">${elementWithoutAttrs}</Tooltip>`;\n updated = updated.slice(0, edit.elementStart) + wrapped + updated.slice(edit.elementEnd);\n needsTooltipImport = true;\n } else {\n // No label to forward (e.g. only `withTooltip`); just strip the props.\n updated = updated.slice(0, edit.elementStart) + elementWithoutAttrs + updated.slice(edit.elementEnd);\n }\n }\n\n if (needsTooltipImport) {\n updated = ensureTooltipImport(updated);\n }\n\n return updated;\n};\n\n/**\n * Removes the deprecated `withTooltip`/`tooltipLabel` props from `<Notice>`\n * usages. When a label is present the element is wrapped in `<Tooltip>` to\n * preserve hover behaviour; when only `withTooltip` was set the props are\n * dropped because they had no remaining effect.\n */\nexport const noticeTooltipLabelToWrapper = (tree: Tree): void => {\n const touched = visitTsxFiles(tree, \"Notice\", transformNoticeUsage);\n logSummary(\"notice-tooltiplabel-to-wrapper\", touched);\n};\n\nexport default noticeTooltipLabelToWrapper;\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"pagination-add-required-titles.js","sourceRoot":"","sources":["../../../../../../libs/react/components/migrations/v2-0-0/pagination-add-required-titles.ts"],"names":[],"mappings":";;;AAAA,uCAA+C;AAC/C,kDAQ4B;AAE5B,MAAM,YAAY,GAAG,6BAA6B,CAAC;AACnD,MAAM,cAAc,GAAG,YAAY,CAAC;AAEpC,MAAM,YAAY,GAA2B;IAC3C,iBAAiB,EAAE,eAAe;IAClC,aAAa,EAAE,WAAW;CAC3B,CAAC;AAEF,MAAM,wBAAwB,GAAG,CAAC,QAAgB,EAAE,OAAe,EAAiB,EAAE;IACpF,MAAM,UAAU,GAAG,IAAA,oBAAQ,EAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAE/C,MAAM,OAAO,GAAG,IAAA,8BAAkB,EAAC,UAAU,EAAE,YAAY,CAAC,CAAC;IAC7D,IAAI,OAAO,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAElC,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,IAAI,KAAK,cAAc,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAC5F,IAAI,UAAU,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IAE1C,MAAM,OAAO,GAAG,IAAA,2BAAe,EAAC,UAAU,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;IAC1D,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAGtC,MAAM,KAAK,GAAgB,EAAE,CAAC;IAE9B,KAAK,MAAM,EAAE,cAAc,EAAE,IAAI,OAAO,EAAE,CAAC;QACzC,IAAI,IAAA,8BAAkB,EAAC,cAA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AAC,EAAE,CAAC;QAChB,eAAM,CAAC,IAAI,CAAC,+FAA+F,CAAC,CAAC;IAC/G,CAAC;AACH,CAAC,CAAC;AANW,QAAA,2BAA2B,+BAMtC;AAEF,kBAAe,mCAA2B,CAAC","sourcesContent":["import { type Tree, logger } from \"@nx/devkit\";\nimport {\n findJsxAttribute,\n findJsxElements,\n getImportedAliases,\n hasSpreadAttribute,\n logSummary,\n parseTsx,\n visitTsxFiles,\n} from \"../utils/jsx-utils\";\n\nconst PACKAGE_NAME = \"@trackunit/react-components\";\nconst COMPONENT_NAME = \"Pagination\";\n\nconst PLACEHOLDERS: Record<string, string> = {\n previousPageTitle: \"Previous page\",\n nextPageTitle: \"Next page\",\n};\n\nconst transformPaginationUsage = (filePath: string, content: string): string | null => {\n const sourceFile = parseTsx(content, filePath);\n\n const aliases = getImportedAliases(sourceFile, PACKAGE_NAME);\n if (aliases === null) return null;\n\n const localAlias = Object.entries(aliases).find(([, name]) => name === COMPONENT_NAME)?.[0];\n if (localAlias === undefined) return null;\n\n const matches = findJsxElements(sourceFile, [localAlias]);\n if (matches.length === 0) return null;\n\n type Edit = { offset: number; text: string };\n const edits: Array<Edit> = [];\n\n for (const { openingElement } of matches) {\n if (hasSpreadAttribute(openingElement)) continue;\n\n for (const [propName, placeholder] of Object.entries(PLACEHOLDERS)) {\n if (findJsxAttribute(openingElement, propName) !== null) continue;\n edits.push({\n offset: openingElement.tagName.getEnd(),\n text: ` ${propName}=\"${placeholder}\"`,\n });\n }\n }\n\n if (edits.length === 0) return null;\n\n // Apply in reverse so earlier offsets stay valid; keep order at the same\n // offset so attributes appear in declaration order in the source.\n edits.sort((a, b) => (a.offset === b.offset ? 0 : b.offset - a.offset));\n\n let updated = content;\n for (const { offset, text } of edits) {\n updated = updated.slice(0, offset) + text + updated.slice(offset);\n }\n return updated;\n};\n\n/**\n * Adds the now-required `previousPageTitle` and `nextPageTitle` props to\n * `<Pagination>` usages that don't already provide them. The values default\n * to the English strings \"Previous page\"/\"Next page\"; consumers should\n * replace them with their own localized strings.\n *\n * Usages with a spread attribute (e.g. `<Pagination {...props} />`) are\n * skipped because we cannot tell whether the props are already provided.\n */\nexport const paginationAddRequiredTitles = (tree: Tree): void => {\n const touched = visitTsxFiles(tree, \"Pagination\", transformPaginationUsage);\n logSummary(\"pagination-add-required-titles\", touched);\n if (touched > 0) {\n logger.info(` Replace the placeholder \"Previous page\"/\"Next page\" strings with your own localized values.`);\n }\n};\n\nexport default paginationAddRequiredTitles;\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"tag-add-removetaglabel.js","sourceRoot":"","sources":["../../../../../../libs/react/components/migrations/v2-0-0/tag-add-removetaglabel.ts"],"names":[],"mappings":";;;AAAA,uCAA+C;AAC/C,kDAQ4B;AAE5B,MAAM,YAAY,GAAG,6BAA6B,CAAC;AACnD,MAAM,cAAc,GAAG,KAAK,CAAC;AAE7B,MAAM,4BAA4B,GAAG,YAAY,CAAC;AAElD,MAAM,iBAAiB,GAAG,CAAC,QAAgB,EAAE,OAAe,EAAiB,EAAE;IAC7E,MAAM,UAAU,GAAG,IAAA,oBAAQ,EAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAE/C,MAAM,OAAO,GAAG,IAAA,8BAAkB,EAAC,UAAU,EAAE,YAAY,CAAC,CAAC;IAC7D,IAAI,OAAO,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAElC,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,IAAI,KAAK,cAAc,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAC5F,IAAI,UAAU,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IAE1C,MAAM,OAAO,GAAG,IAAA,2BAAe,EAAC,UAAU,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;IAC1D,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,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AE,iBAAiB,CAAC,CAAC;IAC9D,IAAA,sBAAU,EAAC,wBAAwB,EAAE,OAAO,CAAC,CAAC;IAC9C,IAAI,OAAO,GAAG,CAAC,EAAE,CAAC;QAChB,eAAM,CAAC,IAAI,CAAC,8EAA8E,CAAC,CAAC;IAC9F,CAAC;AACH,CAAC,CAAC;AANW,QAAA,oBAAoB,wBAM/B;AAEF,kBAAe,4BAAoB,CAAC","sourcesContent":["import { type Tree, logger } from \"@nx/devkit\";\nimport {\n findJsxAttribute,\n findJsxElements,\n getImportedAliases,\n hasSpreadAttribute,\n logSummary,\n parseTsx,\n visitTsxFiles,\n} from \"../utils/jsx-utils\";\n\nconst PACKAGE_NAME = \"@trackunit/react-components\";\nconst COMPONENT_NAME = \"Tag\";\n\nconst REMOVE_TAG_LABEL_PLACEHOLDER = \"Remove tag\";\n\nconst transformTagUsage = (filePath: string, content: string): string | null => {\n const sourceFile = parseTsx(content, filePath);\n\n const aliases = getImportedAliases(sourceFile, PACKAGE_NAME);\n if (aliases === null) return null;\n\n const localAlias = Object.entries(aliases).find(([, name]) => name === COMPONENT_NAME)?.[0];\n if (localAlias === undefined) return null;\n\n const matches = findJsxElements(sourceFile, [localAlias]);\n if (matches.length === 0) return null;\n\n type Edit = { offset: number; text: string };\n const edits: Array<Edit> = [];\n\n for (const { openingElement } of matches) {\n if (hasSpreadAttribute(openingElement)) continue;\n\n // Only act when the tag is dismissible (has onClickClose) and missing the\n // newly required label.\n if (findJsxAttribute(openingElement, \"onClickClose\") === null) continue;\n if (findJsxAttribute(openingElement, \"removeTagLabel\") !== null) continue;\n\n edits.push({\n offset: openingElement.tagName.getEnd(),\n text: ` removeTagLabel=\"${REMOVE_TAG_LABEL_PLACEHOLDER}\"`,\n });\n }\n\n if (edits.length === 0) return null;\n\n edits.sort((a, b) => (a.offset === b.offset ? 0 : b.offset - a.offset));\n\n let updated = content;\n for (const { offset, text } of edits) {\n updated = updated.slice(0, offset) + text + updated.slice(offset);\n }\n return updated;\n};\n\n/**\n * Adds the now-required `removeTagLabel` prop to dismissible `<Tag>` usages\n * (those with `onClickClose`) when it is missing. Default value is the English\n * string \"Remove tag\"; consumers should replace it with their own localized\n * label.\n */\nexport const tagAddRemoveTagLabel = (tree: Tree): void => {\n const touched = visitTsxFiles(tree, \"Tag\", transformTagUsage);\n logSummary(\"tag-add-removetaglabel\", touched);\n if (touched > 0) {\n logger.info(` Replace the placeholder \"Remove tag\" string with your own localized value.`);\n }\n};\n\nexport default tagAddRemoveTagLabel;\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"togglegroup-remove-item-style.js","sourceRoot":"","sources":["../../../../../../libs/react/components/migrations/v2-0-0/togglegroup-remove-item-style.ts"],"names":[],"mappings":";;;;AAAA,uCAA+C;AAC/C,uDAAiC;AACjC,kDAO4B;AAE5B,MAAM,YAAY,GAAG,6BAA6B,CAAC;AACnD,MAAM,cAAc,GAAG,aAAa,CAAC;AAIrC,MAAM,6BAA6B,GAAG,CAAC,YAAuC,EAA0B,EAAE;IACxG,MAAM,QAAQ,GAAmB,EAAE,CAAC;IACpC,KAAK,MAAM,OAAO,IAAI,YAAY,CAAC,QAAQ,EAAE,CAAC;QAC5C,IAAI,CAAC,EAAE,CAAC,yBAAyB,CAAC,OAAO,CAAC;YAAE,SAAS;QACrD,KAAK,MAAM,IAAI,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;YACtC,IACE,CAAC,EAAE,CAAC,oBAAoB,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,6BAA6B,CAAC,IAAI,CAAC,CAAC;gBACzE,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC;gBAC1B,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,OAAO,EAC1B,CAAC;gBACD,QAAQ,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,YAAY,EAAE,EAAE,GAAG,EAAE,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;YACpE,CAAC;QACH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O,EAAE,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAChD,CAAC,CAAC;AAEF;;;;;;;GAOG;AACI,MAAM,0BAA0B,GAAG,CAAC,IAAU,EAAQ,EAAE;IAC7D,IAAI,OAAO,GAAG,CAAC,CAAC;IAChB,IAAI,YAAY,GAAG,CAAC,CAAC;IACrB,IAAA,yBAAa,EAAC,IAAI,EAAE,cAAc,EAAE,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE;QACxD,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,GAAG,yBAAyB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAC5F,YAAY,IAAI,gBAAgB,CAAC;QACjC,IAAI,OAAO,KAAK,IAAI,IAAI,OAAO,KAAK,OAAO,EAAE,CAAC;YAC5C,OAAO,IAAI,CAAC,CAAC;YACb,OAAO,OAAO,CAAC;QACjB,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;IACH,IAAA,sBAAU,EAAC,+BAA+B,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;IACnE,IAAI,YAAY,GAAG,CAAC,EAAE,CAAC;QACrB,eAAM,CAAC,IAAI,CACT,KAAK,YAAY,0IAA0I,CAC5J,CAAC;IACJ,CAAC;AACH,CAAC,CAAC;AAlBW,QAAA,0BAA0B,8BAkBrC;AAEF,kBAAe,kCAA0B,CAAC","sourcesContent":["import { type Tree, logger } from \"@nx/devkit\";\nimport * as ts from \"typescript\";\nimport {\n findJsxAttribute,\n findJsxElements,\n getImportedAliases,\n logSummary,\n parseTsx,\n visitTsxFiles,\n} from \"../utils/jsx-utils\";\n\nconst PACKAGE_NAME = \"@trackunit/react-components\";\nconst COMPONENT_NAME = \"ToggleGroup\";\n\ntype Removal = { start: number; end: number };\n\nconst collectStyleRemovalsFromArray = (arrayLiteral: ts.ArrayLiteralExpression): ReadonlyArray<Removal> => {\n const removals: Array<Removal> = [];\n for (const element of arrayLiteral.elements) {\n if (!ts.isObjectLiteralExpression(element)) continue;\n for (const prop of element.properties) {\n if (\n (ts.isPropertyAssignment(prop) || ts.isShorthandPropertyAssignment(prop)) &&\n ts.isIdentifier(prop.name) &&\n prop.name.text === \"style\"\n ) {\n removals.push({ start: prop.getFullStart(), end: prop.getEnd() });\n }\n }\n }\n return removals;\n};\n\nconst transformToggleGroupUsage = (\n filePath: string,\n content: string\n): { content: string | null; skippedNonInline: number } => {\n const sourceFile = parseTsx(content, filePath);\n\n const aliases = getImportedAliases(sourceFile, PACKAGE_NAME);\n if (aliases === null) return { content: null, skippedNonInline: 0 };\n\n const localAlias = Object.entries(aliases).find(([, name]) => name === COMPONENT_NAME)?.[0];\n if (localAlias === undefined) return { content: null, skippedNonInline: 0 };\n\n const matches = findJsxElements(sourceFile, [localAlias]);\n if (matches.length === 0) return { content: null, skippedNonInline: 0 };\n\n const removals: Array<Removal> = [];\n let skippedNonInline = 0;\n\n for (const { openingElement } of matches) {\n const listAttr = findJsxAttribute(openingElement, \"list\");\n if (listAttr === null) continue;\n\n const initializer = listAttr.initializer;\n if (initializer === undefined || !ts.isJsxExpression(initializer)) continue;\n const expr = initializer.expression;\n if (expr === undefined) continue;\n\n if (!ts.isArrayLiteralExpression(expr)) {\n // The list is referenced through a variable / function call; we can't\n // safely strip `style` without potentially editing unrelated objects.\n skippedNonInline += 1;\n continue;\n }\n\n removals.push(...collectStyleRemovalsFromArray(expr));\n }\n\n if (removals.length === 0) return { content: null, skippedNonInline };\n\n // Remove the property and its trailing comma if present so we don't leave\n // dangling `, ,` sequences.\n const sorted = [...removals].sort((a, b) => b.start - a.start);\n let updated = content;\n for (let { start, end } of sorted) {\n while (start > 0 && (updated[start - 1] === \" \" || updated[start - 1] === \"\\t\")) {\n start -= 1;\n }\n if (updated[end] === \",\") {\n end += 1;\n }\n updated = updated.slice(0, start) + updated.slice(end);\n }\n\n return { content: updated, skippedNonInline };\n};\n\n/**\n * Removes the `style` property from items in `<ToggleGroup list={[...]}>`\n * because `BasicToggleGroupListProps` no longer extends `Styleable`.\n *\n * Only inline array literals are processed; lists pulled in via a variable or\n * function call are left untouched and reported in the migration summary so\n * the developer can review them.\n */\nexport const toggleGroupRemoveItemStyle = (tree: Tree): void => {\n let touched = 0;\n let totalSkipped = 0;\n visitTsxFiles(tree, COMPONENT_NAME, (filePath, content) => {\n const { content: updated, skippedNonInline } = transformToggleGroupUsage(filePath, content);\n totalSkipped += skippedNonInline;\n if (updated !== null && updated !== content) {\n touched += 1;\n return updated;\n }\n return null;\n });\n logSummary(\"togglegroup-remove-item-style\", touched, totalSkipped);\n if (totalSkipped > 0) {\n logger.info(\n ` ${totalSkipped} ToggleGroup usage(s) referenced their list through a variable/function. Remove any 'style' properties from those item objects manually.`\n );\n }\n};\n\nexport default toggleGroupRemoveItemStyle;\n"]}