@bigbinary/neeto-atoms 1.0.34 → 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.
@@ -3265,7 +3265,7 @@ const getPageNumbers = (current, total) => {
3265
3265
  return pages;
3266
3266
  };
3267
3267
 
3268
- const useTableSort = ({ sorting: controlledSorting, onSortingChange: controlledOnSortingChange, enableURLSort = true, }) => {
3268
+ const useTableSort = ({ sorting: controlledSorting, onSortingChange: controlledOnSortingChange, onSort, enableURLSort = true, }) => {
3269
3269
  const isControlled = controlledSorting !== undefined;
3270
3270
  const [internalSorting, setInternalSorting] = React.useState(() => enableURLSort ? readSortFromURL() : []);
3271
3271
  const sorting = isControlled ? controlledSorting : internalSorting;
@@ -3277,10 +3277,18 @@ const useTableSort = ({ sorting: controlledSorting, onSortingChange: controlledO
3277
3277
  setInternalSorting(newSorting);
3278
3278
  }
3279
3279
  controlledOnSortingChange?.(updaterOrValue);
3280
+ if (onSort) {
3281
+ onSort(newSorting.length > 0
3282
+ ? {
3283
+ field: newSorting[0].id,
3284
+ order: newSorting[0].desc ? "descend" : "ascend",
3285
+ }
3286
+ : null);
3287
+ }
3280
3288
  if (enableURLSort) {
3281
3289
  writeSortToURL(newSorting);
3282
3290
  }
3283
- }, [sorting, isControlled, controlledOnSortingChange, enableURLSort]);
3291
+ }, [sorting, isControlled, controlledOnSortingChange, onSort, enableURLSort]);
3284
3292
  React.useEffect(() => {
3285
3293
  if (enableURLSort && !isControlled) {
3286
3294
  const urlSorting = readSortFromURL();
@@ -3456,8 +3464,12 @@ const useColumnVisibility = ({ columnVisibility: controlledVisibility, onColumnV
3456
3464
  controlledOnChange?.(updaterOrValue);
3457
3465
  }, [visibility, isControlled, controlledOnChange]);
3458
3466
  const hideColumn = React.useCallback((columnId) => {
3459
- onColumnVisibilityChange(old => ({ ...old, [columnId]: false }));
3460
- onColumnHide?.(columnId);
3467
+ if (onColumnHide) {
3468
+ onColumnHide(columnId);
3469
+ }
3470
+ else {
3471
+ onColumnVisibilityChange(old => ({ ...old, [columnId]: false }));
3472
+ }
3461
3473
  }, [onColumnVisibilityChange, onColumnHide]);
3462
3474
  const showColumn = React.useCallback((columnId) => {
3463
3475
  onColumnVisibilityChange(old => ({ ...old, [columnId]: true }));
@@ -3608,12 +3620,13 @@ const HeaderCellMenu = ({ column, enableAddColumn, enableColumnFreeze, isColumnP
3608
3620
  }) }))] })] }) }));
3609
3621
  };
3610
3622
 
3611
- 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, }) => {
3623
+ 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, }) => {
3612
3624
  const getRowId = React.useMemo(() => getRowIdProp ??
3613
3625
  ((row) => row.id), [getRowIdProp]);
3614
3626
  const { sorting, onSortingChange } = useTableSort({
3615
3627
  sorting: sortingProp,
3616
3628
  onSortingChange: onSortingChangeProp,
3629
+ onSort: onSortProp,
3617
3630
  enableURLSort,
3618
3631
  });
3619
3632
  const { currentPage, pageCount, paginationState, onPageChange } = useTablePagination({
@@ -3849,4 +3862,4 @@ exports.useColumnVisibility = useColumnVisibility;
3849
3862
  exports.useTablePagination = useTablePagination;
3850
3863
  exports.useTableSelection = useTableSelection;
3851
3864
  exports.useTableSort = useTableSort;
3852
- //# sourceMappingURL=DataTable-Bc9o5j6-.js.map
3865
+ //# sourceMappingURL=DataTable-BynOh4Bs.js.map