@addsign/moje-agenda-shared-lib 2.0.49 → 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.
Files changed (33) hide show
  1. package/dist/assets/style.css +3 -0
  2. package/dist/components/datatable/DataTable.js +1 -1
  3. package/dist/components/datatable/DataTableServer.d.ts +2 -1
  4. package/dist/components/datatable/DataTableServer.js +48 -17
  5. package/dist/components/datatable/DataTableServer.js.map +1 -1
  6. package/dist/components/datatable/DatatableSettings.js +1 -1
  7. package/dist/components/datatable/Resizable.d.ts +2 -1
  8. package/dist/components/datatable/Resizable.js +11 -4
  9. package/dist/components/datatable/Resizable.js.map +1 -1
  10. package/dist/components/form/AutocompleteSearchBar.js +1 -1
  11. package/dist/components/form/AutocompleteSearchBarServer.js +1 -1
  12. package/dist/components/form/FileInput.js +1 -1
  13. package/dist/components/form/FileInputMultiple.js +1 -1
  14. package/dist/components/form/FormField.js +1 -1
  15. package/dist/components/form/InputField.js +1 -1
  16. package/dist/components/form/PositionsSelectorSingle.js +1 -1
  17. package/dist/components/form/SelectField.js +1 -1
  18. package/dist/components/layout/CollapsibleSection.js +1 -1
  19. package/dist/components/layout/IconInCircle.js +1 -1
  20. package/dist/components/layout/PageTitle.js +1 -1
  21. package/dist/components/layout/PageTitle.js.map +1 -1
  22. package/dist/components/layout/SectionTitle.js +1 -1
  23. package/dist/components/layout/SectionTitle.js.map +1 -1
  24. package/dist/components/ui/multi-select.js +2 -2
  25. package/dist/components/ui/multi-select.js.map +1 -1
  26. package/dist/index-CrfjcbOs.js +68 -0
  27. package/dist/index-CrfjcbOs.js.map +1 -0
  28. package/lib/components/datatable/DataTableServer.tsx +68 -11
  29. package/lib/components/datatable/Resizable.tsx +11 -3
  30. package/lib/components/layout/PageTitle.tsx +1 -1
  31. package/lib/components/layout/SectionTitle.tsx +1 -1
  32. package/lib/components/ui/multi-select.tsx +3 -2
  33. package/package.json +1 -1
@@ -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";
@@ -54,6 +55,7 @@ interface DataTableServerProps<T> {
54
55
  filters?: object;
55
56
  selectedItemKey?: string;
56
57
  itemsPerPageOptions?: IOptionItem[];
58
+ setMinWidth?: boolean;
57
59
  }
58
60
  const defaultItemsPerPageOptions: IOptionItem[] = [
59
61
  { value: 10, label: "10" },
@@ -112,8 +114,14 @@ function DataTableServer<T extends DataTableInternalItems>({
112
114
  filters,
113
115
  selectedItemKey = "id",
114
116
  itemsPerPageOptions = defaultItemsPerPageOptions,
117
+ setMinWidth = false,
115
118
  }: DataTableServerProps<T>) {
116
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
+
117
125
  const [itemsPerPageLocal, setItemsPerPageLocal] = useState<number>();
118
126
  const federationContext = useFederationContext();
119
127
  const [data, setData] = useState<IPageable<T>>();
@@ -372,18 +380,10 @@ function DataTableServer<T extends DataTableInternalItems>({
372
380
  ) : sortConfig.direction === "desc" ? (
373
381
  <MdArrowDownward fontSize="small" />
374
382
  ) : (
375
- <MdArrowUpward
376
- fontSize="small"
377
- className="text-gray-300 invisible group-hover:visible "
378
- />
383
+ <MdOutlineUnfoldMore fontSize="small" className=" " />
379
384
  );
380
385
  }
381
- return (
382
- <MdArrowUpward
383
- fontSize="small"
384
- className="text-gray-300 invisible group-hover:visible "
385
- />
386
- );
386
+ return <MdOutlineUnfoldMore fontSize="small" className=" " />;
387
387
  };
388
388
 
389
389
  const handleSelectItem = (item: T) => {
@@ -631,6 +631,53 @@ function DataTableServer<T extends DataTableInternalItems>({
631
631
  columns,
632
632
  ]);
633
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
+
634
681
  const handleItemsPerPageChange = (
635
682
  event: React.ChangeEvent<HTMLSelectElement>
636
683
  ) => {
@@ -704,8 +751,17 @@ function DataTableServer<T extends DataTableInternalItems>({
704
751
  )}
705
752
  </div>
706
753
  )}
707
- <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]">
708
763
  <table
