@machinemetrics/mm-react-components 0.2.3-24 → 0.2.3-26

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.
Files changed (27) hide show
  1. package/agent-docs/agent-documentation-reference.md +46 -9
  2. package/dist/App.d.ts.map +1 -1
  3. package/dist/components/ui/data-table/TableView.d.ts +2 -1
  4. package/dist/components/ui/data-table/TableView.d.ts.map +1 -1
  5. package/dist/components/ui/data-table/cards/ResponsiveTable.d.ts +1 -1
  6. package/dist/components/ui/data-table/cards/ResponsiveTable.d.ts.map +1 -1
  7. package/dist/components/ui/data-table/pagination.d.ts +12 -1
  8. package/dist/components/ui/data-table/pagination.d.ts.map +1 -1
  9. package/dist/components/ui/data-table/parts/TableBody.d.ts +6 -1
  10. package/dist/components/ui/data-table/parts/TableBody.d.ts.map +1 -1
  11. package/dist/components/ui/data-table/types.d.ts +16 -0
  12. package/dist/components/ui/data-table/types.d.ts.map +1 -1
  13. package/dist/components/ui/data-table/useDragAndDrop.d.ts +23 -0
  14. package/dist/components/ui/data-table/useDragAndDrop.d.ts.map +1 -0
  15. package/dist/components/ui/data-table/useTableController.d.ts +10 -0
  16. package/dist/components/ui/data-table/useTableController.d.ts.map +1 -1
  17. package/dist/components/ui/progress.d.ts.map +1 -1
  18. package/dist/components/ui/table/Table.d.ts.map +1 -1
  19. package/dist/lib/mm-react-components.css +1 -1
  20. package/dist/mm-react-components.es.js +921 -608
  21. package/dist/mm-react-components.es.js.map +1 -1
  22. package/dist/mm-react-components.umd.js +10 -10
  23. package/dist/mm-react-components.umd.js.map +1 -1
  24. package/dist/preview/DataTablePreview.d.ts +1 -1
  25. package/dist/preview/DataTablePreview.d.ts.map +1 -1
  26. package/dist/themes/carbide.css +23 -7
  27. package/package.json +1 -1
@@ -3767,10 +3767,9 @@ const Circle = createLucideIcon("circle", __iconNode$g);
3767
3767
  */
3768
3768
  const __iconNode$f = [
3769
3769
  ["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", key: "afitv7" }],
3770
- ["path", { d: "M9 3v18", key: "fh3hqa" }],
3771
- ["path", { d: "M15 3v18", key: "14nvp0" }]
3770
+ ["path", { d: "M12 3v18", key: "108xh3" }]
3772
3771
  ];
3773
- const Columns3 = createLucideIcon("columns-3", __iconNode$f);
3772
+ const Columns2 = createLucideIcon("columns-2", __iconNode$f);
3774
3773
  /**
3775
3774
  * @license lucide-react v0.544.0 - ISC
3776
3775
  *
@@ -3816,41 +3815,53 @@ const Info = createLucideIcon("info", __iconNode$c);
3816
3815
  * This source code is licensed under the ISC license.
3817
3816
  * See the LICENSE file in the root directory of this source tree.
3818
3817
  */
3819
- const __iconNode$b = [["path", { d: "M21 12a9 9 0 1 1-6.219-8.56", key: "13zald" }]];
3820
- const LoaderCircle = createLucideIcon("loader-circle", __iconNode$b);
3818
+ const __iconNode$b = [
3819
+ ["path", { d: "M2 5h20", key: "1fs1ex" }],
3820
+ ["path", { d: "M6 12h12", key: "8npq4p" }],
3821
+ ["path", { d: "M9 19h6", key: "456am0" }]
3822
+ ];
3823
+ const ListFilter = createLucideIcon("list-filter", __iconNode$b);
3824
+ /**
3825
+ * @license lucide-react v0.544.0 - ISC
3826
+ *
3827
+ * This source code is licensed under the ISC license.
3828
+ * See the LICENSE file in the root directory of this source tree.
3829
+ */
3830
+ const __iconNode$a = [["path", { d: "M21 12a9 9 0 1 1-6.219-8.56", key: "13zald" }]];
3831
+ const LoaderCircle = createLucideIcon("loader-circle", __iconNode$a);
3821
3832
  /**
3822
3833
  * @license lucide-react v0.544.0 - ISC
3823
3834
  *
3824
3835
  * This source code is licensed under the ISC license.
3825
3836
  * See the LICENSE file in the root directory of this source tree.
3826
3837
  */
