@raystack/apsara 0.14.2 → 0.14.3

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
@@ -31768,7 +31768,7 @@ function DataTableFilterOptions({ children, ...props }) {
31768
31768
  })] })) : null] }));
31769
31769
  }
31770
31770
 
31771
- var styles$4 = {"wrapper":"datatable-module_wrapper__Sxg2d","datatable":"datatable-module_datatable__z-Th2","table":"datatable-module_table__x2IkY","head":"datatable-module_head__zCfCW","toolbar":"datatable-module_toolbar__lO-aI","chip":"datatable-module_chip__IiwTD","chipWrapper":"datatable-module_chipWrapper__iz69x","filterOperator":"datatable-module_filterOperator__qtDsH","filterText":"datatable-module_filterText__w00L8","flex1":"datatable-module_flex1__fA-kQ"};
31771
+ var styles$4 = {"wrapper":"datatable-module_wrapper__Sxg2d","datatable":"datatable-module_datatable__z-Th2","table":"datatable-module_table__x2IkY","head":"datatable-module_head__zCfCW","toolbar":"datatable-module_toolbar__lO-aI","chip":"datatable-module_chip__IiwTD","chipWrapper":"datatable-module_chipWrapper__iz69x","filterOperator":"datatable-module_filterOperator__qtDsH","filterText":"datatable-module_filterText__w00L8","flex1":"datatable-module_flex1__fA-kQ","tRow":"datatable-module_tRow__GrMHh","tRowClick":"datatable-module_tRowClick__7wzkh"};
31772
31772
 
31773
31773
  const columnTypesMap = {
31774
31774
  select: "select",
@@ -32227,21 +32227,17 @@ function Skeleton({ count = 1, wrapper: Wrapper, className: customClassName, con
32227
32227
  : elements));
32228
32228
  }
32229
32229
 
