@dmsi/wedgekit-react 0.0.159 → 0.0.160

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 (43) hide show
  1. package/dist/{chunk-WJ447JB5.js → chunk-4NCDT5ZY.js} +5 -5
  2. package/dist/{chunk-QFSGM4MP.js → chunk-NT2ZKA4W.js} +4 -4
  3. package/dist/{chunk-GG5JOFS6.js → chunk-PLMGI5K5.js} +1 -1
  4. package/dist/{chunk-IDSFWKOR.js → chunk-PMBEIP24.js} +1 -1
  5. package/dist/{chunk-N7EKJEYO.js → chunk-RUTYNLKS.js} +3 -3
  6. package/dist/{chunk-KADNOKNW.js → chunk-XH65MD2C.js} +1 -1
  7. package/dist/components/DataGridCell.js +8 -8
  8. package/dist/components/DateInput.js +9 -9
  9. package/dist/components/DateRangeInput.js +10 -10
  10. package/dist/components/FilterGroup.js +7 -7
  11. package/dist/components/Input.js +2 -2
  12. package/dist/components/LoadingScrim.cjs +1 -1
  13. package/dist/components/LoadingScrim.js +1 -1
  14. package/dist/components/Menu.js +2 -2
  15. package/dist/components/MenuOption.js +2 -2
  16. package/dist/components/MobileDataGrid.js +3 -3
  17. package/dist/components/Modal.js +2 -2
  18. package/dist/components/NestedMenu.js +2 -2
  19. package/dist/components/Notification.js +3 -3
  20. package/dist/components/PDFViewer.cjs +203 -42
  21. package/dist/components/PDFViewer.js +94 -40
  22. package/dist/components/Password.js +2 -2
  23. package/dist/components/PaymentOnAccountModal.cjs +1 -1
  24. package/dist/components/PaymentOnAccountModal.js +8 -8
  25. package/dist/components/Search.js +3 -3
  26. package/dist/components/Select.js +3 -3
  27. package/dist/components/SelectPaymentMethod.cjs +1 -1
  28. package/dist/components/SelectPaymentMethod.js +3 -3
  29. package/dist/components/Spinner.cjs +1 -1
  30. package/dist/components/Spinner.js +1 -1
  31. package/dist/components/Stepper.js +2 -2
  32. package/dist/components/Time.js +2 -2
  33. package/dist/components/Toast.js +3 -3
  34. package/dist/components/Upload.js +3 -3
  35. package/dist/components/index.cjs +1 -1
  36. package/dist/components/index.js +23 -23
  37. package/package.json +1 -1
  38. package/src/components/PDFViewer.tsx +63 -17
  39. package/src/components/Spinner.tsx +1 -1
  40. package/dist/{chunk-MVGOAMTP.js → chunk-4T3DRGLF.js} +3 -3
  41. package/dist/{chunk-NRCUFAOZ.js → chunk-5GOJRLQO.js} +3 -3
  42. package/dist/{chunk-AEDEFN7A.js → chunk-FFU6FB3K.js} +3 -3
  43. package/dist/{chunk-LPARJM6S.js → chunk-YR7JUKYO.js} +3 -3
@@ -1,24 +1,27 @@
1
1
  "use client";
2
2
  import {
3
3
  Modal
4
- } from "../chunk-NRCUFAOZ.js";
4
+ } from "../chunk-5GOJRLQO.js";
5
5
  import "../chunk-4RJKB7LC.js";
6
6
  import "../chunk-C4JGTH6G.js";
7
7
  import "../chunk-SYEJVSE4.js";
8
8
  import "../chunk-R7ELP5C5.js";
9
9
  import "../chunk-ZFOANBWG.js";
10
+ import {
11
+ Spinner
12
+ } from "../chunk-PLMGI5K5.js";
10
13
  import "../chunk-AZ7LVLOK.js";
11
- import "../chunk-4T7F5BZZ.js";
12
14
  import {
13
15
  Caption
14
16
  } from "../chunk-E7D24OHM.js";
15
- import {
16
- Button
17
- } from "../chunk-FKMKHLQH.js";
18
17
  import "../chunk-WNQ53SVY.js";
18
+ import "../chunk-4T7F5BZZ.js";
19
19
  import {
20
20
  Stack
21
21
  } from "../chunk-N6JVLYEE.js";
