@dmsi/wedgekit-react 0.0.159 → 0.0.161

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 (70) hide show
  1. package/dist/{chunk-NMVSRA5Y.js → chunk-4XA32LKR.js} +2 -3
  2. package/dist/{chunk-4T7F5BZZ.js → chunk-6LN6QT6M.js} +1 -1
  3. package/dist/{chunk-NRCUFAOZ.js → chunk-FCREADUH.js} +3 -3
  4. package/dist/{chunk-IDN3IN2A.js → chunk-M3433XEJ.js} +9 -2
  5. package/dist/{chunk-QFSGM4MP.js → chunk-NT2ZKA4W.js} +4 -4
  6. package/dist/{chunk-GG5JOFS6.js → chunk-PLMGI5K5.js} +1 -1
  7. package/dist/{chunk-IDSFWKOR.js → chunk-PMBEIP24.js} +1 -1
  8. package/dist/{chunk-LPARJM6S.js → chunk-RLK4TBXR.js} +3 -3
  9. package/dist/{chunk-WJ447JB5.js → chunk-SBSHZ327.js} +5 -5
  10. package/dist/{chunk-N7EKJEYO.js → chunk-WFLOAGEI.js} +3 -3
  11. package/dist/{chunk-KADNOKNW.js → chunk-XH65MD2C.js} +1 -1
  12. package/dist/components/CalendarRange.cjs +2 -3
  13. package/dist/components/CalendarRange.js +1 -1
  14. package/dist/components/DataGridCell.cjs +1 -1
  15. package/dist/components/DataGridCell.js +8 -8
  16. package/dist/components/DataTable.cjs +1 -2
  17. package/dist/components/DataTable.js +1 -3
  18. package/dist/components/DateInput.cjs +12 -6
  19. package/dist/components/DateInput.js +11 -11
  20. package/dist/components/DateRangeInput.cjs +12 -6
  21. package/dist/components/DateRangeInput.js +11 -11
  22. package/dist/components/EditingContext.cjs +1 -2
  23. package/dist/components/EditingContext.js +1 -2
  24. package/dist/components/FilterGroup.js +7 -7
  25. package/dist/components/Input.js +2 -2
  26. package/dist/components/LoadingScrim.cjs +1 -1
  27. package/dist/components/LoadingScrim.js +1 -1
  28. package/dist/components/Menu.cjs +1 -1
  29. package/dist/components/Menu.js +2 -2
  30. package/dist/components/MenuOption.js +2 -2
  31. package/dist/components/MobileDataGrid.cjs +7 -3
  32. package/dist/components/MobileDataGrid.js +10 -6
  33. package/dist/components/Modal.cjs +1 -1
  34. package/dist/components/Modal.js +3 -3
  35. package/dist/components/NavigationTabs.cjs +4 -4
  36. package/dist/components/NavigationTabs.js +4 -4
  37. package/dist/components/NestedMenu.js +2 -2
  38. package/dist/components/Notification.js +3 -3
  39. package/dist/components/PDFViewer.cjs +204 -43
  40. package/dist/components/PDFViewer.js +94 -40
  41. package/dist/components/Password.js +2 -2
  42. package/dist/components/PaymentOnAccountModal.cjs +2 -2
  43. package/dist/components/PaymentOnAccountModal.js +8 -8
  44. package/dist/components/Search.js +3 -3
  45. package/dist/components/Select.js +3 -3
  46. package/dist/components/SelectPaymentMethod.cjs +1 -1
  47. package/dist/components/SelectPaymentMethod.js +3 -3
  48. package/dist/components/Spinner.cjs +1 -1
  49. package/dist/components/Spinner.js +1 -1
  50. package/dist/components/Stepper.js +2 -2
  51. package/dist/components/Time.cjs +1 -1
  52. package/dist/components/Time.js +3 -3
  53. package/dist/components/Toast.js +3 -3
  54. package/dist/components/Upload.js +3 -3
  55. package/dist/components/index.cjs +2 -2
  56. package/dist/components/index.js +24 -24
  57. package/dist/utils/index.cjs +9 -2
  58. package/dist/utils/index.js +1 -1
  59. package/package.json +1 -1
  60. package/src/components/CalendarRange.tsx +15 -9
  61. package/src/components/DataTable.tsx +1 -3
  62. package/src/components/EditingContext.tsx +4 -3
  63. package/src/components/MobileDataGrid.tsx +12 -4
  64. package/src/components/NavigationTabs.tsx +1 -1
  65. package/src/components/PDFViewer.tsx +63 -17
  66. package/src/components/Spinner.tsx +1 -1
  67. package/src/utils/date.ts +65 -35
  68. package/src/utils.ts +1 -1
  69. package/dist/{chunk-MVGOAMTP.js → chunk-4T3DRGLF.js} +3 -3
  70. package/dist/{chunk-AEDEFN7A.js → chunk-FFU6FB3K.js} +3 -3
