@dmsi/wedgekit-react 0.0.490 → 0.0.492

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 (46) hide show
  1. package/dist/{chunk-WIDUWFLX.js → chunk-BYY2NTJH.js} +2 -0
  2. package/dist/{chunk-VJVY6NPF.js → chunk-S5ZJ3Q7P.js} +3 -3
  3. package/dist/{chunk-24K4HHV5.js → chunk-TPBEID5X.js} +7 -2
  4. package/dist/{chunk-YNKN6RKF.js → chunk-YEZBNQZI.js} +29 -4
  5. package/dist/components/CalendarRange.cjs +2 -2
  6. package/dist/components/CalendarRange.js +4 -4
  7. package/dist/components/DataGrid/ColumnSelectorHeaderCell/ColumnSelectorMenuOption.cjs +2 -2
  8. package/dist/components/DataGrid/ColumnSelectorHeaderCell/ColumnSelectorMenuOption.js +4 -4
  9. package/dist/components/DataGrid/ColumnSelectorHeaderCell/index.cjs +2 -2
  10. package/dist/components/DataGrid/ColumnSelectorHeaderCell/index.js +4 -4
  11. package/dist/components/DataGrid/PinnedColumns.cjs +2 -2
  12. package/dist/components/DataGrid/PinnedColumns.js +4 -4
  13. package/dist/components/DataGrid/TableBody/LoadingCell.cjs +2 -2
  14. package/dist/components/DataGrid/TableBody/LoadingCell.js +4 -4
  15. package/dist/components/DataGrid/TableBody/TableBodyRow.cjs +2 -2
  16. package/dist/components/DataGrid/TableBody/TableBodyRow.js +4 -4
  17. package/dist/components/DataGrid/TableBody/index.cjs +2 -2
  18. package/dist/components/DataGrid/TableBody/index.js +4 -4
  19. package/dist/components/DataGrid/index.cjs +2 -2
  20. package/dist/components/DataGrid/index.js +4 -4
  21. package/dist/components/DataGrid/utils.cjs +2 -2
  22. package/dist/components/DataGrid/utils.js +4 -4
  23. package/dist/components/DateInput.cjs +2 -2
  24. package/dist/components/DateInput.js +4 -4
  25. package/dist/components/DateRangeInput.cjs +11 -5
  26. package/dist/components/DateRangeInput.js +13 -7
  27. package/dist/components/MobileDataGrid/ColumnSelector/index.cjs +2 -2
  28. package/dist/components/MobileDataGrid/ColumnSelector/index.js +4 -4
  29. package/dist/components/MobileDataGrid/MobileDataGridHeader.cjs +2 -2
  30. package/dist/components/MobileDataGrid/MobileDataGridHeader.js +4 -4
  31. package/dist/components/MobileDataGrid/index.cjs +2 -2
  32. package/dist/components/MobileDataGrid/index.js +4 -4
  33. package/dist/components/PDFViewer/PDFElement.cjs +31 -5
  34. package/dist/components/PDFViewer/PDFElement.js +3 -2
  35. package/dist/components/PDFViewer/PDFPage.cjs +3 -3
  36. package/dist/components/PDFViewer/PDFPage.js +1 -1
  37. package/dist/components/PDFViewer/index.cjs +35 -5
  38. package/dist/components/PDFViewer/index.js +3 -3
  39. package/dist/components/index.cjs +37 -5
  40. package/dist/components/index.js +4 -4
  41. package/package.json +1 -1
  42. package/src/components/CalendarRange.tsx +3 -0
  43. package/src/components/DateRangeInput.tsx +6 -2
  44. package/src/components/PDFViewer/PDFElement.tsx +38 -3
  45. package/src/components/PDFViewer/PDFPage.tsx +4 -2
  46. package/src/components/PDFViewer/index.tsx +9 -1