3827
- const __iconNode$a = [
3838
+ const __iconNode$9 = [
3828
3839
  ["path", { d: "M15 3h6v6", key: "1q9fwt" }],
3829
3840
  ["path", { d: "m21 3-7 7", key: "1l2asr" }],
3830
3841
  ["path", { d: "m3 21 7-7", key: "tjx5ai" }],
3831
3842
  ["path", { d: "M9 21H3v-6", key: "wtvkvv" }]
3832
3843
  ];
3833
- const Maximize2 = createLucideIcon("maximize-2", __iconNode$a);
3844
+ const Maximize2 = createLucideIcon("maximize-2", __iconNode$9);
3834
3845
  /**
3835
3846
  * @license lucide-react v0.544.0 - ISC
3836
3847
  *
3837
3848
  * This source code is licensed under the ISC license.
3838
3849
  * See the LICENSE file in the root directory of this source tree.
3839
3850
  */
3840
- const __iconNode$9 = [
3851
+ const __iconNode$8 = [
3841
3852
  ["path", { d: "m14 10 7-7", key: "oa77jy" }],
3842
3853
  ["path", { d: "M20 10h-6V4", key: "mjg0md" }],
3843
3854
  ["path", { d: "m3 21 7-7", key: "tjx5ai" }],
3844
3855
  ["path", { d: "M4 14h6v6", key: "rmj7iw" }]
3845
3856
  ];
3846
- const Minimize2 = createLucideIcon("minimize-2", __iconNode$9);
3857
+ const Minimize2 = createLucideIcon("minimize-2", __iconNode$8);
3847
3858
  /**
3848
3859
  * @license lucide-react v0.544.0 - ISC
3849
3860
  *
3850
3861
  * This source code is licensed under the ISC license.
3851
3862
  * See the LICENSE file in the root directory of this source tree.
3852
3863
  */
3853
- const __iconNode$8 = [
3864
+ const __iconNode$7 = [
3854
3865
  [
3855
3866
  "path",
3856
3867
  {
@@ -3859,14 +3870,14 @@ const __iconNode$8 = [
3859
3870
  }
3860
3871
  ]
3861
3872
  ];
3862
- const Moon = createLucideIcon("moon", __iconNode$8);
3873
+ const Moon = createLucideIcon("moon", __iconNode$7);
3863
3874
  /**
3864
3875
  * @license lucide-react v0.544.0 - ISC
3865
3876
  *
3866
3877
  * This source code is licensed under the ISC license.
3867
3878
  * See the LICENSE file in the root directory of this source tree.
3868
3879
  */
3869
- const __iconNode$7 = [
3880
+ const __iconNode$6 = [
3870
3881
  ["path", { d: "m15 9-6 6", key: "1uzhvr" }],
3871
3882
  [
3872
3883
  "path",
@@ -3877,49 +3888,31 @@ const __iconNode$7 = [
3877
3888
  ],
3878
3889
  ["path", { d: "m9 9 6 6", key: "z0biqf" }]
3879
3890
  ];
3880
- const OctagonX = createLucideIcon("octagon-x", __iconNode$7);
3891
+ const OctagonX = createLucideIcon("octagon-x", __iconNode$6);
3881
3892
  /**
3882
3893
  * @license lucide-react v0.544.0 - ISC
3883
3894
  *
3884
3895
  * This source code is licensed under the ISC license.
3885
3896
  * See the LICENSE file in the root directory of this source tree.
3886
3897
  */
3887
- const __iconNode$6 = [
3898
+ const __iconNode$5 = [
3888
3899
  ["path", { d: "M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8", key: "v9h5vc" }],
3889
3900
  ["path", { d: "M21 3v5h-5", key: "1q7to0" }],
3890
3901
  ["path", { d: "M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16", key: "3uifl3" }],
3891
3902
  ["path", { d: "M8 16H3v5", key: "1cv678" }]
3892
3903
  ];
3893
- const RefreshCw = createLucideIcon("refresh-cw", __iconNode$6);
3904
+ const RefreshCw = createLucideIcon("refresh-cw", __iconNode$5);
3894
3905
  /**
3895
3906
  * @license lucide-react v0.544.0 - ISC
3896
3907
  *
3897
3908
  * This source code is licensed under the ISC license.
3898
3909
  * See the LICENSE file in the root directory of this source tree.
3899
3910
  */
3900
- const __iconNode$5 = [
3911
+ const __iconNode$4 = [
3901
3912
  ["path", { d: "m21 21-4.34-4.34", key: "14j7rj" }],
3902
3913
  ["circle", { cx: "11", cy: "11", r: "8", key: "4ej97u" }]
3903
3914
  ];
3904
- const Search = createLucideIcon("search", __iconNode$5);
3905
- /**
3906
- * @license lucide-react v0.544.0 - ISC
3907
- *
3908
- * This source code is licensed under the ISC license.
3909
- * See the LICENSE file in the root directory of this source tree.
3910
- */
3911
- const __iconNode$4 = [
3912
- ["path", { d: "M10 5H3", key: "1qgfaw" }],
3913
- ["path", { d: "M12 19H3", key: "yhmn1j" }],
3914
- ["path", { d: "M14 3v4", key: "1sua03" }],
3915
- ["path", { d: "M16 17v4", key: "1q0r14" }],
3916
- ["path", { d: "M21 12h-9", key: "1o4lsq" }],
3917
- ["path", { d: "M21 19h-5", key: "1rlt1p" }],
3918
- ["path", { d: "M21 5h-7", key: "1oszz2" }],
3919
- ["path", { d: "M8 10v4", key: "tgpxqk" }],
3920
- ["path", { d: "M8 12H3", key: "a7s4jb" }]
3921
- ];
3922
- const SlidersHorizontal = createLucideIcon("sliders-horizontal", __iconNode$4);
3915
+ const Search = createLucideIcon("search", __iconNode$4);
3923
3916
  /**
3924
3917
  * @license lucide-react v0.544.0 - ISC
3925
3918
  *
@@ -23988,6 +23981,198 @@ function useDroppable(_ref) {
23988
23981
  setNodeRef
23989
23982
  };
23990
23983
  }
23984
+ const restrictToHorizontalAxis = (_ref) => {
23985
+ let {
23986
+ transform
23987
+ } = _ref;
23988
+ return {
23989
+ ...transform,
23990
+ y: 0
23991
+ };
23992
+ };
23993
+ function restrictToBoundingRect(transform, rect, boundingRect) {
23994
+ const value = {
23995
+ ...transform
23996
+ };
23997
+ if (rect.top + transform.y <= boundingRect.top) {
23998
+ value.y = boundingRect.top - rect.top;
23999
+ } else if (rect.bottom + transform.y >= boundingRect.top + boundingRect.height) {
24000
+ value.y = boundingRect.top + boundingRect.height - rect.bottom;
24001
+ }
24002
+ if (rect.left + transform.x <= boundingRect.left) {
24003
+ value.x = boundingRect.left - rect.left;
24004
+ } else if (rect.right + transform.x >= boundingRect.left + boundingRect.width) {
24005
+ value.x = boundingRect.left + boundingRect.width - rect.right;
24006
+ }
24007
+ return value;
24008
+ }
24009
+ const restrictToParentElement = (_ref) => {
24010
+ let {
24011
+ containerNodeRect,
24012
+ draggingNodeRect,
24013
+ transform
24014
+ } = _ref;
24015
+ if (!draggingNodeRect || !containerNodeRect) {
24016
+ return transform;
24017
+ }
24018
+ return restrictToBoundingRect(transform, draggingNodeRect, containerNodeRect);
24019
+ };
24020
+ const restrictToVerticalAxis = (_ref) => {
24021
+ let {
24022
+ transform
24023
+ } = _ref;
24024
+ return {
24025
+ ...transform,
24026
+ x: 0
24027
+ };
24028
+ };
24029
+ function DataTablePagination({
24030
+ table,
24031
+ pageSizeOptions = [25, 50, 100, 250],
24032
+ className,
24033
+ compact: compact2 = false,
24034
+ onPageChange,
24035
+ onPageSizeChange,
24036
+ manualPagination = false,
24037
+ totalRowCount
24038
+ }) {
24039
+ const state = table.getState();
24040
+ const pageSize = state.pagination?.pageSize ?? 25;
24041
+ const pageIndex = state.pagination?.pageIndex ?? 0;
24042
+ const canPrev = table.getCanPreviousPage();
24043
+ const canNext = table.getCanNextPage();
24044
+ const totalRows = React.useMemo(() => {
24045
+ if (manualPagination) {
24046
+ if (totalRowCount !== void 0) {
24047
+ return totalRowCount;
24048
+ }
24049
+ const pageCount = table.getPageCount();
24050
+ if (pageCount > 0) {
24051
+ const approximateTotal = pageCount * pageSize;
24052
+ const currentPageRows = table.getRowModel().rows.length;
24053
+ if (pageIndex === pageCount - 1 && currentPageRows < pageSize) {
24054
+ return (pageCount - 1) * pageSize + currentPageRows;
24055
+ }
24056
+ return approximateTotal;
24057
+ }
24058
+ return 0;
24059
+ }
24060
+ return table.getFilteredRowModel().rows.length;
24061
+ }, [manualPagination, totalRowCount, table, pageSize, pageIndex]);
24062
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs(
24063
+ "div",
24064
+ {
24065
+ className: "mmc-pagination flex items-center justify-between gap-3 px-4 py-3 " + (className || ""),
24066
+ "data-slot": "pagination",
24067
+ children: [
24068
+ !compact2 && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-4 flex-1", children: [
24069
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-sm text-foreground", children: (() => {
24070
+ const selected = table.getFilteredSelectedRowModel().rows.length;
24071
+ if (selected > 0) {
24072
+ return `${selected} selected of ${totalRows} items`;
24073
+ }
24074
+ if (totalRows === 0) return "Showing 0 to 0 of 0 items";
24075
+ const start = pageIndex * pageSize + 1;
24076
+ const currentPageRows = table.getRowModel().rows.length;
24077
+ const end = manualPagination ? pageIndex * pageSize + currentPageRows : Math.min(totalRows, (pageIndex + 1) * pageSize);
24078
+ return `Showing ${start} to ${end} of ${totalRows} items`;
24079
+ })() }),
24080
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(
24081
+ "div",
24082
+ {
24083
+ className: "mmc-pagination__page-size flex items-center gap-2",
24084
+ "data-slot": "page-size",
24085
+ children: [
24086
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-sm text-foreground", children: "Show:" }),
24087
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(
24088
+ Select$1,
24089
+ {
24090
+ value: String(pageSize),
24091
+ onValueChange: (value) => {
24092
+ const size2 = Number(value);
24093
+ table.setPageIndex(0);
24094
+ table.setPageSize(size2);
24095
+ if (onPageSizeChange) {
24096
+ onPageSizeChange(size2);
24097
+ }
24098
+ if (onPageChange) {
24099
+ onPageChange(0);
24100
+ }
24101
+ },
24102
+ children: [
24103
+ /* @__PURE__ */ jsxRuntimeExports.jsx(SelectTrigger, { className: "h-9 w-20", children: /* @__PURE__ */ jsxRuntimeExports.jsx(SelectValue, {}) }),
24104
+ /* @__PURE__ */ jsxRuntimeExports.jsx(SelectContent, { align: "end", children: pageSizeOptions.map((size2) => /* @__PURE__ */ jsxRuntimeExports.jsx(SelectItem, { value: String(size2), children: size2 }, size2)) })
24105
+ ]
24106
+ }
24107
+ )
24108
+ ]
24109
+ }
24110
+ )
24111
+ ] }),
24112
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mmc-pagination__nav space-x-4", "data-slot": "nav", children: [
24113
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
24114
+ Button$1,
24115
+ {
24116
+ variant: "ghost",
24117
+ className: "px-2.5 text-foreground hover:text-foreground disabled:text-muted-foreground disabled:opacity-50 disabled:hover:text-muted-foreground",
24118
+ onClick: () => {
24119
+ table.previousPage();
24120
+ if (onPageChange) {
24121
+ onPageChange(table.getState().pagination?.pageIndex ?? 0);
24122
+ }
24123
+ },
24124
+ disabled: !canPrev,
24125
+ "data-slot": "previous",
24126
+ children: "Previous"
24127
+ }
24128
+ ),
24129
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
24130
+ "span",
24131
+ {
24132
+ className: "text-sm text-foreground select-none",
24133
+ "data-slot": "page-indicator",
24134
+ children: (() => {
24135
+ const p2 = table.getState().pagination ?? {};
24136
+ const current = Math.max(1, (p2.pageIndex ?? 0) + 1);
24137
+ let count2;
24138
+ if (manualPagination) {
24139
+ const pageCountFn = table.getPageCount;
24140
+ count2 = typeof pageCountFn === "function" ? pageCountFn() : Math.max(1, Math.ceil(totalRows / Math.max(1, pageSize)));
24141
+ } else {
24142
+ const pageCountFn = table.getPageCount;
24143
+ count2 = typeof pageCountFn === "function" ? pageCountFn() : Math.max(
24144
+ 1,
24145
+ Math.ceil(
24146
+ (table.getFilteredRowModel().rows.length || 0) / Math.max(1, p2.pageSize ?? 10)
24147
+ )
24148
+ );
24149
+ }
24150
+ const safeCurrent = Math.min(current, count2);
24151
+ return `Page ${safeCurrent} of ${count2}`;
24152
+ })()
24153
+ }
24154
+ ),
24155
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
24156
+ Button$1,
24157
+ {
24158
+ variant: "ghost",
24159
+ className: "px-2.5 text-foreground hover:text-foreground disabled:text-muted-foreground disabled:opacity-50 disabled:hover:text-muted-foreground",
24160
+ onClick: () => {
24161
+ table.nextPage();
24162
+ if (onPageChange) {
24163
+ onPageChange(table.getState().pagination?.pageIndex ?? 0);
24164
+ }
24165
+ },
24166
+ disabled: !canNext,
24167
+ "data-slot": "next",
24168
+ children: "Next"
24169
+ }
24170
+ )
24171
+ ] })
24172
+ ]
24173
+ }
24174
+ );
24175
+ }
23991
24176
  function arrayMove(array, from, to) {
23992
24177
  const newArray = array.slice();
23993
24178
  newArray.splice(to < 0 ? newArray.length + to : to, 0, newArray.splice(from, 1)[0]);
@@ -24627,180 +24812,15 @@ function isAfter(a2, b) {
24627
24812
  }
24628
24813
  return a2.data.current.sortable.index < b.data.current.sortable.index;
24629
24814
  }
