@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.
@@ -1,16 +1,18 @@
1
1
  "use client";
2
2
  import {
3
3
  Modal
4
- } from "../chunk-GCBW2LDM.js";
4
+ } from "../chunk-REGRTR2Y.js";
5
5
  import "../chunk-4RJKB7LC.js";
6
6
  import "../chunk-T7NDKJDP.js";
7
7
  import "../chunk-SYEJVSE4.js";
8
- import "../chunk-6A54FL75.js";
8
+ import "../chunk-ZSKLCKIR.js";
9
9
  import "../chunk-ZFOANBWG.js";
10
10
  import {
11
11
  Spinner
12
12
  } from "../chunk-PLMGI5K5.js";
13
- import "../chunk-AZ7LVLOK.js";
13
+ import {
14
+ Heading3
15
+ } from "../chunk-AZ7LVLOK.js";
14
16
  import {
15
17
  Caption
16
18
  } from "../chunk-E7D24OHM.js";
@@ -19,6 +21,9 @@ import "../chunk-6LN6QT6M.js";
19
21
  import {
20
22
  Stack
21
23
  } from "../chunk-N6JVLYEE.js";
24
+ import {
25
+ Paragraph
26
+ } from "../chunk-HVI3CL7Y.js";
22
27
  import {
23
28
  Icon
24
29
  } from "../chunk-NKUETCDA.js";
@@ -52,14 +57,32 @@ function PDFViewer(props) {
52
57
  setIsDownloading(false);
53
58
  }, [currentIndex, encodedPdfs]);
54
59
  if (!encodedPdfs.length) return null;
60
+ function handleNextFile() {
61
+ if (currentIndex < encodedPdfs.length - 1) {
62
+ setCurrentIndex((prev) => prev + 1);
63
+ }
64
+ }
65
+ function handlePreviousFile() {
66
+ if (currentIndex > 0) {
67
+ setCurrentIndex((prev) => prev - 1);
68
+ }
69
+ }
70
+ function handleClose() {
71
+ setCurrentIndex(0);
72
+ setIsDownloading(false);
73
+ onClose();
74
+ }
55
75
  return /* @__PURE__ */ jsx(
56
76
  Modal,
57
77
  {
58
78
  testid,
59
79
  open: isOpen,
60
- onClose,
80
+ onClose: handleClose,
61
81
  showButtons: !!customActions,
62
82
  customActions,
83
+ size: "large",
84
+ fixedHeightScrolling: true,
85
+ headerIconAlign: "right",
63
86
  headerIcon: /* @__PURE__ */ jsx(
64
87
  DownloadIcon,
65
88
  {
@@ -68,33 +91,49 @@ function PDFViewer(props) {
68
91
  isDownloading
69
92
  }
70
93
  ),
71
- children: /* @__PURE__ */ jsxs(Stack, { sizing: "layout", children: [
94
+ className: "!max-w-fit",
95
+ children: /* @__PURE__ */ jsxs(Stack, { sizing: "layout", items: "center", children: [
72
96
  /* @__PURE__ */ jsx(PDFElement, { testid, b64: encodedPdfs[currentIndex].base64 }),
73
- /* @__PURE__ */ jsx(Stack, { horizontal: true, overflowX: "auto", sizing: "layout-group", children: encodedPdfs.map((pdf, index) => /* @__PURE__ */ jsxs(
74
- Button,
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,
75
100
  {
76
- testid: testid ? `${testid}-${pdf.fileName}-button` : void 0,
77
- variant: index === currentIndex ? "primary" : "secondary",
78
- classNameLabel: "items-center flex flex-row gap-2",
79
- onClick: (e) => {
80
- setCurrentIndex(index);
81
- requestAnimationFrame(() => {
82
- const button = e.target;
83
- button.scrollIntoView({
84
- behavior: "smooth",
85
- block: "nearest",
86
- inline: "center"
87
- });
88
- });
89
- },
90
- disabled: isDownloading || currentIndex === index || !pdf.base64,
101
+ horizontal: true,
102
+ overflowX: "auto",
103
+ justify: "center",
104
+ items: "center",
105
+ sizing: "layout-group",
91
106
  children: [
92
- !pdf.base64 && /* @__PURE__ */ jsx(Spinner, {}),
93
- pdf.fileName
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
+ )
94
134
  ]
95
- },
96
- `${pdf.fileName}-${index}`
97
- )) })
135
+ }
136
+ )
98
137
  ] })
99
138
  }
100
139
  );
@@ -123,74 +162,93 @@ function PDFElement({ b64, testid }) {
123
162
  workerSrc: "/scripts/pdf.worker.min.mjs",
124
163
  page,
125
164
  canvasRef,
126
- scale: 1
165
+ scale: 1.1
127
166
  });
