@addsign/moje-agenda-shared-lib 1.0.40 → 1.0.41

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.
@@ -11,11 +11,12 @@ interface DataTableServerProps<T> {
11
11
  rowAction?: (item: T) => void;
12
12
  bulkAction?: (items: T[]) => JSX.Element;
13
13
  filters?: object;
14
+ selectedItemKey?: string;
14
15
  }
15
16
  type DataTableInternalItems = {
16
17
  _isHighlighted?: boolean;
17
18
  id: string;
18
19
  };
19
20
  export declare const resetAllDataTablePaging: () => void;
20
- declare function DataTableServer<T extends DataTableInternalItems>({ id, url, columns, title, subtitle, allowSearch, showHeader, rowAction, bulkAction, filters, }: DataTableServerProps<T>): import("react/jsx-runtime").JSX.Element;
21
+ declare function DataTableServer<T extends DataTableInternalItems>({ id, url, columns, title, subtitle, allowSearch, showHeader, rowAction, bulkAction, filters, selectedItemKey, }: DataTableServerProps<T>): import("react/jsx-runtime").JSX.Element;
21
22
  export default DataTableServer;
@@ -21702,7 +21702,8 @@ function DataTableServer({
21702
21702
  showHeader = true,
21703
21703
  rowAction,
21704
21704
  bulkAction,
21705
- filters
21705
+ filters,
21706
+ selectedItemKey = "id"
21706
21707
  }) {
21707
21708
  var _a, _b, _c;
21708
21709
  const [itemsPerPageLocal, setItemsPerPageLocal] = useState();
@@ -21891,9 +21892,11 @@ function DataTableServer({
21891
21892
  };
21892
21893
  const handleSelectItem = (item) => {
21893
21894
  setSelectedItems((prevSelectedItems) => {
21894
- if (prevSelectedItems.find((selectedItem) => selectedItem.id === item.id)) {
21895
+ if (prevSelectedItems.find(
21896
+ (selectedItem) => selectedItem[selectedItemKey] === item[selectedItemKey]
21897
+ )) {
21895
21898
  return prevSelectedItems.filter(
21896
- (selectedItem) => selectedItem.id !== item.id
21899
+ (selectedItem) => selectedItem[selectedItemKey] !== item[selectedItemKey]
21897
21900
  );
21898
21901
  } else {
21899
21902
  return [...prevSelectedItems, item];
@@ -21907,9 +21910,14 @@ function DataTableServer({
21907
21910
  setSelectedItems(data.content);
21908
21911
  }
21909
21912
  };
21910
- const isSelected = (item) => {
21911
- return selectedItems.some((selectedItem) => selectedItem.id === item.id);
21912
- };
21913
+ const isSelected = useCallback(
21914
+ (item) => {
21915
+ return selectedItems.some(
21916
+ (selectedItem) => selectedItem[selectedItemKey] === item[selectedItemKey]
21917
+ );
21918
+ },
21919
+ [selectedItems, selectedItemKey]
21920
+ );
21913
21921
  const nextPage = () => {
21914
21922
  setCurrentPage((currentPage || 0) + 1);
21915
21923
  };
@@ -22218,7 +22226,7 @@ function DataTableServer({
22218
22226
  data.content.map((item, rowIndex) => /* @__PURE__ */ jsxs(
22219
22227
  "tr",
22220
22228
  {
22221
- className: `${item._isHighlighted ? "bg-gray-200" : ""} hover:bg-gray-100 border-gray-200 border-b text-sm`,
22229
+ className: `${item._isHighlighted || isSelected(item) ? "bg-gray-50" : ""} hover:bg-gray-100 border-gray-200 border-b text-sm`,
22222
22230
  children: [
22223
22231
  bulkAction && /* @__PURE__ */ jsx("td", { className: "w-[20px] h-[52px] hover:bg-gray-200 font-medium text-xs text-center text-gray-600 cursor-pointer", children: /* @__PURE__ */ jsx("label", { className: "w-full h-full flex items-center justify-center cursor-pointer px-2", children: /* @__PURE__ */ jsx(
22224
22232
  "input",