@dmsi/wedgekit-react 0.0.171 → 0.0.173

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.
@@ -432,6 +432,7 @@ var ModalHeader = ({
432
432
  title,
433
433
  hideCloseIcon,
434
434
  headerIcon,
435
+ headerIconAlign,
435
436
  onClose,
436
437
  id,
437
438
  testid
@@ -443,13 +444,24 @@ var ModalHeader = ({
443
444
  "data-testid": testid,
444
445
  className: (0, import_clsx5.default)(
445
446
  "flex justify-between items-center",
447
+ headerIconAlign === "center" && "justify-center",
448
+ headerIconAlign === "right" && "justify-end",
449
+ headerIconAlign === "left" && "justify-start",
446
450
  layoutPaddding,
447
451
  layoutGroupGap
448
452
  ),
449
453
  children: [
450
454
  /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: (0, import_clsx5.default)("flex items-center", layoutGroupGap), children: [
451
455
  headerIcon,
452
- title && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Heading2, { id: id ? `${id}-title` : void 0, testid: testid ? `${testid}-title` : void 0, as: "p", children: title })
456
+ title && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
457
+ Heading2,
458
+ {
459
+ id: id ? `${id}-title` : void 0,
460
+ testid: testid ? `${testid}-title` : void 0,
461
+ as: "p",
462
+ children: title
463
+ }
464
+ )
453
465
  ] }),
454
466
  !hideCloseIcon && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
455
467
  Button,
@@ -709,6 +721,7 @@ var Modal = ({
709
721
  showButtons = false,
710
722
  hideCloseIcon = false,
711
723
  headerIcon,
724
+ headerIconAlign,
712
725
  fixedHeightScrolling = false,
713
726
  customActions
714
727
  }) => {
@@ -738,7 +751,7 @@ var Modal = ({
738
751
  fadeInScale(modalRef.current);
739
752
  bgFadeIn(bgRef.current);
740
753
  }
741
- }, [mounted, open]);
754
+ }, [mounted, onClose, open, wasOpen]);
742
755
  const handleKeyDown = (0, import_react5.useCallback)(
743
756
  (e) => {
744
757
  if (e.key === "Escape") {
@@ -748,7 +761,7 @@ var Modal = ({
748
761
  }
749
762
  }
750
763
  },
751
- [onClose, bgRef, modalRef]
764
+ [onClose]
752
765
  );
753
766
  const handleClose = (0, import_react5.useCallback)(() => {
754
767
  if (onClose) {
@@ -833,7 +846,8 @@ var Modal = ({
833
846
  title,
834
847
  onClose: handleClose,
835
848
  hideCloseIcon,
836
- headerIcon
849
+ headerIcon,
850
+ headerIconAlign
837
851
  }
838
852
  ),
839
853
  children && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
@@ -1264,8 +1278,61 @@ var Spinner = ({ size = "small", testid }) => {
1264
1278
  };
1265
1279
  Spinner.displayName = "Spinner";
1266
1280
 
1267
- // src/components/PDFViewer.tsx
1281
+ // src/components/Paragraph.tsx
1282
+ var import_clsx12 = __toESM(require("clsx"), 1);
1268
1283
  var import_jsx_runtime12 = require("react/jsx-runtime");
1284
+ var Paragraph = (_a) => {
1285
+ var _b = _a, {
1286
+ className,
1287
+ color,
1288
+ padded,
1289
+ align = "left",
1290
+ tall,
1291
+ addOverflow,
1292
+ children,
1293
+ as = "p",
1294
+ id,
1295
+ testid
1296
+ } = _b, props = __objRest(_b, [
1297
+ "className",
1298
+ "color",
1299
+ "padded",
1300
+ "align",
1301
+ "tall",
1302
+ "addOverflow",
1303
+ "children",
1304
+ "as",
1305
+ "id",
1306
+ "testid"
1307
+ ]);
1308
+ const Element = as;
1309
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1310
+ Element,
1311
+ __spreadProps(__spreadValues({
1312
+ id,
1313
+ "data-testid": testid
1314
+ }, props), {
1315
+ className: (0, import_clsx12.default)(
1316
+ typography.paragraph,
1317
+ className,
1318
+ padded && componentPaddingXUsingComponentGap,
1319
+ align === "left" && "text-left",
1320
+ align === "center" && "text-center",
1321
+ align === "right" && "text-right",
1322
+ tall && "!leading-6",
1323
+ addOverflow && "whitespace-nowrap text-ellipsis overflow-hidden"
1324
+ ),
1325
+ style: __spreadProps(__spreadValues({}, props.style), {
1326
+ color: color ? `var(--color-${color})` : void 0
1327
+ }),
1328
+ children
1329
+ })
1330
+ );
1331
+ };
1332
+ Paragraph.displayName = "Paragraph";
1333
+
1334
+ // src/components/PDFViewer.tsx
1335
+ var import_jsx_runtime13 = require("react/jsx-runtime");
1269
1336
  function PDFViewer(props) {
1270
1337
  const { isOpen, onClose, encodedPdfs, customActions, testid } = props;
1271
1338
  const [currentIndex, setCurrentIndex] = (0, import_react6.useState)(0);
@@ -1286,15 +1353,33 @@ function PDFViewer(props) {
1286
1353
  setIsDownloading(false);
1287
1354
  }, [currentIndex, encodedPdfs]);
1288
1355
  if (!encodedPdfs.length) return null;
1289
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1356
+ function handleNextFile() {
1357
+ if (currentIndex < encodedPdfs.length - 1) {
1358
+ setCurrentIndex((prev) => prev + 1);
1359
+ }
1360
+ }
1361
+ function handlePreviousFile() {
1362
+ if (currentIndex > 0) {
1363
+ setCurrentIndex((prev) => prev - 1);
1364
+ }
1365
+ }
1366
+ function handleClose() {
1367
+ setCurrentIndex(0);
1368
+ setIsDownloading(false);
1369
+ onClose();
1370
+ }
1371
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1290
1372
  Modal,
1291
1373
  {
1292
1374
  testid,
1293
1375
  open: isOpen,
1294
- onClose,
1376
+ onClose: handleClose,
1295
1377
  showButtons: !!customActions,
1296
1378
  customActions,
1297
- headerIcon: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1379
+ size: "large",
1380
+ fixedHeightScrolling: true,
1381
+ headerIconAlign: "right",
1382
+ headerIcon: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1298
1383
  DownloadIcon,
1299
1384
  {
1300
1385
  testid: testid ? `${testid}-download-icon` : void 0,
@@ -1302,33 +1387,49 @@ function PDFViewer(props) {
1302
1387
  isDownloading
1303
1388
  }
1304
1389
  ),
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)(
1308
- Button,
1390
+ className: "!max-w-fit",
1391
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(Stack, { sizing: "layout", items: "center", children: [
1392
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(PDFElement, { testid, b64: encodedPdfs[currentIndex].base64 }),
1393
+ !!encodedPdfs[currentIndex].fileName && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Paragraph, { children: encodedPdfs[currentIndex].fileName.endsWith(".pdf") ? encodedPdfs[currentIndex].fileName : `${encodedPdfs[currentIndex].fileName}.pdf` }),
1394
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
1395
+ Stack,
1309
1396
  {
1310
- testid: testid ? `${testid}-${pdf.fileName}-button` : void 0,
1311
- variant: index === currentIndex ? "primary" : "secondary",
1312
- classNameLabel: "items-center flex flex-row gap-2",
1313
- onClick: (e) => {
1314
- setCurrentIndex(index);
1315
- requestAnimationFrame(() => {
1316
- const button = e.target;
1317
- button.scrollIntoView({
1318
- behavior: "smooth",
1319
- block: "nearest",
1320
- inline: "center"
1321
- });
1322
- });
1323
- },
1324
- disabled: isDownloading || currentIndex === index || !pdf.base64,
1397
+ horizontal: true,
1398
+ overflowX: "auto",
1399
+ justify: "center",
1400
+ items: "center",
1401
+ sizing: "layout-group",
1325
1402
  children: [
1326
- !pdf.base64 && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Spinner, {}),
1327
- pdf.fileName
1403
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1404
+ Button,
1405
+ {
1406
+ iconOnly: true,
1407
+ variant: "tertiary",
1408
+ onClick: handlePreviousFile,
1409
+ leftIcon: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Icon, { name: "chevron_backward" }),
1410
+ disabled: currentIndex === 0,
1411
+ testid: testid ? `${testid}-pdf-file-previous-button` : void 0
1412
+ }
1413
+ ),
1414
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(Heading3, { className: "text-text-primary-normal", children: [
1415
+ currentIndex + 1,
1416
+ " / ",
1417
+ encodedPdfs.length
1418
+ ] }),
1419
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1420
+ Button,
1421
+ {
1422
+ iconOnly: true,
1423
+ variant: "tertiary",
1424
+ onClick: handleNextFile,
1425
+ rightIcon: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Icon, { name: "chevron_forward" }),
1426
+ disabled: currentIndex === encodedPdfs.length - 1,
1427
+ testid: testid ? `${testid}-pdf-file-next-button` : void 0
1428
+ }
1429
+ )
1328
1430
  ]
1329
- },
1330
- `${pdf.fileName}-${index}`
1331
- )) })
1431
+ }
1432
+ )
1332
1433
  ] })