@@ -584,7 +584,7 @@ function findDocumentRoot(element) {
584
584
  if (!element || !(element instanceof Node)) {
585
585
  return window.document.body;
586
586
  }
587
- var currentElement = element;
587
+ let currentElement = element;
588
588
  while (currentElement && currentElement.parentNode) {
589
589
  if (currentElement.parentNode === document) {
590
590
  return document.body;
@@ -1,16 +1,16 @@
1
1
  "use client";
2
2
  import {
3
3
  Modal
4
- } from "../chunk-NRCUFAOZ.js";
4
+ } from "../chunk-FCREADUH.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
10
  import "../chunk-AZ7LVLOK.js";
11
- import "../chunk-4T7F5BZZ.js";
12
- import "../chunk-FKMKHLQH.js";
13
11
  import "../chunk-WNQ53SVY.js";
12
+ import "../chunk-6LN6QT6M.js";
13
+ import "../chunk-FKMKHLQH.js";
14
14
  import "../chunk-NKUETCDA.js";
15
15
  import "../chunk-RDLEIAQU.js";
16
16
  import "../chunk-ORMEWXMH.js";
@@ -463,14 +463,14 @@ var NavigationTabs = ({
463
463
  onTabChange,
464
464
  colorPrimitives = "dmsi"
465
465
  }) => {
466
- var _a, _b, _c;
467
- const [selectedTab, setSelectedTab] = (0, import_react.useState)((_a = tabs[0]) == null ? void 0 : _a.id);
466
+ var _a, _b, _c, _d;
467
+ const [selectedTab, setSelectedTab] = (0, import_react.useState)((_b = (_a = tabs[0]) == null ? void 0 : _a.id) != null ? _b : "");
468
468
  const handleTabClick = (id2) => {
469
469
  setSelectedTab(id2);
470
470
  onTabChange == null ? void 0 : onTabChange(id2);
471
471
  };
472
- const selectedContent = (_b = tabs.find((tab) => tab.id === selectedTab)) == null ? void 0 : _b.content;
473
- const selectedTabHasHref = (_c = tabs.find((tab) => tab.id === selectedTab)) == null ? void 0 : _c.href;
472
+ const selectedContent = (_c = tabs.find((tab) => tab.id === selectedTab)) == null ? void 0 : _c.content;
473
+ const selectedTabHasHref = (_d = tabs.find((tab) => tab.id === selectedTab)) == null ? void 0 : _d.href;
474
474
  return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { id, "data-testid": testid, children: [
475
475
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
476
476
  "div",
@@ -20,14 +20,14 @@ var NavigationTabs = ({
20
20
  onTabChange,
21
21
  colorPrimitives = "dmsi"
22
22
  }) => {
23
- var _a, _b, _c;
24
- const [selectedTab, setSelectedTab] = useState((_a = tabs[0]) == null ? void 0 : _a.id);
23
+ var _a, _b, _c, _d;
24
+ const [selectedTab, setSelectedTab] = useState((_b = (_a = tabs[0]) == null ? void 0 : _a.id) != null ? _b : "");
25
25
  const handleTabClick = (id2) => {
26
26
  setSelectedTab(id2);
27
27
  onTabChange == null ? void 0 : onTabChange(id2);
28
28
  };
29
- const selectedContent = (_b = tabs.find((tab) => tab.id === selectedTab)) == null ? void 0 : _b.content;
30
- const selectedTabHasHref = (_c = tabs.find((tab) => tab.id === selectedTab)) == null ? void 0 : _c.href;
29
+ const selectedContent = (_c = tabs.find((tab) => tab.id === selectedTab)) == null ? void 0 : _c.content;
30
+ const selectedTabHasHref = (_d = tabs.find((tab) => tab.id === selectedTab)) == null ? void 0 : _d.href;
31
31
  return /* @__PURE__ */ jsxs("div", { id, "data-testid": testid, children: [
32
32
  /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
33
33
  "div",
@@ -1,11 +1,11 @@
1
1
  "use client";
2
2
  import {
3
3
  MenuOption
4
- } from "../chunk-AEDEFN7A.js";
5
- import "../chunk-JWCT72WR.js";
4
+ } from "../chunk-FFU6FB3K.js";
6
5
  import {
7
6
  useKeydown
8
7
  } from "../chunk-WNQ53SVY.js";
8
+ import "../chunk-JWCT72WR.js";
9
9
  import "../chunk-HVI3CL7Y.js";
10
10
  import {
11
11
  Icon
@@ -2,15 +2,15 @@
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
  Stack
10
7
  } from "../chunk-N6JVLYEE.js";
11
8
  import {
12
9
  Paragraph
13
10
  } from "../chunk-HVI3CL7Y.js";
11
+ import {
12
+ Button
13
+ } from "../chunk-FKMKHLQH.js";
14
14
  import {
15
15
  Icon
16
16
  } from "../chunk-NKUETCDA.js";
@@ -588,7 +588,7 @@ function findDocumentRoot(element) {
588
588
  if (!element || !(element instanceof Node)) {
589
589
  return window.document.body;
590
590
  }
591
- var currentElement = element;
591
+ let currentElement = element;
592
592
  while (currentElement && currentElement.parentNode) {
593
593
  if (currentElement.parentNode === document) {
594
594
  return document.body;
@@ -1154,8 +1154,118 @@ var WhichIcon = ({
1154
1154
  };
1155
1155
  Caption.displayName = "Caption";
1156
1156
 
1157
- // src/components/PDFViewer.tsx
1157
+ // src/components/Spinner.tsx
1158
1158
  var import_jsx_runtime11 = require("react/jsx-runtime");
1159
+ var Spinner = ({ size = "small", testid }) => {
1160
+ const dimension = size === "large" ? 48 : 24;
1161
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
1162
+ "svg",
1163
+ {
1164
+ "data-testid": testid,
1165
+ width: dimension,
1166
+ height: dimension,
1167
+ viewBox: "0 0 24 24",
1168
+ xmlns: "http://www.w3.org/2000/svg",
1169
+ fill: "#1D1E1E",
1170
+ className: "animate-spin",
1171
+ "aria-label": "Loading",
1172
+ children: [
1173
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("circle", { cx: "12", cy: "4", r: "2", opacity: "1", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1174
+ "animate",
1175
+ {
1176
+ attributeName: "opacity",
1177
+ begin: "0s",
1178
+ dur: "1s",
1179
+ from: "1",
1180
+ to: "0",
1181
+ repeatCount: "indefinite"
1182
+ }
1183
+ ) }),
1184
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("circle", { cx: "17.666", cy: "6.334", r: "2", opacity: "0.125", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1185
+ "animate",
1186
+ {
1187
+ attributeName: "opacity",
1188
+ begin: "-0.875s",
1189
+ dur: "1s",
1190
+ from: "1",
1191
+ to: "0",
1192
+ repeatCount: "indefinite"
1193
+ }
1194
+ ) }),
1195
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("circle", { cx: "20", cy: "12", r: "2", opacity: "0.25", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1196
+ "animate",
1197
+ {
1198
+ attributeName: "opacity",
1199
+ begin: "-0.75s",
1200
+ dur: "1s",
1201
+ from: "1",
1202
+ to: "0",
1203
+ repeatCount: "indefinite"
1204
+ }
1205
+ ) }),
1206
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("circle", { cx: "17.666", cy: "17.666", r: "2", opacity: "0.375", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1207
+ "animate",
1208
+ {
1209
+ attributeName: "opacity",
1210
+ begin: "-0.625s",
1211
+ dur: "1s",
1212
+ from: "1",
1213
+ to: "0",
1214
+ repeatCount: "indefinite"
1215
+ }
1216
+ ) }),
1217
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("circle", { cx: "12", cy: "20", r: "2", opacity: "0.5", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1218
+ "animate",
1219
+ {
1220
+ attributeName: "opacity",
1221
+ begin: "-0.5s",
1222
+ dur: "1s",
1223
+ from: "1",
1224
+ to: "0",
1225
+ repeatCount: "indefinite"
1226
+ }
1227
+ ) }),
1228
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("circle", { cx: "6.334", cy: "17.666", r: "2", opacity: "0.625", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1229
+ "animate",
1230
+ {
1231
+ attributeName: "opacity",
1232
+ begin: "-0.375s",
1233
+ dur: "1s",
1234
+ from: "1",
1235
+ to: "0",
1236
+ repeatCount: "indefinite"
1237
+ }
1238
+ ) }),
1239
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("circle", { cx: "4", cy: "12", r: "2", opacity: "0.75", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1240
+ "animate",
1241
+ {
1242
+ attributeName: "opacity",
1243
+ begin: "-0.25s",
1244
+ dur: "1s",
1245
+ from: "1",
1246
+ to: "0",
1247
+ repeatCount: "indefinite"
1248
+ }
1249
+ ) }),
1250
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("circle", { cx: "6.334", cy: "6.334", r: "2", opacity: "0.875", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1251
+ "animate",
1252
+ {
1253
+ attributeName: "opacity",
1254
+ begin: "-0.125s",
1255
+ dur: "1s",
1256
+ from: "1",
1257
+ to: "0",
1258
+ repeatCount: "indefinite"
1259
+ }
1260
+ ) })
1261
+ ]
1262
+ }
1263
+ );
1264
+ };
1265
+ Spinner.displayName = "Spinner";
1266
+
1267
+ // src/components/PDFViewer.tsx
1268
+ var import_jsx_runtime12 = require("react/jsx-runtime");
1159
1269
  function PDFViewer(props) {
1160
1270
  const { isOpen, onClose, encodedPdfs, customActions, testid } = props;
1161
1271
  const [currentIndex, setCurrentIndex] = (0, import_react6.useState)(0);
@@ -1163,15 +1273,20 @@ function PDFViewer(props) {
1163
1273
  const handleDownload = (0, import_react6.useCallback)(() => {
1164
1274
  setIsDownloading(true);
1165
1275
  const link = document.createElement("a");
1166
- link.href = `data:application/pdf;base64,${encodedPdfs[currentIndex].base64}`;
1167
- link.download = encodedPdfs[currentIndex].fileName.endsWith(".pdf") ? encodedPdfs[currentIndex].fileName : `${encodedPdfs[currentIndex].fileName}.pdf`;
1276
+ const currentPdf = encodedPdfs[currentIndex];
1277
+ if (!currentPdf) {
1278
+ setIsDownloading(false);
1279
+ return;
1280
+ }
1281
+ link.href = `data:application/pdf;base64,${currentPdf.base64}`;
1282
+ link.download = currentPdf.fileName.endsWith(".pdf") ? currentPdf.fileName : `${currentPdf.fileName}.pdf`;
1168
1283
  document.body.appendChild(link);
1169
1284
  link.click();
1170
1285
  document.body.removeChild(link);
1171
1286
  setIsDownloading(false);
1172
1287
  }, [currentIndex, encodedPdfs]);
1173
1288
  if (!encodedPdfs.length) return null;
1174
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1289
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1175
1290
  Modal,
1176
1291
  {
1177
1292
  testid,
@@ -1179,14 +1294,22 @@ function PDFViewer(props) {
1179
1294
  onClose,
1180
1295
  showButtons: !!customActions,
1181
1296
  customActions,
1182
- headerIcon: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(DownloadIcon, { testid: testid ? `${testid}-download-icon` : void 0, onClick: handleDownload, isDownloading }),
1183
- children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(Stack, { sizing: "layout", children: [
1184
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(PDFElement, { testid, b64: encodedPdfs[currentIndex].base64 }),
1185
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Stack, { horizontal: true, overflowX: "auto", sizing: "layout-group", children: encodedPdfs.map((pdf, index) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1297
+ headerIcon: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1298
+ DownloadIcon,
1299
+ {
1300
+ testid: testid ? `${testid}-download-icon` : void 0,
1301
+ onClick: handleDownload,
1302
+ isDownloading
1303
+ }
1304
+ ),
1305
+ children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(Stack, { sizing: "layout", children: [
1306
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(PDFElement, { testid, b64: encodedPdfs[currentIndex].base64 }),
1307
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Stack, { horizontal: true, overflowX: "auto", sizing: "layout-group", children: encodedPdfs.map((pdf, index) => /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
1186
1308
  Button,
1187
1309
  {
1188
1310
  testid: testid ? `${testid}-${pdf.fileName}-button` : void 0,
1189
1311
  variant: index === currentIndex ? "primary" : "secondary",
1312
+ classNameLabel: "items-center flex flex-row gap-2",
1190
1313
  onClick: (e) => {
1191
1314
  setCurrentIndex(index);
1192
1315
  requestAnimationFrame(() => {
@@ -1198,8 +1321,11 @@ function PDFViewer(props) {
1198
1321
  });
1199
1322
  });
1200
1323
  },
1201
- disabled: isDownloading || currentIndex === index,
1202
- children: pdf.fileName
1324
+ disabled: isDownloading || currentIndex === index || !pdf.base64,
1325
+ children: [
1326
+ !pdf.base64 && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Spinner, {}),
1327
+ pdf.fileName
1328
+ ]
1203
1329
  },
1204
1330
  `${pdf.fileName}-${index}`
1205
1331
  )) })
@@ -1212,13 +1338,13 @@ function DownloadIcon({
1212
1338
  isDownloading,
1213
1339
  testid
1214
1340
  }) {
1215
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1341
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1216
1342
  Button,
1217
1343
  {
1218
1344
  testid,
1219
1345
  iconOnly: true,
1220
1346
  variant: "tertiary",
1221
- leftIcon: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Icon, { name: isDownloading ? "cached" : "download" }),
1347
+ leftIcon: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Icon, { name: isDownloading ? "cached" : "download" }),
1222
1348
  onClick
1223
1349
  }
1224
1350
  );
@@ -1233,36 +1359,71 @@ function PDFElement({ b64, testid }) {
1233
1359
  canvasRef,
1234
1360
  scale: 1
1235
1361
  });
1236
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "flex flex-col space-y-4", children: [
1237
- pdfDocument ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("canvas", { "data-testid": testid ? `${testid}-pdf-content` : void 0, ref: canvasRef }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { "data-testid": testid ? `${testid}-pdf-loading` : void 0, children: "Loading PDF..." }),
1238
- (pdfDocument == null ? void 0 : pdfDocument.numPages) && pdfDocument.numPages > 1 && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("ul", { className: "flex flex-row justify-between items-center", "data-testid": testid ? `${testid}-pdf-pagination` : void 0, children: [
1239
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("li", { className: "previous", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1240
- "button",
1241
- {
1242
- "data-testid": testid ? `${testid}-pdf-pagination-previous-button` : void 0,
1243
- disabled: page === 1,
1244
- onClick: () => setPage(page - 1),
1245
- className: "not-disabled:cursor-pointer not-disabled:hover:underline ",
1246
- children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Caption, { children: "Previous" })
1247
- }
1248
- ) }),
1249
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("li", { "data-testid": testid ? `${testid}-pdf-pagination-text` : void 0, className: "text-label-desktop text-text-on-action-primary-normal", children: [
1250
- "Page ",
1251
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { "data-testid": testid ? `${testid}-pdf-pagination-page-${page}` : void 0, children: page }),
1252
- " of ",
1253
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { "data-testid": testid ? `${testid}-pdf-pagination-total-page-${pdfDocument.numPages}` : void 0, children: pdfDocument.numPages })
1254
- ] }),
1255
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("li", { className: "next", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1256
- "button",
1257
- {
1258
- "data-testid": testid ? `${testid}-pdf-pagination-next-button` : void 0,
1259
- disabled: page === pdfDocument.numPages,
1260
- onClick: () => setPage(page + 1),
1261
- className: "not-disabled:cursor-pointer not-disabled:hover:underline ",
1262
- children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Caption, { children: "Next" })
1263
- }
1264
- ) })
1265
- ] })
1362
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex flex-col space-y-4", children: [
1363
+ pdfDocument ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1364
+ "canvas",
1365
+ {
1366
+ "data-testid": testid ? `${testid}-pdf-content` : void 0,
1367
+ ref: canvasRef
1368
+ }
1369
+ ) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { "data-testid": testid ? `${testid}-pdf-loading` : void 0, children: "Loading PDF..." }),
1370
+ (pdfDocument == null ? void 0 : pdfDocument.numPages) && pdfDocument.numPages > 1 && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
1371
+ "ul",
1372
+ {
1373
+ className: "flex flex-row justify-between items-center",
1374
+ "data-testid": testid ? `${testid}-pdf-pagination` : void 0,
1375
+ children: [
1376
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("li", { className: "previous", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1377
+ "button",
1378
+ {
1379
+ "data-testid": testid ? `${testid}-pdf-pagination-previous-button` : void 0,
1380
+ disabled: page === 1,
1381
+ onClick: () => setPage(page - 1),
1382
+ className: "not-disabled:cursor-pointer not-disabled:hover:underline ",
1383
+ children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Caption, { children: "Previous" })
1384
+ }
1385
+ ) }),
1386
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
1387
+ "li",
1388
+ {
1389
+ "data-testid": testid ? `${testid}-pdf-pagination-text` : void 0,
1390
+ className: "text-label-desktop text-text-on-action-primary-normal",
1391
+ children: [
1392
+ "Page",
1393
+ " ",
1394
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1395
+ "span",
1396
+ {
1397
+ "data-testid": testid ? `${testid}-pdf-pagination-page-${page}` : void 0,
1398
+ children: page
1399
+ }
1400
+ ),
1401
+ " ",
1402
+ "of",
1403
+ " ",
1404
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1405
+ "span",
1406
+ {
1407
+ "data-testid": testid ? `${testid}-pdf-pagination-total-page-${pdfDocument.numPages}` : void 0,
1408
+ children: pdfDocument.numPages
1409
+ }
1410
+ )
1411
+ ]
1412
+ }
1413
+ ),
1414
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("li", { className: "next", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1415
+ "button",
1416
+ {
1417
+ "data-testid": testid ? `${testid}-pdf-pagination-next-button` : void 0,
1418
+ disabled: page === pdfDocument.numPages,
1419
+ onClick: () => setPage(page + 1),
1420
+ className: "not-disabled:cursor-pointer not-disabled:hover:underline ",
1421
+ children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Caption, { children: "Next" })
1422
+ }
1423
+ ) })
1424
+ ]
1425
+ }
1426
+ )
1266
1427
  ] });
1267
1428
  }
1268
1429
  // Annotate the CommonJS export names for ESM import in node:
@@ -1,24 +1,27 @@
1
1
  "use client";
2
2
  import {
3
3
  Modal
4
- } from "../chunk-NRCUFAOZ.js";
4
+ } from "../chunk-FCREADUH.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-6LN6QT6M.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";
@@ -586,7 +586,7 @@ function findDocumentRoot(element) {
586
586
  if (!element || !(element instanceof Node)) {
587
587
  return window.document.body;
588
588
  }
589
- var currentElement = element;
589
+ let currentElement = element;
590
590
  while (currentElement && currentElement.parentNode) {
591
591
  if (currentElement.parentNode === document) {
592
592
  return document.body;
@@ -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)(