@dmsi/wedgekit-react 0.0.369 → 0.0.371

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 (205) hide show
  1. package/dist/{chunk-RLLQRVM7.js → chunk-2H35FETR.js} +18 -10
  2. package/dist/chunk-2IKT6IHB.js +190 -0
  3. package/dist/chunk-4UNWXB4A.js +89 -0
  4. package/dist/chunk-5IFPG6TS.js +17 -0
  5. package/dist/{chunk-6GAYJCFE.js → chunk-6DPFKSCT.js} +1 -1
  6. package/dist/{chunk-ZFOANBWG.js → chunk-AG43RS4Q.js} +2 -1
  7. package/dist/chunk-AJ5M6MVX.js +7 -0
  8. package/dist/chunk-AT4AWD6B.js +44 -0
  9. package/dist/chunk-BQNPOGD5.js +105 -0
  10. package/dist/chunk-CQFPNZTN.js +172 -0
  11. package/dist/chunk-EJSPFQCY.js +29 -0
  12. package/dist/chunk-ER6RCOH3.js +97 -0
  13. package/dist/{chunk-4VER5OEU.js → chunk-FBE2HGEF.js} +35 -11
  14. package/dist/chunk-HPQWEZJL.js +45 -0
  15. package/dist/{chunk-URCLLHO5.js → chunk-IBX6DVHU.js} +376 -102
  16. package/dist/{chunk-I3WFZOFY.js → chunk-J5V2JRIK.js} +1 -1
  17. package/dist/chunk-JGJUVJKD.js +283 -0
  18. package/dist/chunk-KEMCFN4U.js +78 -0
  19. package/dist/chunk-M6TSTDNZ.js +22 -0
  20. package/dist/chunk-M7INAUAJ.js +140 -0
  21. package/dist/chunk-MBZ55T2D.js +51 -0
  22. package/dist/chunk-N6PNLLNS.js +77 -0
  23. package/dist/{chunk-ZA5E7ZYM.js → chunk-NXGUDYRR.js} +1 -1
  24. package/dist/chunk-P36QKH26.js +143 -0
  25. package/dist/chunk-PTRZHGHA.js +89 -0
  26. package/dist/chunk-QVWYTQKL.js +29 -0
  27. package/dist/{chunk-6CPGOW6J.js → chunk-T36HX6QY.js} +6 -4
  28. package/dist/chunk-U6PUOGG4.js +114 -0
  29. package/dist/{chunk-NQXZBWDZ.js → chunk-V6U7LU6M.js} +15 -6
  30. package/dist/chunk-VJVY6NPF.js +32 -0
  31. package/dist/chunk-VVXPGI2P.js +61 -0
  32. package/dist/{chunk-ARQBSR3I.js → chunk-YCKRVNJ3.js} +4 -4
  33. package/dist/chunk-YYHQLQDQ.js +68 -0
  34. package/dist/components/Accordion.cjs +47 -14
  35. package/dist/components/Accordion.js +2 -2
  36. package/dist/components/CalendarRange.cjs +700 -46
  37. package/dist/components/CalendarRange.css +186 -3
  38. package/dist/components/CalendarRange.js +43 -11
  39. package/dist/components/CompactImagesPreview.cjs +485 -0
  40. package/dist/components/CompactImagesPreview.js +13 -0
  41. package/dist/components/ContentTabs.cjs +3 -2
  42. package/dist/components/ContentTabs.js +3 -2
  43. package/dist/components/DataGrid/ColumnSelectorHeaderCell/ColumnSelectorMenuOption.cjs +4687 -0
  44. package/dist/components/DataGrid/ColumnSelectorHeaderCell/ColumnSelectorMenuOption.css +5051 -0
  45. package/dist/components/DataGrid/ColumnSelectorHeaderCell/ColumnSelectorMenuOption.js +62 -0
  46. package/dist/components/DataGrid/ColumnSelectorHeaderCell/index.cjs +4687 -0
  47. package/dist/components/DataGrid/ColumnSelectorHeaderCell/index.css +5051 -0
  48. package/dist/components/DataGrid/ColumnSelectorHeaderCell/index.js +62 -0
  49. package/dist/components/DataGrid/PinnedColumns.cjs +4687 -0
  50. package/dist/components/DataGrid/PinnedColumns.css +5051 -0
  51. package/dist/components/DataGrid/PinnedColumns.js +62 -0
  52. package/dist/components/DataGrid/TableBody/LoadingCell.cjs +4689 -0
  53. package/dist/components/DataGrid/TableBody/LoadingCell.css +5051 -0
  54. package/dist/components/DataGrid/TableBody/LoadingCell.js +62 -0
  55. package/dist/components/DataGrid/TableBody/TableBodyRow.cjs +4689 -0
  56. package/dist/components/DataGrid/TableBody/TableBodyRow.css +5051 -0
  57. package/dist/components/DataGrid/TableBody/TableBodyRow.js +62 -0
  58. package/dist/components/DataGrid/TableBody/index.cjs +4689 -0
  59. package/dist/components/DataGrid/TableBody/index.css +5051 -0
  60. package/dist/components/DataGrid/TableBody/index.js +62 -0
  61. package/dist/components/DataGrid/index.cjs +4692 -0
  62. package/dist/components/DataGrid/index.css +5051 -0
  63. package/dist/components/DataGrid/index.js +65 -0
  64. package/dist/components/DataGrid/utils.cjs +4687 -0
  65. package/dist/components/DataGrid/utils.css +5051 -0
  66. package/dist/components/DataGrid/utils.js +62 -0
  67. package/dist/components/DataGridCell.js +6 -6
  68. package/dist/components/DateInput.cjs +721 -67
  69. package/dist/components/DateInput.css +186 -3
  70. package/dist/components/DateInput.js +45 -13
  71. package/dist/components/DateRangeInput.cjs +721 -67
  72. package/dist/components/DateRangeInput.css +186 -3
  73. package/dist/components/DateRangeInput.js +45 -13
  74. package/dist/components/FilterGroup.js +3 -3
  75. package/dist/components/Grid.cjs +3 -1
  76. package/dist/components/Grid.js +3 -92
  77. package/dist/components/ImagePlaceholder.cjs +65 -0
  78. package/dist/components/ImagePlaceholder.js +7 -0
  79. package/dist/components/Input.js +2 -2
  80. package/dist/components/MenuOption.js +2 -2
  81. package/dist/components/MobileDataGrid/ColumnList.cjs +845 -0
  82. package/dist/components/MobileDataGrid/ColumnList.js +17 -0
  83. package/dist/components/MobileDataGrid/ColumnSelector/index.cjs +4797 -0
  84. package/dist/components/MobileDataGrid/ColumnSelector/index.css +5051 -0
  85. package/dist/components/MobileDataGrid/ColumnSelector/index.js +62 -0
  86. package/dist/components/MobileDataGrid/GridContextProvider/GridContext.cjs +31 -0
  87. package/dist/components/MobileDataGrid/GridContextProvider/GridContext.js +7 -0
  88. package/dist/components/MobileDataGrid/GridContextProvider/index.cjs +177 -0
  89. package/dist/components/MobileDataGrid/GridContextProvider/index.js +8 -0
  90. package/dist/components/MobileDataGrid/MobileDataGridCard/MobileDataGridColumn.cjs +269 -0
  91. package/dist/components/MobileDataGrid/MobileDataGridCard/MobileDataGridColumn.js +9 -0
  92. package/dist/components/MobileDataGrid/MobileDataGridCard/index.cjs +790 -0
  93. package/dist/components/MobileDataGrid/MobileDataGridCard/index.js +16 -0
  94. package/dist/components/MobileDataGrid/MobileDataGridHeader.cjs +5059 -0
  95. package/dist/components/MobileDataGrid/MobileDataGridHeader.css +5051 -0
  96. package/dist/components/MobileDataGrid/MobileDataGridHeader.js +62 -0
  97. package/dist/components/MobileDataGrid/RowDetailModalProvider/ModalContent.cjs +509 -0
  98. package/dist/components/MobileDataGrid/RowDetailModalProvider/ModalContent.js +13 -0
  99. package/dist/components/MobileDataGrid/RowDetailModalProvider/index.cjs +1261 -0
  100. package/dist/components/MobileDataGrid/RowDetailModalProvider/index.js +27 -0
  101. package/dist/components/MobileDataGrid/index.cjs +5521 -0
  102. package/dist/components/MobileDataGrid/index.css +5051 -0
  103. package/dist/components/MobileDataGrid/index.js +62 -0
  104. package/dist/components/Modal.cjs +24 -13
  105. package/dist/components/Modal.js +3 -3
  106. package/dist/components/ModalHeader.cjs +6 -4
  107. package/dist/components/ModalHeader.js +1 -1
  108. package/dist/components/ModalScrim.cjs +2 -1
  109. package/dist/components/ModalScrim.js +1 -1
  110. package/dist/components/NestedMenu.js +4 -4
  111. package/dist/components/Notification.cjs +15 -6
  112. package/dist/components/Notification.js +1 -1
  113. package/dist/components/PDFViewer/DownloadIcon.cjs +394 -0
  114. package/dist/components/PDFViewer/DownloadIcon.js +10 -0
  115. package/dist/components/PDFViewer/PDFElement.cjs +515 -0
  116. package/dist/components/PDFViewer/PDFElement.js +11 -0
  117. package/dist/components/{MobileDataGrid.cjs → PDFViewer/PDFNavigation.cjs} +318 -402
  118. package/dist/components/PDFViewer/PDFNavigation.js +13 -0
  119. package/dist/components/PDFViewer/PDFPage.cjs +56 -0
  120. package/dist/components/PDFViewer/PDFPage.js +7 -0
  121. package/dist/components/{PDFViewer.cjs → PDFViewer/index.cjs} +290 -202
  122. package/dist/components/PDFViewer/index.js +29 -0
  123. package/dist/components/Password.js +2 -2
  124. package/dist/components/ProductImagePreview/CarouselPagination.cjs +75 -0
  125. package/dist/components/ProductImagePreview/CarouselPagination.js +7 -0
  126. package/dist/components/ProductImagePreview/MobileImageCarousel.cjs +214 -0
  127. package/dist/components/ProductImagePreview/MobileImageCarousel.js +7 -0
  128. package/dist/components/ProductImagePreview/ProductPrimaryImage.cjs +255 -0
  129. package/dist/components/ProductImagePreview/ProductPrimaryImage.js +9 -0
  130. package/dist/components/ProductImagePreview/Thumbnail.cjs +105 -0
  131. package/dist/components/ProductImagePreview/Thumbnail.js +8 -0
  132. package/dist/components/ProductImagePreview/ZoomWindow.cjs +198 -0
  133. package/dist/components/ProductImagePreview/ZoomWindow.js +8 -0
  134. package/dist/components/ProductImagePreview/index.cjs +1369 -0
  135. package/dist/components/ProductImagePreview/index.js +22 -0
  136. package/dist/components/Search.js +3 -3
  137. package/dist/components/Select.js +3 -3
  138. package/dist/components/SideMenuGroup.cjs +15 -6
  139. package/dist/components/SideMenuGroup.js +1 -1
  140. package/dist/components/SideMenuItem.cjs +15 -6
  141. package/dist/components/SideMenuItem.js +1 -1
  142. package/dist/components/SkeletonParagraph.cjs +33 -0
  143. package/dist/components/SkeletonParagraph.js +10 -0
  144. package/dist/components/Stack.cjs +15 -6
  145. package/dist/components/Stack.js +1 -1
  146. package/dist/components/Stepper.cjs +61 -53
  147. package/dist/components/Stepper.js +63 -55
  148. package/dist/components/Surface.js +3 -39
  149. package/dist/components/Swatch.cjs +15 -6
  150. package/dist/components/Swatch.js +4 -4
  151. package/dist/components/Time.cjs +15 -6
  152. package/dist/components/Time.js +5 -5
  153. package/dist/components/Upload.cjs +15 -6
  154. package/dist/components/Upload.js +1 -1
  155. package/dist/components/index.cjs +2559 -14
  156. package/dist/components/index.css +186 -3
  157. package/dist/components/index.js +57 -14
  158. package/dist/index.css +186 -3
  159. package/package.json +1 -1
  160. package/src/components/Accordion.tsx +23 -4
  161. package/src/components/CompactImagesPreview.tsx +99 -0
  162. package/src/components/ContentTabs.tsx +3 -1
  163. package/src/components/DataGrid/types.ts +5 -0
  164. package/src/components/Grid.tsx +2 -0
  165. package/src/components/ImagePlaceholder.tsx +22 -0
  166. package/src/components/MobileDataGrid/ColumnList.tsx +66 -0
  167. package/src/components/MobileDataGrid/ColumnSelector/index.tsx +97 -0
  168. package/src/components/MobileDataGrid/GridContextProvider/GridContext.tsx +25 -0
  169. package/src/components/MobileDataGrid/GridContextProvider/index.tsx +132 -0
  170. package/src/components/MobileDataGrid/GridContextProvider/useGridContext.ts +10 -0
  171. package/src/components/MobileDataGrid/MobileDataGridCard/MobileDataGridColumn.tsx +20 -0
  172. package/src/components/MobileDataGrid/MobileDataGridCard/index.tsx +129 -0
  173. package/src/components/MobileDataGrid/MobileDataGridHeader.tsx +80 -0
  174. package/src/components/MobileDataGrid/RowDetailModalProvider/ModalContent.tsx +42 -0
  175. package/src/components/MobileDataGrid/RowDetailModalProvider/index.tsx +68 -0
  176. package/src/components/MobileDataGrid/dataGridReducer.ts +55 -0
  177. package/src/components/MobileDataGrid/index.tsx +92 -0
  178. package/src/components/MobileDataGrid/types.ts +4 -0
  179. package/src/components/Modal.tsx +31 -12
  180. package/src/components/ModalButtons.tsx +1 -1
  181. package/src/components/ModalHeader.tsx +5 -2
  182. package/src/components/ModalScrim.tsx +3 -2
  183. package/src/components/PDFViewer/DownloadIcon.tsx +22 -0
  184. package/src/components/PDFViewer/PDFElement.tsx +90 -0
  185. package/src/components/PDFViewer/PDFNavigation.tsx +68 -0
  186. package/src/components/PDFViewer/PDFPage.tsx +34 -0
  187. package/src/components/PDFViewer/index.tsx +128 -0
  188. package/src/components/ProductImagePreview/CarouselPagination.tsx +54 -0
  189. package/src/components/ProductImagePreview/MobileImageCarousel.tsx +226 -0
  190. package/src/components/ProductImagePreview/ProductPrimaryImage.tsx +218 -0
  191. package/src/components/ProductImagePreview/Thumbnail.tsx +49 -0
  192. package/src/components/ProductImagePreview/ZoomWindow.tsx +136 -0
  193. package/src/components/ProductImagePreview/index.tsx +182 -0
  194. package/src/components/ProductImagePreview/useProductImagePreview.ts +211 -0
  195. package/src/components/SkeletonParagraph.tsx +5 -0
  196. package/src/components/Stack.tsx +29 -6
  197. package/src/components/Stepper.tsx +5 -1
  198. package/src/components/index.ts +4 -0
  199. package/src/types.ts +2 -1
  200. package/dist/components/MobileDataGrid.js +0 -150
  201. package/dist/components/PDFViewer.js +0 -250
  202. package/src/components/MobileDataGrid.tsx +0 -163
  203. package/src/components/PDFViewer.tsx +0 -264
  204. package/dist/{chunk-OXSBIBGT.js → chunk-CKQNJNU3.js} +3 -3
  205. package/dist/{chunk-RJUN52HJ.js → chunk-ZL5X7KP6.js} +3 -3
