next-recomponents 2.0.70 → 2.0.72

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.d.mts CHANGED
@@ -211,8 +211,9 @@ type Props = {
211
211
  width?: string;
212
212
  height?: string;
213
213
  onDelete?: (item: Item) => void;
214
+ groupId?: number;
214
215
  };
215
- declare function DocumentViewer({ item, width, height, onDelete, }: Props): react_jsx_runtime.JSX.Element;
216
+ declare function DocumentViewer({ item, width, height, onDelete, groupId, }: Props): react_jsx_runtime.JSX.Element;
216
217
 
217
218
  interface Table3Props<T extends Record<string, any>> extends DetailedHTMLProps<TableHTMLAttributes<HTMLTableElement>, HTMLTableElement> {
218
219
  data: T[];
package/dist/index.d.ts CHANGED
@@ -211,8 +211,9 @@ type Props = {
211
211
  width?: string;
212
212
  height?: string;
213
213
  onDelete?: (item: Item) => void;
214
+ groupId?: number;
214
215
  };
215
- declare function DocumentViewer({ item, width, height, onDelete, }: Props): react_jsx_runtime.JSX.Element;
216
+ declare function DocumentViewer({ item, width, height, onDelete, groupId, }: Props): react_jsx_runtime.JSX.Element;
216
217
 
217
218
  interface Table3Props<T extends Record<string, any>> extends DetailedHTMLProps<TableHTMLAttributes<HTMLTableElement>, HTMLTableElement> {
218
219
  data: T[];
package/dist/index.js CHANGED
@@ -37594,9 +37594,12 @@ function DocumentViewer({
37594
37594
  item,
37595
37595
  width = "100%",
37596
37596
  height = "100%",
37597
- onDelete
37597
+ onDelete,
37598
+ groupId = 1
37598
37599
  }) {
37599
37600
  const { url, name, contentType } = item;
37601
+ const [index, setIndex] = (0, import_react12.useState)(-1);
37602
+ const [items, setItems] = (0, import_react12.useState)([]);
37600
37603
  const isImage = contentType.startsWith("image/");
37601
37604
  const isPdf = contentType === "application/pdf";
37602
37605
  const isGoogleDocCompatible = contentType.includes("msword") || contentType.includes("officedocument") || contentType.includes("presentation");
@@ -37604,10 +37607,30 @@ function DocumentViewer({
37604
37607
  url
37605
37608
  )}&embedded=true` : url;
37606
37609
  const [isOpen, setIsOpen] = (0, import_react12.useState)(false);
37610
+ function handleChangeIndex(nuevoIndex) {
37611
+ var _a, _b, _c, _d;
37612
+ const currentIndex = items.findIndex((a) => a.id == item.name);
37613
+ const openButton = (_b = (_a = items[nuevoIndex]).querySelector) == null ? void 0 : _b.call(_a, ".open-button");
37614
+ const closeButton = (_d = (_c = items[currentIndex]).querySelector) == null ? void 0 : _d.call(
37615
+ _c,
37616
+ ".close-button"
37617
+ );
37618
+ setIndex(nuevoIndex);
37619
+ closeButton.click();
37620
+ openButton.click();
37621
+ }
37622
+ (0, import_react12.useEffect)(() => {
37623
+ if (typeof window != "undefined") {
37624
+ const i = document.querySelectorAll(`.documentviewer-${groupId}`);
37625
+ const arr = Array.from(i);
37626
+ setItems(arr);
37627
+ }
37628
+ }, []);
37607
37629
  return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
37608
37630
  "div",
37609
37631
  {
37610
- className: "group relative rounded-lg bg-white shadow-md overflow-hidden",
37632
+ id: item.name,
37633
+ className: `group relative rounded-lg bg-white shadow-md overflow-hidden documentviewer-${groupId} `,
37611
37634
  style: {
37612
37635
  width,
37613
37636
  height
@@ -37632,7 +37655,7 @@ function DocumentViewer({
37632
37655
  isOpen && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
37633
37656
  "div",
37634
37657
  {
37635
- className: "\r\n fixed inset-0 z-[9999]\r\n bg-black/50\r\n flex items-center justify-center\r\n p-6\r\n ",
37658
+ className: "\r\n fixed inset-0 z-[9999]\r\n bg-black/50\r\n flex items-center justify-center\r\n py-5 px-[200px]\r\n ",
37636
37659
  onClick: () => setIsOpen(false),
37637
37660
  children: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
37638
37661
  "div",
@@ -37645,10 +37668,28 @@ function DocumentViewer({
37645
37668
  {
37646
37669
  type: "button",
37647
37670
  onClick: () => setIsOpen(false),
37648
- className: "\r\n absolute top-4 right-4 z-10\r\n w-10 h-10\r\n rounded-full\r\n bg-black/70 text-white\r\n hover:bg-black\r\n flex items-center justify-center\r\n text-xl\r\n ",
37671
+ className: "\r\n absolute top-4 right-4 z-10\r\n w-10 h-10\r\n rounded-full\r\n bg-black/70 text-white\r\n hover:bg-black\r\n flex items-center justify-center\r\n text-xl close-button\r\n ",
37649
37672
  children: "\u2715"
37650
37673
  }
37651
37674
  ),
37675
+ index < items.length - 1 && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
37676
+ "button",
37677
+ {
37678
+ type: "button",
37679
+ onClick: () => handleChangeIndex(index + 1),
37680
+ className: "\r\n absolute top-[50%] -right-20 z-10\r\n w-10 h-10\r\n rounded-full\r\n bg-black/70 text-white\r\n hover:bg-black\r\n flex items-center justify-center\r\n text-xl\r\n ",
37681
+ children: ">"
37682
+ }
37683
+ ),
37684
+ index > 0 && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
37685
+ "button",
37686
+ {
37687
+ type: "button",
37688
+ onClick: () => handleChangeIndex(index - 1),
37689
+ className: "\r\n absolute top-[50%] -left-20 z-10\r\n w-10 h-10\r\n rounded-full\r\n bg-black/70 text-white\r\n hover:bg-black\r\n flex items-center justify-center\r\n text-xl\r\n ",
37690
+ children: "<"
37691
+ }
37692
+ ),
37652
37693
  isImage ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
37653
37694
  "img",
37654
37695
  {
@@ -37697,8 +37738,10 @@ function DocumentViewer({
37697
37738
  /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
37698
37739
  "div",
37699
37740
  {
37700
- className: "border bg-black/50 shadow rounded p-2 hover:bg-black/70 transition-all duration-200 text-white cursor-pointer",
37741
+ className: "border bg-black/50 shadow rounded p-2 hover:bg-black/70 transition-all duration-200 text-white cursor-pointer open-button",
37701
37742
  onClick: (e) => {
37743
+ const currentIndex = items.findIndex((a) => a.id == item.name);
37744
+ setIndex(currentIndex);
37702
37745
  setIsOpen(true);
37703
37746
  },
37704
37747
  children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("a", { title: "Open", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(OpenIcon, {}) })
package/dist/index.mjs CHANGED
@@ -37493,7 +37493,7 @@ function MyCalendar({
37493
37493
  }
37494
37494
 
37495
37495
  // src/doc-viewer/index.tsx
37496
- import { useState as useState10 } from "react";
37496
+ import { useEffect as useEffect8, useState as useState10 } from "react";
37497
37497
 
37498
37498
  // src/doc-viewer/icon.tsx
37499
37499
  import { jsx as jsx19, jsxs as jsxs12 } from "react/jsx-runtime";
@@ -37577,9 +37577,12 @@ function DocumentViewer({
37577
37577
  item,
37578
37578
  width = "100%",
37579
37579
  height = "100%",
37580
- onDelete
37580
+ onDelete,
37581
+ groupId = 1
37581
37582
  }) {
37582
37583
  const { url, name, contentType } = item;
37584
+ const [index, setIndex] = useState10(-1);
37585
+ const [items, setItems] = useState10([]);
37583
37586
  const isImage = contentType.startsWith("image/");
37584
37587
  const isPdf = contentType === "application/pdf";
37585
37588
  const isGoogleDocCompatible = contentType.includes("msword") || contentType.includes("officedocument") || contentType.includes("presentation");
@@ -37587,10 +37590,30 @@ function DocumentViewer({
37587
37590
  url
37588
37591
  )}&embedded=true` : url;
37589
37592
  const [isOpen, setIsOpen] = useState10(false);
37593
+ function handleChangeIndex(nuevoIndex) {
37594
+ var _a, _b, _c, _d;
37595
+ const currentIndex = items.findIndex((a) => a.id == item.name);
37596
+ const openButton = (_b = (_a = items[nuevoIndex]).querySelector) == null ? void 0 : _b.call(_a, ".open-button");
37597
+ const closeButton = (_d = (_c = items[currentIndex]).querySelector) == null ? void 0 : _d.call(
37598
+ _c,
37599
+ ".close-button"
37600
+ );
37601
+ setIndex(nuevoIndex);
37602
+ closeButton.click();
37603
+ openButton.click();
37604
+ }
37605
+ useEffect8(() => {
37606
+ if (typeof window != "undefined") {
37607
+ const i = document.querySelectorAll(`.documentviewer-${groupId}`);
37608
+ const arr = Array.from(i);
37609
+ setItems(arr);
37610
+ }
37611
+ }, []);
37590
37612
  return /* @__PURE__ */ jsxs13(
37591
37613
  "div",
37592
37614
  {
37593
- className: "group relative rounded-lg bg-white shadow-md overflow-hidden",
37615
+ id: item.name,
37616
+ className: `group relative rounded-lg bg-white shadow-md overflow-hidden documentviewer-${groupId} `,
37594
37617
  style: {
37595
37618
  width,
37596
37619
  height
@@ -37615,7 +37638,7 @@ function DocumentViewer({
37615
37638
  isOpen && /* @__PURE__ */ jsx20(
37616
37639
  "div",
37617
37640
  {
37618
- className: "\r\n fixed inset-0 z-[9999]\r\n bg-black/50\r\n flex items-center justify-center\r\n p-6\r\n ",
37641
+ className: "\r\n fixed inset-0 z-[9999]\r\n bg-black/50\r\n flex items-center justify-center\r\n py-5 px-[200px]\r\n ",
37619
37642
  onClick: () => setIsOpen(false),
37620
37643
  children: /* @__PURE__ */ jsxs13(
37621
37644
  "div",
@@ -37628,10 +37651,28 @@ function DocumentViewer({
37628
37651
  {
37629
37652
  type: "button",
37630
37653
  onClick: () => setIsOpen(false),
37631
- className: "\r\n absolute top-4 right-4 z-10\r\n w-10 h-10\r\n rounded-full\r\n bg-black/70 text-white\r\n hover:bg-black\r\n flex items-center justify-center\r\n text-xl\r\n ",
37654
+ className: "\r\n absolute top-4 right-4 z-10\r\n w-10 h-10\r\n rounded-full\r\n bg-black/70 text-white\r\n hover:bg-black\r\n flex items-center justify-center\r\n text-xl close-button\r\n ",
37632
37655
  children: "\u2715"
37633
37656
  }
37634
37657
  ),
37658
+ index < items.length - 1 && /* @__PURE__ */ jsx20(
37659
+ "button",
37660
+ {
37661
+ type: "button",
37662
+ onClick: () => handleChangeIndex(index + 1),
37663
+ className: "\r\n absolute top-[50%] -right-20 z-10\r\n w-10 h-10\r\n rounded-full\r\n bg-black/70 text-white\r\n hover:bg-black\r\n flex items-center justify-center\r\n text-xl\r\n ",
37664
+ children: ">"
37665
+ }
37666
+ ),
37667
+ index > 0 && /* @__PURE__ */ jsx20(
37668
+ "button",
37669
+ {
37670
+ type: "button",
37671
+ onClick: () => handleChangeIndex(index - 1),
37672
+ className: "\r\n absolute top-[50%] -left-20 z-10\r\n w-10 h-10\r\n rounded-full\r\n bg-black/70 text-white\r\n hover:bg-black\r\n flex items-center justify-center\r\n text-xl\r\n ",
37673
+ children: "<"
37674
+ }
37675
+ ),
37635
37676
  isImage ? /* @__PURE__ */ jsx20(
37636
37677
  "img",
37637
37678
  {
@@ -37680,8 +37721,10 @@ function DocumentViewer({
37680
37721
  /* @__PURE__ */ jsx20(
37681
37722
  "div",
37682
37723
  {
37683
- className: "border bg-black/50 shadow rounded p-2 hover:bg-black/70 transition-all duration-200 text-white cursor-pointer",
37724
+ className: "border bg-black/50 shadow rounded p-2 hover:bg-black/70 transition-all duration-200 text-white cursor-pointer open-button",
37684
37725
  onClick: (e) => {
37726
+ const currentIndex = items.findIndex((a) => a.id == item.name);
37727
+ setIndex(currentIndex);
37685
37728
  setIsOpen(true);
37686
37729
  },
37687
37730
  children: /* @__PURE__ */ jsx20("a", { title: "Open", children: /* @__PURE__ */ jsx20(OpenIcon, {}) })
@@ -37705,7 +37748,7 @@ function DocumentViewer({
37705
37748
 
37706
37749
  // src/table3/index.tsx
37707
37750
  import React9, {
37708
- useEffect as useEffect9,
37751
+ useEffect as useEffect10,
37709
37752
  useMemo as useMemo7,
37710
37753
  useReducer as useReducer2,
37711
37754
  useRef as useRef5,
@@ -37713,7 +37756,7 @@ import React9, {
37713
37756
  } from "react";
37714
37757
 
37715
37758
  // src/table3/filter.tsx
37716
- import { useEffect as useEffect8, useMemo as useMemo5, useState as useState11 } from "react";
37759
+ import { useEffect as useEffect9, useMemo as useMemo5, useState as useState11 } from "react";
37717
37760
 
37718
37761
  // src/table3/filters.tsx
37719
37762
  import { jsx as jsx21, jsxs as jsxs14 } from "react/jsx-runtime";
@@ -37867,7 +37910,7 @@ function Filter({
37867
37910
  const hidden = Object.values(objectData).filter(
37868
37911
  (d) => d._visible === false
37869
37912
  );
37870
- useEffect8(() => {
37913
+ useEffect9(() => {
37871
37914
  if (data.length != Object.values(objectData).map((o) => (o == null ? void 0 : o._id) || (o == null ? void 0 : o.id)).length) {
37872
37915
  const news = [...new Set(data.map((o) => o[h]))];
37873
37916
  setSelected(news);
@@ -38555,7 +38598,7 @@ function Table3({
38555
38598
  }
38556
38599
  }
38557
38600
  const [objectData, setObjectData] = useReducer2(dataReducer, null);
38558
- useEffect9(() => {
38601
+ useEffect10(() => {
38559
38602
  setObjectData(data);
38560
38603
  setPage(1);
38561
38604
  }, [data]);
@@ -38600,7 +38643,7 @@ function Table3({
38600
38643
  setSort,
38601
38644
  ...props
38602
38645
  };
38603
- useEffect9(() => {
38646
+ useEffect10(() => {
38604
38647
  if ((dialogRow == null ? void 0 : dialogRow.id) || (dialogRow == null ? void 0 : dialogRow._id)) {
38605
38648
  const newDialogRow = objectData[dialogRow == null ? void 0 : dialogRow.id] || objectData[dialogRow == null ? void 0 : dialogRow._id];
38606
38649
  setDialogRow(newDialogRow);
@@ -38630,19 +38673,19 @@ function Table3({
38630
38673
  }
38631
38674
 
38632
38675
  // src/table-advanced/index.tsx
38633
- import { useEffect as useEffect14 } from "react";
38676
+ import { useEffect as useEffect15 } from "react";
38634
38677
 
38635
38678
  // src/table-advanced/h.table.tsx
38636
38679
  import React10, {
38637
38680
  useCallback as useCallback3,
38638
- useEffect as useEffect12,
38681
+ useEffect as useEffect13,
38639
38682
  useMemo as useMemo10,
38640
38683
  useRef as useRef7,
38641
38684
  useState as useState16
38642
38685
  } from "react";
38643
38686
 
38644
38687
  // src/table-advanced/header.tsx
38645
- import { useEffect as useEffect10, useMemo as useMemo8, useRef as useRef6, useState as useState14 } from "react";
38688
+ import { useEffect as useEffect11, useMemo as useMemo8, useRef as useRef6, useState as useState14 } from "react";
38646
38689
  import { createPortal } from "react-dom";
38647
38690
 
38648
38691
  // src/table-advanced/icons.tsx
@@ -38912,16 +38955,16 @@ function Header({
38912
38955
  }, [context.data, header, text]);
38913
38956
  const [selected, setSelected] = useState14([]);
38914
38957
  const hasFilter = context.filters.find((b) => b.field == header);
38915
- useEffect10(() => {
38958
+ useEffect11(() => {
38916
38959
  setSelected(filteredValues);
38917
38960
  }, [filteredValues]);
38918
- useEffect10(() => {
38961
+ useEffect11(() => {
38919
38962
  if (visible) {
38920
38963
  context.setCurrentHeader(header);
38921
38964
  }
38922
38965
  setText("");
38923
38966
  }, [visible]);
38924
- useEffect10(() => {
38967
+ useEffect11(() => {
38925
38968
  if (!visible || !cellRef.current) {
38926
38969
  setCoords(null);
38927
38970
  return;
@@ -39260,7 +39303,7 @@ function valueFormatter({
39260
39303
  }
39261
39304
 
39262
39305
  // src/table-advanced/use.pagination.tsx
39263
- import { useState as useState15, useMemo as useMemo9, useCallback as useCallback2, useEffect as useEffect11 } from "react";
39306
+ import { useState as useState15, useMemo as useMemo9, useCallback as useCallback2, useEffect as useEffect12 } from "react";
39264
39307
  function usePaginacion({
39265
39308
  total,
39266
39309
  tamanioPagina = 100,
@@ -39292,7 +39335,7 @@ function usePaginacion({
39292
39335
  },
39293
39336
  [totalPaginas]
39294
39337
  );
39295
- useEffect11(() => {
39338
+ useEffect12(() => {
39296
39339
  setTotalPaginas(Math.max(1, Math.ceil(total / tamanioPagina)));
39297
39340
  setPagina(1);
39298
39341
  }, [total]);
@@ -39370,7 +39413,7 @@ function HTable({
39370
39413
  return { widths: widths2, gridTemplateColumns: gridTemplateColumns2, startDrag: startDrag2, setWidths: setWidths2 };
39371
39414
  }
39372
39415
  const { gridTemplateColumns, startDrag, widths, setWidths } = useResizableColumns(headers);
39373
- useEffect12(() => {
39416
+ useEffect13(() => {
39374
39417
  if (!tableRef.current) return;
39375
39418
  const observer = new ResizeObserver(([entry]) => {
39376
39419
  const ocultos = headers.filter(
@@ -39808,7 +39851,7 @@ function ModalContent({
39808
39851
  }
39809
39852
 
39810
39853
  // src/table-advanced/context.ts
39811
- import { useEffect as useEffect13, useMemo as useMemo11, useReducer as useReducer3, useState as useState17 } from "react";
39854
+ import { useEffect as useEffect14, useMemo as useMemo11, useReducer as useReducer3, useState as useState17 } from "react";
39812
39855
 
39813
39856
  // src/table-advanced/filter.reducer.ts
39814
39857
  var filterReducer = (acc, b) => {
@@ -39878,7 +39921,7 @@ function useContext({ onSelect }) {
39878
39921
  }
39879
39922
  return true;
39880
39923
  });
39881
- useEffect13(() => {
39924
+ useEffect14(() => {
39882
39925
  if (filters.length == 0) {
39883
39926
  setEditions([]);
39884
39927
  }
@@ -39911,7 +39954,7 @@ import { jsx as jsx34 } from "react/jsx-runtime";
39911
39954
  function TableAdvanced(tableProps) {
39912
39955
  const { data, ...props } = tableProps;
39913
39956
  const context = useContext({ onSelect: Boolean(tableProps.onSelect) });
39914
- useEffect14(() => {
39957
+ useEffect15(() => {
39915
39958
  context.setData(
39916
39959
  Array.isArray(data) ? data.map((d) => {
39917
39960
  return {
@@ -39922,7 +39965,7 @@ function TableAdvanced(tableProps) {
39922
39965
  }) : data
39923
39966
  );
39924
39967
  }, [data]);
39925
- useEffect14(() => {
39968
+ useEffect15(() => {
39926
39969
  if (tableProps == null ? void 0 : tableProps.sortBy) {
39927
39970
  const [k, v] = Object.entries(tableProps.sortBy)[0];
39928
39971
  context.setSort({ [k]: v });
@@ -39941,7 +39984,7 @@ function TableAdvanced(tableProps) {
39941
39984
  }
39942
39985
 
39943
39986
  // src/tabs/index.tsx
39944
- import React11, { useEffect as useEffect15, useState as useState19 } from "react";
39987
+ import React11, { useEffect as useEffect16, useState as useState19 } from "react";
39945
39988
  import { Fragment as Fragment3, jsx as jsx35, jsxs as jsxs27 } from "react/jsx-runtime";
39946
39989
  function TabContainer({
39947
39990
  children,
@@ -39958,7 +40001,7 @@ function TabContainer({
39958
40001
  if (e.key === "ArrowLeft")
39959
40002
  setIndex((k - 1 + labels.length) % labels.length);
39960
40003
  };
39961
- useEffect15(() => {
40004
+ useEffect16(() => {
39962
40005
  setIndex(currentIndex);
39963
40006
  }, [currentIndex]);
39964
40007
  return /* @__PURE__ */ jsxs27("div", { className: "w-full bg-white border shadow rounded-lg ", children: [
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "next-recomponents",
3
- "version": "2.0.70",
3
+ "version": "2.0.72",
4
4
  "description": "description nueva",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "scripts": {
8
8
  "build": "tsup src/index.tsx --dts --format esm,cjs --out-dir dist",
9
- "prepublishOnly": "npm run build",
9
+ "version:patch": "npm version patch",
10
+ "prepublishOnly": "npm version patch && npm run build",
10
11
  "publish:public": "npm publish --access public"
11
12
  },
12
13
  "keywords": [],
@@ -1,4 +1,4 @@
1
- import React, { useState } from "react";
1
+ import React, { useEffect, useState } from "react";
2
2
  import Icon, { DeleteIcon, DownloadIcon, OpenIcon } from "./icon";
3
3
 
4
4
  type Item = {
@@ -12,6 +12,7 @@ type Props = {
12
12
  width?: string;
13
13
  height?: string;
14
14
  onDelete?: (item: Item) => void;
15
+ groupId?: number;
15
16
  };
16
17
 
17
18
  export default function DocumentViewer({
@@ -19,9 +20,11 @@ export default function DocumentViewer({
19
20
  width = "100%",
20
21
  height = "100%",
21
22
  onDelete,
23
+ groupId = 1,
22
24
  }: Props) {
23
25
  const { url, name, contentType } = item;
24
-
26
+ const [index, setIndex] = useState<number>(-1);
27
+ const [items, setItems] = useState<Element[]>([]);
25
28
  const isImage = contentType.startsWith("image/");
26
29
  const isPdf = contentType === "application/pdf";
27
30
  const isGoogleDocCompatible =
@@ -35,9 +38,33 @@ export default function DocumentViewer({
35
38
  )}&embedded=true`
36
39
  : url;
37
40
  const [isOpen, setIsOpen] = useState(false);
41
+
42
+ function handleChangeIndex(nuevoIndex: number) {
43
+ const currentIndex = items.findIndex((a) => a.id == item.name);
44
+ const openButton = items[nuevoIndex].querySelector?.(".open-button") as any;
45
+ const closeButton = items[currentIndex].querySelector?.(
46
+ ".close-button",
47
+ ) as any;
48
+ setIndex(nuevoIndex);
49
+ closeButton.click();
50
+ openButton.click();
51
+ }
52
+
53
+ useEffect(() => {
54
+ if (typeof window != "undefined") {
55
+ const i = document.querySelectorAll(`.documentviewer-${groupId}`);
56
+ const arr = Array.from(i);
57
+ setItems(arr);
58
+ }
59
+ }, []);
60
+
38
61
  return (
39
62
  <div
40
- className="group relative rounded-lg bg-white shadow-md overflow-hidden"
63
+ id={item.name}
64
+ className={
65
+ "group relative rounded-lg bg-white shadow-md overflow-hidden " +
66
+ ` documentviewer-${groupId} `
67
+ }
41
68
  style={{
42
69
  width,
43
70
  height,
@@ -70,7 +97,7 @@ export default function DocumentViewer({
70
97
  fixed inset-0 z-[9999]
71
98
  bg-black/50
72
99
  flex items-center justify-center
73
- p-6
100
+ py-5 px-[200px]
74
101
  "
75
102
  onClick={() => setIsOpen(false)}
76
103
  >
@@ -94,12 +121,48 @@ export default function DocumentViewer({
94
121
  bg-black/70 text-white
95
122
  hover:bg-black
96
123
  flex items-center justify-center
97
- text-xl
124
+ text-xl close-button
98
125
  "
99
126
  >
100
127
 
101
128
  </button>
102
129
 
130
+ {index < items.length - 1 && (
131
+ <button
132
+ type="button"
133
+ onClick={() => handleChangeIndex(index + 1)}
134
+ className="
135
+ absolute top-[50%] -right-20 z-10
136
+ w-10 h-10
137
+ rounded-full
138
+ bg-black/70 text-white
139
+ hover:bg-black
140
+ flex items-center justify-center
141
+ text-xl
142
+ "
143
+ >
144
+ {">"}
145
+ </button>
146
+ )}
147
+
148
+ {index > 0 && (
149
+ <button
150
+ type="button"
151
+ onClick={() => handleChangeIndex(index - 1)}
152
+ className="
153
+ absolute top-[50%] -left-20 z-10
154
+ w-10 h-10
155
+ rounded-full
156
+ bg-black/70 text-white
157
+ hover:bg-black
158
+ flex items-center justify-center
159
+ text-xl
160
+ "
161
+ >
162
+ {"<"}
163
+ </button>
164
+ )}
165
+
103
166
  {isImage ? (
104
167
  <img
105
168
  src={url}
@@ -157,8 +220,10 @@ export default function DocumentViewer({
157
220
  </a>
158
221
  </div>
159
222
  <div
160
- className="border bg-black/50 shadow rounded p-2 hover:bg-black/70 transition-all duration-200 text-white cursor-pointer"
223
+ className="border bg-black/50 shadow rounded p-2 hover:bg-black/70 transition-all duration-200 text-white cursor-pointer open-button"
161
224
  onClick={(e) => {
225
+ const currentIndex = items.findIndex((a) => a.id == item.name);
226
+ setIndex(currentIndex);
162
227
  setIsOpen(true);
163
228
  }}
164
229
  >