764
+ ref={tableRef}
709
765
  className="w-full leading-normal"
710
766
  key={tableKey}
711
767
  data-cy={"datatable-table-" + id}
@@ -749,6 +805,7 @@ function DataTableServer<T extends DataTableInternalItems>({
749
805
  tableId={id}
750
806
  colKey={String(key)}
751
807
  defaultWidth={width || "auto"}
808
+ setMinWidth={setMinWidth}
752
809
  >
753
810
  {({ ref }: { ref: any }) => (
754
811
  <th
@@ -5,6 +5,7 @@ interface IResizableProps {
5
5
  colKey: string;
6
6
  children: any;
7
7
  defaultWidth: string;
8
+ setMinWidth?: boolean;
8
9
  }
9
10
 
10
11
  export const Resizable = ({
@@ -12,6 +13,7 @@ export const Resizable = ({
12
13
  colKey,
13
14
  defaultWidth,
14
15
  children,
16
+ setMinWidth = false,
15
17
  }: IResizableProps) => {
16
18
  const [node, setNode] = React.useState<HTMLElement | null>(null);
17
19
 
@@ -62,7 +64,9 @@ export const Resizable = ({
62
64
  const newWidth = w + dx + "px";
63
65
 
64
66
  parent?.style.setProperty("width", newWidth);
65
- parent?.style.setProperty("min-width", newWidth);
67
+ if (setMinWidth) {
68
+ parent?.style.setProperty("min-width", newWidth);
69
+ }
66
70
  setWidth(newWidth);
67
71
  };
68
72
 
@@ -85,10 +89,14 @@ export const Resizable = ({
85
89
  const parent = node.parentElement;
86
90
  if (node.parentNode !== node.parentNode?.parentNode?.lastChild) {
87
91
  parent?.style.setProperty("width", `${width}`);
88
- parent?.style.setProperty("min-width", `${width}`);
92
+ if (setMinWidth) {
93
+ parent?.style.setProperty("min-width", `${width}`);
94
+ }
89
95
  } else {
90
96
  parent?.style.setProperty("width", `auto`);
91
- parent?.style.setProperty("min-width", `auto`);
97
+ if (setMinWidth) {
98
+ parent?.style.setProperty("min-width", `auto`);
99
+ }
92
100
  }
93
101
 
94
102
  node.addEventListener("mousedown", handleMouseDown);
@@ -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 ">
@@ -310,7 +310,7 @@ export const MultiSelect = React.forwardRef<
310
310
  <div
311
311
  className={cn(
312
312
  "mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary",
313
- selectedValues.length === options.length
313
+ selectedValues && selectedValues.length === options.length
314
314
  ? "bg-primary text-primary-foreground"
315
315
  : "opacity-50 [&_svg]:invisible"
316
316
  )}
@@ -321,7 +321,8 @@ export const MultiSelect = React.forwardRef<
321
321
  </CommandItem>
322
322
  {options.map((option) => {
323
323
  const optionStr = String(option.value);
324
- const isSelected = selectedValues.includes(optionStr);
324
+ const isSelected =
325
+ selectedValues?.includes(optionStr) || false;
325
326
  return (
326
327
  <CommandItem
327
328
  key={optionStr}
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.49",
4
+ "version": "2.0.51",
5
5
  "type": "module",
6
6
  "main": "dist/main.js",
7
7
  "types": "dist/main.d.ts",