@7shifts/sous-chef 3.67.2-beta.0 → 3.67.2-beta.2

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.
@@ -6603,7 +6603,8 @@ const AMOUNT_OF_SKELETON_ROWS = 10;
6603
6603
  const initialValue = {
6604
6604
  columns: [],
6605
6605
  numberOfRows: 0,
6606
- state: DATA_TABLE_STATES.SKELETON_LOADING
6606
+ state: DATA_TABLE_STATES.SKELETON_LOADING,
6607
+ tableId: ''
6607
6608
  };
6608
6609
  const Context$1 = createContext(initialValue);
6609
6610
  const useDataTableContext = () => {
@@ -6630,6 +6631,23 @@ const useTableHeaderHeight = (tableRef, isShowingColumns) => {
6630
6631
  return headerHeight;
6631
6632
  };
6632
6633
 
6634
+ const useDetectFixedScroll = () => {
6635
+ const [hasFixedScroll] = useState(detectAlwaysShowScrollbars);
6636
+ const [hasScroll, setHasScroll] = useState(false);
6637
+ const {
6638
+ tableId
6639
+ } = useDataTableContext();
6640
+ useLayoutEffect(() => {
6641
+ const content = document.querySelector(`#${tableId}-content`);
6642
+ if (!content) {
6643
+ return;
6644
+ }
6645
+ const hasScroll = content.scrollHeight > content.clientHeight;
6646
+ setHasScroll(hasScroll);
6647
+ }, [setHasScroll, tableId]);
6648
+ return hasScroll && hasFixedScroll;
6649
+ };
6650
+
6633
6651
  /**
6634
6652
  * This internal component is used to pass the impression the user is scrolling
6635
6653
  * just the table content instead of the whole table.
@@ -6642,7 +6660,7 @@ const DataTableScrollFakeBorder = ({
6642
6660
  tableRef
6643
6661
  }) => {
6644
6662
  const headerHeight = useTableHeaderHeight(tableRef, isShowingColumns);
6645
- const [hasFixedScroll] = useState(detectAlwaysShowScrollbars());
6663
+ const hasFixedScroll = useDetectFixedScroll();
6646
6664
  const backgroundColor = useBackgroundColor();
6647
6665
  return React__default.createElement("div", {
6648
6666
  className: classnames(styles$19['data-table-scroll-fake-border'], {
@@ -9409,7 +9427,7 @@ const DataTableCoverShadow = ({
9409
9427
  tableRef
9410
9428
  }) => {
9411
9429
  const headerHeight = useTableHeaderHeight(tableRef, isShowingColumns);
9412
- const [hasFixedScroll] = useState(detectAlwaysShowScrollbars());
9430
+ const [hasFixedScroll] = useState(detectAlwaysShowScrollbars);
9413
9431
  const SCROLL_SIZE = '15px';
9414
9432
  const getHeaderHeight = () => {
9415
9433
  if (hasFixedScroll) {
@@ -9684,6 +9702,7 @@ const DataTable = _ref => {
9684
9702
  const prevPaginationRef = useRef(false);
9685
9703
  const RowItem = itemComponent || DataTableDefaultItemComponent;
9686
9704
  const tableRef = useRef(null);
9705
+ const tableId = useMemo(() => `data-table-${Math.floor(Math.random() * 1000000)}`, []);
9687
9706
  let conditionalStyles = {};
9688
9707
  const isScrollableTable = !!maxHeight;
9689
9708
  if (isScrollableTable) {
@@ -9740,7 +9759,8 @@ const DataTable = _ref => {
9740
9759
  showActionMenu: state === DATA_TABLE_STATES.EMPTY ? false : showActionMenu,
9741
9760
  numberOfRows,
9742
9761
  hasVerticalBorders,
9743
- state
9762
+ state,
9763
+ tableId
9744
9764
  }
9745
9765
  }, React__default.createElement("div", {
9746
9766
  className: classnames(styles$1a['data-table']),
@@ -9758,7 +9778,8 @@ const DataTable = _ref => {
9758
9778
  className: classnames(styles$1a['data-table__content'], {
9759
9779
  [styles$1a['data-table__content--with-scroll']]: isScrollableTable
9760
9780
  }),
9761
- style: conditionalStyles
9781
+ style: conditionalStyles,
9782
+ id: `${tableId}-content`
9762
9783
  }, state === DATA_TABLE_STATES.BACKGROUND_LOADING && React__default.createElement("div", {
9763
9784
  className: styles$1a['data-table__background-loading']
9764
9785
  }, React__default.createElement(Spinner, null)), React__default.createElement("table", _extends({