32230
- function DataTableRoot({ columns, data, emptyState, children, parentStyle, isLoading = false, ShouldShowHeader = true, loaderRow = 5, ...props }) {
32230
+ function DataTableRoot({ columns, data, emptyState, children, parentStyle, isLoading = false, ShouldShowHeader = true, initialState, loaderRow = 5, onRowClick, ...props }) {
32231
32231
  const [tableCustomFilter, setTableCustomFilter] = React.useState({});
32232
32232
  const convertedChildren = React.Children.toArray(children);
32233
32233
  const header = convertedChildren.find((child) => child.type === DataTableToolbar) || null;
32234
32234
  const footer = convertedChildren.find((child) => child.type === DataTableFooter) || null;
32235
32235
  const detail = convertedChildren.find((child) => child.type === TableDetailContainer) ||
32236
32236
  null;
32237
- const [sorting, setSorting] = React.useState([]);
32238
- const [columnFilters, setColumnFilters] = React.useState([]);
32237
+ const [tableState, setTableState] = React.useState({});
32239
32238
  const tableData = isLoading
32240
32239
  ? [...new Array(loaderRow)].map((_, i) => ({ id: i }))
32241
32240
  : data;
32242
- const [columnVisibility, setColumnVisibility] = React.useState({});
32243
- const [rowSelection, setRowSelection] = React.useState({});
32244
- const [globalFilter, setGlobalFilter] = React.useState("");
32245
32241
  const { filteredColumns, addFilterColumn, removeFilterColumn, resetColumns } = useTableColumn();
32246
32242
  const columnWithCustomFilter = columns.map((col) => {
32247
32243
  // @ts-ignore;
@@ -32264,36 +32260,30 @@ function DataTableRoot({ columns, data, emptyState, children, parentStyle, isLoa
32264
32260
  enableRowSelection: true,
32265
32261
  manualPagination: true,
32266
32262
  pageCount: -1,
32267
- onGlobalFilterChange: setGlobalFilter,
32268
- onSortingChange: setSorting,
32269
- onColumnFiltersChange: setColumnFilters,
32270
- onColumnVisibilityChange: setColumnVisibility,
32271
- onRowSelectionChange: setRowSelection,
32263
+ onStateChange: (updater) => setTableState(updater),
32272
32264
  getCoreRowModel: getCoreRowModel(),
32273
32265
  getFilteredRowModel: getFilteredRowModel(),
32274
32266
  getPaginationRowModel: getPaginationRowModel(),
32275
32267
  getSortedRowModel: getSortedRowModel(),
32276
32268
  getFacetedRowModel: getFacetedRowModel(),
32277
32269
  getFacetedUniqueValues: getFacetedUniqueValues(),
32278
- state: {
32279
- sorting,
32280
- globalFilter,
32281
- columnFilters,
32282
- columnVisibility,
32283
- rowSelection,
32284
- },
32270
+ initialState,
32271
+ state: tableState,
32285
32272
  });
32286
- const tableStyle = table.getRowModel().rows?.length
32287
- ? { width: "100%" }
32288
- : { width: "100%", height: "100%" };
32273
+ const tableStyle = {
32274
+ ...(table.getRowModel().rows?.length
32275
+ ? { width: "100%" }
32276
+ : { width: "100%", height: "100%" }),
32277
+ ...{ "border-collapse": "collapse" },
32278
+ };
32289
32279
  return (jsxRuntimeExports$1.jsx(Flex, { direction: "column", justify: "between", className: styles$4.wrapper, children: jsxRuntimeExports$1.jsxs(TableContext.Provider, { value: {
32290
32280
  table,
32291
- globalFilter,
32281
+ globalFilter: tableState.globalFilter,
32292
32282
  filteredColumns,
32293
32283
  addFilterColumn,
32294
32284
  removeFilterColumn,
32295
32285
  resetColumns,
32296
- onGlobalFilterChange: setGlobalFilter,
32286
+ onGlobalFilterChange: (value) => setTableState((prev) => ({ ...prev, globalFilter: value })),
32297
32287
  onChange: () => ({}),
32298
32288
  tableCustomFilter,
32299
32289
  updateColumnCustomFilter,
@@ -32311,7 +32301,7 @@ function DataTableRoot({ columns, data, emptyState, children, parentStyle, isLoa
32311
32301
  }[header.column.getIsSorted()] ?? jsxRuntimeExports$1.jsx(CaretSortIcon, {})
32312
32302
  : null] }) }, `${header.id}_${index}`));
32313
32303
  }) }, headerGroup.id)))
32314
- : null }), jsxRuntimeExports$1.jsx(Table.Body, { children: table.getRowModel().rows?.length ? (table.getRowModel().rows.map((row) => (jsxRuntimeExports$1.jsx(Table.Row, { "data-state": row.getIsSelected() && "selected", children: row.getVisibleCells().map((cell, index) => (jsxRuntimeExports$1.jsx(Table.Cell, { style: {
32304
+ : null }), jsxRuntimeExports$1.jsx(Table.Body, { children: table.getRowModel().rows?.length ? (table.getRowModel().rows.map((row) => (jsxRuntimeExports$1.jsx(Table.Row, { "data-state": row.getIsSelected() && "selected", onClick: () => onRowClick?.(row.original), className: `${styles$4.tRow} ${onRowClick ? styles$4.tRowClick : ""}`, children: row.getVisibleCells().map((cell, index) => (jsxRuntimeExports$1.jsx(Table.Cell, { style: {
32315
32305
  ...(cell.column.columnDef?.meta?.style ?? {}),
32316
32306
  }, children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, `${cell.id}_${index}`))) }, row.id)))) : (jsxRuntimeExports$1.jsx(Table.Row, { children: jsxRuntimeExports$1.jsx(Table.Cell, { colSpan: columns.length, children: emptyState || "No results." }) })) })] }), detail] })] }), footer] }) }));
32317
32307
  }