@moontra/moonui-pro 2.26.43 → 2.26.45

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
@@ -74001,23 +74001,50 @@ function DataTable({
74001
74001
  const checkboxColumn = {
74002
74002
  id: "select",
74003
74003
  header: ({ table: table2 }) => {
74004
+ const allRows = table2.getFilteredRowModel().rows;
74005
+ const selectedCount = Object.keys(rowSelection).filter((key) => rowSelection[key]).length;
74006
+ const isAllSelected = allRows.length > 0 && selectedCount === allRows.length;
74007
+ const isSomeSelected = selectedCount > 0 && selectedCount < allRows.length;
74004
74008
  return /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center", children: /* @__PURE__ */ jsx(
74005
74009
  MoonUICheckboxPro,
74006
74010
  {
74007
- checked: table2.getIsAllPageRowsSelected() || table2.getIsSomePageRowsSelected() && "indeterminate",
74008
- onCheckedChange: (value) => table2.toggleAllPageRowsSelected(!!value),
74011
+ checked: isAllSelected ? true : isSomeSelected ? "indeterminate" : false,
74012
+ onCheckedChange: (value) => {
74013
+ const newSelection = {};
74014
+ if (value) {
74015
+ allRows.forEach((row, index2) => {
74016
+ newSelection[index2.toString()] = true;
74017
+ });
74018
+ }
74019
+ setRowSelection(newSelection);
74020
+ if (onRowSelect) {
74021
+ const selectedRows = value ? allRows.map((row) => row.original) : [];
74022
+ setTimeout(() => onRowSelect(selectedRows), 0);
74023
+ }
74024
+ },
74009
74025
  "aria-label": "Select all",
74010
74026
  className: "h-4 w-4"
74011
74027
  }
74012
74028
  ) });
74013
74029
  },
74014
74030
  cell: ({ row }) => {
74031
+ const rowIndex = row.index.toString();
74032
+ const isChecked = !!rowSelection[rowIndex];
74015
74033
  return /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center", children: /* @__PURE__ */ jsx(
74016
74034
  MoonUICheckboxPro,
74017
74035
  {
74018
- checked: row.getIsSelected(),
74019
- onCheckedChange: (value) => row.toggleSelected(!!value),
74020
- disabled: !row.getCanSelect(),
74036
+ checked: isChecked,
74037
+ onCheckedChange: (value) => {
74038
+ const newSelection = {
74039
+ ...rowSelection,
74040
+ [rowIndex]: !!value
74041
+ };
74042
+ setRowSelection(newSelection);
74043
+ if (onRowSelect) {
74044
+ const selectedRows = Object.keys(newSelection).filter((key) => newSelection[key]).map((index2) => stableData[parseInt(index2)]).filter(Boolean);
74045
+ setTimeout(() => onRowSelect(selectedRows), 0);
74046
+ }
74047
+ },
74021
74048
  "aria-label": "Select row",
74022
74049
  className: "h-4 w-4"
74023
74050
  }
@@ -74031,7 +74058,7 @@ function DataTable({
74031
74058
  cols = [checkboxColumn, ...cols];
74032
74059
  }
74033
74060
  return cols;
74034
- }, [columns, selectable, enableRowSelection]);
74061
+ }, [columns, selectable, enableRowSelection, rowSelection, setRowSelection, stableData, onRowSelect]);
74035
74062
  const table = useReactTable({
74036
74063
  data: stableData,
74037
74064
  columns: processedColumns,
@@ -74050,16 +74077,7 @@ function DataTable({
74050
74077
  sortDescFirst: false,
74051
74078
  // First click should be ascending
74052
74079
  onColumnVisibilityChange: setColumnVisibility,
74053
- onRowSelectionChange: (updater) => {
74054
- const newSelection = typeof updater === "function" ? updater(rowSelection) : updater;
74055
- setRowSelection(newSelection);
74056
- if (onRowSelect) {
74057
- const selectedRows = Object.keys(newSelection).filter((key) => newSelection[key]).map((index2) => stableData[parseInt(index2)]).filter(Boolean);
74058
- setTimeout(() => {
74059
- onRowSelect(selectedRows);
74060
- }, 0);
74061
- }
74062
- },
74080
+ onRowSelectionChange: setRowSelection,
74063
74081
  onGlobalFilterChange: setGlobalFilter,
74064
74082
  globalFilterFn: "includesString",
74065
74083
  enableRowSelection: selectable || enableRowSelection || false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moontra/moonui-pro",
3
- "version": "2.26.43",
3
+ "version": "2.26.45",
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",
@@ -81,6 +81,7 @@
81
81
  "react-dom": ">=18.0.0 || ^19.0.0"
82
82
  },
83
83
  "dependencies": {
84
+ "@moontra/moonui-pro": "^2.26.44",
84
85
  "@radix-ui/react-accordion": "^1.2.11",
85
86
  "@radix-ui/react-avatar": "^1.1.10",
86
87
  "@radix-ui/react-checkbox": "^1.3.2",