@@ -4245,6 +4245,7 @@ function CalendarRange({
4245
4245
  from,
4246
4246
  to,
4247
4247
  onChange,
4248
+ onPendingFromChange,
4248
4249
  isDateAvailable,
4249
4250
  mode = "double",
4250
4251
  cardStyle = false,
@@ -4329,6 +4330,7 @@ function CalendarRange({
4329
4330
  setPendingFrom(date);
4330
4331
  setSelecting("to");
4331
4332
  setHoveredDate(void 0);
4333
+ onPendingFromChange == null ? void 0 : onPendingFromChange(date.toString());
4332
4334
  } else if (pendingFrom) {
4333
4335
  if (onChange) {
4334
4336
  const [start, end] = import_polyfill.Temporal.PlainDate.compare(date, pendingFrom) < 0 ? [date, pendingFrom] : [pendingFrom, date];
@@ -7483,7 +7485,6 @@ function SimpleTable({
7483
7485
  var import_react36 = require("react");
7484
7486
 
7485
7487
  // src/components/PDFViewer/PDFElement.tsx
7486
- var import_react_pdf2 = require("@mikecousins/react-pdf");
7487
7488
  var import_react35 = require("react");
7488
7489
 
7489
7490
  // src/components/Spinner.tsx
@@ -7517,17 +7518,17 @@ var Spinner = ({ size = "small", testid }) => {
7517
7518
  Spinner.displayName = "Spinner";
7518
7519
 
7519
7520
  // src/components/PDFViewer/PDFPage.tsx
7520
- var import_react_pdf = require("@mikecousins/react-pdf");
7521
7521
  var import_react34 = require("react");
7522
7522
  var import_jsx_runtime55 = require("react/jsx-runtime");
7523
7523
  function PdfPage({
7524
7524
  file,
7525
7525
  pageNumber,
7526
7526
  testid,
7527
- isMobile
7527
+ isMobile,
7528
+ usePDF
7528
7529
  }) {
7529
7530
  const canvasRef = (0, import_react34.useRef)(null);
7530
- const { pdfDocument } = (0, import_react_pdf.usePdf)({
7531
+ const { pdfDocument } = usePDF({
7531
7532
  file,
7532
7533
  page: pageNumber,
7533
7534
  canvasRef,
@@ -7553,10 +7554,35 @@ function PDFElement({
7553
7554
  testid,
7554
7555
  isMobile,
7555
7556
  error
7557
+ }) {
7558
+ const [pdfHook, setPDFHook] = (0, import_react35.useState)(null);
7559
+ (0, import_react35.useEffect)(() => {
7560
+ import("@mikecousins/react-pdf").then((m) => setPDFHook(m.usePdf));
7561
+ }, []);
7562
+ if (pdfHook === null) {
7563
+ return null;
7564
+ }
7565
+ return /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
7566
+ PDFElementInternal,
7567
+ {
7568
+ b64,
7569
+ testid,
7570
+ isMobile,
7571
+ error,
7572
+ usePDF: pdfHook
7573
+ }
7574
+ );
7575
+ }
7576
+ function PDFElementInternal({
7577
+ b64,
7578
+ testid,
7579
+ isMobile,
7580
+ error,
7581
+ usePDF
7556
7582
  }) {
7557
7583
  var _a;
7558
7584
  const canvasRef = (0, import_react35.useRef)(null);
7559
- const { pdfDocument } = (0, import_react_pdf2.usePdf)({
7585
+ const { pdfDocument } = usePDF({
7560
7586
  file: `data:application/pdf;base64,${b64}`,
7561
7587
  workerSrc: "/scripts/pdf.worker.min.mjs",
7562
7588
  scale: isMobile ? 1 : 1.3,
@@ -7581,6 +7607,7 @@ function PDFElement({
7581
7607
  children: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
7582
7608
  PdfPage,
7583
7609
  {
7610
+ usePDF,
7584
7611
  testid: testid ? `${testid}-pdf_page_${i + 1}` : void 0,
7585
7612
  file: `data:application/pdf;base64,${b64}`,
7586
7613
  pageNumber: i + 1
@@ -7713,6 +7740,10 @@ function PDFViewer(props) {
7713
7740
  } = props;
7714
7741
  const [currentIndex, setCurrentIndex] = (0, import_react36.useState)(0);
7715
7742
  const [isDownloading, setIsDownloading] = (0, import_react36.useState)(false);
7743
+ const [isMounted, setIsMounted] = (0, import_react36.useState)(false);
7744
+ (0, import_react36.useEffect)(() => {
7745
+ setIsMounted(true);
7746
+ }, []);
7716
7747
  const handleDownload = (0, import_react36.useCallback)(() => {
7717
7748
  setIsDownloading(true);
7718
7749
  const link = document.createElement("a");
@@ -7744,6 +7775,7 @@ function PDFViewer(props) {
7744
7775
  setIsDownloading(false);
7745
7776
  onClose();
7746
7777
  }
7778
+ if (!isMounted) return null;
7747
7779
  return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
7748
7780
  Modal,
7749
7781
  {
@@ -2,7 +2,7 @@ import {
2
2
  DataGrid,
3
3
  DateInput,
4
4
  MobileDataGrid
5
- } from "../chunk-WIDUWFLX.js";
5
+ } from "../chunk-BYY2NTJH.js";
6
6
  import "../chunk-M7INAUAJ.js";
7
7
  import "../chunk-4Q7T4GJ2.js";
8
8
  import "../chunk-3DEYCNUE.js";
@@ -11,7 +11,7 @@ import {
11
11
  } from "../chunk-DYBJUTGK.js";
12
12
  import {
13
13
  PDFViewer
14
- } from "../chunk-24K4HHV5.js";
14
+ } from "../chunk-TPBEID5X.js";
15
15
  import "../chunk-B53XDCLO.js";
16
16
  import "../chunk-MBZ55T2D.js";
17
17
  import "../chunk-2IKT6IHB.js";
@@ -24,8 +24,8 @@ import "../chunk-5IFPG6TS.js";
24
24
  import "../chunk-KW6V7O3H.js";
25
25
  import "../chunk-AJ5M6MVX.js";
26
26
  import "../chunk-JUFBGNWW.js";
27
- import "../chunk-YNKN6RKF.js";
28
- import "../chunk-VJVY6NPF.js";
27
+ import "../chunk-YEZBNQZI.js";
28
+ import "../chunk-S5ZJ3Q7P.js";
29
29
  import "../chunk-AT4AWD6B.js";
30
30
  import "../chunk-EWGHVZL5.js";
31
31
  import {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dmsi/wedgekit-react",
3
3
  "private": false,
4
- "version": "0.0.490",
4
+ "version": "0.0.492",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "build": "tsup",
@@ -14,6 +14,7 @@ export interface CalendarRangeProps {
14
14
  from?: string | number;
15
15
  to?: string | number;
16
16
  onChange?: (from: string, to: string) => void;
17
+ onPendingFromChange?: (from: string) => void;
17
18
  isDateAvailable?: (date: Temporal.PlainDate) => boolean;
18
19
  /**
19
20
  * Display mode: 'single' for one month, 'double' for two months side by side (default)
@@ -141,6 +142,7 @@ export function CalendarRange({
141
142
  from,
142
143
  to,
143
144
  onChange,
145
+ onPendingFromChange,
144
146
  isDateAvailable,
145
147
  mode = "double",
146
148
  cardStyle = false,
@@ -249,6 +251,7 @@ export function CalendarRange({
249
251
  setPendingFrom(date);
250
252
  setSelecting("to");
251
253
  setHoveredDate(undefined);
254
+ onPendingFromChange?.(date.toString());
252
255
  // Hide current from/to selection when starting a new selection
253
256
  } else if (pendingFrom) {
254
257
  if (onChange) {
@@ -1,7 +1,7 @@
1
1
  import { useRef, useEffect, useState, useLayoutEffect } from "react";
2
2
  import { createPortal } from "react-dom";
3
3
  import { InputBaseProps, InputBase } from "./Input";
4
- import { CalendarRange } from "./CalendarRange";
4
+ import { CalendarRange, CalendarRangeProps } from "./CalendarRange";
5
5
  import { Icon } from "./Icon";
6
6
  import { findDocumentRoot } from "../utils";
7
7
  import {
@@ -42,7 +42,7 @@ type DateRangeInputProps = Omit<InputBaseProps, "id"> & {
42
42
  disableRange?: boolean;
43
43
  readOnly?: boolean; // If true, input is read-only and cannot be focused
44
44
  label?: string; // Optional label for the input
45
- };
45
+ } & Pick<CalendarRangeProps, "isDateAvailable" | "onPendingFromChange">;
46
46
 
47
47
  export const DateRangeInput = ({
48
48
  id,
@@ -55,6 +55,8 @@ export const DateRangeInput = ({
55
55
  single = false,
56
56
  disableRange = false,
57
57
  label,
58
+ isDateAvailable,
59
+ onPendingFromChange,
58
60
  ...props
59
61
  }: DateRangeInputProps) => {
60
62
  const [visible, setVisible] = useState(false);
@@ -626,6 +628,8 @@ export const DateRangeInput = ({
626
628
  cardStyle
627
629
  mode={single ? "single" : "double"}
628
630
  disableRange={disableRange}
631
+ isDateAvailable={isDateAvailable}
632
+ onPendingFromChange={onPendingFromChange}
629
633
  />
630
634
  </div>,
631
635
  findDocumentRoot(popoverRef.current),
@@ -1,5 +1,6 @@
1
- import { usePdf } from "@mikecousins/react-pdf";
2
- import { useRef } from "react";
1
+ "use client";
2
+ import { type usePdf } from "@mikecousins/react-pdf";
3
+ import { useEffect, useRef, useState } from "react";
3
4
  import { Spinner } from "../Spinner";
4
5
  import { Stack } from "../Stack";
5
6
  import { PdfPage } from "./PDFPage";
@@ -15,10 +16,43 @@ export function PDFElement({
15
16
  testid?: string;
16
17
  isMobile?: boolean;
17
18
  error?: React.ReactNode;
19
+ }) {
20
+ const [pdfHook, setPDFHook] = useState<typeof usePdf | null>(null);
21
+ useEffect(() => {
22
+ import("@mikecousins/react-pdf").then((m) => setPDFHook(m.usePdf));
23
+ }, []);
24
+
25
+ if (pdfHook === null) {
26
+ return null;
27
+ }
28
+
29
+ return (
30
+ <PDFElementInternal
31
+ b64={b64}
32
+ testid={testid}
33
+ isMobile={isMobile}
34
+ error={error}
35
+ usePDF={pdfHook}
36
+ />
37
+ );
38
+ }
39
+
40
+ function PDFElementInternal({
41
+ b64,
42
+ testid,
43
+ isMobile,
44
+ error,
45
+ usePDF,
46
+ }: {
47
+ b64: string;
48
+ testid?: string;
49
+ isMobile?: boolean;
50
+ error?: React.ReactNode;
51
+ usePDF: typeof usePdf;
18
52
  }) {
19
53
  const canvasRef = useRef<HTMLCanvasElement>(null);
20
54
 
21
- const { pdfDocument } = usePdf({
55
+ const { pdfDocument } = usePDF({
22
56
  file: `data:application/pdf;base64,${b64}`,
23
57
  workerSrc: "/scripts/pdf.worker.min.mjs",
24
58
  scale: isMobile ? 1 : 1.3,
@@ -51,6 +85,7 @@ export function PDFElement({
51
85
  )}
52
86
  >
53
87
  <PdfPage
88
+ usePDF={usePDF}
54
89
  testid={testid ? `${testid}-pdf_page_${i + 1}` : undefined}
55
90
  file={`data:application/pdf;base64,${b64}`}
56
91
  pageNumber={i + 1}
@@ -1,4 +1,4 @@
1
- import { usePdf } from "@mikecousins/react-pdf";
1
+ import { type usePdf } from "@mikecousins/react-pdf";
2
2
  import { useRef } from "react";
3
3
 
4
4
  export function PdfPage({
@@ -6,15 +6,17 @@ export function PdfPage({
6
6
  pageNumber,
7
7
  testid,
8
8
  isMobile,
9
+ usePDF,
9
10
  }: {
10
11
  file: string;
11
12
  pageNumber: number;
12
13
  testid?: string;
13
14
  isMobile?: boolean;
15
+ usePDF: typeof usePdf;
14
16
  }) {
15
17
  const canvasRef = useRef<HTMLCanvasElement>(null);
16
18
 
17
- const { pdfDocument } = usePdf({
19
+ const { pdfDocument } = usePDF({
18
20
  file,
19
21
  page: pageNumber,
20
22
  canvasRef,
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
 
3
- import { useCallback, useState } from "react";
3
+ import { useCallback, useEffect, useState } from "react";
4
4
  import { Modal } from "../Modal";
5
5
  import { PDFElement } from "./PDFElement";
6
6
  import { DownloadIcon } from "./DownloadIcon";
@@ -35,6 +35,12 @@ export function PDFViewer(props: PDFViewerProps) {
35
35
  const [currentIndex, setCurrentIndex] = useState(0);
36
36
  const [isDownloading, setIsDownloading] = useState(false);
37
37
 
38
+ const [isMounted, setIsMounted] = useState(false);
39
+
40
+ useEffect(() => {
41
+ setIsMounted(true);
42
+ }, []);
43
+
38
44
  const handleDownload = useCallback(() => {
39
45
  setIsDownloading(true);
40
46
  const link = document.createElement("a");
@@ -73,6 +79,8 @@ export function PDFViewer(props: PDFViewerProps) {
73
79
  onClose();
74
80
  }
75
81
 
82
+ if (!isMounted) return null;
83
+
76
84
  return (
77
85
  <Modal
78
86
  testid={testid}