@dmsi/wedgekit-react 0.0.79 → 0.0.81

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.
@@ -0,0 +1,68 @@
1
+ "use client";
2
+ import {
3
+ Modal
4
+ } from "../chunk-2DCVAATK.js";
5
+ import "../chunk-4RJKB7LC.js";
6
+ import "../chunk-QUPHLL7D.js";
7
+ import "../chunk-FWPJ73IK.js";
8
+ import "../chunk-TVDFTRGL.js";
9
+ import "../chunk-4JLU7TAC.js";
10
+ import "../chunk-J6LETUNM.js";
11
+ import "../chunk-SWA5WVQO.js";
12
+ import "../chunk-4T7F5BZZ.js";
13
+ import {
14
+ Button
15
+ } from "../chunk-MZJS2ZAU.js";
16
+ import "../chunk-IGQVA7SC.js";
17
+ import "../chunk-RDLEIAQU.js";
18
+ import "../chunk-ORMEWXMH.js";
19
+
20
+ // src/components/PDFViewer.tsx
21
+ import { usePdf } from "@mikecousins/react-pdf";
22
+ import { useRef, useState } from "react";
23
+ import { jsx, jsxs } from "react/jsx-runtime";
24
+ function PDFViewer(props) {
25
+ const { base64, isOpen, onClose, datab64 } = props;
26
+ const [page, setPage] = useState(1);
27
+ const canvasRef = useRef(null);
28
+ const { pdfDocument } = usePdf({
29
+ file: datab64 ? datab64 : `data:application/pdf;base64,${base64}`,
30
+ workerSrc: "/scripts/pdf.worker.min.mjs",
31
+ page,
32
+ canvasRef,
33
+ scale: 1
34
+ });
35
+ if (!base64 && !datab64) return null;
36
+ return /* @__PURE__ */ jsx(Modal, { open: isOpen, onClose, hideCloseIcon: true, children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col space-y-4", children: [
37
+ pdfDocument ? /* @__PURE__ */ jsx("canvas", { ref: canvasRef }) : /* @__PURE__ */ jsx("div", { children: "Loading PDF..." }),
38
+ Boolean(pdfDocument && pdfDocument.numPages) && /* @__PURE__ */ jsxs("ul", { className: "flex flex-row justify-between items-center", children: [
39
+ /* @__PURE__ */ jsx("li", { className: "previous", children: /* @__PURE__ */ jsx(
40
+ Button,
41
+ {
42
+ disabled: page === 1,
43
+ onClick: () => setPage(page - 1),
44
+ variant: "navigation",
45
+ children: "Previous"
46
+ }
47
+ ) }),
48
+ /* @__PURE__ */ jsxs("li", { className: "text-label-desktop text-text-on-action-primary-normal", children: [
49
+ "Page ",
50
+ page,
51
+ " of ",
52
+ pdfDocument.numPages
53
+ ] }),
54
+ /* @__PURE__ */ jsx("li", { className: "next", children: /* @__PURE__ */ jsx(
55
+ Button,
56
+ {
57
+ disabled: page === pdfDocument.numPages,
58
+ onClick: () => setPage(page + 1),
59
+ variant: "navigation",
60
+ children: "Next"
61
+ }
62
+ ) })
63
+ ] })
64
+ ] }) });
65
+ }
66
+ export {
67
+ PDFViewer
68
+ };
package/dist/index.css CHANGED
@@ -1034,6 +1034,13 @@
1034
1034
  .gap-mobile-layout-group-gap {
1035
1035
  gap: var(--spacing-mobile-layout-group-gap);
1036
1036
  }
