@economic/taco 2.53.0-settings.0 → 2.53.0-settings.1

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.
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
- import { TableScrollToIndexHandler } from '../../types';
3
- export declare function useTableRowActive(isEnabled?: boolean, initialRowActiveIndex?: number): {
2
+ import { TableDefaultRowActiveIndex, TableScrollToIndexHandler, TableSettings } from '../../types';
3
+ export declare function useTableRowActive(isEnabled: boolean | undefined, tableSettings: TableSettings, initialRowActiveIndex?: TableDefaultRowActiveIndex): {
4
4
  isEnabled: boolean;
5
5
  rowActiveIndex: number | undefined;
6
6
  setRowActiveIndex: React.Dispatch<React.SetStateAction<number | undefined>>;
@@ -10733,7 +10733,8 @@ function useReactTableInitialState(props, columns, persistedSettings, defaults)
10733
10733
  columnPinning.left = freezeUptoExternalColumn(columnOrder.indexOf(columnPinning.left[columnPinning.left.length - 1]), columnOrder);
10734
10734
  } else {
10735
10735
  if (props.defaultColumnFreezingIndex) {
10736
- columnPinning.left = freezeUptoExternalColumn(props.defaultColumnFreezingIndex, columnOrder);
10736
+ const index = typeof props.defaultColumnFreezingIndex === 'function' ? props.defaultColumnFreezingIndex(persistedSettings) : props.defaultColumnFreezingIndex;
10737
+ columnPinning.left = freezeUptoExternalColumn(index, columnOrder);
10737
10738
  } else {
10738
10739
  columnPinning.left = unfreezeAllExternalColumns(columnOrder);
10739
10740
  }
@@ -11003,8 +11004,8 @@ const useIsHoverStatePaused = () => {
11003
11004
  return [shouldPauseHoverState, setShouldPauseHoverState];
11004
11005
  };
11005
11006
 
11006
- function useTableRowActive(isEnabled = false, initialRowActiveIndex) {
11007
- const [rowActiveIndex, setRowActiveIndex] = React__default.useState(initialRowActiveIndex);
11007
+ function useTableRowActive(isEnabled = false, tableSettings, initialRowActiveIndex) {
11008
+ const [rowActiveIndex, setRowActiveIndex] = React__default.useState(typeof initialRowActiveIndex === 'function' ? initialRowActiveIndex(tableSettings) : initialRowActiveIndex);
11008
11009
  const [rowHoverIndex, setRowHoverIndex] = React__default.useState(undefined);
11009
11010
  const [isHoverStatePaused, setHoverStatePaused] = useIsHoverStatePaused();
11010
11011
  const move = (direction, length, scrollToIndex) => {
@@ -11945,7 +11946,7 @@ function useTableManager(props, meta, internalColumns) {
11945
11946
  const fontSize = useTableFontSize(options.enableFontSize, settings.fontSize);
11946
11947
  const footer = useTableFooter(options.enableFooter);
11947
11948
  const printing = useTablePrinting(options.enablePrinting, safeId);
11948
- const rowActive = useTableRowActive(options.enableRowActive, props.defaultRowActiveIndex);
11949
+ const rowActive = useTableRowActive(options.enableRowActive, settings, props.defaultRowActiveIndex);
11949
11950
  const rowActions = useTableRowActions(options.enableRowActions, props.rowActions, props.rowActionsLength);
11950
11951
  const rowClick = useTableRowClick(options.enableRowClick, props.onRowClick);
11951
11952
  const rowDrag = useTableRowDrag(options.enableRowDrag && !(meta !== null && meta !== void 0 && (_meta$editing = meta.editing) !== null && _meta$editing !== void 0 && _meta$editing.isEditing), props.onRowDrag);
@@ -12482,7 +12483,8 @@ function useTableRenderer(renderers, table, tableRef, length, defaultRowActiveIn
12482
12483
  // ensure default active rows are scrolled to
12483
12484
  React__default.useEffect(() => {
12484
12485
  if (defaultRowActiveIndex) {
12485
- scrollToIndex(defaultRowActiveIndex, {
12486
+ const index = typeof defaultRowActiveIndex === 'function' ? defaultRowActiveIndex(getSettings(table)) : defaultRowActiveIndex;
12487
+ scrollToIndex(index, {
12486
12488
  align: 'center',
12487
12489
  behavior: 'auto'
12488
12490
  });