@@ -1,250 +0,0 @@
1
- "use client";
2
- import {
3
- Modal
4
- } from "../chunk-RLLQRVM7.js";
5
- import "../chunk-4RJKB7LC.js";
6
- import "../chunk-XM7IQHBU.js";
7
- import "../chunk-FRHPFACM.js";
8
- import "../chunk-6CPGOW6J.js";
9
- import "../chunk-ZFOANBWG.js";
10
- import {
11
- Spinner
12
- } from "../chunk-SBRRNFOP.js";
13
- import {
14
- Heading3
15
- } from "../chunk-EU73QPW7.js";
16
- import "../chunk-JUJBS4ZV.js";
17
- import "../chunk-VXWSAIB5.js";
18
- import "../chunk-TYTD4FLW.js";
19
- import "../chunk-5UH6QUFB.js";
20
- import {
21
- Stack
22
- } from "../chunk-NQXZBWDZ.js";
23
- import {
24
- Paragraph
25
- } from "../chunk-OGIFIPKH.js";
26
- import {
27
- Icon
28
- } from "../chunk-NKUETCDA.js";
29
- import {
30
- Button
31
- } from "../chunk-WWAPK5PH.js";
32
- import "../chunk-6CTCHYIS.js";
33
- import "../chunk-ORMEWXMH.js";
34
-
35
- // src/components/PDFViewer.tsx
36
- import { usePdf } from "@mikecousins/react-pdf";
37
- import { useCallback, useRef, useState } from "react";
38
- import { jsx, jsxs } from "react/jsx-runtime";
39
- function PDFViewer(props) {
40
- const { isOpen, onClose, encodedPdfs, customActions, testid } = props;
41
- const [currentIndex, setCurrentIndex] = useState(0);
42
- const [isDownloading, setIsDownloading] = useState(false);
43
- const handleDownload = useCallback(() => {
44
- setIsDownloading(true);
45
- const link = document.createElement("a");
46
- const currentPdf = encodedPdfs[currentIndex];
47
- if (!currentPdf) {
48
- setIsDownloading(false);
49
- return;
50
- }
51
- link.href = `data:application/pdf;base64,${currentPdf.base64}`;
52
- link.download = currentPdf.fileName.endsWith(".pdf") ? currentPdf.fileName : `${currentPdf.fileName}.pdf`;
53
- document.body.appendChild(link);
54
- link.click();
55
- document.body.removeChild(link);
56
- setIsDownloading(false);
57
- }, [currentIndex, encodedPdfs]);
58
- if (!encodedPdfs.length) return null;
59
- function handleNextFile() {
60
- if (currentIndex < encodedPdfs.length - 1) {
61
- setCurrentIndex((prev) => prev + 1);
62
- }
63
- }
64
- function handlePreviousFile() {
65
- if (currentIndex > 0) {
66
- setCurrentIndex((prev) => prev - 1);
67
- }
68
- }
69
- function handleClose() {
70
- setCurrentIndex(0);
71
- setIsDownloading(false);
72
- onClose();
73
- }
74
- return /* @__PURE__ */ jsx(
75
- Modal,
76
- {
77
- testid,
78
- open: isOpen,
79
- onClose: handleClose,
80
- showButtons: !!encodedPdfs.length,
81
- customActions: !!encodedPdfs.length && /* @__PURE__ */ jsx(
82
- PdfNavigation,
83
- {
84
- testid,
85
- currentIndex,
86
- total: encodedPdfs.length,
87
- onPrev: handlePreviousFile,
88
- onNext: handleNextFile,
89
- disablePrev: currentIndex === 0,
90
- disableNext: currentIndex === encodedPdfs.length - 1,
91
- extraActions: customActions,
92
- fileName: encodedPdfs[currentIndex].fileName
93
- }
94
- ),
95
- size: "large",
96
- fixedHeightScrolling: true,
97
- headerIconAlign: "right",
98
- headerIcon: /* @__PURE__ */ jsx(
99
- DownloadIcon,
100
- {
101
- testid: testid ? `${testid}-download-icon` : void 0,
102
- onClick: handleDownload,
103
- isDownloading
104
- }
105
- ),
106
- className: "!max-w-fit",
107
- children: /* @__PURE__ */ jsx(PDFElement, { testid, b64: encodedPdfs[currentIndex].base64 })
108
- }
109
- );
110
- }
111
- function DownloadIcon({
112
- onClick,
113
- isDownloading,
114
- testid
115
- }) {
116
- return /* @__PURE__ */ jsx(
117
- Button,
118
- {
119
- testid,
120
- iconOnly: true,
121
- variant: "tertiary",
122
- leftIcon: /* @__PURE__ */ jsx(Icon, { name: isDownloading ? "cached" : "download" }),
123
- onClick
124
- }
125
- );
126
- }
127
- function PDFElement({ b64, testid }) {
128
- var _a;
129
- const canvasRef = useRef(null);
130
- const { pdfDocument } = usePdf({
131
- file: `data:application/pdf;base64,${b64}`,
132
- workerSrc: "/scripts/pdf.worker.min.mjs",
133
- canvasRef,
134
- scale: 1.1
135
- });
136
- const pagesArr = new Array((_a = pdfDocument == null ? void 0 : pdfDocument.numPages) != null ? _a : 1).fill(null);
137
- return /* @__PURE__ */ jsx(
138
- "div",
139
- {
140
- className: "flex flex-col space-y-4",
141
- style: {
142
- minHeight: 871,
143
- minWidth: 654
144
- },
145
- children: !!pdfDocument && !!b64 ? /* @__PURE__ */ jsx(Stack, { sizing: "layout-group", children: pagesArr.length > 1 ? pagesArr.map((_, i) => /* @__PURE__ */ jsx(
146
- "div",
147
- {
148
- className: "flex justify-center border border-border-primary-normal",
149
- children: /* @__PURE__ */ jsx(
150
- PdfPage,
151
- {
152
- testid: testid ? `${testid}-pdf_page_${i + 1}` : void 0,
153
- file: `data:application/pdf;base64,${b64}`,
154
- pageNumber: i + 1
155
- }
156
- )
157
- },
158
- `${testid}-pdf-page-${i + 1}`
159
- )) : /* @__PURE__ */ jsx("div", { className: "flex justify-center border border-border-primary-normal", children: /* @__PURE__ */ jsx(
160
- "canvas",
161
- {
162
- "data-testid": testid ? `${testid}-pdf-content` : void 0,
163
- ref: canvasRef
164
- }
165
- ) }) }) : /* @__PURE__ */ jsx(
166
- Stack,
167
- {
168
- justify: "center",
169
- items: "center",
170
- height: "full",
171
- flexGrow: 1,
172
- "data-testid": testid ? `${testid}-pdf-loading` : void 0,
173
- children: /* @__PURE__ */ jsx(Spinner, { size: "large" })
174
- }
175
- )
176
- }
177
- );
178
- }
179
- function PdfNavigation({
180
- currentIndex,
181
- total,
182
- onPrev,
183
- onNext,
184
- disablePrev,
185
- disableNext,
186
- extraActions,
187
- testid,
188
- fileName
189
- }) {
190
- return /* @__PURE__ */ jsx("div", { className: "w-full", children: /* @__PURE__ */ jsxs(
191
- Stack,
192
- {
193
- horizontal: true,
194
- items: "center",
195
- justify: "between",
196
- sizing: "layout-group",
197
- testid: testid ? `${testid}-pdf-navigation` : void 0,
198
- children: [
199
- /* @__PURE__ */ jsxs(Stack, { horizontal: true, items: "center", children: [
200
- /* @__PURE__ */ jsx(
201
- Button,
202
- {
203
- iconOnly: true,
204
- variant: "tertiary",
205
- onClick: onPrev,
206
- leftIcon: /* @__PURE__ */ jsx(Icon, { name: "chevron_backward" }),
207
- disabled: disablePrev,
208
- testid: testid ? `${testid}-pdf-file-previous-button` : void 0
209
- }
210
- ),
211
- /* @__PURE__ */ jsxs(Heading3, { className: "text-text-primary-normal whitespace-nowrap", children: [
212
- currentIndex + 1,
213
- " / ",
214
- total
215
- ] }),
216
- /* @__PURE__ */ jsx(
217
- Button,
218
- {
219
- iconOnly: true,
220
- variant: "tertiary",
221
- onClick: onNext,
222
- rightIcon: /* @__PURE__ */ jsx(Icon, { name: "chevron_forward" }),
223
- disabled: disableNext,
224
- testid: testid ? `${testid}-pdf-file-next-button` : void 0
225
- }
226
- ),
227
- /* @__PURE__ */ jsx(Paragraph, { children: (fileName == null ? void 0 : fileName.endsWith(".pdf")) ? fileName : `${fileName}.pdf` })
228
- ] }),
229
- extraActions && /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2", children: extraActions })
230
- ]
231
- }
232
- ) });
233
- }
234
- function PdfPage({
235
- file,
236
- pageNumber,
237
- testid
238
- }) {
239
- const canvasRef = useRef(null);
240
- const { pdfDocument } = usePdf({
241
- file,
242
- page: pageNumber,
243
- canvasRef
244
- });
245
- if (!pdfDocument) return null;
246
- return /* @__PURE__ */ jsx("canvas", { ref: canvasRef, "data-testid": testid });
247
- }
248
- export {
249
- PDFViewer
250
- };
@@ -1,163 +0,0 @@
1
- import clsx from "clsx";
2
- import { Icon } from "./Icon";
3
- import { ComponentProps } from "react";
4
- import { Stack } from "./Stack";
5
- import { Button } from "./Button";
6
- import { Theme } from "./Theme";
7
- import { Heading3 } from "./Heading";
8
- import { Paragraph } from "./Paragraph";
9
-
10
- export type RowData = Record<string, unknown>;
11
-
12
- export type MobileColumnDef<T extends RowData> = {
13
- header: string;
14
- accessorKey: keyof T;
15
- show?: boolean;
16
-
17
- cell?: (info: { row: T }) => React.ReactNode;
18
- };
19
-
20
- export function MobileDataGrid<T extends RowData>({
21
- columns,
22
- data,
23
- header,
24
- getId,
25
- renderLink,
26
- renderChevron,
27
- id,
28
- testid,
29
- }: {
30
- columns: MobileColumnDef<T>[];
31
- data: T[];
32
- header: string;
33
- getId: (data: T) => string | number | undefined;
34
- renderLink?: (data: T) => React.ReactNode;
35
- renderChevron?: (data: T) => React.ReactNode;
36
- id?: string;
37
- testid?: string;
38
- } & ComponentProps<"div">) {
39
- return (
40
- <div
41
- id={id}
42
- data-testid={testid}
43
- className={clsx(
44
- "rounded",
45
- "overflow-hidden",
46
- "divide-y divide-border-primary-normal",
47
- "border border-border-primary-normal",
48
- "overflow-y-scroll scrollbar-thin",
49
- )}
50
- >
51
- <MobileDataGridHeader
52
- id={id ? `${id}-header` : undefined}
53
- testid={testid ? `${testid}-header` : undefined}
54
- header={header}
55
- />
56
- {data.map((item) => (
57
- <MobileDataGridCard
58
- id={id ? `${id}-card-${getId(item)}` : undefined}
59
- testid={testid ? `${testid}-card-${getId(item)}` : undefined}
60
- data={item}
61
- key={getId(item)}
62
- columns={columns}
63
- renderLink={renderLink}
64
- renderChevron={renderChevron}
65
- />
66
- ))}
67
- </div>
68
- );
69
- }
70
-
71
- function MobileDataGridHeader({
72
- header,
73
- id,
74
- testid,
75
- }: {
76
- header: string;
77
- id?: string;
78
- testid?: string;
79
- }) {
80
- return (
81
- <div id={id} data-testid={testid} className="sticky top-0">
82
- <Theme theme="brand">
83
- <Stack
84
- horizontal
85
- items="start"
86
- justify="center"
87
- backgroundColor="background-primary-normal"
88
- padding
89
- sizing="component"
90
- >
91
- <Heading3 as="span" color="text-primary-normal">
92
- {header}
93
- </Heading3>
94
- </Stack>
95
- </Theme>
96
- </div>
97
- );
98
- }
99
-
100
- function MobileDataGridCard<T extends RowData>({
101
- data,
102
- columns,
103
- renderLink,
104
- renderChevron,
105
- id,
106
- testid,
107
- }: {
108
- data: T;
109
- columns: MobileColumnDef<T>[];
110
- renderLink?: (data: T) => React.ReactNode;
111
- renderChevron?: (data: T) => React.ReactNode;
112
- id?: string;
113
- testid?: string;
114
- }) {
115
- return (
116
- <div id={id} data-testid={testid}>
117
- <Stack sizing="component" padding>
118
- <Stack horizontal horizontalMobile items="center" justify="between">
119
- {renderLink && renderLink(data)}
120
- <Stack horizontal horizontalMobile items="center" justify="end">
121
- <Button
122
- id={id ? `${id}-docs-button` : undefined}
123
- testid={testid ? `${testid}-docs-button` : undefined}
124
- iconOnly
125
- variant="tertiary"
126
- onClick={() => {}}
127
- leftIcon={<Icon name="docs" />}
128
- ></Button>
129
- <Button
130
- id={id ? `${id}-swap-button` : undefined}
131
- testid={testid ? `${testid}-swap-button` : undefined}
132
- iconOnly
133
- variant="tertiary"
134
- onClick={() => {}}
135
- leftIcon={<Icon name="swap_vert" />}
136
- ></Button>
137
- </Stack>
138
- </Stack>
139
-
140
- {columns
141
- .filter((x) => x.show)
142
- .map((column) => (
143
- <div
144
- key={String(column.accessorKey)}
145
- className="mb-2 grid grid-cols-2"
146
- >
147
- <Paragraph color="text-secondary-normal" className="text-left">
148
- {column.header}:
149
- </Paragraph>{" "}
150
- {column.cell
151
- ? column.cell({ row: data })
152
- : String(data[column.accessorKey])}
153
- </div>
154
- ))}
155
- </Stack>
156
- {renderChevron && (
157
- <Stack items="center" justify="center" horizontal horizontalMobile>
158
- {renderChevron(data)}
159
- </Stack>
160
- )}
161
- </div>
162
- );
163
- }
@@ -1,264 +0,0 @@
1
- "use client";
2
-
3
- import { usePdf } from "@mikecousins/react-pdf";
4
- import { useCallback, useEffect, useRef, useState } from "react";
5
- import { Modal } from "./Modal";
6
- import { Button } from "./Button";
7
- import { Icon } from "./Icon";
8
- import { Stack } from "./Stack";
9
- import { Spinner } from "./Spinner";
10
- import { Paragraph } from "./Paragraph";
11
- import { Heading3 } from "./Heading";
12
- import { PDFDocumentProxy } from "pdfjs-dist";
13
-
14
- type PDFViewerProps = {
15
- isOpen: boolean;
16
- onClose: () => void;
17
- encodedPdfs: { fileName: string; base64: string }[];
18
- customActions?: React.ReactNode;
19
- testid?: string;
20
- };
21
-
22
- export function PDFViewer(props: PDFViewerProps) {
23
- const { isOpen, onClose, encodedPdfs, customActions, testid } = props;
24
- const [currentIndex, setCurrentIndex] = useState(0);
25
- const [isDownloading, setIsDownloading] = useState(false);
26
-
27
- const handleDownload = useCallback(() => {
28
- setIsDownloading(true);
29
- const link = document.createElement("a");
30
- const currentPdf = encodedPdfs[currentIndex];
31
- if (!currentPdf) {
32
- setIsDownloading(false);
33
- return;
34
- }
35
- link.href = `data:application/pdf;base64,${currentPdf.base64}`;
36
- link.download = currentPdf.fileName.endsWith(".pdf")
37
- ? currentPdf.fileName
38
- : `${currentPdf.fileName}.pdf`;
39
- document.body.appendChild(link);
40
- link.click();
41
- document.body.removeChild(link);
42
- setIsDownloading(false);
43
- }, [currentIndex, encodedPdfs]);
44
-
45
- if (!encodedPdfs.length) return null;
46
-
47
- function handleNextFile() {
48
- if (currentIndex < encodedPdfs.length - 1) {
49
- setCurrentIndex((prev) => prev + 1);
50
- }
51
- }
52
-
53
- function handlePreviousFile() {
54
- if (currentIndex > 0) {
55
- setCurrentIndex((prev) => prev - 1);
56
- }
57
- }
58
-
59
- function handleClose() {
60
- setCurrentIndex(0);
61
- setIsDownloading(false);
62
- onClose();
63
- }
64
-
65
- return (
66
- <Modal
67
- testid={testid}
68
- open={isOpen}
69
- onClose={handleClose}
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
- }
86
- size="large"
87
- fixedHeightScrolling
88
- headerIconAlign="right"
89
- headerIcon={
90
- <DownloadIcon
91
- testid={testid ? `${testid}-download-icon` : undefined}
92
- onClick={handleDownload}
93
- isDownloading={isDownloading}
94
- />
95
- }
96
- className="!max-w-fit"
97
- >
98
- <PDFElement testid={testid} b64={encodedPdfs[currentIndex].base64} />
99
- </Modal>
100
- );
101
- }
102
-
103
- function DownloadIcon({
104
- onClick,
105
- isDownloading,
106
- testid,
107
- }: {
108
- onClick: () => void;
109
- isDownloading?: boolean;
110
- testid?: string;
111
- }) {
112
- return (
113
- <Button
114
- testid={testid}
115
- iconOnly
116
- variant="tertiary"
117
- leftIcon={<Icon name={isDownloading ? "cached" : "download"} />}
118
- onClick={onClick}
119
- />
120
- );
121
- }
122
-
123
- function PDFElement({ b64, testid }: { b64: string; testid?: string }) {
124
- const canvasRef = useRef<HTMLCanvasElement>(null);
125
-
126
- const { pdfDocument } = usePdf({
127
- file: `data:application/pdf;base64,${b64}`,
128
- workerSrc: "/scripts/pdf.worker.min.mjs",
129
- canvasRef,
130
- scale: 1.1,
131
- });
132
-
133
- const pagesArr = new Array(pdfDocument?.numPages ?? 1).fill(null);
134
-
135
- return (
136
- <div
137
- className="flex flex-col space-y-4"
138
- style={{
139
- minHeight: 871,
140
- minWidth: 654,
141
- }}
142
- >
143
- {!!pdfDocument && !!b64 ? (
144
- <Stack sizing="layout-group">
145
- {pagesArr.length > 1 ? (
146
- pagesArr.map((_, i) => (
147
- <div
148
- key={`${testid}-pdf-page-${i + 1}`}
149
- className="flex justify-center border border-border-primary-normal"
150
- >
151
- <PdfPage
152
- testid={testid ? `${testid}-pdf_page_${i + 1}` : undefined}
153
- file={`data:application/pdf;base64,${b64}`}
154
- pageNumber={i + 1}
155
- />
156
- </div>
157
- ))
158
- ) : (
159
- <div className="flex justify-center border border-border-primary-normal">
160
- <canvas
161
- data-testid={testid ? `${testid}-pdf-content` : undefined}
162
- ref={canvasRef}
163
- />
164
- </div>
165
- )}
166
- </Stack>
167
- ) : (
168
- <Stack
169
- justify="center"
170
- items="center"
171
- height="full"
172
- flexGrow={1}
173
- data-testid={testid ? `${testid}-pdf-loading` : undefined}
174
- >
175
- <Spinner size="large" />
176
- </Stack>
177
- )}
178
- </div>
179
- );
180
- }
181
-
182
- function PdfNavigation({
183
- currentIndex,
184
- total,
185
- onPrev,
186
- onNext,
187
- disablePrev,
188
- disableNext,
189
- extraActions,
190
- testid,
191
- fileName,
192
- }: {
193
- currentIndex: number;
194
- total: number;
195
- onPrev: () => void;
196
- onNext: () => void;
197
- disablePrev: boolean;
198
- disableNext: boolean;
199
- extraActions?: React.ReactNode;
200
- testid?: string;
201
- fileName?: string;
202
- }) {
203
- return (
204
- <div className="w-full">
205
- <Stack
206
- horizontal
207
- items="center"
208
- justify="between"
209
- sizing="layout-group"
210
- testid={testid ? `${testid}-pdf-navigation` : undefined}
211
- >
212
- <Stack horizontal items="center">
213
- <Button
214
- iconOnly
215
- variant="tertiary"
216
- onClick={onPrev}
217
- leftIcon={<Icon name="chevron_backward" />}
218
- disabled={disablePrev}
219
- testid={testid ? `${testid}-pdf-file-previous-button` : undefined}
220
- />
221
- <Heading3 className="text-text-primary-normal whitespace-nowrap">
222
- {currentIndex + 1} / {total}
223
- </Heading3>
224
- <Button
225
- iconOnly
226
- variant="tertiary"
227
- onClick={onNext}
228
- rightIcon={<Icon name="chevron_forward" />}
229
- disabled={disableNext}
230
- testid={testid ? `${testid}-pdf-file-next-button` : undefined}
231
- />
232
- <Paragraph>
233
- {fileName?.endsWith(".pdf") ? fileName : `${fileName}.pdf`}
234
- </Paragraph>
235
- </Stack>
236
- {extraActions && (
237
- <div className="flex items-center gap-2">{extraActions}</div>
238
- )}
239
- </Stack>
240
- </div>
241
- );
242
- }
243
-
244
- function PdfPage({
245
- file,
246
- pageNumber,
247
- testid,
248
- }: {
249
- file: string;
250
- pageNumber: number;
251
- testid?: string;
252
- }) {
253
- const canvasRef = useRef<HTMLCanvasElement>(null);
254
-
255
- const { pdfDocument } = usePdf({
256
- file,
257
- page: pageNumber,
258
- canvasRef,
259
- });
260
-
261
- if (!pdfDocument) return null;
262
-
263
- return <canvas ref={canvasRef} data-testid={testid} />;
264
- }
@@ -1,9 +1,9 @@
1
- import {
2
- useMatchesMobile
3
- } from "./chunk-JUJBS4ZV.js";
4
1
  import {
5
2
  Label
6
3
  } from "./chunk-7CS736EF.js";
4
+ import {
5
+ useMatchesMobile
6
+ } from "./chunk-JUJBS4ZV.js";
7
7
  import {
8
8
  Paragraph
9
9
  } from "./chunk-OGIFIPKH.js";
@@ -1,11 +1,11 @@
1
+ import {
2
+ Label
3
+ } from "./chunk-7CS736EF.js";
1
4
  import {
2
5
  formatCurrencyDisplay,
3
6
  formatDecimalValue,
4
7
  getDecimalPlaceholder
5
8
  } from "./chunk-5UH6QUFB.js";
6
- import {
7
- Label
8
- } from "./chunk-7CS736EF.js";
9
9
  import {
10
10
  Icon
11
11
  } from "./chunk-NKUETCDA.js";