@geowiki/design-system 0.16.19 → 0.16.20

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.
package/dist/index.js CHANGED
@@ -7617,17 +7617,21 @@ var GalleryCarouselOpen = ({
7617
7617
  const [text, setDefaultText] = (0, import_react25.useState)("");
7618
7618
  const [id, setDefaultId] = (0, import_react25.useState)("");
7619
7619
  const [rotation, setRotation] = (0, import_react25.useState)(imageRotation);
7620
+ const imageRef = (0, import_react25.useRef)(null);
7621
+ const currentPhotoUrl = currentPhoto.imageUrl;
7622
+ const currentPhotoId = currentPhoto.id;
7620
7623
  (0, import_react25.useEffect)(() => {
7621
- setDefaultPhoto(currentPhoto);
7622
- }, [currentPhoto]);
7624
+ setDefaultPhoto({ imageUrl: currentPhotoUrl, id: currentPhotoId });
7625
+ setRotation(imageRotation);
7626
+ }, [currentPhotoUrl, currentPhotoId, imageRotation]);
7623
7627
  const handlePrevious = () => {
7624
7628
  const currentIndex = list.findIndex(
7625
7629
  (item) => item.url === defaultPhoto.imageUrl
7626
7630
  );
7627
7631
  if (currentIndex > 0) {
7628
7632
  const previousIndex = currentIndex - 1;
7629
- setDefaultPhoto({ imageUrl: list[previousIndex].url });
7630
- setDefaultId(list[previousIndex].id);
7633
+ setDefaultPhoto({ imageUrl: list[previousIndex].url, id: list[previousIndex].id });
7634
+ setRotation(0);
7631
7635
  }
7632
7636
  };
