@dmsi/wedgekit-react 0.0.189 → 0.0.190

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.
@@ -1374,8 +1374,21 @@ function PDFViewer(props) {
1374
1374
  testid,
1375
1375
  open: isOpen,
1376
1376
  onClose: handleClose,
1377
- showButtons: !!customActions,
1378
- customActions,
1377
+ showButtons: !!encodedPdfs.length,
1378
+ customActions: !!encodedPdfs.length && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1379
+ PdfNavigation,
1380
+ {
1381
+ testid,
1382
+ currentIndex,
1383
+ total: encodedPdfs.length,
1384
+ onPrev: handlePreviousFile,
1385
+ onNext: handleNextFile,
1386
+ disablePrev: currentIndex === 0,
1387
+ disableNext: currentIndex === encodedPdfs.length - 1,
1388
+ extraActions: customActions,
1389
+ fileName: encodedPdfs[currentIndex].fileName
1390
+ }
1391
+ ),
1379
1392
  size: "large",
1380
1393
  fixedHeightScrolling: true,
1381
1394
  headerIconAlign: "right",
@@ -1390,46 +1403,7 @@ function PDFViewer(props) {
1390
1403
  className: "!max-w-fit",
1391
1404
  children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(Stack, { sizing: "layout", items: "center", children: [
1392
1405
  /* @__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,
1396
- {
1397
- horizontal: true,
1398
- overflowX: "auto",
1399
- justify: "center",
1400
- items: "center",
1401
- sizing: "layout-group",
1402
- children: [
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
- )
1430
- ]
1431
- }
1432
- )
1406
+ !!encodedPdfs[currentIndex].fileName && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Paragraph, { children: encodedPdfs[currentIndex].fileName.endsWith(".pdf") ? encodedPdfs[currentIndex].fileName : `${encodedPdfs[currentIndex].fileName}.pdf` })
1433
1407
  ] })
1434
1408
  }
1435
1409
  );
@@ -1546,6 +1520,61 @@ function PDFElement({ b64, testid }) {
1546
1520
  }
1547
1521
  );
1548
1522
  }
1523
+ function PdfNavigation({
1524
+ currentIndex,
1525
+ total,
1526
+ onPrev,
1527
+ onNext,
1528
+ disablePrev,
1529
+ disableNext,
1530
+ extraActions,
1531
+ testid,
1532
+ fileName
1533
+ }) {
1534
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "w-full", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
1535
+ Stack,
1536
+ {
1537
+ horizontal: true,
1538
+ items: "center",
1539
+ justify: "between",
1540
+ sizing: "layout-group",
1541
+ testid: testid ? `${testid}-pdf-navigation` : void 0,
1542
+ children: [
1543
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(Stack, { horizontal: true, items: "center", children: [
1544
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1545
+ Button,
1546
+ {
1547
+ iconOnly: true,
1548
+ variant: "tertiary",
1549
+ onClick: onPrev,
1550
+ leftIcon: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Icon, { name: "chevron_backward" }),
1551
+ disabled: disablePrev,
1552
+ testid: testid ? `${testid}-pdf-file-previous-button` : void 0
1553
+ }
1554
+ ),
1555
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(Heading3, { className: "text-text-primary-normal whitespace-nowrap", children: [
1556
+ currentIndex + 1,
1557
+ " / ",
1558
+ total
1559
+ ] }),
1560
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1561
+ Button,
1562
+ {
1563
+ iconOnly: true,
1564
+ variant: "tertiary",
1565
+ onClick: onNext,
1566
+ rightIcon: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Icon, { name: "chevron_forward" }),
1567
+ disabled: disableNext,
1568
+ testid: testid ? `${testid}-pdf-file-next-button` : void 0
1569
+ }
1570
+ ),
1571
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Paragraph, { children: (fileName == null ? void 0 : fileName.endsWith(".pdf")) ? fileName : `${fileName}.pdf` })
1572
+ ] }),
1573
+ extraActions && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "flex items-center gap-2", children: extraActions })
1574
+ ]
1575
+ }
1576
+ ) });
1577
+ }
1549
1578
  // Annotate the CommonJS export names for ESM import in node:
1550
1579
  0 && (module.exports = {
1551
1580
  PDFViewer
@@ -78,8 +78,21 @@ function PDFViewer(props) {
78
78
  testid,
79
79
  open: isOpen,
80
80
  onClose: handleClose,
81
- showButtons: !!customActions,
82
- customActions,
81
+ showButtons: !!encodedPdfs.length,
82
+ customActions: !!encodedPdfs.length && /* @__PURE__ */ jsx(
83
+ PdfNavigation,
84
+ {
85
+ testid,
86
+ currentIndex,
87
+ total: encodedPdfs.length,
88
+ onPrev: handlePreviousFile,
89
+ onNext: handleNextFile,
90
+ disablePrev: currentIndex === 0,
91
+ disableNext: currentIndex === encodedPdfs.length - 1,
92
+ extraActions: customActions,
93
+ fileName: encodedPdfs[currentIndex].fileName
94
+ }
95
+ ),
83
96
  size: "large",
84
97
  fixedHeightScrolling: true,
85
98
  headerIconAlign: "right",
@@ -94,46 +107,7 @@ function PDFViewer(props) {
94
107
  className: "!max-w-fit",
95
108
  children: /* @__PURE__ */ jsxs(Stack, { sizing: "layout", items: "center", children: [
96
109
  /* @__PURE__ */ jsx(PDFElement, { testid, b64: encodedPdfs[currentIndex].base64 }),
97
- !!encodedPdfs[currentIndex].fileName && /* @__PURE__ */ jsx(Paragraph, { children: encodedPdfs[currentIndex].fileName.endsWith(".pdf") ? encodedPdfs[currentIndex].fileName : `${encodedPdfs[currentIndex].fileName}.pdf` }),
98
- /* @__PURE__ */ jsxs(
99
- Stack,
100
- {
101
- horizontal: true,
102
- overflowX: "auto",
103
- justify: "center",
104
- items: "center",
105
- sizing: "layout-group",
106
- children: [
107
- /* @__PURE__ */ jsx(
108
- Button,
109
- {
110
- iconOnly: true,
111
- variant: "tertiary",
112
- onClick: handlePreviousFile,
113
- leftIcon: /* @__PURE__ */ jsx(Icon, { name: "chevron_backward" }),
114
- disabled: currentIndex === 0,
115
- testid: testid ? `${testid}-pdf-file-previous-button` : void 0
116
- }
117
- ),
118
- /* @__PURE__ */ jsxs(Heading3, { className: "text-text-primary-normal", children: [
119
- currentIndex + 1,
120
- " / ",
121
- encodedPdfs.length
122
- ] }),
123
- /* @__PURE__ */ jsx(
124
- Button,
125
- {
126
- iconOnly: true,
127
- variant: "tertiary",
128
- onClick: handleNextFile,
129
- rightIcon: /* @__PURE__ */ jsx(Icon, { name: "chevron_forward" }),
130
- disabled: currentIndex === encodedPdfs.length - 1,
131
- testid: testid ? `${testid}-pdf-file-next-button` : void 0
132
- }
133
- )
134
- ]
135
- }
136
- )
110
+ !!encodedPdfs[currentIndex].fileName && /* @__PURE__ */ jsx(Paragraph, { children: encodedPdfs[currentIndex].fileName.endsWith(".pdf") ? encodedPdfs[currentIndex].fileName : `${encodedPdfs[currentIndex].fileName}.pdf` })
137
111
  ] })
138
112
  }
139
113
  );
@@ -250,6 +224,61 @@ function PDFElement({ b64, testid }) {
250
224
  }
251
225
  );
252
226
  }
227
+ function PdfNavigation({
228
+ currentIndex,
229
+ total,
230
+ onPrev,
231
+ onNext,
232
+ disablePrev,
233
+ disableNext,
234
+ extraActions,
235
+ testid,
236
+ fileName
237
+ }) {
238
+ return /* @__PURE__ */ jsx("div", { className: "w-full", children: /* @__PURE__ */ jsxs(
239
+ Stack,
240
+ {
241
+ horizontal: true,
242
+ items: "center",
243
+ justify: "between",
244
+ sizing: "layout-group",
245
+ testid: testid ? `${testid}-pdf-navigation` : void 0,
246
+ children: [
247
+ /* @__PURE__ */ jsxs(Stack, { horizontal: true, items: "center", children: [
248
+ /* @__PURE__ */ jsx(
249
+ Button,
250
+ {
251
+ iconOnly: true,
252
+ variant: "tertiary",
253
+ onClick: onPrev,
254
+ leftIcon: /* @__PURE__ */ jsx(Icon, { name: "chevron_backward" }),
255
+ disabled: disablePrev,
256
+ testid: testid ? `${testid}-pdf-file-previous-button` : void 0
257
+ }
258
+ ),
259
+ /* @__PURE__ */ jsxs(Heading3, { className: "text-text-primary-normal whitespace-nowrap", children: [
260
+ currentIndex + 1,
261
+ " / ",
262
+ total
263
+ ] }),
264
+ /* @__PURE__ */ jsx(
265
+ Button,
266
+ {
267
+ iconOnly: true,
268
+ variant: "tertiary",
269
+ onClick: onNext,
270
+ rightIcon: /* @__PURE__ */ jsx(Icon, { name: "chevron_forward" }),
271
+ disabled: disableNext,
272
+ testid: testid ? `${testid}-pdf-file-next-button` : void 0
273
+ }
274
+ ),
275
+ /* @__PURE__ */ jsx(Paragraph, { children: (fileName == null ? void 0 : fileName.endsWith(".pdf")) ? fileName : `${fileName}.pdf` })
276
+ ] }),
277
+ extraActions && /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2", children: extraActions })
278
+ ]
279
+ }
280
+ ) });
281
+ }
253
282
  export {
254
283
  PDFViewer
255
284
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dmsi/wedgekit-react",
3
3
  "private": false,
4
- "version": "0.0.189",
4
+ "version": "0.0.190",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "build": "tsup",
@@ -67,8 +67,22 @@ export function PDFViewer(props: PDFViewerProps) {
67
67
  testid={testid}
68
68
  open={isOpen}
69
69
  onClose={handleClose}
70
- showButtons={!!customActions}
71
- customActions={customActions}
70
+ showButtons={!!encodedPdfs.length}
71
+ customActions={
72
+ !!encodedPdfs.length && (
73
+ <PdfNavigation
74
+ testid={testid}
75
+ currentIndex={currentIndex}
76
+ total={encodedPdfs.length}
77
+ onPrev={handlePreviousFile}
78
+ onNext={handleNextFile}
79
+ disablePrev={currentIndex === 0}
80
+ disableNext={currentIndex === encodedPdfs.length - 1}
81
+ extraActions={customActions}
82
+ fileName={encodedPdfs[currentIndex].fileName}
83
+ />
84
+ )
85
+ }
72
86
  size="large"
73
87
  fixedHeightScrolling
74
88
  headerIconAlign="right"
@@ -90,58 +104,6 @@ export function PDFViewer(props: PDFViewerProps) {
90
104
  : `${encodedPdfs[currentIndex].fileName}.pdf`}
91
105
  </Paragraph>
92
106
  )}
93
- <Stack
94
- horizontal
95
- overflowX="auto"
96
- justify="center"
97
- items="center"
98
- sizing="layout-group"
99
- >
100
- <Button
101
- iconOnly
102
- variant="tertiary"
103
- onClick={handlePreviousFile}
104
- leftIcon={<Icon name="chevron_backward" />}
105
- disabled={currentIndex === 0}
106
- testid={testid ? `${testid}-pdf-file-previous-button` : undefined}
107
- />
108
- <Heading3 className="text-text-primary-normal">
109
- {currentIndex + 1} / {encodedPdfs.length}
110
- </Heading3>
111
- <Button
112
- iconOnly
113
- variant="tertiary"
114
- onClick={handleNextFile}
115
- rightIcon={<Icon name="chevron_forward" />}
116
- disabled={currentIndex === encodedPdfs.length - 1}
117
- testid={testid ? `${testid}-pdf-file-next-button` : undefined}
118
- />
119
- {/* {encodedPdfs.map((pdf, index) => (
120
- <Button
121
- testid={testid ? `${testid}-${pdf.fileName}-button` : undefined}
122
- variant={index === currentIndex ? "primary" : "secondary"}
123
- key={`${pdf.fileName}-${index}`}
124
- classNameLabel="items-center flex flex-row gap-2"
125
- onClick={(e: React.MouseEvent<HTMLButtonElement>) => {
126
- setCurrentIndex(index);
127
-
128
- requestAnimationFrame(() => {
129
- const button = e.target as HTMLButtonElement;
130
-
131
- button.scrollIntoView({
132
- behavior: "smooth",
133
- block: "nearest",
134
- inline: "center",
135
- });
136
- });
137
- }}
138
- disabled={isDownloading || currentIndex === index || !pdf.base64}
139
- >
140
- {!pdf.base64 && <Spinner />}
141
- {pdf.fileName}
142
- </Button>
143
- ))} */}
144
- </Stack>
145
107
  </Stack>
146
108
  </Modal>
147
109
  );