22
+ import {
23
+ Button
24
+ } from "../chunk-FKMKHLQH.js";
22
25
  import {
23
26
  Icon
24
27
  } from "../chunk-NKUETCDA.js";
@@ -36,8 +39,13 @@ function PDFViewer(props) {
36
39
  const handleDownload = useCallback(() => {
37
40
  setIsDownloading(true);
38
41
  const link = document.createElement("a");
39
- link.href = `data:application/pdf;base64,${encodedPdfs[currentIndex].base64}`;
40
- link.download = encodedPdfs[currentIndex].fileName.endsWith(".pdf") ? encodedPdfs[currentIndex].fileName : `${encodedPdfs[currentIndex].fileName}.pdf`;
42
+ const currentPdf = encodedPdfs[currentIndex];
43
+ if (!currentPdf) {
44
+ setIsDownloading(false);
45
+ return;
46
+ }
47
+ link.href = `data:application/pdf;base64,${currentPdf.base64}`;
48
+ link.download = currentPdf.fileName.endsWith(".pdf") ? currentPdf.fileName : `${currentPdf.fileName}.pdf`;
41
49
  document.body.appendChild(link);
42
50
  link.click();
43
51
  document.body.removeChild(link);
@@ -52,14 +60,22 @@ function PDFViewer(props) {
52
60
  onClose,
53
61
  showButtons: !!customActions,
54
62
  customActions,
55
- headerIcon: /* @__PURE__ */ jsx(DownloadIcon, { testid: testid ? `${testid}-download-icon` : void 0, onClick: handleDownload, isDownloading }),
63
+ headerIcon: /* @__PURE__ */ jsx(
64
+ DownloadIcon,
65
+ {
66
+ testid: testid ? `${testid}-download-icon` : void 0,
67
+ onClick: handleDownload,
68
+ isDownloading
69
+ }
70
+ ),
56
71
  children: /* @__PURE__ */ jsxs(Stack, { sizing: "layout", children: [
57
72
  /* @__PURE__ */ jsx(PDFElement, { testid, b64: encodedPdfs[currentIndex].base64 }),
58
- /* @__PURE__ */ jsx(Stack, { horizontal: true, overflowX: "auto", sizing: "layout-group", children: encodedPdfs.map((pdf, index) => /* @__PURE__ */ jsx(
73
+ /* @__PURE__ */ jsx(Stack, { horizontal: true, overflowX: "auto", sizing: "layout-group", children: encodedPdfs.map((pdf, index) => /* @__PURE__ */ jsxs(
59
74
  Button,
60
75
  {
61
76
  testid: testid ? `${testid}-${pdf.fileName}-button` : void 0,
62
77
  variant: index === currentIndex ? "primary" : "secondary",
78
+ classNameLabel: "items-center flex flex-row gap-2",
63
79
  onClick: (e) => {
64
80
  setCurrentIndex(index);
65
81
  requestAnimationFrame(() => {
@@ -71,8 +87,11 @@ function PDFViewer(props) {
71
87
  });
72
88
  });
73
89
  },
74
- disabled: isDownloading || currentIndex === index,
75
- children: pdf.fileName
90
+ disabled: isDownloading || currentIndex === index || !pdf.base64,
91
+ children: [
92
+ !pdf.base64 && /* @__PURE__ */ jsx(Spinner, {}),
93
+ pdf.fileName
94
+ ]
76
95
  },
77
96
  `${pdf.fileName}-${index}`
78
97
  )) })
@@ -107,35 +126,70 @@ function PDFElement({ b64, testid }) {
107
126
  scale: 1
108
127
  });
109
128
  return /* @__PURE__ */ jsxs("div", { className: "flex flex-col space-y-4", children: [
110
- pdfDocument ? /* @__PURE__ */ jsx("canvas", { "data-testid": testid ? `${testid}-pdf-content` : void 0, ref: canvasRef }) : /* @__PURE__ */ jsx("div", { "data-testid": testid ? `${testid}-pdf-loading` : void 0, children: "Loading PDF..." }),
111
- (pdfDocument == null ? void 0 : pdfDocument.numPages) && pdfDocument.numPages > 1 && /* @__PURE__ */ jsxs("ul", { className: "flex flex-row justify-between items-center", "data-testid": testid ? `${testid}-pdf-pagination` : void 0, children: [
112
- /* @__PURE__ */ jsx("li", { className: "previous", children: /* @__PURE__ */ jsx(
113
- "button",
114
- {
115
- "data-testid": testid ? `${testid}-pdf-pagination-previous-button` : void 0,
116
- disabled: page === 1,
117
- onClick: () => setPage(page - 1),
118
- className: "not-disabled:cursor-pointer not-disabled:hover:underline ",
119
- children: /* @__PURE__ */ jsx(Caption, { children: "Previous" })
120
- }
121
- ) }),
122
- /* @__PURE__ */ jsxs("li", { "data-testid": testid ? `${testid}-pdf-pagination-text` : void 0, className: "text-label-desktop text-text-on-action-primary-normal", children: [
123
- "Page ",
124
- /* @__PURE__ */ jsx("span", { "data-testid": testid ? `${testid}-pdf-pagination-page-${page}` : void 0, children: page }),
125
- " of ",
126
- /* @__PURE__ */ jsx("span", { "data-testid": testid ? `${testid}-pdf-pagination-total-page-${pdfDocument.numPages}` : void 0, children: pdfDocument.numPages })
127
- ] }),
128
- /* @__PURE__ */ jsx("li", { className: "next", children: /* @__PURE__ */ jsx(
129
- "button",
130
- {
131
- "data-testid": testid ? `${testid}-pdf-pagination-next-button` : void 0,
132
- disabled: page === pdfDocument.numPages,
133
- onClick: () => setPage(page + 1),
134
- className: "not-disabled:cursor-pointer not-disabled:hover:underline ",
135
- children: /* @__PURE__ */ jsx(Caption, { children: "Next" })
136
- }
137
- ) })
138
- ] })
129
+ pdfDocument ? /* @__PURE__ */ jsx(
130
+ "canvas",
131
+ {
132
+ "data-testid": testid ? `${testid}-pdf-content` : void 0,
133
+ ref: canvasRef
134
+ }
135
+ ) : /* @__PURE__ */ jsx("div", { "data-testid": testid ? `${testid}-pdf-loading` : void 0, children: "Loading PDF..." }),
136
+ (pdfDocument == null ? void 0 : pdfDocument.numPages) && pdfDocument.numPages > 1 && /* @__PURE__ */ jsxs(
137
+ "ul",
138
+ {
139
+ className: "flex flex-row justify-between items-center",
140
+ "data-testid": testid ? `${testid}-pdf-pagination` : void 0,
141
+ children: [
142
+ /* @__PURE__ */ jsx("li", { className: "previous", children: /* @__PURE__ */ jsx(
143
+ "button",
144
+ {
145
+ "data-testid": testid ? `${testid}-pdf-pagination-previous-button` : void 0,
146
+ disabled: page === 1,
147
+ onClick: () => setPage(page - 1),
148
+ className: "not-disabled:cursor-pointer not-disabled:hover:underline ",
149
+ children: /* @__PURE__ */ jsx(Caption, { children: "Previous" })
150
+ }
151
+ ) }),
152
+ /* @__PURE__ */ jsxs(
153
+ "li",
154
+ {
155
+ "data-testid": testid ? `${testid}-pdf-pagination-text` : void 0,
156
+ className: "text-label-desktop text-text-on-action-primary-normal",
157
+ children: [
158
+ "Page",
159
+ " ",
160
+ /* @__PURE__ */ jsx(
161
+ "span",
162
+ {
163
+ "data-testid": testid ? `${testid}-pdf-pagination-page-${page}` : void 0,
164
+ children: page
165
+ }
166
+ ),
167
+ " ",
168
+ "of",
169
+ " ",
170
+ /* @__PURE__ */ jsx(
171
+ "span",
172
+ {
173
+ "data-testid": testid ? `${testid}-pdf-pagination-total-page-${pdfDocument.numPages}` : void 0,
174
+ children: pdfDocument.numPages
175
+ }
176
+ )
177
+ ]
178
+ }
179
+ ),
180
+ /* @__PURE__ */ jsx("li", { className: "next", children: /* @__PURE__ */ jsx(
181
+ "button",
182
+ {
183
+ "data-testid": testid ? `${testid}-pdf-pagination-next-button` : void 0,
184
+ disabled: page === pdfDocument.numPages,
185
+ onClick: () => setPage(page + 1),
186
+ className: "not-disabled:cursor-pointer not-disabled:hover:underline ",
187
+ children: /* @__PURE__ */ jsx(Caption, { children: "Next" })
188
+ }
189
+ ) })
190
+ ]
191
+ }
192
+ )
139
193
  ] });
140
194
  }
141
195
  export {
@@ -1,9 +1,9 @@
1
1
  "use client";
2
2
  import {
3
3
  InputBase
4
- } from "../chunk-MVGOAMTP.js";
5
- import "../chunk-JWCT72WR.js";
4
+ } from "../chunk-4T3DRGLF.js";
6
5
  import "../chunk-5UH6QUFB.js";
6
+ import "../chunk-JWCT72WR.js";
7
7
  import {
8
8
  Icon
9
9
  } from "../chunk-NKUETCDA.js";
@@ -1964,7 +1964,7 @@ var Spinner = ({ size = "small", testid }) => {
1964
1964
  viewBox: "0 0 24 24",
1965
1965
  xmlns: "http://www.w3.org/2000/svg",
1966
1966
  fill: "#1D1E1E",
1967
- className: size === "large" ? "animate-spin" : "",
1967
+ className: "animate-spin",
1968
1968
  "aria-label": "Loading",
1969
1969
  children: [
1970
1970
  /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("circle", { cx: "12", cy: "4", r: "2", opacity: "1", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
@@ -1,31 +1,31 @@
1
1
  import {
2
2
  PaymentOnAccountModal,
3
3
  calculateSurcharge
4
- } from "../chunk-N7EKJEYO.js";
5
- import "../chunk-QFSGM4MP.js";
4
+ } from "../chunk-RUTYNLKS.js";
5
+ import "../chunk-NT2ZKA4W.js";
6
6
  import "../chunk-WFGKIR5A.js";
7
7
  import "../chunk-BATIOCXB.js";
8
- import "../chunk-NRCUFAOZ.js";
8
+ import "../chunk-5GOJRLQO.js";
9
9
  import "../chunk-4RJKB7LC.js";
10
10
  import "../chunk-C4JGTH6G.js";
11
11
  import "../chunk-SYEJVSE4.js";
12
12
  import "../chunk-R7ELP5C5.js";
13
13
  import "../chunk-ZFOANBWG.js";
14
- import "../chunk-GG5JOFS6.js";
14
+ import "../chunk-PLMGI5K5.js";
15
15
  import "../chunk-AZ7LVLOK.js";
16
16
  import "../chunk-EPQLWHCL.js";
17
- import "../chunk-4T7F5BZZ.js";
18
- import "../chunk-MVGOAMTP.js";
19
- import "../chunk-JWCT72WR.js";
20
17
  import "../chunk-WFQEE2OO.js";
21
- import "../chunk-FKMKHLQH.js";
22
18
  import "../chunk-WNQ53SVY.js";
19
+ import "../chunk-4T7F5BZZ.js";
20
+ import "../chunk-4T3DRGLF.js";
23
21
  import "../chunk-5UH6QUFB.js";
22
+ import "../chunk-JWCT72WR.js";
24
23
  import "../chunk-CYZL57LH.js";
25
24
  import "../chunk-WSS2DFTP.js";
26
25
  import "../chunk-N6JVLYEE.js";
27
26
  import "../chunk-4LXG6QNT.js";
28
27
  import "../chunk-HVI3CL7Y.js";
28
+ import "../chunk-FKMKHLQH.js";
29
29
  import "../chunk-NKUETCDA.js";
30
30
  import "../chunk-RDLEIAQU.js";
31
31
  import "../chunk-ORMEWXMH.js";
@@ -1,10 +1,10 @@
1
1
  "use client";
2
2
  import {
3
3
  Search
4
- } from "../chunk-IDSFWKOR.js";
5
- import "../chunk-MVGOAMTP.js";
6
- import "../chunk-JWCT72WR.js";
4
+ } from "../chunk-PMBEIP24.js";
5
+ import "../chunk-4T3DRGLF.js";
7
6
  import "../chunk-5UH6QUFB.js";
7
+ import "../chunk-JWCT72WR.js";
8
8
  import "../chunk-NKUETCDA.js";
9
9
  import "../chunk-RDLEIAQU.js";
10
10
  import "../chunk-ORMEWXMH.js";
@@ -1,10 +1,10 @@
1
1
  "use client";
2
2
  import {
3
3
  Select
4
- } from "../chunk-KADNOKNW.js";
5
- import "../chunk-MVGOAMTP.js";
6
- import "../chunk-JWCT72WR.js";
4
+ } from "../chunk-XH65MD2C.js";
5
+ import "../chunk-4T3DRGLF.js";
7
6
  import "../chunk-5UH6QUFB.js";
7
+ import "../chunk-JWCT72WR.js";
8
8
  import "../chunk-NKUETCDA.js";
9
9
  import "../chunk-RDLEIAQU.js";
10
10
  import "../chunk-ORMEWXMH.js";
@@ -1020,7 +1020,7 @@ var Spinner = ({ size = "small", testid }) => {
1020
1020
  viewBox: "0 0 24 24",
1021
1021
  xmlns: "http://www.w3.org/2000/svg",
1022
1022
  fill: "#1D1E1E",
1023
- className: size === "large" ? "animate-spin" : "",
1023
+ className: "animate-spin",
1024
1024
  "aria-label": "Loading",
1025
1025
  children: [
1026
1026
  /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("circle", { cx: "12", cy: "4", r: "2", opacity: "1", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
@@ -1,19 +1,19 @@
1
1
  "use client";
2
2
  import {
3
3
  SelectPaymentMethod
4
- } from "../chunk-QFSGM4MP.js";
4
+ } from "../chunk-NT2ZKA4W.js";
5
5
  import "../chunk-WFGKIR5A.js";
6
6
  import "../chunk-BATIOCXB.js";
7
- import "../chunk-GG5JOFS6.js";
7
+ import "../chunk-PLMGI5K5.js";
8
8
  import "../chunk-EPQLWHCL.js";
9
9
  import "../chunk-WFQEE2OO.js";
10
- import "../chunk-FKMKHLQH.js";
11
10
  import "../chunk-5UH6QUFB.js";
12
11
  import "../chunk-CYZL57LH.js";
13
12
  import "../chunk-WSS2DFTP.js";
14
13
  import "../chunk-N6JVLYEE.js";
15
14
  import "../chunk-4LXG6QNT.js";
16
15
  import "../chunk-HVI3CL7Y.js";
16
+ import "../chunk-FKMKHLQH.js";
17
17
  import "../chunk-NKUETCDA.js";
18
18
  import "../chunk-RDLEIAQU.js";
19
19
  import "../chunk-ORMEWXMH.js";
@@ -35,7 +35,7 @@ var Spinner = ({ size = "small", testid }) => {
35
35
  viewBox: "0 0 24 24",
36
36
  xmlns: "http://www.w3.org/2000/svg",
37
37
  fill: "#1D1E1E",
38
- className: size === "large" ? "animate-spin" : "",
38
+ className: "animate-spin",
39
39
  "aria-label": "Loading",
40
40
  children: [
41
41
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "12", cy: "4", r: "2", opacity: "1", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Spinner
3
- } from "../chunk-GG5JOFS6.js";
3
+ } from "../chunk-PLMGI5K5.js";
4
4
  import "../chunk-ORMEWXMH.js";
5
5
  export {
6
6
  Spinner
@@ -1,12 +1,12 @@
1
1
  "use client";
2
2
  import {
3
3
  InputBase
4
- } from "../chunk-MVGOAMTP.js";
4
+ } from "../chunk-4T3DRGLF.js";
5
+ import "../chunk-5UH6QUFB.js";
5
6
  import "../chunk-JWCT72WR.js";
6
7
  import {
7
8
  Button
8
9
  } from "../chunk-FKMKHLQH.js";
9
- import "../chunk-5UH6QUFB.js";
10
10
  import {
11
11
  Icon
12
12
  } from "../chunk-NKUETCDA.js";
@@ -3,9 +3,9 @@ import {
3
3
  } from "../chunk-4T7F5BZZ.js";
4
4
  import {
5
5
  InputBase
6
- } from "../chunk-MVGOAMTP.js";
7
- import "../chunk-JWCT72WR.js";
6
+ } from "../chunk-4T3DRGLF.js";
8
7
  import "../chunk-5UH6QUFB.js";
8
+ import "../chunk-JWCT72WR.js";
9
9
  import {
10
10
  Stack
11
11
  } from "../chunk-N6JVLYEE.js";
@@ -2,12 +2,12 @@
2
2
  import {
3
3
  Heading3
4
4
  } from "../chunk-AZ7LVLOK.js";
5
- import {
6
- Button
7
- } from "../chunk-FKMKHLQH.js";
8
5
  import {
9
6
  Paragraph
10
7
  } from "../chunk-HVI3CL7Y.js";
8
+ import {
9
+ Button
10
+ } from "../chunk-FKMKHLQH.js";
11
11
  import {
12
12
  Icon
13
13
  } from "../chunk-NKUETCDA.js";
@@ -1,9 +1,9 @@
1
- import {
2
- Button
3
- } from "../chunk-FKMKHLQH.js";
4
1
  import {
5
2
  Paragraph
6
3
  } from "../chunk-HVI3CL7Y.js";
4
+ import {
5
+ Button
6
+ } from "../chunk-FKMKHLQH.js";
7
7
  import {
8
8
  Icon
9
9
  } from "../chunk-NKUETCDA.js";
@@ -4564,7 +4564,7 @@ var Spinner = ({ size = "small", testid }) => {
4564
4564
  viewBox: "0 0 24 24",
4565
4565
  xmlns: "http://www.w3.org/2000/svg",
4566
4566
  fill: "#1D1E1E",
4567
- className: size === "large" ? "animate-spin" : "",
4567
+ className: "animate-spin",
4568
4568
  "aria-label": "Loading",
4569
4569
  children: [
4570
4570
  /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("circle", { cx: "12", cy: "4", r: "2", opacity: "1", children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
@@ -1,58 +1,55 @@
1
1
  import {
2
2
  Tooltip
3
3
  } from "../chunk-4VTOTNKJ.js";
4
- import {
5
- PaymentOnAccountModal
6
- } from "../chunk-N7EKJEYO.js";
7
4
  import {
8
5
  Select
9
- } from "../chunk-KADNOKNW.js";
10
- import "../chunk-QFSGM4MP.js";
6
+ } from "../chunk-XH65MD2C.js";
7
+ import {
8
+ PaymentOnAccountModal
9
+ } from "../chunk-RUTYNLKS.js";
10
+ import "../chunk-NT2ZKA4W.js";
11
11
  import "../chunk-WFGKIR5A.js";
12
12
  import "../chunk-BATIOCXB.js";
13
- import "../chunk-NRCUFAOZ.js";
13
+ import "../chunk-5GOJRLQO.js";
14
14
  import "../chunk-4RJKB7LC.js";
15
15
  import "../chunk-C4JGTH6G.js";
16
16
  import "../chunk-SYEJVSE4.js";
17
17
  import "../chunk-R7ELP5C5.js";
18
18
  import "../chunk-ZFOANBWG.js";
19
- import "../chunk-GG5JOFS6.js";
19
+ import "../chunk-PLMGI5K5.js";
20
20
  import "../chunk-AZ7LVLOK.js";
21
21
  import "../chunk-EPQLWHCL.js";
22
+ import {
23
+ Checkbox
24
+ } from "../chunk-WFQEE2OO.js";
22
25
  import {
23
26
  DataCellHeader,
24
27
  DataGridCell,
25
28
  DragAlongCell,
26
29
  DraggableCellHeader
27
- } from "../chunk-WJ447JB5.js";
30
+ } from "../chunk-4NCDT5ZY.js";
28
31
  import {
29
32
  Menu
30
- } from "../chunk-LPARJM6S.js";
33
+ } from "../chunk-YR7JUKYO.js";
31
34
  import "../chunk-5GUW4DUY.js";
32
35
  import {
33
36
  MenuOption
34
- } from "../chunk-AEDEFN7A.js";
35
- import "../chunk-WVUIIBRR.js";
37
+ } from "../chunk-FFU6FB3K.js";
38
+ import {
39
+ useInfiniteScroll
40
+ } from "../chunk-WNQ53SVY.js";
36
41
  import "../chunk-4T7F5BZZ.js";
37
42
  import {
38
43
  Search
39
- } from "../chunk-IDSFWKOR.js";
44
+ } from "../chunk-PMBEIP24.js";
40
45
  import {
41
46
  Input
42
- } from "../chunk-MVGOAMTP.js";
47
+ } from "../chunk-4T3DRGLF.js";
48
+ import "../chunk-5UH6QUFB.js";
43
49
  import {
44
50
  Label
45
51
  } from "../chunk-JWCT72WR.js";
46
- import {
47
- Checkbox
48
- } from "../chunk-WFQEE2OO.js";
49
- import {
50
- Button
51
- } from "../chunk-FKMKHLQH.js";
52
- import {
53
- useInfiniteScroll
54
- } from "../chunk-WNQ53SVY.js";
55
- import "../chunk-5UH6QUFB.js";
52
+ import "../chunk-WVUIIBRR.js";
56
53
  import {
57
54
  Subheader
58
55
  } from "../chunk-CYZL57LH.js";
@@ -66,6 +63,9 @@ import {
66
63
  import {
67
64
  Paragraph
68
65
  } from "../chunk-HVI3CL7Y.js";
66
+ import {
67
+ Button
68
+ } from "../chunk-FKMKHLQH.js";
69
69
  import {
70
70
  Icon
71
71
  } from "../chunk-NKUETCDA.js";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dmsi/wedgekit-react",
3
3
  "private": false,
4
- "version": "0.0.159",
4
+ "version": "0.0.160",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "build": "tsup",
@@ -7,6 +7,7 @@ import { Button } from "./Button";
7
7
  import { Icon } from "./Icon";
8
8
  import { Stack } from "./Stack";
9
9
  import { Caption } from "./Caption";
10
+ import { Spinner } from "./Spinner";
10
11
 
11
12
  type PDFViewerProps = {
12
13
  isOpen: boolean;
@@ -24,12 +25,15 @@ export function PDFViewer(props: PDFViewerProps) {
24
25
  const handleDownload = useCallback(() => {
25
26
  setIsDownloading(true);
26
27
  const link = document.createElement("a");
27
- link.href = `data:application/pdf;base64,${
28
- encodedPdfs[currentIndex].base64
29
- }`;
30
- link.download = encodedPdfs[currentIndex].fileName.endsWith(".pdf")
31
- ? encodedPdfs[currentIndex].fileName
32
- : `${encodedPdfs[currentIndex].fileName}.pdf`;
28
+ const currentPdf = encodedPdfs[currentIndex];
29
+ if (!currentPdf) {
30
+ setIsDownloading(false);
31
+ return;
32
+ }
33
+ link.href = `data:application/pdf;base64,${currentPdf.base64}`;
34
+ link.download = currentPdf.fileName.endsWith(".pdf")
35
+ ? currentPdf.fileName
36
+ : `${currentPdf.fileName}.pdf`;
33
37
  document.body.appendChild(link);
34
38
  link.click();
35
39
  document.body.removeChild(link);
@@ -46,7 +50,11 @@ export function PDFViewer(props: PDFViewerProps) {
46
50
  showButtons={!!customActions}
47
51
  customActions={customActions}
48
52
  headerIcon={
49
- <DownloadIcon testid={testid ? `${testid}-download-icon` : undefined} onClick={handleDownload} isDownloading={isDownloading} />
53
+ <DownloadIcon
54
+ testid={testid ? `${testid}-download-icon` : undefined}
55
+ onClick={handleDownload}
56
+ isDownloading={isDownloading}
57
+ />
50
58
  }
51
59
  >
52
60
  <Stack sizing="layout">
@@ -57,6 +65,7 @@ export function PDFViewer(props: PDFViewerProps) {
57
65
  testid={testid ? `${testid}-${pdf.fileName}-button` : undefined}
58
66
  variant={index === currentIndex ? "primary" : "secondary"}
59
67
  key={`${pdf.fileName}-${index}`}
68
+ classNameLabel="items-center flex flex-row gap-2"
60
69
  onClick={(e: React.MouseEvent<HTMLButtonElement>) => {
61
70
  setCurrentIndex(index);
62
71
 
@@ -66,12 +75,13 @@ export function PDFViewer(props: PDFViewerProps) {
66
75
  button.scrollIntoView({
67
76
  behavior: "smooth",
68
77
  block: "nearest",
69
- inline: "center"
78
+ inline: "center",
70
79
  });
71
80
  });
72
81
  }}
73
- disabled={isDownloading || currentIndex === index}
82
+ disabled={isDownloading || currentIndex === index || !pdf.base64}
74
83
  >
84
+ {!pdf.base64 && <Spinner />}
75
85
  {pdf.fileName}
76
86
  </Button>
77
87
  ))}
@@ -84,7 +94,7 @@ export function PDFViewer(props: PDFViewerProps) {
84
94
  function DownloadIcon({
85
95
  onClick,
86
96
  isDownloading,
87
- testid
97
+ testid,
88
98
  }: {
89
99
  onClick: () => void;
90
100
  isDownloading?: boolean;
@@ -101,7 +111,7 @@ function DownloadIcon({
101
111
  );
102
112
  }
103
113
 
104
- function PDFElement({ b64, testid }: { b64: string, testid?: string }) {
114
+ function PDFElement({ b64, testid }: { b64: string; testid?: string }) {
105
115
  const [page, setPage] = useState(1);
106
116
  const canvasRef = useRef(null);
107
117
 
@@ -115,12 +125,26 @@ function PDFElement({ b64, testid }: { b64: string, testid?: string }) {
115
125
 
116
126
  return (
117
127
  <div className="flex flex-col space-y-4">
118
- {pdfDocument ? <canvas data-testid={testid ? `${testid}-pdf-content` : undefined} ref={canvasRef} /> : <div data-testid={testid ? `${testid}-pdf-loading` : undefined}>Loading PDF...</div>}
128
+ {pdfDocument ? (
129
+ <canvas
130
+ data-testid={testid ? `${testid}-pdf-content` : undefined}
131
+ ref={canvasRef}
132
+ />
133
+ ) : (
134
+ <div data-testid={testid ? `${testid}-pdf-loading` : undefined}>
135
+ Loading PDF...
136
+ </div>
137
+ )}
119
138
  {pdfDocument?.numPages && pdfDocument.numPages > 1 && (
120
- <ul className="flex flex-row justify-between items-center" data-testid={testid ? `${testid}-pdf-pagination` : undefined}>
139
+ <ul
140
+ className="flex flex-row justify-between items-center"
141
+ data-testid={testid ? `${testid}-pdf-pagination` : undefined}
142
+ >
121
143
  <li className="previous">
122
144
  <button
123
- data-testid={testid ? `${testid}-pdf-pagination-previous-button` : undefined}
145
+ data-testid={
146
+ testid ? `${testid}-pdf-pagination-previous-button` : undefined
147
+ }
124
148
  disabled={page === 1}
125
149
  onClick={() => setPage(page - 1)}
126
150
  className="not-disabled:cursor-pointer not-disabled:hover:underline "
@@ -128,12 +152,34 @@ function PDFElement({ b64, testid }: { b64: string, testid?: string }) {
128
152
  <Caption>Previous</Caption>
129
153
  </button>
130
154
  </li>
131
- <li data-testid={testid ? `${testid}-pdf-pagination-text` : undefined} className="text-label-desktop text-text-on-action-primary-normal">
132
- Page <span data-testid={testid ? `${testid}-pdf-pagination-page-${page}` : undefined}>{page}</span> of <span data-testid={testid ? `${testid}-pdf-pagination-total-page-${pdfDocument!.numPages}` : undefined}>{pdfDocument!.numPages}</span>
155
+ <li
156
+ data-testid={testid ? `${testid}-pdf-pagination-text` : undefined}
157
+ className="text-label-desktop text-text-on-action-primary-normal"
158
+ >
159
+ Page{" "}
160
+ <span
161
+ data-testid={
162
+ testid ? `${testid}-pdf-pagination-page-${page}` : undefined
163
+ }
164
+ >
165
+ {page}
166
+ </span>{" "}
167
+ of{" "}
168
+ <span
169
+ data-testid={
170
+ testid
171
+ ? `${testid}-pdf-pagination-total-page-${pdfDocument!.numPages}`
172
+ : undefined
173
+ }
174
+ >
175
+ {pdfDocument!.numPages}
176
+ </span>
133
177
  </li>
134
178
  <li className="next">
135
179
  <button
136
- data-testid={testid ? `${testid}-pdf-pagination-next-button` : undefined}
180
+ data-testid={
181
+ testid ? `${testid}-pdf-pagination-next-button` : undefined
182
+ }
137
183
  disabled={page === pdfDocument!.numPages}
138
184
  onClick={() => setPage(page + 1)}
139
185
  className="not-disabled:cursor-pointer not-disabled:hover:underline "