ab-ui-library 1.54.0 → 1.54.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,3 +1,3 @@
1
1
  import type { TTableProps } from './types';
2
2
  import 'react-loading-skeleton/dist/skeleton.css';
3
- export declare function Table<TData>({ data, columns, isLoading, hasError, isActionsVisible, totalCount, emptyTitle, emptySubTitle, emptyIllustration, withSelect, withBorder, defaultPageIndex, defaultPageSize, defaultHiddenColumns, collapsibleRows, renderExpandedContent, renderHeader, renderFooter, onSortChange, onRowClick, tableSettings, onRowSelection, onColumnSizing, onPaginationChange, rowEventsProps, activeRowId }: TTableProps<TData>): import("react/jsx-runtime").JSX.Element;
3
+ export declare function Table<TData>({ data, columns, isLoading, hasError, isActionsVisible, totalCount, emptyTitle, emptySubTitle, emptyIllustration, withSelect, withBorder, defaultPageIndex, defaultPageSize, defaultHiddenColumns, collapsibleRows, renderExpandedContent, renderHeader, renderFooter, onSortChange, onRowClick, tableSettings, onRowSelection, onColumnSizing, onPaginationChange, rowEventsProps, activeRowId, getRowId, resetExpandedOnPageChange }: TTableProps<TData>): import("react/jsx-runtime").JSX.Element;
@@ -2,7 +2,7 @@ import { _ as _extends } from '../../extends-853d11fa.js';
2
2
  import { _ as _defineProperty } from '../../defineProperty-636f4bda.js';
3
3
  import { _ as _toConsumableArray } from '../../toConsumableArray-7902e9b8.js';
4
4
  import { _ as _slicedToArray } from '../../slicedToArray-c2957b14.js';
5
- import React, { useState, useCallback, useMemo } from 'react';
5
+ import React, { useState, useCallback, useMemo, useEffect } from 'react';
6
6
  import { flexRender } from '@tanstack/react-table';
7
7
  import { DndContext, closestCenter, DragOverlay } from '@dnd-kit/core';
8
8
  import { SortableContext, horizontalListSortingStrategy } from '@dnd-kit/sortable';
@@ -108,7 +108,10 @@ function Table(_ref2) {
108
108
  onColumnSizing = _ref2.onColumnSizing,
109
109
  onPaginationChange = _ref2.onPaginationChange,
110
110
  rowEventsProps = _ref2.rowEventsProps,
111
- activeRowId = _ref2.activeRowId;
111
+ activeRowId = _ref2.activeRowId,
112
+ getRowId = _ref2.getRowId,
113
+ _ref2$resetExpandedOn = _ref2.resetExpandedOnPageChange,
114
+ resetExpandedOnPageChange = _ref2$resetExpandedOn === void 0 ? true : _ref2$resetExpandedOn;
112
115
  var _useState = useState(new Set()),
113
116
  _useState2 = _slicedToArray(_useState, 2),
114
117
  expandedRows = _useState2[0],
@@ -169,7 +172,8 @@ function Table(_ref2) {
169
172
  onSortChange: onSortChange,
170
173
  onRowSelection: onRowSelection,
171
174
  onColumnSizing: onColumnSizing,
172
- onPaginationChange: onPaginationChange
175
+ onPaginationChange: onPaginationChange,
176
+ getRowId: getRowId
173
177
  }),
174
178
  table = _useTableControl.table,
175
179
  sensors = _useTableControl.sensors,
@@ -205,6 +209,11 @@ function Table(_ref2) {
205
209
  length: table.getState().pagination.pageSize
206
210
  });
207
211
  }, [table.getState().pagination.pageSize]);
212
+ useEffect(function () {
213
+ if (resetExpandedOnPageChange) {
214
+ setExpandedRows(new Set());
215
+ }
216
+ }, [table.getState().pagination.pageIndex, resetExpandedOnPageChange]);
208
217
  return /*#__PURE__*/React.createElement("div", {
209
218
  className: classNames('advanced-table', {
210
219
  'with-border': withBorder
@@ -1,6 +1,6 @@
1
1
  import type { DragEndEvent, DragStartEvent } from '@dnd-kit/core';
2
2
  import type { Column, TTableProps } from '../types';
3
- export declare function useTableControl<TData>({ withSelect, columns, data, tableSettings, totalCount, defaultPageSize, defaultPageIndex, defaultHiddenColumns, onSortChange, onRowSelection, onColumnSizing, onPaginationChange }: TTableProps<TData>): {
3
+ export declare function useTableControl<TData>({ withSelect, columns, data, tableSettings, totalCount, defaultPageSize, defaultPageIndex, defaultHiddenColumns, onSortChange, onRowSelection, onColumnSizing, onPaginationChange, getRowId }: TTableProps<TData>): {
4
4
  table: import("@tanstack/react-table").Table<TData>;
5
5
  activeHeader: import("@tanstack/react-table").Header<TData, unknown> | null | undefined;
6
6
  sensors: import("@dnd-kit/core").SensorDescriptor<import("@dnd-kit/core").SensorOptions>[];
@@ -54,7 +54,8 @@ function useTableControl(_ref) {
54
54
  onSortChange = _ref.onSortChange,
55
55
  onRowSelection = _ref.onRowSelection,
56
56
  onColumnSizing = _ref.onColumnSizing,
57
- onPaginationChange = _ref.onPaginationChange;
57
+ onPaginationChange = _ref.onPaginationChange,
58
+ getRowId = _ref.getRowId;
58
59
  var shouldPersistToStorage = (tableSettings === null || tableSettings === void 0 ? void 0 : tableSettings.persistColumnSettings) === STORAGE_TYPE.LOCAL;
59
60
  var shouldEmitExternal = (tableSettings === null || tableSettings === void 0 ? void 0 : tableSettings.persistColumnSettings) === STORAGE_TYPE.EXTERNAL;
60
61
  var tableName = "".concat(TABLE_NAME_PREFIX, "-").concat(tableSettings === null || tableSettings === void 0 ? void 0 : tableSettings.tableName);
@@ -177,6 +178,7 @@ function useTableControl(_ref) {
177
178
  data: data,
178
179
  columns: reorderedColumns,
179
180
  pageCount: Math.ceil(totalCount / pagination.pageSize),
181
+ getRowId: getRowId,
180
182
  state: {
181
183
  sorting: sorting,
182
184
  pagination: pagination,
@@ -41,6 +41,8 @@ export type TTableProps<TData> = {
41
41
  onRowSelection?: (state: TRowSelectionState) => void;
42
42
  onColumnSizing?: (state: TColumnSizingState) => void;
43
43
  onPaginationChange?: (state: TPaginationState) => void;
44
+ getRowId?: (row: TData) => string;
45
+ resetExpandedOnPageChange?: boolean;
44
46
  };
45
47
  export type Column<TData> = ColumnDef<TData> & {
46
48
  enableColumnDragging?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ab-ui-library",
3
- "version": "1.54.0",
3
+ "version": "1.54.1",
4
4
  "description": "UI library for AM",
5
5
  "main": "./index.js",
6
6
  "module": "./index.js",