7633
7637
  const handleNext = () => {
@@ -7636,13 +7640,13 @@ var GalleryCarouselOpen = ({
7636
7640
  );
7637
7641
  if (currentIndex < list.length - 1) {
7638
7642
  const nextIndex = currentIndex + 1;
7639
- setDefaultPhoto({ imageUrl: list[nextIndex].url });
7640
- setDefaultId(list[nextIndex].id);
7643
+ setDefaultPhoto({ imageUrl: list[nextIndex].url, id: list[nextIndex].id });
7644
+ setRotation(0);
7641
7645
  }
7642
7646
  };
7643
7647
  const generateBase64ofImage = () => {
7644
- const img = document.getElementById(id);
7645
- let base64;
7648
+ const img = imageRef.current;
7649
+ if (!img || !img.complete || img.naturalWidth === 0) return null;
7646
7650
  const canvas = document.createElement("canvas");
7647
7651
  const ctx = canvas.getContext("2d");
7648
7652
  if (!ctx) return null;
@@ -7654,8 +7658,7 @@ var GalleryCarouselOpen = ({
7654
7658
  ctx.translate(canvas.width / 2, canvas.height / 2);
7655
7659
  ctx.rotate(radians);
7656
7660
  ctx.drawImage(img, -img.naturalWidth / 2, -img.naturalHeight / 2);
7657
- base64 = canvas.toDataURL("image/jpeg");
7658
- return base64;
7661
+ return canvas.toDataURL("image/jpeg");
7659
7662
  };
7660
7663
  (0, import_react25.useEffect)(() => {
7661
7664
  const foundPhoto = list.find((list2) => list2.url === defaultPhoto.imageUrl);
@@ -7705,7 +7708,7 @@ var GalleryCarouselOpen = ({
7705
7708
  type: "button",
7706
7709
  className: " rounded-md focus:outline-none focus:ring-2 focus:ring-offset-2 z-40 ",
7707
7710
  onClick: handlePrevious,
7708
- children: /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(import_lucide_react20.ChevronLeft, { className: "h-8 w-8 disabled:pointer-events-none disabled:opacity-60 text-white", onClick: () => setRotation(0) })
7711
+ children: /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(import_lucide_react20.ChevronLeft, { className: "h-8 w-8 disabled:pointer-events-none disabled:opacity-60 text-white" })
7709
7712
  }
7710
7713
  ),
7711
7714
  /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(
@@ -7754,6 +7757,7 @@ var GalleryCarouselOpen = ({
7754
7757
  !defaultPhoto.imageUrl.includes(".mp4") && !defaultPhoto.imageUrl.includes(".mov") && /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(
7755
7758
  "img",
7756
7759
  {
7760
+ ref: imageRef,
7757
7761
  id,
7758
7762
  src: defaultPhoto.imageUrl,
7759
7763
  crossOrigin: "anonymous",
@@ -7786,7 +7790,7 @@ var GalleryCarouselOpen = ({
7786
7790
  type: "button",
7787
7791
  className: " rounded-md focus:outline-none focus:ring-2 focus:ring-offset-2 z-40",
7788
7792
  onClick: handleNext,
7789
- children: /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(import_lucide_react20.ChevronRight, { className: "h-8 w-8 disabled:pointer-events-none disabled:opacity-60 text-white", onClick: () => setRotation(0) })
7793
+ children: /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(import_lucide_react20.ChevronRight, { className: "h-8 w-8 disabled:pointer-events-none disabled:opacity-60 text-white" })
7790
7794
  }
7791
7795
  )
7792
7796
  ] }),
@@ -7804,7 +7808,11 @@ var GalleryCarouselOpen = ({
7804
7808
  {
7805
7809
  className: "z-40 text-white hover:cursor-pointer",
7806
7810
  onClick: () => {
7807
- saveRotationChanges(generateBase64ofImage(), id);
7811
+ const base64 = generateBase64ofImage();
7812
+ saveRotationChanges(base64, id);
7813
+ if (base64) {
7814
+ setDefaultPhoto({ imageUrl: base64, id });
7815
+ }
7808
7816
  setRotation(0);
7809
7817
  },
7810
7818
  children: "Save rotation changes"
package/dist/index.mjs CHANGED
@@ -7230,7 +7230,7 @@ var CarouselGalleryItem = ({ text, url, id }) => {
7230
7230
  import { Fragment as Fragment10 } from "react";
7231
7231
  import { Dialog as Dialog5, Transition as Transition3 } from "@headlessui/react";
7232
7232
  import { XMarkIcon as XMarkIcon4 } from "@heroicons/react/24/outline";
7233
- import { useState as useState14, useEffect as useEffect8 } from "react";
7233
+ import { useState as useState14, useEffect as useEffect8, useRef as useRef2 } from "react";
7234
7234
  import { ChevronLeft as ChevronLeft2, ChevronRight as ChevronRight5, RotateCw, RotateCcw } from "lucide-react";
7235
7235
  import { TransformComponent, TransformWrapper } from "react-zoom-pan-pinch";
7236
7236
  import { jsx as jsx133, jsxs as jsxs58 } from "react/jsx-runtime";
@@ -7249,17 +7249,21 @@ var GalleryCarouselOpen = ({
7249
7249
  const [text, setDefaultText] = useState14("");
7250
7250
  const [id, setDefaultId] = useState14("");
7251
7251
  const [rotation, setRotation] = useState14(imageRotation);
7252
+ const imageRef = useRef2(null);
7253
+ const currentPhotoUrl = currentPhoto.imageUrl;
7254
+ const currentPhotoId = currentPhoto.id;
7252
7255
  useEffect8(() => {
7253
- setDefaultPhoto(currentPhoto);
7254
- }, [currentPhoto]);
7256
+ setDefaultPhoto({ imageUrl: currentPhotoUrl, id: currentPhotoId });
7257
+ setRotation(imageRotation);
7258
+ }, [currentPhotoUrl, currentPhotoId, imageRotation]);
7255
7259
  const handlePrevious = () => {
7256
7260
  const currentIndex = list.findIndex(
7257
7261
  (item) => item.url === defaultPhoto.imageUrl
7258
7262
  );
7259
7263
  if (currentIndex > 0) {
7260
7264
  const previousIndex = currentIndex - 1;
7261
- setDefaultPhoto({ imageUrl: list[previousIndex].url });
7262
- setDefaultId(list[previousIndex].id);
7265
+ setDefaultPhoto({ imageUrl: list[previousIndex].url, id: list[previousIndex].id });
7266
+ setRotation(0);
7263
7267
  }
7264
7268
  };
7265
7269
  const handleNext = () => {
@@ -7268,13 +7272,13 @@ var GalleryCarouselOpen = ({
7268
7272
  );
7269
7273
  if (currentIndex < list.length - 1) {
7270
7274
  const nextIndex = currentIndex + 1;
7271
- setDefaultPhoto({ imageUrl: list[nextIndex].url });
7272
- setDefaultId(list[nextIndex].id);
7275
+ setDefaultPhoto({ imageUrl: list[nextIndex].url, id: list[nextIndex].id });
7276
+ setRotation(0);
7273
7277
  }
7274
7278
  };
7275
7279
  const generateBase64ofImage = () => {
7276
- const img = document.getElementById(id);
7277
- let base64;
7280
+ const img = imageRef.current;
7281
+ if (!img || !img.complete || img.naturalWidth === 0) return null;
7278
7282
  const canvas = document.createElement("canvas");
7279
7283
  const ctx = canvas.getContext("2d");
7280
7284
  if (!ctx) return null;
@@ -7286,8 +7290,7 @@ var GalleryCarouselOpen = ({
7286
7290
  ctx.translate(canvas.width / 2, canvas.height / 2);
7287
7291
  ctx.rotate(radians);
7288
7292
  ctx.drawImage(img, -img.naturalWidth / 2, -img.naturalHeight / 2);
7289
- base64 = canvas.toDataURL("image/jpeg");
7290
- return base64;
7293
+ return canvas.toDataURL("image/jpeg");
7291
7294
  };
7292
7295
  useEffect8(() => {
7293
7296
  const foundPhoto = list.find((list2) => list2.url === defaultPhoto.imageUrl);
@@ -7337,7 +7340,7 @@ var GalleryCarouselOpen = ({
7337
7340
  type: "button",
7338
7341
  className: " rounded-md focus:outline-none focus:ring-2 focus:ring-offset-2 z-40 ",
7339
7342
  onClick: handlePrevious,
7340
- children: /* @__PURE__ */ jsx133(ChevronLeft2, { className: "h-8 w-8 disabled:pointer-events-none disabled:opacity-60 text-white", onClick: () => setRotation(0) })
7343
+ children: /* @__PURE__ */ jsx133(ChevronLeft2, { className: "h-8 w-8 disabled:pointer-events-none disabled:opacity-60 text-white" })
7341
7344
  }
7342
7345
  ),
7343
7346
  /* @__PURE__ */ jsx133(
@@ -7386,6 +7389,7 @@ var GalleryCarouselOpen = ({
7386
7389
  !defaultPhoto.imageUrl.includes(".mp4") && !defaultPhoto.imageUrl.includes(".mov") && /* @__PURE__ */ jsx133(
7387
7390
  "img",
7388
7391
  {
7392
+ ref: imageRef,
7389
7393
  id,
7390
7394
  src: defaultPhoto.imageUrl,
7391
7395
  crossOrigin: "anonymous",
@@ -7418,7 +7422,7 @@ var GalleryCarouselOpen = ({
7418
7422
  type: "button",
7419
7423
  className: " rounded-md focus:outline-none focus:ring-2 focus:ring-offset-2 z-40",
7420
7424
  onClick: handleNext,
7421
- children: /* @__PURE__ */ jsx133(ChevronRight5, { className: "h-8 w-8 disabled:pointer-events-none disabled:opacity-60 text-white", onClick: () => setRotation(0) })
7425
+ children: /* @__PURE__ */ jsx133(ChevronRight5, { className: "h-8 w-8 disabled:pointer-events-none disabled:opacity-60 text-white" })
7422
7426
  }
7423
7427
  )
7424
7428
  ] }),
@@ -7436,7 +7440,11 @@ var GalleryCarouselOpen = ({
7436
7440
  {
7437
7441
  className: "z-40 text-white hover:cursor-pointer",
7438
7442
  onClick: () => {
7439
- saveRotationChanges(generateBase64ofImage(), id);
7443
+ const base64 = generateBase64ofImage();
7444
+ saveRotationChanges(base64, id);
7445
+ if (base64) {
7446
+ setDefaultPhoto({ imageUrl: base64, id });
7447
+ }
7440
7448
  setRotation(0);
7441
7449
  },
7442
7450
  children: "Save rotation changes"
@@ -7639,10 +7647,10 @@ var FeatureDisabled = () => {
7639
7647
  };
7640
7648
 
7641
7649
  // src/components/Elements/IframeViewer.tsx
7642
- import { useEffect as useEffect9, useRef as useRef2 } from "react";
7650
+ import { useEffect as useEffect9, useRef as useRef3 } from "react";
7643
7651
  import { jsx as jsx138 } from "react/jsx-runtime";
7644
7652
  var IframeViewer = ({ html, className }) => {
7645
- const containerRef = useRef2(null);
7653
+ const containerRef = useRef3(null);
7646
7654
  useEffect9(() => {
7647
7655
  if (containerRef.current) {
7648
7656
  containerRef.current.innerHTML = "";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geowiki/design-system",
3
- "version": "0.16.19",
3
+ "version": "0.16.20",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "files": [
@@ -15,7 +15,7 @@
15
15
  "peerDependencies": {
16
16
  "react": "^19.2.0",
17
17
  "react-dom": "^19.2.0",
18
- "@geowiki/core": "0.16.19"
18
+ "@geowiki/core": "0.16.20"
19
19
  },
20
20
  "devDependencies": {
21
21
  "@types/react": "^19.2.14",