@raystack/apsara 0.20.3 → 0.20.4

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/index.cjs CHANGED
@@ -32249,7 +32249,7 @@ function DataTableRoot({ columns, data, emptyState, children, parentStyle, isLoa
32249
32249
  }, { threshold: 0.1 });
32250
32250
  observerRef.current = observer;
32251
32251
  return () => observer.disconnect();
32252
- }, [onLoadMore]);
32252
+ }, [onLoadMore, isLoading]);
32253
32253
  React.useEffect(() => {
32254
32254
  const observer = observerRef.current;
32255
32255
  const lastRow = lastRowRef.current;
@@ -32264,19 +32264,26 @@ function DataTableRoot({ columns, data, emptyState, children, parentStyle, isLoa
32264
32264
  };
32265
32265
  }, [isLoading]);
32266
32266
  const getLoader = (loaderRow, columns) => ([...new Array(loaderRow)].map((_, rowIndex) => (jsxRuntimeExports.jsx(Table.Row, { children: columns.map((_, colIndex) => (jsxRuntimeExports.jsx(Table.Cell, { children: jsxRuntimeExports.jsx(Skeleton, { containerClassName: styles$4.flex1, highlightColor: "var(--background-base)", baseColor: "var(--background-base-hover)" }) }, `col_${colIndex}`))) }, `row_${rowIndex}`))));
32267
+ const tableData = onLoadMore ? data : (isLoading
32268
+ ? [...new Array(loaderRow)].map((_, i) => ({ id: i }))
32269
+ : data);
32267
32270
  const { filteredColumns, addFilterColumn, removeFilterColumn, resetColumns } = useTableColumn();
32268
32271
  const columnWithCustomFilter = React.useMemo(() => columns.map((col) => {
32269
32272
  const colId = col.id || col?.accessorKey;
32270
32273
  const filterFn = colId && tableCustomFilter.hasOwnProperty(colId)
32271
32274
  ? tableCustomFilter[colId]
32272
32275
  : undefined;
32273
- const { cell } = col;
32276
+ const cell = onLoadMore
32277
+ ? col.cell
32278
+ : (isLoading
32279
+ ? () => (jsxRuntimeExports.jsx(Skeleton, { containerClassName: styles$4.flex1, highlightColor: "var(--background-base)", baseColor: "var(--background-base-hover)" }))
32280
+ : col.cell);
32274
32281
  return {
32275
32282
  ...col,
32276
32283
  cell,
32277
32284
  filterFn,
32278
32285
  };
32279
- }), [isLoading, columns, tableCustomFilter]);
32286
+ }), [isLoading, columns, tableCustomFilter, onLoadMore]);
32280
32287
  React.useEffect(() => {
32281
32288
  if (onStateChange) {
32282
32289
  onStateChange(tableState);
@@ -32286,7 +32293,7 @@ function DataTableRoot({ columns, data, emptyState, children, parentStyle, isLoa
32286
32293
  setTableCustomFilter((old) => ({ ...old, [id]: filterFn }));
32287
32294
  };
32288
32295
  const table = useReactTable({
32289
- data,
32296
+ data: tableData,
32290
32297
  columns: columnWithCustomFilter,
32291
32298
  globalFilterFn: "auto",
32292
32299
  enableRowSelection: true,
@@ -32336,12 +32343,12 @@ function DataTableRoot({ columns, data, emptyState, children, parentStyle, isLoa
32336
32343
  }) }, headerGroup.id)))
32337
32344
  : null }), jsxRuntimeExports.jsxs(Table.Body, { children: [table.getRowModel().rows?.length ? (table.getRowModel().rows.map((row, rowIndex) => (jsxRuntimeExports.jsx(Table.Row, { "data-state": row.getIsSelected() && "selected", onClick: () => onRowClick?.(row.original), className: isLoading
32338
32345
  ? ""
32339
- : `${styles$4.tRow} ${onRowClick ? styles$4.tRowClick : ""}`, ref: rowIndex === table.getRowModel().rows.length - 1
32346
+ : `${styles$4.tRow} ${onRowClick ? styles$4.tRowClick : ""}`, ref: onLoadMore && rowIndex === table.getRowModel().rows.length - 1
32340
32347
  ? lastRowRef
32341
32348
  : null, children: row.getVisibleCells().map((cell, index) => (jsxRuntimeExports.jsx(Table.Cell, { style: {
32342
32349
  ...(cell.column.columnDef?.meta?.style ?? {}),
32343
32350
  }, children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, `${cell.id}_${index}`))) }, row.id)))) : (!isLoading ?
32344
- jsxRuntimeExports.jsx(Table.Row, { children: jsxRuntimeExports.jsx(Table.Cell, { colSpan: columns.length, children: emptyState || "No results." }) }) : jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, {})), isLoading && getLoader(loaderRow, columns)] })] }), detail] })] }), footer] }) }));
32351
+ jsxRuntimeExports.jsx(Table.Row, { children: jsxRuntimeExports.jsx(Table.Cell, { colSpan: columns.length, children: emptyState || "No results." }) }) : jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, {})), isLoading && onLoadMore && getLoader(loaderRow, columns)] })] }), detail] })] }), footer] }) }));
32345
32352
  }
32346
32353
  const DataTable = Object.assign(DataTableRoot, {
32347
32354
  Toolbar: DataTableToolbar,