1333
1434
  }
1334
1435
  );
@@ -1338,13 +1439,13 @@ function DownloadIcon({
1338
1439
  isDownloading,
1339
1440
  testid
1340
1441
  }) {
1341
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1442
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1342
1443
  Button,
1343
1444
  {
1344
1445
  testid,
1345
1446
  iconOnly: true,
1346
1447
  variant: "tertiary",
1347
- leftIcon: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Icon, { name: isDownloading ? "cached" : "download" }),
1448
+ leftIcon: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Icon, { name: isDownloading ? "cached" : "download" }),
1348
1449
  onClick
1349
1450
  }
1350
1451
  );
@@ -1357,74 +1458,93 @@ function PDFElement({ b64, testid }) {
1357
1458
  workerSrc: "/scripts/pdf.worker.min.mjs",
1358
1459
  page,
1359
1460
  canvasRef,
1360
- scale: 1
1461
+ scale: 1.1
1361
1462
  });
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
- )
1427
- ] });
1463
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
1464
+ "div",
1465
+ {
1466
+ className: "flex flex-col space-y-4 ",
1467
+ style: {
1468
+ minHeight: 871,
1469
+ minWidth: 654
1470
+ },
1471
+ children: [
1472
+ !!pdfDocument && !!b64 ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1473
+ "canvas",
1474
+ {
1475
+ "data-testid": testid ? `${testid}-pdf-content` : void 0,
1476
+ ref: canvasRef
1477
+ }
1478
+ ) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1479
+ Stack,
1480
+ {
1481
+ justify: "center",
1482
+ items: "center",
1483
+ height: "full",
1484
+ flexGrow: 1,
1485
+ "data-testid": testid ? `${testid}-pdf-loading` : void 0,
1486
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Spinner, { size: "large" })
1487
+ }
1488
+ ),
1489
+ (pdfDocument == null ? void 0 : pdfDocument.numPages) && pdfDocument.numPages > 1 && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
1490
+ "ul",
1491
+ {
1492
+ className: "flex flex-row justify-between items-center",
1493
+ "data-testid": testid ? `${testid}-pdf-pagination` : void 0,
1494
+ children: [
1495
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("li", { className: "previous", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1496
+ "button",
1497
+ {
1498
+ "data-testid": testid ? `${testid}-pdf-pagination-previous-button` : void 0,
1499
+ disabled: page === 1,
1500
+ onClick: () => setPage(page - 1),
1501
+ className: "not-disabled:cursor-pointer not-disabled:hover:underline ",
1502
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Caption, { className: "not-disabled:cursor-pointer not-disabled:hover:underline not-disabled:text-text-primary-normal", children: "Previous" })
1503
+ }
1504
+ ) }),
1505
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
1506
+ "li",
1507
+ {
1508
+ "data-testid": testid ? `${testid}-pdf-pagination-text` : void 0,
1509
+ className: "text-label-desktop text-text-primary-normal",
1510
+ children: [
1511
+ "Page",
1512
+ " ",
1513
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1514
+ "span",
1515
+ {
1516
+ "data-testid": testid ? `${testid}-pdf-pagination-page-${page}` : void 0,
1517
+ children: page
1518
+ }
1519
+ ),
1520
+ " ",
1521
+ "of",
1522
+ " ",
1523
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1524
+ "span",
1525
+ {
1526
+ "data-testid": testid ? `${testid}-pdf-pagination-total-page-${pdfDocument.numPages}` : void 0,
1527
+ children: pdfDocument.numPages
1528
+ }
1529
+ )
1530
+ ]
1531
+ }
1532
+ ),
1533
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("li", { className: "next", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1534
+ "button",
1535
+ {
1536
+ "data-testid": testid ? `${testid}-pdf-pagination-next-button` : void 0,
1537
+ disabled: page === pdfDocument.numPages,
1538
+ onClick: () => setPage(page + 1),
1539
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Caption, { className: "not-disabled:cursor-pointer not-disabled:hover:underline not-disabled:text-text-primary-normal", children: "Next" })
1540
+ }
1541
+ ) })
1542
+ ]
1543
+ }
1544
+ )
1545
+ ]
1546
+ }
1547
+ );
1428
1548
  }
1429
1549
  // Annotate the CommonJS export names for ESM import in node:
1430
1550
  0 && (module.exports = {