@bigbinary/neeto-atoms 1.0.35 → 1.0.36

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.
@@ -3244,7 +3244,7 @@ const getPageNumbers = (current, total) => {
3244
3244
  return pages;
3245
3245
  };
3246
3246
 
3247
- const useTableSort = ({ sorting: controlledSorting, onSortingChange: controlledOnSortingChange, enableURLSort = true, }) => {
3247
+ const useTableSort = ({ sorting: controlledSorting, onSortingChange: controlledOnSortingChange, onSort, enableURLSort = true, }) => {
3248
3248
  const isControlled = controlledSorting !== undefined;
3249
3249
  const [internalSorting, setInternalSorting] = useState(() => enableURLSort ? readSortFromURL() : []);
3250
3250
  const sorting = isControlled ? controlledSorting : internalSorting;
@@ -3256,10 +3256,18 @@ const useTableSort = ({ sorting: controlledSorting, onSortingChange: controlledO
3256
3256
  setInternalSorting(newSorting);
3257
3257
  }
3258
3258
  controlledOnSortingChange?.(updaterOrValue);
3259
+ if (onSort) {
3260
+ onSort(newSorting.length > 0
3261
+ ? {
3262
+ field: newSorting[0].id,
3263
+ order: newSorting[0].desc ? "descend" : "ascend",
3264
+ }
3265
+ : null);
3266
+ }
3259
3267
  if (enableURLSort) {
3260
3268
  writeSortToURL(newSorting);
3261
3269
  }
3262
- }, [sorting, isControlled, controlledOnSortingChange, enableURLSort]);
3270
+ }, [sorting, isControlled, controlledOnSortingChange, onSort, enableURLSort]);
3263
3271
  useEffect(() => {
3264
3272
  if (enableURLSort && !isControlled) {
3265
3273
  const urlSorting = readSortFromURL();
@@ -3591,12 +3599,13 @@ const HeaderCellMenu = ({ column, enableAddColumn, enableColumnFreeze, isColumnP
3591
3599
  }) }))] })] }) }));
3592
3600
  };
3593
3601
 
3594
- const DataTable = ({ columns, data, getRowId: getRowIdProp, sorting: sortingProp, onSortingChange: onSortingChangeProp, enableSorting = false, enableURLSort = true, totalCount, pageSize = DEFAULT_PAGE_SIZE, currentPage: currentPageProp, onPageChange: onPageChangeProp, enableURLPagination = true, enableRowSelection: enableRowSelectionProp, selectedRowKeys, onRowSelect, bulkSelectAllRowsProps, enableColumnResize = true, enableColumnFreeze = true, columnPinning: columnPinningProp, onColumnPinningChange: onColumnPinningChangeProp, localStorageKeyPrefix, columnVisibility: columnVisibilityProp, onColumnVisibilityChange: onColumnVisibilityChangeProp, onColumnHide: onColumnHideProp, enableColumnReorder = false, columnOrder: columnOrderProp, onColumnOrderChange: onColumnOrderChangeProp, enableAddColumn = false, onColumnAdd, onColumnDelete, onColumnUpdate, onMoreActionClick, enableHeaderMenu, loading = false, bordered = true, className, emptyMessage, onRowClick, allowRowClick = true, }) => {
3602
+ const DataTable = ({ columns, data, getRowId: getRowIdProp, sorting: sortingProp, onSortingChange: onSortingChangeProp, onSort: onSortProp, enableSorting = false, enableURLSort = true, totalCount, pageSize = DEFAULT_PAGE_SIZE, currentPage: currentPageProp, onPageChange: onPageChangeProp, enableURLPagination = true, enableRowSelection: enableRowSelectionProp, selectedRowKeys, onRowSelect, bulkSelectAllRowsProps, enableColumnResize = true, enableColumnFreeze = true, columnPinning: columnPinningProp, onColumnPinningChange: onColumnPinningChangeProp, localStorageKeyPrefix, columnVisibility: columnVisibilityProp, onColumnVisibilityChange: onColumnVisibilityChangeProp, onColumnHide: onColumnHideProp, enableColumnReorder = false, columnOrder: columnOrderProp, onColumnOrderChange: onColumnOrderChangeProp, enableAddColumn = false, onColumnAdd, onColumnDelete, onColumnUpdate, onMoreActionClick, enableHeaderMenu, loading = false, bordered = true, className, emptyMessage, onRowClick, allowRowClick = true, }) => {
3595
3603
  const getRowId = useMemo(() => getRowIdProp ??
3596
3604
  ((row) => row.id), [getRowIdProp]);
3597
3605
  const { sorting, onSortingChange } = useTableSort({
3598
3606
  sorting: sortingProp,
3599
3607
  onSortingChange: onSortingChangeProp,
3608
+ onSort: onSortProp,
3600
3609
  enableURLSort,
3601
3610
  });
3602
3611
  const { currentPage, pageCount, paginationState, onPageChange } = useTablePagination({
@@ -3826,4 +3835,4 @@ const DataTable = ({ columns, data, getRowId: getRowIdProp, sorting: sortingProp
3826
3835
  };
3827
3836
 
3828
3837
  export { DataTable as D, useColumnPinning as a, useColumnVisibility as b, useTablePagination as c, useTableSelection as d, useTableSort as e, useColumnOrdering as u };
3829
- //# sourceMappingURL=DataTable-ZLvVywpD.js.map
3838
+ //# sourceMappingURL=DataTable-BpMBsz5i.js.map