@moontra/moonui-pro 2.26.42 → 2.26.44

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.mjs CHANGED
@@ -73975,9 +73975,7 @@ function DataTable({
73975
73975
  t__default.useEffect(() => {
73976
73976
  if (onRowSelect) {
73977
73977
  const selectedRows = Object.keys(rowSelection).filter((key) => rowSelection[key]).map((index2) => stableData[parseInt(index2)]).filter(Boolean);
73978
- setTimeout(() => {
73979
- onRowSelect(selectedRows);
73980
- }, 0);
73978
+ onRowSelect(selectedRows);
73981
73979
  }
73982
73980
  }, [rowSelection, stableData, onRowSelect]);
73983
73981
  const createSortingHandler = (columnId) => {
@@ -74009,23 +74007,41 @@ function DataTable({
74009
74007
  const checkboxColumn = {
74010
74008
  id: "select",
74011
74009
  header: ({ table: table2 }) => {
74010
+ const allRows = table2.getFilteredRowModel().rows;
74011
+ const selectedCount = Object.keys(rowSelection).filter((key) => rowSelection[key]).length;
74012
+ const isAllSelected = allRows.length > 0 && selectedCount === allRows.length;
74013
+ const isSomeSelected = selectedCount > 0 && selectedCount < allRows.length;
74012
74014
  return /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center", children: /* @__PURE__ */ jsx(
74013
74015
  MoonUICheckboxPro,
74014
74016
  {
74015
- checked: table2.getIsAllPageRowsSelected() || table2.getIsSomePageRowsSelected() && "indeterminate",
74016
- onCheckedChange: (value) => table2.toggleAllPageRowsSelected(!!value),
74017
+ checked: isAllSelected ? true : isSomeSelected ? "indeterminate" : false,
74018
+ onCheckedChange: (value) => {
74019
+ const newSelection = {};
74020
+ if (value) {
74021
+ allRows.forEach((row, index2) => {
74022
+ newSelection[index2.toString()] = true;
74023
+ });
74024
+ }
74025
+ setRowSelection(newSelection);
74026
+ },
74017
74027
  "aria-label": "Select all",
74018
74028
  className: "h-4 w-4"
74019
74029
  }
74020
74030
  ) });
74021
74031
  },
74022
74032
  cell: ({ row }) => {
74033
+ const rowIndex = row.index.toString();
74034
+ const isChecked = !!rowSelection[rowIndex];
74023
74035
  return /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center", children: /* @__PURE__ */ jsx(
74024
74036
  MoonUICheckboxPro,
74025
74037
  {
74026
- checked: row.getIsSelected(),
74027
- onCheckedChange: (value) => row.toggleSelected(!!value),
74028
- disabled: !row.getCanSelect(),
74038
+ checked: isChecked,
74039
+ onCheckedChange: (value) => {
74040
+ setRowSelection((prev) => ({
74041
+ ...prev,
74042
+ [rowIndex]: !!value
74043
+ }));
74044
+ },
74029
74045
  "aria-label": "Select row",
74030
74046
  className: "h-4 w-4"
74031
74047
  }
@@ -74039,7 +74055,7 @@ function DataTable({
74039
74055
  cols = [checkboxColumn, ...cols];
74040
74056
  }
74041
74057
  return cols;
74042
- }, [columns, selectable, enableRowSelection]);
74058
+ }, [columns, selectable, enableRowSelection, rowSelection, setRowSelection]);
74043
74059
  const table = useReactTable({
74044
74060
  data: stableData,
74045
74061
  columns: processedColumns,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moontra/moonui-pro",
3
- "version": "2.26.42",
3
+ "version": "2.26.44",
4
4
  "description": "Premium React components for MoonUI - Advanced UI library with 50+ pro components including performance, interactive, and gesture components",
5
5
  "type": "module",
6
6
  "main": "dist/index.mjs",