@moontra/moonui-pro 2.26.43 → 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
@@ -73972,6 +73972,12 @@ function DataTable({
73972
73972
  const expandedRows = controlledExpandedRows || internalExpandedRows;
73973
73973
  const actualPageSize = defaultPageSize || pageSize;
73974
73974
  const stableData = t__default.useMemo(() => data, [data]);
73975
+ t__default.useEffect(() => {
73976
+ if (onRowSelect) {
73977
+ const selectedRows = Object.keys(rowSelection).filter((key) => rowSelection[key]).map((index2) => stableData[parseInt(index2)]).filter(Boolean);
73978
+ onRowSelect(selectedRows);
73979
+ }
73980
+ }, [rowSelection, stableData, onRowSelect]);
73975
73981
  const createSortingHandler = (columnId) => {
73976
73982
  return () => {
73977
73983
  const currentSorting = externalState?.sorting ?? sorting;
@@ -74001,23 +74007,41 @@ function DataTable({
74001
74007
  const checkboxColumn = {
74002
74008
  id: "select",
74003
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;
74004
74014
  return /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center", children: /* @__PURE__ */ jsx(
74005
74015
  MoonUICheckboxPro,
74006
74016
  {
74007
- checked: table2.getIsAllPageRowsSelected() || table2.getIsSomePageRowsSelected() && "indeterminate",
74008
- 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
+ },
74009
74027
  "aria-label": "Select all",
74010
74028
  className: "h-4 w-4"
74011
74029
  }
74012
74030
  ) });
74013
74031
  },
74014
74032
  cell: ({ row }) => {
74033
+ const rowIndex = row.index.toString();
74034
+ const isChecked = !!rowSelection[rowIndex];
74015
74035
  return /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center", children: /* @__PURE__ */ jsx(
74016
74036
  MoonUICheckboxPro,
74017
74037
  {
74018
- checked: row.getIsSelected(),
74019
- onCheckedChange: (value) => row.toggleSelected(!!value),
74020
- disabled: !row.getCanSelect(),
74038
+ checked: isChecked,
74039
+ onCheckedChange: (value) => {
74040
+ setRowSelection((prev) => ({
74041
+ ...prev,
74042
+ [rowIndex]: !!value
74043
+ }));
74044
+ },
74021
74045
  "aria-label": "Select row",
74022
74046
  className: "h-4 w-4"
74023
74047
  }
@@ -74031,7 +74055,7 @@ function DataTable({
74031
74055
  cols = [checkboxColumn, ...cols];
74032
74056
  }
74033
74057
  return cols;
74034
- }, [columns, selectable, enableRowSelection]);
74058
+ }, [columns, selectable, enableRowSelection, rowSelection, setRowSelection]);
74035
74059
  const table = useReactTable({
74036
74060
  data: stableData,
74037
74061
  columns: processedColumns,
@@ -74050,16 +74074,7 @@ function DataTable({
74050
74074
  sortDescFirst: false,
74051
74075
  // First click should be ascending
74052
74076
  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
- },
74077
+ onRowSelectionChange: setRowSelection,
74063
74078
  onGlobalFilterChange: setGlobalFilter,
74064
74079
  globalFilterFn: "includesString",
74065
74080
  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.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",