1037
+ .space-y-4 {
1038
+ :where(& > :not(:last-child)) {
1039
+ --tw-space-y-reverse: 0;
1040
+ margin-block-start: calc(calc(var(--spacing) * 4) * var(--tw-space-y-reverse));
1041
+ margin-block-end: calc(calc(var(--spacing) * 4) * calc(1 - var(--tw-space-y-reverse)));
1042
+ }
1043
+ }
1037
1044
  .space-x-1 {
1038
1045
  :where(& > :not(:last-child)) {
1039
1046
  --tw-space-x-reverse: 0;
@@ -1931,6 +1938,9 @@
1931
1938
  .text-heading-3-mobile {
1932
1939
  font-size: var(--text-heading-3-mobile);
1933
1940
  }
1941
+ .text-label-desktop {
1942
+ font-size: var(--text-label-desktop);
1943
+ }
1934
1944
  .text-label-mobile {
1935
1945
  font-size: var(--text-label-mobile);
1936
1946
  }
@@ -4645,6 +4655,7 @@ body {
4645
4655
  @property --tw-rotate-z { syntax: "*"; inherits: false; }
4646
4656
  @property --tw-skew-x { syntax: "*"; inherits: false; }
4647
4657
  @property --tw-skew-y { syntax: "*"; inherits: false; }
4658
+ @property --tw-space-y-reverse { syntax: "*"; inherits: false; initial-value: 0; }
4648
4659
  @property --tw-space-x-reverse { syntax: "*"; inherits: false; initial-value: 0; }
4649
4660
  @property --tw-divide-x-reverse { syntax: "*"; inherits: false; initial-value: 0; }
4650
4661
  @property --tw-border-style { syntax: "*"; inherits: false; initial-value: solid; }
@@ -4714,6 +4725,7 @@ body {
4714
4725
  --tw-rotate-z: initial;
4715
4726
  --tw-skew-x: initial;
4716
4727
  --tw-skew-y: initial;
4728
+ --tw-space-y-reverse: 0;
4717
4729
  --tw-space-x-reverse: 0;
4718
4730
  --tw-divide-x-reverse: 0;
4719
4731
  --tw-border-style: solid;
package/package.json CHANGED
@@ -1,13 +1,16 @@
1
1
  {
2
2
  "name": "@dmsi/wedgekit-react",
3
3
  "private": false,
4
- "version": "0.0.79",
4
+ "version": "0.0.81",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "build": "tsup",
8
8
  "dev": "tsup --watch",
9
9
  "lint": "eslint . --max-warnings 0",
10
- "fmt": "prettier --write src/**/*.{ts,tsx,css,json}"
10
+ "fmt": "prettier --write src/**/*.{ts,tsx,css,json}",
11
+ "copy:pdf-worker": "shx mkdir -p ../frontend/public/scripts/ && shx cp ../../node_modules/pdfjs-dist/build/pdf.worker.min.mjs ../frontend/public/scripts/pdf.worker.min.mjs",
12
+ "predev": "npm run copy:pdf-worker",
13
+ "postbuild": "npm run copy:pdf-worker"
11
14
  },
12
15
  "files": [
13
16
  "dist",
@@ -40,9 +43,11 @@
40
43
  "@dnd-kit/sortable": "^10.0.0",
41
44
  "@headlessui/react": "^2.2.4",
42
45
  "@js-temporal/polyfill": "^0.5.1",
46
+ "@mikecousins/react-pdf": "^8.0.1",
43
47
  "@tanstack/react-table": "^8.21.3",
44
48
  "@tanstack/react-virtual": "^3.13.12",
45
49
  "clsx": "^2.1.1",
50
+ "pdfjs-dist": "^5.3.93",
46
51
  "react-use": "^17.6.0"
47
52
  },
48
53
  "peerDependencies": {
@@ -60,6 +65,7 @@
60
65
  "prettier": "^3.6.2",
61
66
  "react": "^19.1.0",
62
67
  "react-dom": "^19.1.0",
68
+ "shx": "^0.4.0",
63
69
  "tailwindcss": "^4.1.11",
64
70
  "tsup": "^8.5.0",
65
71
  "typescript": "5.8.3"
@@ -0,0 +1,63 @@
1
+ "use client";
2
+
3
+ import { usePdf } from "@mikecousins/react-pdf";
4
+ import { useRef, useState } from "react";
5
+ import { Modal } from "./Modal";
6
+ import { Button } from "./Button";
7
+
8
+ type PDFViewerProps = {
9
+ isOpen: boolean;
10
+ onClose: () => void;
11
+ base64: string;
12
+ datab64?: string;
13
+ };
14
+
15
+ export function PDFViewer(props: PDFViewerProps) {
16
+ const { base64, isOpen, onClose, datab64 } = props;
17
+ const [page, setPage] = useState(1);
18
+
19
+ const canvasRef = useRef(null);
20
+
21
+ const { pdfDocument } = usePdf({
22
+ file: datab64 ? datab64 : `data:application/pdf;base64,${base64}`,
23
+ workerSrc: "/scripts/pdf.worker.min.mjs",
24
+ page,
25
+ canvasRef,
26
+ scale: 1,
27
+ });
28
+
29
+ if (!base64 && !datab64) return null;
30
+
31
+ return (
32
+ <Modal open={isOpen} onClose={onClose} hideCloseIcon>
33
+ <div className="flex flex-col space-y-4">
34
+ {pdfDocument ? <canvas ref={canvasRef} /> : <div>Loading PDF...</div>}
35
+ {Boolean(pdfDocument && pdfDocument.numPages) && (
36
+ <ul className="flex flex-row justify-between items-center">
37
+ <li className="previous">
38
+ <Button
39
+ disabled={page === 1}
40
+ onClick={() => setPage(page - 1)}
41
+ variant="navigation"
42
+ >
43
+ Previous
44
+ </Button>
45
+ </li>
46
+ <li className="text-label-desktop text-text-on-action-primary-normal">
47
+ Page {page} of {pdfDocument!.numPages}
48
+ </li>
49
+ <li className="next">
50
+ <Button
51
+ disabled={page === pdfDocument!.numPages}
52
+ onClick={() => setPage(page + 1)}
53
+ variant="navigation"
54
+ >
55
+ Next
56
+ </Button>
57
+ </li>
58
+ </ul>
59
+ )}
60
+ </div>
61
+ </Modal>
62
+ );
63
+ }