@dust-tt/sparkle 0.2.240 → 0.2.241

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.
package/dist/cjs/index.js CHANGED
@@ -103435,38 +103435,34 @@ function shouldRenderColumn(windowWidth, breakpoint) {
103435
103435
  return windowWidth >= breakpoints[breakpoint];
103436
103436
  }
103437
103437
  function DataTable(_a) {
103438
- var data = _a.data, totalRowCount = _a.totalRowCount, columns = _a.columns, className = _a.className, _b = _a.widthClassName, widthClassName = _b === void 0 ? "s-w-full s-max-w-4xl" : _b, filter = _a.filter, filterColumn = _a.filterColumn, initialColumnOrder = _a.initialColumnOrder, _c = _a.columnsBreakpoints, columnsBreakpoints = _c === void 0 ? {} : _c, pagination = _a.pagination, setPagination = _a.setPagination;
103438
+ var data = _a.data, totalRowCount = _a.totalRowCount, columns = _a.columns, className = _a.className, _b = _a.widthClassName, widthClassName = _b === void 0 ? "s-w-full s-max-w-4xl" : _b, filter = _a.filter, filterColumn = _a.filterColumn, _c = _a.columnsBreakpoints, columnsBreakpoints = _c === void 0 ? {} : _c, pagination = _a.pagination, setPagination = _a.setPagination, sorting = _a.sorting, setSorting = _a.setSorting, _d = _a.isServerSideSorting, isServerSideSorting = _d === void 0 ? false : _d;
103439
103439
  var windowSize = useWindowSize();
103440
- var _d = __read(React.useState(initialColumnOrder !== null && initialColumnOrder !== void 0 ? initialColumnOrder : []), 2), sorting = _d[0], setSorting = _d[1];
103441
103440
  var _e = __read(React.useState([]), 2), columnFilters = _e[0], setColumnFilters = _e[1];
103442
103441
  var isServerSidePagination = !!totalRowCount && totalRowCount > data.length;
103442
+ var isClientSideSortingEnabled = !isServerSideSorting && !isServerSidePagination;
103443
103443
  var onPaginationChange = pagination && setPagination
103444
103444
  ? function (updater) {
103445
103445
  var newValue = typeof updater === "function" ? updater(pagination) : updater;
103446
103446
  setPagination(newValue);
103447
103447
  }
103448
103448
  : undefined;
103449
- var table = useReactTable({
103450
- data: data,
103451
- columns: columns,
103452
- rowCount: totalRowCount,
103453
- manualPagination: isServerSidePagination,
103454
- onSortingChange: setSorting,
103455
- getCoreRowModel: getCoreRowModel(),
103449
+ var onSortingChange = sorting && setSorting
103450
+ ? function (updater) {
103451
+ var newValue = typeof updater === "function" ? updater(sorting) : updater;
103452
+ setSorting(newValue);
103453
+ }
103454
+ : undefined;
103455
+ var table = useReactTable(__assign(__assign(__assign(__assign({ data: data, columns: columns, rowCount: totalRowCount, manualPagination: isServerSidePagination, manualSorting: isServerSideSorting }, (isServerSideSorting && {
103456
+ onSortingChange: onSortingChange,
103457
+ })), { getCoreRowModel: getCoreRowModel() }), (!isServerSideSorting && {
103456
103458
  getSortedRowModel: getSortedRowModel(),
103457
- getFilteredRowModel: getFilteredRowModel(),
103458
- getPaginationRowModel: pagination ? getPaginationRowModel() : undefined,
103459
- onColumnFiltersChange: setColumnFilters,
103460
- state: {
103461
- columnFilters: columnFilters,
103462
- sorting: isServerSidePagination ? undefined : sorting,
103459
+ enableSorting: isClientSideSortingEnabled,
103460
+ })), { getFilteredRowModel: getFilteredRowModel(), getPaginationRowModel: pagination ? getPaginationRowModel() : undefined, onColumnFiltersChange: setColumnFilters, state: __assign(__assign({ columnFilters: columnFilters }, (isServerSideSorting && {
103461
+ sorting: sorting,
103462
+ })), { pagination: pagination }), initialState: {
103463
103463
  pagination: pagination,
103464
- },
103465
- initialState: {
103466
- pagination: pagination,
103467
- },
103468
- onPaginationChange: onPaginationChange,
103469
- });
103464
+ sorting: sorting,
103465
+ }, onPaginationChange: onPaginationChange }));
103470
103466
  React.useEffect(function () {
103471
103467
  var _a;
103472
103468
  if (filterColumn) {