@@ -263,3 +225,65 @@ function PDFElement({ b64, testid }: { b64: string; testid?: string }) {
263
225
  </div>
264
226
  );
265
227
  }
228
+
229
+ function PdfNavigation({
230
+ currentIndex,
231
+ total,
232
+ onPrev,
233
+ onNext,
234
+ disablePrev,
235
+ disableNext,
236
+ extraActions,
237
+ testid,
238
+ fileName,
239
+ }: {
240
+ currentIndex: number;
241
+ total: number;
242
+ onPrev: () => void;
243
+ onNext: () => void;
244
+ disablePrev: boolean;
245
+ disableNext: boolean;
246
+ extraActions?: React.ReactNode;
247
+ testid?: string;
248
+ fileName?: string;
249
+ }) {
250
+ return (
251
+ <div className="w-full">
252
+ <Stack
253
+ horizontal
254
+ items="center"
255
+ justify="between"
256
+ sizing="layout-group"
257
+ testid={testid ? `${testid}-pdf-navigation` : undefined}
258
+ >
259
+ <Stack horizontal items="center">
260
+ <Button
261
+ iconOnly
262
+ variant="tertiary"
263
+ onClick={onPrev}
264
+ leftIcon={<Icon name="chevron_backward" />}
265
+ disabled={disablePrev}
266
+ testid={testid ? `${testid}-pdf-file-previous-button` : undefined}
267
+ />
268
+ <Heading3 className="text-text-primary-normal whitespace-nowrap">
269
+ {currentIndex + 1} / {total}
270
+ </Heading3>
271
+ <Button
272
+ iconOnly
273
+ variant="tertiary"
274
+ onClick={onNext}
275
+ rightIcon={<Icon name="chevron_forward" />}
276
+ disabled={disableNext}
277
+ testid={testid ? `${testid}-pdf-file-next-button` : undefined}
278
+ />
279
+ <Paragraph>
280
+ {fileName?.endsWith(".pdf") ? fileName : `${fileName}.pdf`}
281
+ </Paragraph>
282
+ </Stack>
283
+ {extraActions && (
284
+ <div className="flex items-center gap-2">{extraActions}</div>
285
+ )}
286
+ </Stack>
287
+ </div>
288
+ );
289
+ }