@addsign/moje-agenda-shared-lib 2.0.50 → 2.0.51

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.
@@ -25,6 +25,7 @@ import {
25
25
  MdClose,
26
26
  MdOutlineFilterAlt,
27
27
  MdOutlineFilterAltOff,
28
+ MdOutlineUnfoldMore,
28
29
  MdSearch,
29
30
  } from "react-icons/md";
30
31
  import SelectField from "../form/SelectField";
@@ -116,6 +117,11 @@ function DataTableServer<T extends DataTableInternalItems>({
116
117
  setMinWidth = false,
117
118
  }: DataTableServerProps<T>) {
118
119
  const abortControllerRef = useRef<AbortController | null>(null);
120
+ const topScrollbarRef = useRef<HTMLDivElement | null>(null);
121
+ const bottomScrollbarRef = useRef<HTMLDivElement | null>(null);
122
+ const tableRef = useRef<HTMLTableElement | null>(null);
123
+ const syncWidthRef = useRef<HTMLDivElement | null>(null);
124
+
119
125
  const [itemsPerPageLocal, setItemsPerPageLocal] = useState<number>();
120
126
  const federationContext = useFederationContext();
121
127
  const [data, setData] = useState<IPageable<T>>();
@@ -374,18 +380,10 @@ function DataTableServer<T extends DataTableInternalItems>({
374
380
  ) : sortConfig.direction === "desc" ? (
375
381
  <MdArrowDownward fontSize="small" />
376
382
  ) : (
377
- <MdArrowUpward
378
- fontSize="small"
379
- className="text-gray-300 invisible group-hover:visible "
380
- />
383
+ <MdOutlineUnfoldMore fontSize="small" className=" " />
381
384
  );
382
385
  }
383
- return (
384
- <MdArrowUpward
385
- fontSize="small"
386
- className="text-gray-300 invisible group-hover:visible "
387
- />
388
- );
386
+ return <MdOutlineUnfoldMore fontSize="small" className=" " />;
389
387
  };
390
388
 
391
389
  const handleSelectItem = (item: T) => {
@@ -633,6 +631,53 @@ function DataTableServer<T extends DataTableInternalItems>({
633
631
  columns,
634
632
  ]);
635
633
 
634
+ // Update sync width to match table content width
635
+ const updateSyncWidth = useCallback(() => {
636
+ if (tableRef.current && syncWidthRef.current && setMinWidth) {
637
+ syncWidthRef.current.style.width = tableRef.current.scrollWidth + "px";
638
+ }
639
+ }, [setMinWidth]);
640
+
641
+ // Set up scroll synchronization between top and bottom scrollbars
642
+ useEffect(() => {
643
+ if (!setMinWidth) return;
644
+ const topScrollbar = topScrollbarRef.current;
645
+ const bottomScrollbar = bottomScrollbarRef.current;
646
+
647
+ if (!topScrollbar || !bottomScrollbar) return;
648
+
649
+ const handleTopScroll = () => {
650
+ bottomScrollbar.scrollLeft = topScrollbar.scrollLeft;
651
+ };
652
+
653
+ const handleBottomScroll = () => {
654
+ topScrollbar.scrollLeft = bottomScrollbar.scrollLeft;
655
+ };
656
+
657
+ topScrollbar.addEventListener("scroll", handleTopScroll);
658
+ bottomScrollbar.addEventListener("scroll", handleBottomScroll);
659
+
660
+ return () => {
661
+ topScrollbar.removeEventListener("scroll", handleTopScroll);
662
+ bottomScrollbar.removeEventListener("scroll", handleBottomScroll);
663
+ };
664
+ }, [setMinWidth]);
665
+
666
+ // Set up ResizeObserver to update sync width when table content changes
667
+ useEffect(() => {
668
+ if (!tableRef.current) return;
669
+
670
+ const resizeObserver = new ResizeObserver(updateSyncWidth);
671
+ resizeObserver.observe(tableRef.current);
672
+
673
+ // Initial update
674
+ updateSyncWidth();
675
+
676
+ return () => {
677
+ resizeObserver.disconnect();
678
+ };
679
+ }, [updateSyncWidth, data, isLoading]);
680
+
636
681
  const handleItemsPerPageChange = (
637
682
  event: React.ChangeEvent<HTMLSelectElement>
638
683
  ) => {
@@ -706,8 +751,17 @@ function DataTableServer<T extends DataTableInternalItems>({
706
751
  )}
707
752
  </div>
708
753
  )}
709
- <div className="overflow-auto min-h-[500px]">
754
+ {/* Top horizontal scrollbar */}
755
+ {setMinWidth && (
756
+ <div ref={topScrollbarRef} className="overflow-x-auto h-4 mb-1 mmmmm">
757
+ <div ref={syncWidthRef} className="h-full"></div>
758
+ </div>
759
+ )}
760
+
761
+ {/* Main scrollable content area */}
762
+ <div ref={bottomScrollbarRef} className="overflow-auto min-h-[500px]">
710
763
  <table
764
+ ref={tableRef}
711
765
  className="w-full leading-normal"
712
766
  key={tableKey}
713
767
  data-cy={"datatable-table-" + id}
@@ -9,7 +9,7 @@ export default function PageTitle({
9
9
  ...props
10
10
  }: IPageTitleProps) {
11
11
  // Combine textSize with the other fixed class names
12
- const className = ` text-muted-foreground ${textSize} font-medium font-['Inter'] leading-7 mb-5`;
12
+ const className = ` text-foreground ${textSize} font-medium font-['Inter'] leading-7 mb-5`;
13
13
 
14
14
  return (
15
15
  <h1 {...props} className={className}>
@@ -10,7 +10,7 @@ export default function SectionTitle({
10
10
  ...props
11
11
  }: ISectionTitleProps) {
12
12
  // Combine textSize with the other fixed class names
13
- const className = ` text-muted-foreground ${textSize} font-semibold font-['Inter'] leading-7 mb-3`;
13
+ const className = `text-foreground ${textSize} font-semibold font-['Inter'] leading-7 mb-3`;
14
14
 
15
15
  return (
16
16
  <div className="border-b border-gray-300 pt-2 mb-5 ">
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@addsign/moje-agenda-shared-lib",
3
3
  "private": false,
4
- "version": "2.0.50",
4
+ "version": "2.0.51",
5
5
  "type": "module",
6
6
  "main": "dist/main.js",
7
7
  "types": "dist/main.d.ts",