24630
- const restrictToHorizontalAxis = (_ref) => {
24631
- let {
24632
- transform
24633
- } = _ref;
24634
- return {
24635
- ...transform,
24636
- y: 0
24637
- };
24638
- };
24639
- function restrictToBoundingRect(transform, rect, boundingRect) {
24640
- const value = {
24641
- ...transform
24642
- };
24643
- if (rect.top + transform.y <= boundingRect.top) {
24644
- value.y = boundingRect.top - rect.top;
24645
- } else if (rect.bottom + transform.y >= boundingRect.top + boundingRect.height) {
24646
- value.y = boundingRect.top + boundingRect.height - rect.bottom;
24647
- }
24648
- if (rect.left + transform.x <= boundingRect.left) {
24649
- value.x = boundingRect.left - rect.left;
24650
- } else if (rect.right + transform.x >= boundingRect.left + boundingRect.width) {
24651
- value.x = boundingRect.left + boundingRect.width - rect.right;
24652
- }
24653
- return value;
24654
- }
24655
- const restrictToParentElement = (_ref) => {
24656
- let {
24657
- containerNodeRect,
24658
- draggingNodeRect,
24659
- transform
24660
- } = _ref;
24661
- if (!draggingNodeRect || !containerNodeRect) {
24662
- return transform;
24663
- }
24664
- return restrictToBoundingRect(transform, draggingNodeRect, containerNodeRect);
24665
- };
24666
- const restrictToVerticalAxis = (_ref) => {
24667
- let {
24668
- transform
24669
- } = _ref;
24670
- return {
24671
- ...transform,
24672
- x: 0
24673
- };
24674
- };
24675
- function DataTablePagination({
24676
- table,
24677
- pageSizeOptions = [25, 50, 100, 250],
24678
- className,
24679
- compact: compact2 = false,
24680
- onPageChange,
24681
- onPageSizeChange
24682
- }) {
24683
- const state = table.getState();
24684
- const pageSize = state.pagination?.pageSize ?? 25;
24685
- const canPrev = table.getCanPreviousPage();
24686
- const canNext = table.getCanNextPage();
24815
+ function MenuHeader({ title, className, right }) {
24687
24816
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(
24688
24817
  "div",
24689
24818
  {
24690
- className: "mmc-pagination flex items-center justify-between gap-3 px-4 py-3 " + (className || ""),
24691
- "data-slot": "pagination",
24692
- children: [
24693
- !compact2 && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-4 flex-1", children: [
24694
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-sm text-muted-foreground", children: (() => {
24695
- const total = table.getFilteredRowModel().rows.length;
24696
- const selected = table.getFilteredSelectedRowModel().rows.length;
24697
- if (selected > 0) {
24698
- return `${selected} selected of ${total} items`;
24699
- }
24700
- if (total === 0) return "Showing 0 to 0 of 0 items";
24701
- const { pageIndex = 0, pageSize: pageSize2 = 25 } = table.getState().pagination ?? {};
24702
- const start = pageIndex * pageSize2 + 1;
24703
- const end = Math.min(total, (pageIndex + 1) * pageSize2);
24704
- return `Showing ${start} to ${end} of ${total} items`;
24705
- })() }),
24706
- /* @__PURE__ */ jsxRuntimeExports.jsxs(
24707
- "div",
24708
- {
24709
- className: "mmc-pagination__page-size flex items-center gap-2",
24710
- "data-slot": "page-size",
24711
- children: [
24712
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-sm text-muted-foreground", children: "Show:" }),
24713
- /* @__PURE__ */ jsxRuntimeExports.jsxs(
24714
- Select$1,
24715
- {
24716
- value: String(pageSize),
24717
- onValueChange: (value) => {
24718
- const size2 = Number(value);
24719
- table.setPageIndex(0);
24720
- table.setPageSize(size2);
24721
- if (onPageSizeChange) {
24722
- onPageSizeChange(size2);
24723
- }
24724
- if (onPageChange) {
24725
- onPageChange(0);
24726
- }
24727
- },
24728
- children: [
24729
- /* @__PURE__ */ jsxRuntimeExports.jsx(SelectTrigger, { className: "h-9 w-20", children: /* @__PURE__ */ jsxRuntimeExports.jsx(SelectValue, {}) }),
24730
- /* @__PURE__ */ jsxRuntimeExports.jsx(SelectContent, { align: "end", children: pageSizeOptions.map((size2) => /* @__PURE__ */ jsxRuntimeExports.jsx(SelectItem, { value: String(size2), children: size2 }, size2)) })
24731
- ]
24732
- }
24733
- )
24734
- ]
24735
- }
24736
- )
24737
- ] }),
24738
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mmc-pagination__nav space-x-4", "data-slot": "nav", children: [
24739
- /* @__PURE__ */ jsxRuntimeExports.jsx(
24740
- Button$1,
24741
- {
24742
- variant: "outline",
24743
- className: "h-9 rounded-md px-3",
24744
- onClick: () => {
24745
- table.previousPage();
24746
- if (onPageChange) {
24747
- onPageChange(table.getState().pagination?.pageIndex ?? 0);
24748
- }
24749
- },
24750
- disabled: !canPrev,
24751
- "data-slot": "previous",
24752
- children: "Previous"
24753
- }
24754
- ),
24755
- /* @__PURE__ */ jsxRuntimeExports.jsx(
24756
- "span",
24757
- {
24758
- className: "text-sm text-muted-foreground select-none",
24759
- "data-slot": "page-indicator",
24760
- children: (() => {
24761
- const p2 = table.getState().pagination ?? {};
24762
- const current = Math.max(1, (p2.pageIndex ?? 0) + 1);
24763
- const count2 = typeof table.getPageCount === "function" ? table.getPageCount() : Math.max(
24764
- 1,
24765
- Math.ceil(
24766
- (table.getFilteredRowModel().rows.length || 0) / Math.max(1, p2.pageSize ?? 10)
24767
- )
24768
- );
24769
- const safeCurrent = Math.min(current, count2);
24770
- return `Page ${safeCurrent} of ${count2}`;
24771
- })()
24772
- }
24773
- ),
24774
- /* @__PURE__ */ jsxRuntimeExports.jsx(
24775
- Button$1,
24776
- {
24777
- variant: "outline",
24778
- className: "h-9 rounded-md px-3",
24779
- onClick: () => {
24780
- table.nextPage();
24781
- if (onPageChange) {
24782
- onPageChange(table.getState().pagination?.pageIndex ?? 0);
24783
- }
24784
- },
24785
- disabled: !canNext,
24786
- "data-slot": "next",
24787
- children: "Next"
24788
- }
24789
- )
24790
- ] })
24791
- ]
24792
- }
24793
- );
24794
- }
24795
- function MenuHeader({ title, className, right }) {
24796
- return /* @__PURE__ */ jsxRuntimeExports.jsxs(
24797
- "div",
24798
- {
24799
- className: cn$1(
24800
- "mmc-menu-header flex items-center justify-between border-b px-4 py-2",
24801
- className
24802
- ),
24803
- "data-slot": "menu-header",
24819
+ className: cn$1(
24820
+ "mmc-menu-header flex items-center justify-between border-b px-4 py-2",
24821
+ className
24822
+ ),
24823
+ "data-slot": "menu-header",
24804
24824
  children: [
24805
24825
  /* @__PURE__ */ jsxRuntimeExports.jsx(
24806
24826
  "span",
@@ -24915,7 +24935,7 @@ function ColumnVisibilityMenu({
24915
24935
  size: "icon",
24916
24936
  className: "h-10 w-10",
24917
24937
  "aria-label": "Edit columns",
24918
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(Columns3, { className: "h-4 w-4" })
24938
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(Columns2, { className: "h-4 w-4" })
24919
24939
  }
24920
24940
  ) }),
24921
24941
  /* @__PURE__ */ jsxRuntimeExports.jsxs(DropdownMenuContent, { align: "end", className: "w-64 p-0", children: [
@@ -25829,7 +25849,7 @@ function FilterMenu({
25829
25849
  "aria-label": activeTotal ? `Filters, ${activeTotal} active` : "Filters",
25830
25850
  className: "relative h-10 w-10",
25831
25851
  children: [
25832
- /* @__PURE__ */ jsxRuntimeExports.jsx(SlidersHorizontal, { className: "h-4 w-4" }),
25852
+ /* @__PURE__ */ jsxRuntimeExports.jsx(ListFilter, { className: "h-4 w-4" }),
25833
25853
  activeTotal > 0 ? /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: cn$1("absolute -top-1 -right-1", bubbleClass), children: activeTotal }) : null
25834
25854
  ]
25835
25855
  }
@@ -26103,7 +26123,7 @@ function SortMenu({ table }) {
26103
26123
  const activeColumn = currentColumn ?? sortableColumns[0];
26104
26124
  const activeLabel = activeColumn ? getColumnLabel(activeColumn) : "Sort";
26105
26125
  const buttonLabel = currentSort ? `Sort by ${activeLabel}` : "Sort";
26106
- const SortIcon = currentDirection === "asc" ? ArrowUp : ArrowDown;
26126
+ const SortIcon = currentDirection === "asc" ? ChevronUp : ChevronDown;
26107
26127
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(DropdownMenu, { children: [
26108
26128
  /* @__PURE__ */ jsxRuntimeExports.jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
26109
26129
  Button$1,
@@ -26133,7 +26153,7 @@ function SortMenu({ table }) {
26133
26153
  setSorting(String(activeColumn.id), pressed ? "desc" : "asc");
26134
26154
  },
26135
26155
  className: "h-8 w-8 p-0",
26136
- children: currentDirection === "asc" ? /* @__PURE__ */ jsxRuntimeExports.jsx(ArrowUp, { className: "h-4 w-4" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(ArrowDown, { className: "h-4 w-4" })
26156
+ children: currentDirection === "asc" ? /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronUp, { className: "h-4 w-4" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronDown, { className: "h-4 w-4" })
26137
26157
  }
26138
26158
  )
26139
26159
  }
@@ -29457,77 +29477,56 @@ function useBreakpoint(query = QUERY) {
29457
29477
  }, [query]);
29458
29478
  return matches;
29459
29479
  }
29460
- function useTableController(options) {
29461
- const {
29462
- columns,
29463
- data,
29464
- columnRegistry,
29465
- initialState: initialState2,
29466
- tableId,
29467
- disableGlobalFilter,
29468
- customGlobalFilterFn,
29469
- onRowSelectionChange,
29470
- onSortingChange,
29471
- onPaginationChange,
29472
- onColumnVisibilityChange,
29473
- onColumnOrderChange,
29474
- onBatchAction,
29475
- onRowClick,
29476
- onExportComplete
29477
- } = options;
29478
- const storageKey = tableId ? `mmrc:table:${tableId}` : void 0;
29479
- const persistedState = React.useMemo(() => {
29480
- if (!storageKey) return null;
29481
- try {
29482
- const raw = localStorage.getItem(storageKey);
29483
- if (!raw) return null;
29484
- const parsed = JSON.parse(raw);
29485
- return parsed;
29486
- } catch {
29487
- return null;
29480
+ function loadPersistedState(storageKey) {
29481
+ if (!storageKey) return null;
29482
+ try {
29483
+ const raw = localStorage.getItem(storageKey);
29484
+ if (!raw) return null;
29485
+ return JSON.parse(raw);
29486
+ } catch {
29487
+ return null;
29488
+ }
29489
+ }
29490
+ function resolveColumnsFromRegistry(columns, columnRegistry, columnOrder) {
29491
+ if (!columnRegistry) return columns;
29492
+ const entries = Object.entries(columnRegistry);
29493
+ const registryOrder = resolveColumnOrder(
29494
+ columnRegistry
29495
+ );
29496
+ const activeOrder = columnOrder.length ? columnOrder : registryOrder;
29497
+ const registryMap = new Map(entries);
29498
+ const seen = /* @__PURE__ */ new Set();
29499
+ const ordered = activeOrder.map((id) => {
29500
+ const descriptor = registryMap.get(id);
29501
+ if (!descriptor) return null;
29502
+ seen.add(id);
29503
+ return descriptor.columnDef;
29504
+ }).filter(Boolean);
29505
+ entries.forEach(([id, descriptor]) => {
29506
+ if (!seen.has(id)) {
29507
+ ordered.push(descriptor.columnDef);
29488
29508
  }
29489
- }, [storageKey]);
29490
- const {
29491
- sorting: [sorting, setSorting],
29492
- columnVisibility: [columnVisibility, setColumnVisibility],
29493
- columnOrder: [columnOrder, setColumnOrder],
29494
- columnPinning: [columnPinning, setColumnPinning],
29495
- rowSelection: [rowSelection, setRowSelection]
29496
- } = useDataTableState({
29497
- registry: columnRegistry,
29498
- initialSorting: persistedState?.sorting ?? initialState2?.sorting,
29499
- initialVisibility: persistedState?.columnVisibility ?? initialState2?.visibility,
29500
- initialColumnOrder: persistedState?.columnOrder ?? initialState2?.columnOrder,
29501
- initialPinning: initialState2?.columnPinning,
29502
- initialRowSelection: initialState2?.rowSelection
29503
- });
29504
- const resolvedColumns = React.useMemo(() => {
29505
- if (!columnRegistry) return columns;
29506
- const entries = Object.entries(columnRegistry);
29507
- const registryOrder = resolveColumnOrder(
29508
- columnRegistry
29509
- );
29510
- const activeOrder = columnOrder.length ? columnOrder : registryOrder;
29511
- const registryMap = new Map(entries);
29512
- const seen = /* @__PURE__ */ new Set();
29513
- const ordered = activeOrder.map((id) => {
29514
- const descriptor = registryMap.get(id);
29515
- if (!descriptor) return null;
29516
- seen.add(id);
29517
- return descriptor.columnDef;
29518
- }).filter(Boolean);
29519
- entries.forEach(([id, descriptor]) => {
29520
- if (!seen.has(id)) {
29521
- ordered.push(descriptor.columnDef);
29522
- }
29523
- });
29524
- return ordered;
29525
- }, [columnRegistry, columns, columnOrder]);
29526
- const [globalFilter, setGlobalFilter] = React.useState("");
29527
- const [pagination, setPagination] = React.useState({
29528
- pageIndex: 0,
29529
- pageSize: 25
29530
29509
  });
29510
+ return ordered;
29511
+ }
29512
+ function useWrappedStateSetters({
29513
+ rowSelection,
29514
+ setRowSelection,
29515
+ onRowSelectionChange,
29516
+ data,
29517
+ sorting,
29518
+ setSorting,
29519
+ onSortingChange,
29520
+ pagination,
29521
+ setPagination,
29522
+ onPaginationChange,
29523
+ columnVisibility,
29524
+ setColumnVisibility,
29525
+ onColumnVisibilityChange,
29526
+ columnOrder,
29527
+ setColumnOrder,
29528
+ onColumnOrderChange
29529
+ }) {
29531
29530
  const wrappedSetRowSelection = React.useCallback(
29532
29531
  (updater) => {
29533
29532
  const newSelection = typeof updater === "function" ? updater(rowSelection) : updater;
@@ -29579,6 +29578,141 @@ function useTableController(options) {
29579
29578
  },
29580
29579
  [columnOrder, setColumnOrder, onColumnOrderChange]
29581
29580
  );
29581
+ return {
29582
+ wrappedSetRowSelection,
29583
+ wrappedSetSorting,
29584
+ wrappedSetPagination,
29585
+ wrappedSetColumnVisibility,
29586
+ wrappedSetColumnOrder
29587
+ };
29588
+ }
29589
+ function getGlobalFilterFn(disableGlobalFilter, customGlobalFilterFn) {
29590
+ if (disableGlobalFilter) {
29591
+ return (_row, _columnId, _filterValue) => true;
29592
+ }
29593
+ if (customGlobalFilterFn) {
29594
+ return customGlobalFilterFn;
29595
+ }
29596
+ return void 0;
29597
+ }
29598
+ function createResetColumnsHandler({
29599
+ columnRegistry,
29600
+ initialState: initialState2,
29601
+ storageKey,
29602
+ registryDefaultVisibility,
29603
+ registryDefaultOrder,
29604
+ setSorting,
29605
+ setColumnVisibility,
29606
+ setColumnOrder,
29607
+ setColumnPinning,
29608
+ table
29609
+ }) {
29610
+ if (!columnRegistry && !initialState2) return void 0;
29611
+ return () => {
29612
+ if (storageKey) {
29613
+ try {
29614
+ localStorage.removeItem(storageKey);
29615
+ } catch {
29616
+ }
29617
+ }
29618
+ if (initialState2?.sorting) {
29619
+ setSorting([...initialState2.sorting]);
29620
+ } else {
29621
+ setSorting([]);
29622
+ }
29623
+ if (registryDefaultVisibility) {
29624
+ setColumnVisibility({ ...registryDefaultVisibility });
29625
+ } else if (initialState2?.visibility) {
29626
+ setColumnVisibility({ ...initialState2.visibility });
29627
+ } else {
29628
+ setColumnVisibility({});
29629
+ }
29630
+ if (registryDefaultOrder?.length) {
29631
+ setColumnOrder([...registryDefaultOrder]);
29632
+ } else if (initialState2?.columnOrder) {
29633
+ setColumnOrder([...initialState2.columnOrder]);
29634
+ }
29635
+ setColumnPinning(
29636
+ initialState2?.columnPinning ? {
29637
+ left: [...initialState2.columnPinning.left ?? []],
29638
+ right: [...initialState2.columnPinning.right ?? []]
29639
+ } : { left: [], right: [] }
29640
+ );
29641
+ table.resetColumnSizing();
29642
+ };
29643
+ }
29644
+ function useTableController(options) {
29645
+ const {
29646
+ columns,
29647
+ data,
29648
+ columnRegistry,
29649
+ initialState: initialState2,
29650
+ tableId,
29651
+ disableGlobalFilter,
29652
+ customGlobalFilterFn,
29653
+ manualPagination = false,
29654
+ pageCount,
29655
+ onRowSelectionChange,
29656
+ onSortingChange,
29657
+ onPaginationChange,
29658
+ onColumnVisibilityChange,
29659
+ onColumnOrderChange,
29660
+ onBatchAction,
29661
+ onRowClick,
29662
+ onExportComplete
29663
+ } = options;
29664
+ const storageKey = tableId ? `mmrc:table:${tableId}` : void 0;
29665
+ const persistedState = React.useMemo(
29666
+ () => loadPersistedState(storageKey),
29667
+ [storageKey]
29668
+ );
29669
+ const {
29670
+ sorting: [sorting, setSorting],
29671
+ columnVisibility: [columnVisibility, setColumnVisibility],
29672
+ columnOrder: [columnOrder, setColumnOrder],
29673
+ columnPinning: [columnPinning, setColumnPinning],
29674
+ rowSelection: [rowSelection, setRowSelection]
29675
+ } = useDataTableState({
29676
+ registry: columnRegistry,
29677
+ initialSorting: persistedState?.sorting ?? initialState2?.sorting,
29678
+ initialVisibility: persistedState?.columnVisibility ?? initialState2?.visibility,
29679
+ initialColumnOrder: persistedState?.columnOrder ?? initialState2?.columnOrder,
29680
+ initialPinning: initialState2?.columnPinning,
29681
+ initialRowSelection: initialState2?.rowSelection
29682
+ });
29683
+ const resolvedColumns = React.useMemo(
29684
+ () => resolveColumnsFromRegistry(columns, columnRegistry, columnOrder),
29685
+ [columns, columnRegistry, columnOrder]
29686
+ );
29687
+ const [globalFilter, setGlobalFilter] = React.useState("");
29688
+ const [pagination, setPagination] = React.useState({
29689
+ pageIndex: 0,
29690
+ pageSize: 25
29691
+ });
29692
+ const {
29693
+ wrappedSetRowSelection,
29694
+ wrappedSetSorting,
29695
+ wrappedSetPagination,
29696
+ wrappedSetColumnVisibility,
29697
+ wrappedSetColumnOrder
29698
+ } = useWrappedStateSetters({
29699
+ rowSelection,
29700
+ setRowSelection,
29701
+ onRowSelectionChange,
29702
+ data,
29703
+ sorting,
29704
+ setSorting,
29705
+ onSortingChange,
29706
+ pagination,
29707
+ setPagination,
29708
+ onPaginationChange,
29709
+ columnVisibility,
29710
+ setColumnVisibility,
29711
+ onColumnVisibilityChange,
29712
+ columnOrder,
29713
+ setColumnOrder,
29714
+ onColumnOrderChange
29715
+ });
29582
29716
  React.useEffect(() => {
29583
29717
  if (!storageKey) return;
29584
29718
  try {
@@ -29591,15 +29725,10 @@ function useTableController(options) {
29591
29725
  } catch {
29592
29726
  }
29593
29727
  }, [columnOrder, columnVisibility, sorting, storageKey]);
29594
- const globalFilterFn = React.useMemo(() => {
29595
- if (disableGlobalFilter) {
29596
- return (_row, _columnId, _filterValue) => true;
29597
- }
29598
- if (customGlobalFilterFn) {
29599
- return customGlobalFilterFn;
29600
- }
29601
- return void 0;
29602
- }, [disableGlobalFilter, customGlobalFilterFn]);
29728
+ const globalFilterFn = React.useMemo(
29729
+ () => getGlobalFilterFn(disableGlobalFilter, customGlobalFilterFn),
29730
+ [disableGlobalFilter, customGlobalFilterFn]
29731
+ );
29603
29732
  const table = useReactTable({
29604
29733
  data,
29605
29734
  columns: resolvedColumns,
@@ -29616,6 +29745,9 @@ function useTableController(options) {
29616
29745
  enableColumnResizing: true,
29617
29746
  enableColumnPinning: true,
29618
29747
  enableGlobalFilter: true,
29748
+ // Server-side pagination configuration
29749
+ manualPagination,
29750
+ ...manualPagination && pageCount !== void 0 && { pageCount },
29619
29751
  // Only include globalFilterFn prop if we have a custom filter or disabled filter
29620
29752
  // Omitting it allows TanStack Table to use its default filter behavior
29621
29753
  ...globalFilterFn !== void 0 && { globalFilterFn },
@@ -29629,7 +29761,10 @@ function useTableController(options) {
29629
29761
  getCoreRowModel: getCoreRowModel(),
29630
29762
  getSortedRowModel: getSortedRowModel(),
29631
29763
  getFilteredRowModel: getFilteredRowModel(),
29632
- getPaginationRowModel: getPaginationRowModel(),
29764
+ // Only use pagination row model for client-side pagination
29765
+ ...!manualPagination && {
29766
+ getPaginationRowModel: getPaginationRowModel()
29767
+ },
29633
29768
  getFacetedRowModel: getFacetedRowModel(),
29634
29769
  getFacetedUniqueValues: getFacetedUniqueValues(),
29635
29770
  debugTable: false
@@ -29649,52 +29784,32 @@ function useTableController(options) {
29649
29784
  ) : void 0,
29650
29785
  [columnRegistry]
29651
29786
  );
29652
- const handleResetColumns = React.useMemo(() => {
29653
- if (!columnRegistry && !initialState2) return void 0;
29654
- return () => {
29655
- if (storageKey) {
29656
- try {
29657
- localStorage.removeItem(storageKey);
29658
- } catch {
29659
- }
29660
- }
29661
- if (initialState2?.sorting) {
29662
- setSorting([...initialState2.sorting]);
29663
- } else {
29664
- setSorting([]);
29665
- }
29666
- if (registryDefaultVisibility) {
29667
- setColumnVisibility({ ...registryDefaultVisibility });
29668
- } else if (initialState2?.visibility) {
29669
- setColumnVisibility({ ...initialState2.visibility });
29670
- } else {
29671
- setColumnVisibility({});
29672
- }
29673
- if (registryDefaultOrder && registryDefaultOrder.length) {
29674
- setColumnOrder([...registryDefaultOrder]);
29675
- } else if (initialState2?.columnOrder) {
29676
- setColumnOrder([...initialState2.columnOrder]);
29677
- }
29678
- setColumnPinning(
29679
- initialState2?.columnPinning ? {
29680
- left: [...initialState2.columnPinning.left ?? []],
29681
- right: [...initialState2.columnPinning.right ?? []]
29682
- } : { left: [], right: [] }
29683
- );
29684
- table.resetColumnSizing();
29685
- };
29686
- }, [
29687
- columnRegistry,
29688
- initialState2,
29689
- registryDefaultVisibility,
29690
- registryDefaultOrder,
29691
- setColumnVisibility,
29692
- setColumnOrder,
29693
- setColumnPinning,
29694
- setSorting,
29695
- table,
29696
- storageKey
29697
- ]);
29787
+ const handleResetColumns = React.useMemo(
29788
+ () => createResetColumnsHandler({
29789
+ columnRegistry,
29790
+ initialState: initialState2,
29791
+ storageKey,
29792
+ registryDefaultVisibility,
29793
+ registryDefaultOrder,
29794
+ setSorting,
29795
+ setColumnVisibility,
29796
+ setColumnOrder,
29797
+ setColumnPinning,
29798
+ table
29799
+ }),
29800
+ [
29801
+ columnRegistry,
29802
+ initialState2,
29803
+ storageKey,
29804
+ registryDefaultVisibility,
29805
+ registryDefaultOrder,
29806
+ setSorting,
29807
+ setColumnVisibility,
29808
+ setColumnOrder,
29809
+ setColumnPinning,
29810
+ table
29811
+ ]
29812
+ );
29698
29813
  return {
29699
29814
  table,
29700
29815
  resolvedColumns,
@@ -29752,19 +29867,120 @@ function getAlignmentClass(align) {
29752
29867
  return void 0;
29753
29868
  }
29754
29869
  }
29755
- const TABLE_TOKENS = {
29756
- defaultColumnWidth: 160,
29757
- minColumnWidth: 96,
29758
- maxColumnWidth: 420,
29759
- toolbarGap: 8,
29760
- selectionColumnWidth: 44,
29761
- actionsColumnWidth: 64
29762
- };
29763
- function SortableHeader({
29764
- header,
29765
- isDragging,
29766
- activeColumnId,
29767
- clampRef
29870
+ function computeClampBounds(activeId, containerRef) {
29871
+ try {
29872
+ const th = document.querySelector(`th[data-col-id="${activeId}"]`);
29873
+ const container = containerRef.current;
29874
+ if (th && container) {
29875
+ const t = th.getBoundingClientRect();
29876
+ const c2 = container.getBoundingClientRect();
29877
+ return { minX: c2.left - t.left, maxX: c2.right - t.right };
29878
+ }
29879
+ } catch {
29880
+ }
29881
+ return {
29882
+ minX: Number.NEGATIVE_INFINITY,
29883
+ maxX: Number.POSITIVE_INFINITY
29884
+ };
29885
+ }
29886
+ function getVisibleColumnOrder(table, currentOrder) {
29887
+ const groups = table.getHeaderGroups();
29888
+ if (!groups.length) return currentOrder;
29889
+ return groups[0].headers.filter((h) => h.column.getIsVisible()).map((h) => h.column.id);
29890
+ }
29891
+ function useDragAndDrop({
29892
+ table,
29893
+ containerRef
29894
+ }) {
29895
+ const [isDragging, setIsDragging] = React.useState(false);
29896
+ const [activeColumnId, setActiveColumnId] = React.useState(
29897
+ null
29898
+ );
29899
+ const [tempColumnOrder, setTempColumnOrder] = React.useState([]);
29900
+ const clampRef = React.useRef({
29901
+ minX: Number.NEGATIVE_INFINITY,
29902
+ maxX: Number.POSITIVE_INFINITY
29903
+ });
29904
+ const stateColumnOrder = table.getState().columnOrder;
29905
+ const allLeafColumnIds = table.getAllLeafColumns().map((c2) => c2.id);
29906
+ const baseOrder = stateColumnOrder?.length ? stateColumnOrder : allLeafColumnIds;
29907
+ const currentOrder = pinBoundaries(baseOrder);
29908
+ const visibleOrder = getVisibleColumnOrder(table, currentOrder);
29909
+ const renderOrder = pinBoundaries(
29910
+ isDragging && tempColumnOrder.length ? tempColumnOrder : visibleOrder
29911
+ );
29912
+ const sortableHeaderIds = React.useMemo(
29913
+ () => renderOrder.filter((id) => id !== "select" && id !== "actions"),
29914
+ [renderOrder]
29915
+ );
29916
+ const handleDragStart = React.useCallback(
29917
+ (event) => {
29918
+ setIsDragging(true);
29919
+ const activeId = String(event.active.id);
29920
+ setActiveColumnId(activeId);
29921
+ const visible = getVisibleColumnOrder(table, currentOrder);
29922
+ setTempColumnOrder(pinBoundaries(visible));
29923
+ clampRef.current = computeClampBounds(activeId, containerRef);
29924
+ },
29925
+ [currentOrder, table, containerRef]
29926
+ );
29927
+ const handleDragOver = React.useCallback((event) => {
29928
+ const { active, over } = event;
29929
+ if (!over) return;
29930
+ const activeId = String(active.id);
29931
+ const overId = String(over.id);
29932
+ if (activeId === overId) return;
29933
+ setTempColumnOrder((prev) => {
29934
+ const from = prev.indexOf(activeId);
29935
+ const to = prev.indexOf(overId);
29936
+ if (from === -1 || to === -1) return prev;
29937
+ const moved = arrayMove(prev, from, to);
29938
+ if (!moved.includes("select")) return moved;
29939
+ return ["select", ...moved.filter((id) => id !== "select")];
29940
+ });
29941
+ }, []);
29942
+ const handleDragEnd = React.useCallback(
29943
+ (_event) => {
29944
+ setIsDragging(false);
29945
+ setActiveColumnId(null);
29946
+ if (!tempColumnOrder.length) {
29947
+ setTempColumnOrder([]);
29948
+ return;
29949
+ }
29950
+ const normalizedTempOrder = pinBoundaries(tempColumnOrder);
29951
+ const prev = JSON.stringify(currentOrder);
29952
+ const next = JSON.stringify(normalizedTempOrder);
29953
+ if (prev !== next) {
29954
+ table.setColumnOrder(normalizedTempOrder);
29955
+ }
29956
+ setTempColumnOrder([]);
29957
+ },
29958
+ [currentOrder, table, tempColumnOrder]
29959
+ );
29960
+ return {
29961
+ isDragging,
29962
+ activeColumnId,
29963
+ renderOrder,
29964
+ sortableHeaderIds,
29965
+ clampRef,
29966
+ handleDragStart,
29967
+ handleDragOver,
29968
+ handleDragEnd
29969
+ };
29970
+ }
29971
+ const TABLE_TOKENS = {
29972
+ defaultColumnWidth: 160,
29973
+ minColumnWidth: 96,
29974
+ maxColumnWidth: 420,
29975
+ toolbarGap: 8,
29976
+ selectionColumnWidth: 44,
29977
+ actionsColumnWidth: 64
29978
+ };
29979
+ function SortableHeader({
29980
+ header,
29981
+ isDragging,
29982
+ activeColumnId,
29983
+ clampRef
29768
29984
  }) {
29769
29985
  const id = header.column.id;
29770
29986
  const {
@@ -29881,7 +30097,7 @@ function TableHeader({
29881
30097
  "thead",
29882
30098
  {
29883
30099
  "data-scrolled": isBodyScrolled || void 0,
29884
- className: "sticky top-0 z-10 bg-[var(--tablehead-bg)] border-b border-[var(--tablehead-border)] shadow-none data-[scrolled=true]:shadow-sm",
30100
+ className: "sticky top-0 z-10 bg-[var(--tablehead-bg)] shadow-none data-[scrolled=true]:shadow-sm",
29885
30101
  children: headerGroups.map((headerGroup) => {
29886
30102
  const selectHeader = headerGroup.headers.find(
29887
30103
  (h) => h.column.id === "select" && h.column.getIsVisible()
@@ -29896,7 +30112,7 @@ function TableHeader({
29896
30112
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
29897
30113
  "tr",
29898
30114
  {
29899
- className: "border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",
30115
+ className: "transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",
29900
30116
  children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
29901
30117
  SortableContext,
29902
30118
  {
@@ -29907,7 +30123,7 @@ function TableHeader({
29907
30123
  TableHead$1,
29908
30124
  {
29909
30125
  className: cn$1(
29910
- "relative group border-b-0 p-0",
30126
+ "relative group p-0",
29911
30127
  getAlignmentClass(
29912
30128
  selectHeader.column.columnDef.meta?.align
29913
30129
  )
@@ -29947,7 +30163,7 @@ function TableHeader({
29947
30163
  TableHead$1,
29948
30164
  {
29949
30165
  className: cn$1(
29950
- "relative group border-b-0",
30166
+ "relative group",
29951
30167
  getAlignmentClass(
29952
30168
  actionsHeader.column.columnDef.meta?.align
29953
30169
  )
@@ -30035,71 +30251,115 @@ function CellContent({
30035
30251
  }, [isRightAligned]);
30036
30252
  return /* @__PURE__ */ jsxRuntimeExports.jsx("span", { ref, className: "mmc-table-cell__content", children });
30037
30253
  }
30254
+ function renderSkeletonRows(skeletonRowCount, resolvedColumns) {
30255
+ return [...Array(skeletonRowCount)].map((_, rowIndex) => {
30256
+ const rowKey = `skeleton-row-${rowIndex}`;
30257
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("tr", { className: "border-b", children: resolvedColumns.map((column, colIndex) => {
30258
+ const columnId = column.id || `skeleton-col-${rowIndex}-${colIndex}`;
30259
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
30260
+ "td",
30261
+ {
30262
+ className: cn$1(
30263
+ "px-4 py-2.5 align-middle text-xs font-normal transition-all duration-300 ease-[cubic-bezier(0.23,1,0.32,1)] will-change-transform",
30264
+ getAlignmentClass(column.meta?.align)
30265
+ ),
30266
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-[21.333px] w-full" })
30267
+ },
30268
+ columnId
30269
+ );
30270
+ }) }, rowKey);
30271
+ });
30272
+ }
30273
+ function createFixedWidthStyle(width) {
30274
+ return {
30275
+ width,
30276
+ minWidth: width,
30277
+ maxWidth: width
30278
+ };
30279
+ }
30280
+ function renderTableCell(cell, isDragging, activeColumnId) {
30281
+ const isOtherColumnDimmed = isDragging && activeColumnId != null && cell.column.id !== activeColumnId && cell.column.id !== "select";
30282
+ let cellPaddingClass;
30283
+ if (cell.column.id === "select") {
30284
+ cellPaddingClass = "p-0";
30285
+ } else {
30286
+ cellPaddingClass = "[&:has([role=checkbox])]:pr-0";
30287
+ }
30288
+ const actionsPaddingClass = cell.column.id === "actions" ? "py-1.5" : void 0;
30289
+ let cellStyle;
30290
+ if (cell.column.id === "select") {
30291
+ cellStyle = createFixedWidthStyle(TABLE_TOKENS.selectionColumnWidth);
30292
+ } else if (cell.column.id === "actions") {
30293
+ cellStyle = createFixedWidthStyle(TABLE_TOKENS.actionsColumnWidth);
30294
+ } else {
30295
+ cellStyle = { width: cell.column.getSize() };
30296
+ }
30297
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
30298
+ "td",
30299
+ {
30300
+ className: cn$1(
30301
+ "px-4 py-2.5 align-middle text-xs font-normal",
30302
+ cellPaddingClass,
30303
+ actionsPaddingClass,
30304
+ getAlignmentClass(
30305
+ cell.column.columnDef.meta?.align
30306
+ ),
30307
+ isOtherColumnDimmed ? "opacity-40" : void 0
30308
+ ),
30309
+ style: cellStyle,
30310
+ "data-col-id": cell.column.id,
30311
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(
30312
+ CellContent,
30313
+ {
30314
+ align: cell.column.columnDef.meta?.align,
30315
+ children: flexRender(cell.column.columnDef.cell, cell.getContext())
30316
+ }
30317
+ )
30318
+ },
30319
+ cell.id
30320
+ );
30321
+ }
30322
+ function getVisibleCellsInOrder(row, isDragging, renderOrder) {
30323
+ if (!isDragging) {
30324
+ return row.getVisibleCells();
30325
+ }
30326
+ return row.getVisibleCells().slice().sort((a2, b) => {
30327
+ const ia = renderOrder.indexOf(a2.column.id);
30328
+ const ib = renderOrder.indexOf(b.column.id);
30329
+ return ia - ib;
30330
+ });
30331
+ }
30038
30332
  function TableBody({
30039
30333
  loading,
30040
30334
  resolvedColumns,
30041
30335
  rows,
30042
30336
  renderOrder,
30043
30337
  isDragging,
30044
- activeColumnId
30338
+ activeColumnId,
30339
+ skeletonRowCount = 5
30045
30340
  }) {
30046
- return /* @__PURE__ */ jsxRuntimeExports.jsx("tbody", { className: "[&_tr:last-child]:border-0", children: loading ? [...Array(5)].map((_, i) => /* @__PURE__ */ jsxRuntimeExports.jsx("tr", { children: resolvedColumns.map((column, j) => /* @__PURE__ */ jsxRuntimeExports.jsx(
30047
- "td",
30048
- {
30049
- className: cn$1(
30050
- "px-4 py-2.5 align-middle text-xs font-normal transition-all duration-300 ease-[cubic-bezier(0.23,1,0.32,1)] will-change-transform",
30051
- getAlignmentClass(column.meta?.align)
30052
- ),
30053
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-6 w-full" })
30054
- },
30055
- j
30056
- )) }, i)) : rows?.length ? rows.map((row) => /* @__PURE__ */ jsxRuntimeExports.jsx(
30057
- "tr",
30058
- {
30059
- "data-state": row.getIsSelected() && "selected",
30060
- className: "border-b transition-colors hover:bg-[var(--accent)] data-[state=selected]:bg-muted",
30061
- children: (isDragging ? row.getVisibleCells().slice().sort((a2, b) => {
30062
- const ia = renderOrder.indexOf(a2.column.id);
30063
- const ib = renderOrder.indexOf(b.column.id);
30064
- return ia - ib;
30065
- }) : row.getVisibleCells()).map((cell) => {
30066
- const isOtherColumnDimmed = isDragging && activeColumnId != null && cell.column.id !== activeColumnId && cell.column.id !== "select";
30067
- return /* @__PURE__ */ jsxRuntimeExports.jsx(
30068
- "td",
30069
- {
30070
- className: cn$1(
30071
- "px-4 py-2.5 align-middle text-xs font-normal",
30072
- cell.column.id === "select" ? "p-0" : "[&:has([role=checkbox])]:pr-0",
30073
- cell.column.id === "actions" ? "py-1.5" : void 0,
30074
- getAlignmentClass(
30075
- cell.column.columnDef.meta?.align
30076
- ),
30077
- isOtherColumnDimmed ? "opacity-40" : void 0
30078
- ),
30079
- style: cell.column.id === "select" ? {
30080
- width: TABLE_TOKENS.selectionColumnWidth,
30081
- minWidth: TABLE_TOKENS.selectionColumnWidth,
30082
- maxWidth: TABLE_TOKENS.selectionColumnWidth
30083
- } : cell.column.id === "actions" ? {
30084
- width: TABLE_TOKENS.actionsColumnWidth,
30085
- minWidth: TABLE_TOKENS.actionsColumnWidth,
30086
- maxWidth: TABLE_TOKENS.actionsColumnWidth
30087
- } : { width: cell.column.getSize() },
30088
- "data-col-id": cell.column.id,
30089
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(
30090
- CellContent,
30091
- {
30092
- align: cell.column.columnDef.meta?.align,
30093
- children: flexRender(cell.column.columnDef.cell, cell.getContext())
30094
- }
30095
- )
30096
- },
30097
- cell.id
30098
- );
30099
- })
30100
- },
30101
- row.id
30102
- )) : /* @__PURE__ */ jsxRuntimeExports.jsx("tr", { children: /* @__PURE__ */ jsxRuntimeExports.jsx("td", { colSpan: resolvedColumns.length, className: "h-24 text-center", children: "No results." }) }) });
30341
+ let tableContent;
30342
+ if (loading) {
30343
+ tableContent = renderSkeletonRows(skeletonRowCount, resolvedColumns);
30344
+ } else if (rows?.length) {
30345
+ tableContent = rows.map((row) => {
30346
+ const visibleCells = getVisibleCellsInOrder(row, isDragging, renderOrder);
30347
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
30348
+ "tr",
30349
+ {
30350
+ "data-state": row.getIsSelected() && "selected",
30351
+ className: "border-b transition-colors hover:bg-[var(--accent)] data-[state=selected]:bg-muted",
30352
+ children: visibleCells.map(
30353
+ (cell) => renderTableCell(cell, isDragging, activeColumnId)
30354
+ )
30355
+ },
30356
+ row.id
30357
+ );
30358
+ });
30359
+ } else {
30360
+ tableContent = /* @__PURE__ */ jsxRuntimeExports.jsx("tr", { children: /* @__PURE__ */ jsxRuntimeExports.jsx("td", { colSpan: resolvedColumns.length, className: "h-24 text-center", children: "No results." }) });
30361
+ }
30362
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("tbody", { className: "[&_tr:last-child]:border-0", children: tableContent });
30103
30363
  }
30104
30364
  function BatchActionsToolbar({
30105
30365
  selectedCount,
@@ -30140,6 +30400,149 @@ function ColGroup({ columns, debug: debug2 }) {
30140
30400
  return /* @__PURE__ */ jsxRuntimeExports.jsx("col", { style: { width } }, String(col.id));
30141
30401
  }) });
30142
30402
  }
30403
+ function useDataTableHandlers({
30404
+ table,
30405
+ controllerOnBatchAction,
30406
+ onPaginationChange,
30407
+ setIsBodyScrolled,
30408
+ isBodyScrolled
30409
+ }) {
30410
+ const handleBatchAction = React.useCallback(
30411
+ (action) => {
30412
+ if (!controllerOnBatchAction) return;
30413
+ const selectedRows = table.getFilteredSelectedRowModel().rows.map((row) => row.original);
30414
+ controllerOnBatchAction(action, selectedRows);
30415
+ },
30416
+ [controllerOnBatchAction, table]
30417
+ );
30418
+ const handleScroll2 = React.useCallback(
30419
+ (e) => {
30420
+ const scrolled = (e.currentTarget?.scrollTop ?? 0) > 0;
30421
+ if (scrolled !== isBodyScrolled) setIsBodyScrolled(scrolled);
30422
+ },
30423
+ [isBodyScrolled, setIsBodyScrolled]
30424
+ );
30425
+ const handlePageChange = React.useCallback(
30426
+ (pageIndex) => {
30427
+ if (!onPaginationChange) return;
30428
+ onPaginationChange(
30429
+ pageIndex,
30430
+ table.getState().pagination?.pageSize ?? 25
30431
+ );
30432
+ },
30433
+ [onPaginationChange, table]
30434
+ );
30435
+ const handlePageSizeChange = React.useCallback(
30436
+ (pageSize) => {
30437
+ if (!onPaginationChange) return;
30438
+ onPaginationChange(table.getState().pagination?.pageIndex ?? 0, pageSize);
30439
+ },
30440
+ [onPaginationChange, table]
30441
+ );
30442
+ const handleExport = React.useCallback(() => {
30443
+ exportTableToCSV(table);
30444
+ }, [table]);
30445
+ return {
30446
+ handleBatchAction,
30447
+ handleScroll: handleScroll2,
30448
+ handlePageChange,
30449
+ handlePageSizeChange,
30450
+ handleExport
30451
+ };
30452
+ }
30453
+ function renderEmptyState(emptyState) {
30454
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
30455
+ "div",
30456
+ {
30457
+ className: "mmc-table-empty flex h-full w-full items-center justify-center",
30458
+ role: "region",
30459
+ "aria-label": "Empty state",
30460
+ children: emptyState
30461
+ }
30462
+ );
30463
+ }
30464
+ function renderTableLayout({
30465
+ toolbar,
30466
+ batchActions,
30467
+ scrollArea,
30468
+ pagination
30469
+ }) {
30470
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "w-full flex flex-col min-h-0", children: [
30471
+ toolbar,
30472
+ batchActions,
30473
+ scrollArea,
30474
+ pagination
30475
+ ] });
30476
+ }
30477
+ function renderTableContent({
30478
+ table,
30479
+ loading,
30480
+ resolvedColumns,
30481
+ renderOrder,
30482
+ isDragging,
30483
+ activeColumnId,
30484
+ skeletonRowCount,
30485
+ isBodyScrolled,
30486
+ sortableHeaderIds,
30487
+ clampRef,
30488
+ sensors,
30489
+ handleDragStart,
30490
+ handleDragOver,
30491
+ handleDragEnd,
30492
+ tableRef,
30493
+ debug: debug2
30494
+ }) {
30495
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
30496
+ DndContext,
30497
+ {
30498
+ sensors,
30499
+ collisionDetection: closestCenter,
30500
+ modifiers: [restrictToHorizontalAxis],
30501
+ onDragStart: handleDragStart,
30502
+ onDragOver: handleDragOver,
30503
+ onDragEnd: handleDragEnd,
30504
+ children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
30505
+ "table",
30506
+ {
30507
+ ref: tableRef,
30508
+ className: "w-full caption-bottom text-sm table-fixed",
30509
+ children: [
30510
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
30511
+ ColGroup,
30512
+ {
30513
+ columns: table.getVisibleLeafColumns(),
30514
+ debug: debug2
30515
+ }
30516
+ ),
30517
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
30518
+ TableHeader,
30519
+ {
30520
+ headerGroups: table.getHeaderGroups(),
30521
+ sortableHeaderIds,
30522
+ isBodyScrolled,
30523
+ isDragging,
30524
+ activeColumnId,
30525
+ clampRef
30526
+ }
30527
+ ),
30528
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
30529
+ TableBody,
30530
+ {
30531
+ loading,
30532
+ resolvedColumns,
30533
+ rows: table.getRowModel().rows,
30534
+ renderOrder,
30535
+ isDragging,
30536
+ activeColumnId,
30537
+ skeletonRowCount
30538
+ }
30539
+ )
30540
+ ]
30541
+ }
30542
+ )
30543
+ }
30544
+ );
30545
+ }
30143
30546
  function DataTable({
30144
30547
  columns,
30145
30548
  data,
@@ -30150,6 +30553,9 @@ function DataTable({
30150
30553
  toolbar,
30151
30554
  emptyState,
30152
30555
  forceEmptyState,
30556
+ manualPagination = false,
30557
+ pageCount,
30558
+ totalRowCount,
30153
30559
  onRowSelectionChange,
30154
30560
  onSortingChange,
30155
30561
  onPaginationChange,
@@ -30179,6 +30585,8 @@ function DataTable({
30179
30585
  tableId,
30180
30586
  disableGlobalFilter: toolbar?.disableGlobalFilter,
30181
30587
  customGlobalFilterFn,
30588
+ manualPagination,
30589
+ pageCount,
30182
30590
  onRowSelectionChange,
30183
30591
  onSortingChange,
30184
30592
  onPaginationChange,
@@ -30188,208 +30596,110 @@ function DataTable({
30188
30596
  onRowClick,
30189
30597
  onExportComplete
30190
30598
  });
30191
- const [isDragging, setIsDragging] = React.useState(false);
30192
- const [activeColumnId, setActiveColumnId] = React.useState(
30193
- null
30194
- );
30195
- const [tempColumnOrder, setTempColumnOrder] = React.useState([]);
30196
30599
  const containerRef = React.useRef(null);
30197
30600
  const tableRef = React.useRef(null);
30198
- const clampRef = React.useRef({
30199
- minX: Number.NEGATIVE_INFINITY,
30200
- maxX: Number.POSITIVE_INFINITY
30201
- });
30202
30601
  const [isBodyScrolled, setIsBodyScrolled] = React.useState(false);
30203
30602
  const sensors = useSensors(
30204
30603
  useSensor(PointerSensor, { activationConstraint: { distance: 10 } }),
30205
30604
  useSensor(KeyboardSensor)
30206
30605
  );
30207
- const stateColumnOrder = table.getState().columnOrder;
30208
- const allLeafColumnIds = table.getAllLeafColumns().map((c2) => c2.id);
30209
- const baseOrder = stateColumnOrder?.length ? stateColumnOrder : allLeafColumnIds;
30210
- const currentOrder = pinBoundaries(baseOrder);
30211
- const headerGroups = table.getHeaderGroups();
30212
- const visibleOrder = headerGroups.length ? headerGroups[0].headers.filter((h) => h.column.getIsVisible()).map((h) => h.column.id) : currentOrder;
30213
- const renderOrder = pinBoundaries(
30214
- isDragging && tempColumnOrder.length ? tempColumnOrder : visibleOrder
30215
- );
30216
- const sortableHeaderIds = React.useMemo(
30217
- () => renderOrder.filter((id) => id !== "select" && id !== "actions"),
30218
- [renderOrder]
30219
- );
30220
- const handleDragStart = React.useCallback(
30221
- (event) => {
30222
- setIsDragging(true);
30223
- setActiveColumnId(String(event.active.id));
30224
- const groups = table.getHeaderGroups();
30225
- const visible = groups.length ? groups[0].headers.filter((h) => h.column.getIsVisible()).map((h) => h.column.id) : currentOrder;
30226
- setTempColumnOrder(pinBoundaries(visible));
30227
- try {
30228
- const activeId = String(event.active.id);
30229
- const th = document.querySelector(`th[data-col-id="${activeId}"]`);
30230
- const container = containerRef.current;
30231
- if (th && container) {
30232
- const t = th.getBoundingClientRect();
30233
- const c2 = container.getBoundingClientRect();
30234
- clampRef.current = { minX: c2.left - t.left, maxX: c2.right - t.right };
30235
- } else {
30236
- clampRef.current = {
30237
- minX: Number.NEGATIVE_INFINITY,
30238
- maxX: Number.POSITIVE_INFINITY
30239
- };
30240
- }
30241
- } catch {
30242
- clampRef.current = {
30243
- minX: Number.NEGATIVE_INFINITY,
30244
- maxX: Number.POSITIVE_INFINITY
30245
- };
30246
- }
30247
- },
30248
- [currentOrder, table]
30606
+ const {
30607
+ isDragging,
30608
+ activeColumnId,
30609
+ renderOrder,
30610
+ sortableHeaderIds,
30611
+ clampRef,
30612
+ handleDragStart,
30613
+ handleDragOver,
30614
+ handleDragEnd
30615
+ } = useDragAndDrop({
30616
+ table,
30617
+ containerRef
30618
+ });
30619
+ const {
30620
+ handleBatchAction,
30621
+ handleScroll: handleScroll2,
30622
+ handlePageChange,
30623
+ handlePageSizeChange,
30624
+ handleExport
30625
+ } = useDataTableHandlers({
30626
+ table,
30627
+ controllerOnBatchAction,
30628
+ onPaginationChange,
30629
+ setIsBodyScrolled,
30630
+ isBodyScrolled
30631
+ });
30632
+ const isForcedEmpty = !loading && Boolean(forceEmptyState) && Boolean(emptyState);
30633
+ const selectedRowCount = table.getFilteredSelectedRowModel().rows.length;
30634
+ const hasSelectedRows = selectedRowCount > 0;
30635
+ const skeletonRowCount = loading ? table.getState().pagination?.pageSize ?? 25 : void 0;
30636
+ const batchActionHandler = controllerOnBatchAction ? handleBatchAction : void 0;
30637
+ const pageChangeHandler = onPaginationChange ? handlePageChange : void 0;
30638
+ const pageSizeChangeHandler = onPaginationChange ? handlePageSizeChange : void 0;
30639
+ const tableContent = isForcedEmpty ? renderEmptyState(emptyState) : renderTableContent({
30640
+ table,
30641
+ loading,
30642
+ resolvedColumns,
30643
+ renderOrder,
30644
+ isDragging,
30645
+ activeColumnId,
30646
+ skeletonRowCount,
30647
+ isBodyScrolled,
30648
+ sortableHeaderIds,
30649
+ clampRef,
30650
+ sensors,
30651
+ handleDragStart,
30652
+ handleDragOver,
30653
+ handleDragEnd,
30654
+ tableRef,
30655
+ debug: debug2
30656
+ });
30657
+ const toolbarElement = /* @__PURE__ */ jsxRuntimeExports.jsx(
30658
+ DataTableToolbar,
30659
+ {
30660
+ table,
30661
+ loading,
30662
+ globalFilter: globalFilter ?? "",
30663
+ onGlobalFilterChange: setGlobalFilter,
30664
+ onResetColumns: handleResetColumns,
30665
+ columnRegistry,
30666
+ onExport: handleExport,
30667
+ onExportComplete: controllerOnExportComplete,
30668
+ options: toolbar
30669
+ }
30249
30670
  );
30250
- const handleDragOver = React.useCallback((event) => {
30251
- const { active, over } = event;
30252
- if (!over) return;
30253
- const activeId = String(active.id);
30254
- const overId = String(over.id);
30255
- if (activeId === overId) return;
30256
- setTempColumnOrder((prev) => {
30257
- const from = prev.indexOf(activeId);
30258
- const to = prev.indexOf(overId);
30259
- if (from === -1 || to === -1) return prev;
30260
- const moved = arrayMove(prev, from, to);
30261
- if (moved.includes("select")) {
30262
- const next = ["select", ...moved.filter((id) => id !== "select")];
30263
- return next;
30264
- }
30265
- return moved;
30266
- });
30267
- }, []);
30268
- const handleDragEnd = React.useCallback(
30269
- (_event) => {
30270
- setIsDragging(false);
30271
- setActiveColumnId(null);
30272
- if (!tempColumnOrder.length) return;
30273
- const normalizedTempOrder = pinBoundaries(tempColumnOrder);
30274
- const prev = JSON.stringify(currentOrder);
30275
- const next = JSON.stringify(normalizedTempOrder);
30276
- if (prev !== next) {
30277
- table.setColumnOrder(normalizedTempOrder);
30278
- }
30279
- setTempColumnOrder([]);
30280
- },
30281
- [currentOrder, table, tempColumnOrder]
30671
+ const batchActions = hasSelectedRows ? /* @__PURE__ */ jsxRuntimeExports.jsx(
30672
+ BatchActionsToolbar,
30673
+ {
30674
+ selectedCount: selectedRowCount,
30675
+ onBatchAction: batchActionHandler
30676
+ }
30677
+ ) : null;
30678
+ const scrollArea = /* @__PURE__ */ jsxRuntimeExports.jsx(
30679
+ "div",
30680
+ {
30681
+ className: "relative w-full flex-1 min-h-0 overflow-auto",
30682
+ ref: containerRef,
30683
+ onScroll: handleScroll2,
30684
+ children: tableContent
30685
+ }
30282
30686
  );
30283
- const isForcedEmpty = !loading && Boolean(forceEmptyState) && Boolean(emptyState);
30284
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "w-full h-full flex flex-col min-h-0", children: [
30285
- /* @__PURE__ */ jsxRuntimeExports.jsx(
30286
- DataTableToolbar,
30287
- {
30288
- table,
30289
- loading,
30290
- globalFilter: globalFilter ?? "",
30291
- onGlobalFilterChange: setGlobalFilter,
30292
- onResetColumns: handleResetColumns,
30293
- columnRegistry,
30294
- onExport: () => exportTableToCSV(table),
30295
- onExportComplete: controllerOnExportComplete,
30296
- options: toolbar
30297
- }
30298
- ),
30299
- table.getFilteredSelectedRowModel().rows.length > 0 && /* @__PURE__ */ jsxRuntimeExports.jsx(
30300
- BatchActionsToolbar,
30301
- {
30302
- selectedCount: table.getFilteredSelectedRowModel().rows.length,
30303
- onBatchAction: controllerOnBatchAction ? (action) => {
30304
- const selectedRows = table.getFilteredSelectedRowModel().rows.map((row) => row.original);
30305
- controllerOnBatchAction(action, selectedRows);
30306
- } : void 0
30307
- }
30308
- ),
30309
- /* @__PURE__ */ jsxRuntimeExports.jsx(
30310
- "div",
30311
- {
30312
- className: "relative w-full flex-1 min-h-0 overflow-auto",
30313
- ref: containerRef,
30314
- onScroll: (e) => {
30315
- const t = e.currentTarget;
30316
- const scrolled = (t?.scrollTop ?? 0) > 0;
30317
- if (scrolled !== isBodyScrolled) setIsBodyScrolled(scrolled);
30318
- },
30319
- children: isForcedEmpty ? /* @__PURE__ */ jsxRuntimeExports.jsx(
30320
- "div",
30321
- {
30322
- className: "mmc-table-empty flex h-full w-full items-center justify-center",
30323
- role: "region",
30324
- "aria-label": "Empty state",
30325
- children: emptyState
30326
- }
30327
- ) : /* @__PURE__ */ jsxRuntimeExports.jsx(
30328
- DndContext,
30329
- {
30330
- sensors,
30331
- collisionDetection: closestCenter,
30332
- modifiers: [restrictToHorizontalAxis],
30333
- onDragStart: handleDragStart,
30334
- onDragOver: handleDragOver,
30335
- onDragEnd: handleDragEnd,
30336
- children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
30337
- "table",
30338
- {
30339
- ref: tableRef,
30340
- className: "w-full caption-bottom text-sm table-fixed",
30341
- children: [
30342
- /* @__PURE__ */ jsxRuntimeExports.jsx(
30343
- ColGroup,
30344
- {
30345
- columns: table.getVisibleLeafColumns(),
30346
- debug: debug2
30347
- }
30348
- ),
30349
- /* @__PURE__ */ jsxRuntimeExports.jsx(
30350
- TableHeader,
30351
- {
30352
- headerGroups: table.getHeaderGroups(),
30353
- sortableHeaderIds,
30354
- isBodyScrolled,
30355
- isDragging,
30356
- activeColumnId,
30357
- clampRef
30358
- }
30359
- ),
30360
- /* @__PURE__ */ jsxRuntimeExports.jsx(
30361
- TableBody,
30362
- {
30363
- loading,
30364
- resolvedColumns,
30365
- rows: table.getRowModel().rows,
30366
- renderOrder,
30367
- isDragging,
30368
- activeColumnId
30369
- }
30370
- )
30371
- ]
30372
- }
30373
- )
30374
- }
30375
- )
30376
- }
30377
- ),
30378
- isForcedEmpty ? null : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "border-t border-border bg-[var(--tablehead-bg)]", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
30379
- DataTablePagination,
30380
- {
30381
- table,
30382
- onPageChange: onPaginationChange ? (pageIndex) => onPaginationChange(
30383
- pageIndex,
30384
- table.getState().pagination?.pageSize ?? 25
30385
- ) : void 0,
30386
- onPageSizeChange: onPaginationChange ? (pageSize) => onPaginationChange(
30387
- table.getState().pagination?.pageIndex ?? 0,
30388
- pageSize
30389
- ) : void 0
30390
- }
30391
- ) })
30392
- ] });
30687
+ const pagination = !isForcedEmpty ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-shrink-0 border-t border-border bg-[var(--tablehead-bg)]", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
30688
+ DataTablePagination,
30689
+ {
30690
+ table,
30691
+ manualPagination,
30692
+ totalRowCount,
30693
+ onPageChange: pageChangeHandler,
30694
+ onPageSizeChange: pageSizeChangeHandler
30695
+ }
30696
+ ) }) : null;
30697
+ return renderTableLayout({
30698
+ toolbar: toolbarElement,
30699
+ batchActions,
30700
+ scrollArea,
30701
+ pagination
30702
+ });
30393
30703
  }
30394
30704
  const ALIGNMENT_PRESETS = {
30395
30705
  NAME: "left",
@@ -31955,7 +32265,7 @@ const TableHead = React.forwardRef(({ className, ...props }, ref) => /* @__PURE_
31955
32265
  ref,
31956
32266
  "data-slot": "table-head",
31957
32267
  className: cn$1(
31958
- "h-10 px-4 text-left align-middle text-xs font-semibold bg-[var(--tablehead-bg)] text-[var(--tablehead-fg)] border-b border-[var(--tablehead-border)] [&:has([role=checkbox])]:pr-0 [&:has([role=checkbox])]:pl-0",
32268
+ "h-10 px-4 text-left align-middle text-xs font-semibold bg-[var(--tablehead-bg)] text-[var(--tablehead-fg)] [&:has([role=checkbox])]:pr-0 [&:has([role=checkbox])]:pl-0",
31959
32269
  // Enforce header button/controls to 12px/600
31960
32270
  "[&_button]:text-xs [&_button]:font-semibold [&_[data-slot='button']]:text-xs [&_[data-slot='button']]:font-semibold",
31961
32271
  className
@@ -32047,6 +32357,9 @@ function ResponsiveTable({
32047
32357
  toolbarOptions,
32048
32358
  emptyState,
32049
32359
  forceEmptyState,
32360
+ manualPagination,
32361
+ pageCount,
32362
+ totalRowCount,
32050
32363
  onRowSelectionChange,
32051
32364
  onSortingChange,
32052
32365
  onPaginationChange,
@@ -32071,6 +32384,9 @@ function ResponsiveTable({
32071
32384
  toolbar: toolbarOptions,
32072
32385
  emptyState,
32073
32386
  forceEmptyState,
32387
+ manualPagination,
32388
+ pageCount,
32389
+ totalRowCount,
32074
32390
  onRowSelectionChange,
32075
32391
  onSortingChange,
32076
32392
  onPaginationChange,
@@ -32396,10 +32712,7 @@ const Progress = React.forwardRef(({ className, value, ...props }, ref) => {
32396
32712
  "aria-valuemax": 100,
32397
32713
  "aria-valuenow": typeof clamped === "number" ? clamped : void 0,
32398
32714
  "data-unknown": typeof clamped !== "number" ? "true" : void 0,
32399
- className: cn$1(
32400
- "relative h-2 w-full overflow-hidden rounded-full",
32401
- className
32402
- ),
32715
+ className: cn$1("relative h-2 w-full overflow-hidden", className),
32403
32716
  ...props,
32404
32717
  children: /* @__PURE__ */ jsxRuntimeExports.jsx(
32405
32718
  Indicator,