128
- return /* @__PURE__ */ jsxs("div", { className: "flex flex-col space-y-4", children: [
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
- )
193
- ] });
167
+ return /* @__PURE__ */ jsxs(
168
+ "div",
169
+ {
170
+ className: "flex flex-col space-y-4 ",
171
+ style: {
172
+ minHeight: 871,
173
+ minWidth: 654
174
+ },
175
+ children: [
176
+ !!pdfDocument && !!b64 ? /* @__PURE__ */ jsx(
177
+ "canvas",
178
+ {
179
+ "data-testid": testid ? `${testid}-pdf-content` : void 0,
180
+ ref: canvasRef
181
+ }
182
+ ) : /* @__PURE__ */ jsx(
183
+ Stack,
184
+ {
185
+ justify: "center",
186
+ items: "center",
187
+ height: "full",
188
+ flexGrow: 1,
189
+ "data-testid": testid ? `${testid}-pdf-loading` : void 0,
190
+ children: /* @__PURE__ */ jsx(Spinner, { size: "large" })
191
+ }
192
+ ),
193
+ (pdfDocument == null ? void 0 : pdfDocument.numPages) && pdfDocument.numPages > 1 && /* @__PURE__ */ jsxs(
194
+ "ul",
195
+ {
196
+ className: "flex flex-row justify-between items-center",
197
+ "data-testid": testid ? `${testid}-pdf-pagination` : void 0,
198
+ children: [
199
+ /* @__PURE__ */ jsx("li", { className: "previous", children: /* @__PURE__ */ jsx(
200
+ "button",
201
+ {
202
+ "data-testid": testid ? `${testid}-pdf-pagination-previous-button` : void 0,
203
+ disabled: page === 1,
204
+ onClick: () => setPage(page - 1),
205
+ className: "not-disabled:cursor-pointer not-disabled:hover:underline ",
206
+ children: /* @__PURE__ */ jsx(Caption, { className: "not-disabled:cursor-pointer not-disabled:hover:underline not-disabled:text-text-primary-normal", children: "Previous" })
207
+ }
208
+ ) }),
209
+ /* @__PURE__ */ jsxs(
210
+ "li",
211
+ {
212
+ "data-testid": testid ? `${testid}-pdf-pagination-text` : void 0,
213
+ className: "text-label-desktop text-text-primary-normal",
214
+ children: [
215
+ "Page",
216
+ " ",
217
+ /* @__PURE__ */ jsx(
218
+ "span",
219
+ {
220
+ "data-testid": testid ? `${testid}-pdf-pagination-page-${page}` : void 0,
221
+ children: page
222
+ }
223
+ ),
224
+ " ",
225
+ "of",
226
+ " ",
227
+ /* @__PURE__ */ jsx(
228
+ "span",
229
+ {
230
+ "data-testid": testid ? `${testid}-pdf-pagination-total-page-${pdfDocument.numPages}` : void 0,
231
+ children: pdfDocument.numPages
232
+ }
233
+ )
234
+ ]
235
+ }
236
+ ),
237
+ /* @__PURE__ */ jsx("li", { className: "next", children: /* @__PURE__ */ jsx(
238
+ "button",
239
+ {
240
+ "data-testid": testid ? `${testid}-pdf-pagination-next-button` : void 0,
241
+ disabled: page === pdfDocument.numPages,
242
+ onClick: () => setPage(page + 1),
243
+ children: /* @__PURE__ */ jsx(Caption, { className: "not-disabled:cursor-pointer not-disabled:hover:underline not-disabled:text-text-primary-normal", children: "Next" })
244
+ }
245
+ ) })
246
+ ]
247
+ }
248
+ )
249
+ ]
250
+ }
251
+ );
194
252
  }
195
253
  export {
196
254
  PDFViewer