@geowiki/design-system 0.16.18 → 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
@@ -7610,22 +7610,28 @@ var GalleryCarouselOpen = ({
7610
7610
  setOpen,
7611
7611
  saveRotationChanges,
7612
7612
  selectImage,
7613
- selectImageText
7613
+ selectImageText,
7614
+ imageRotation
7614
7615
  }) => {
7615
7616
  const [defaultPhoto, setDefaultPhoto] = (0, import_react25.useState)(currentPhoto);
7616
7617
  const [text, setDefaultText] = (0, import_react25.useState)("");
7617
7618
  const [id, setDefaultId] = (0, import_react25.useState)("");
7618
- const [rotation, setRotation] = (0, import_react25.useState)(0);
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;
7619
7623
  (0, import_react25.useEffect)(() => {
7620
- setDefaultPhoto(currentPhoto);
7621
- }, [currentPhoto]);
7624
+ setDefaultPhoto({ imageUrl: currentPhotoUrl, id: currentPhotoId });
7625
+ setRotation(imageRotation);
7626
+ }, [currentPhotoUrl, currentPhotoId, imageRotation]);
7622
7627
  const handlePrevious = () => {
7623
7628
  const currentIndex = list.findIndex(
7624
7629
  (item) => item.url === defaultPhoto.imageUrl
7625
7630
  );
7626
7631
  if (currentIndex > 0) {
7627
7632
  const previousIndex = currentIndex - 1;
7628
- setDefaultPhoto({ imageUrl: list[previousIndex].url });
7633
+ setDefaultPhoto({ imageUrl: list[previousIndex].url, id: list[previousIndex].id });
7634
+ setRotation(0);
7629
7635
  }
7630
7636
  };
7631
7637
  const handleNext = () => {
@@ -7634,12 +7640,13 @@ var GalleryCarouselOpen = ({
7634
7640
  );
7635
7641
  if (currentIndex < list.length - 1) {
7636
7642
  const nextIndex = currentIndex + 1;
7637
- setDefaultPhoto({ imageUrl: list[nextIndex].url });
7643
+ setDefaultPhoto({ imageUrl: list[nextIndex].url, id: list[nextIndex].id });
7644
+ setRotation(0);
7638
7645
  }
7639
7646
  };
7640
7647
  const generateBase64ofImage = () => {
7641
- const img = document.getElementById(id);
7642
- let base64;
7648
+ const img = imageRef.current;
7649
+ if (!img || !img.complete || img.naturalWidth === 0) return null;
7643
7650
  const canvas = document.createElement("canvas");
7644
7651
  const ctx = canvas.getContext("2d");
7645
7652
  if (!ctx) return null;
@@ -7651,8 +7658,7 @@ var GalleryCarouselOpen = ({
7651
7658
  ctx.translate(canvas.width / 2, canvas.height / 2);
7652
7659
  ctx.rotate(radians);
7653
7660
  ctx.drawImage(img, -img.naturalWidth / 2, -img.naturalHeight / 2);
7654
- base64 = canvas.toDataURL("image/jpeg");
7655
- return base64;
7661
+ return canvas.toDataURL("image/jpeg");
7656
7662
  };
7657
7663
  (0, import_react25.useEffect)(() => {
7658
7664
  const foundPhoto = list.find((list2) => list2.url === defaultPhoto.imageUrl);
@@ -7702,7 +7708,7 @@ var GalleryCarouselOpen = ({
7702
7708
  type: "button",
7703
7709
  className: " rounded-md focus:outline-none focus:ring-2 focus:ring-offset-2 z-40 ",
7704
7710
  onClick: handlePrevious,
7705
- 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" })
7706
7712
  }
7707
7713
  ),
7708
7714
  /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(
@@ -7751,6 +7757,7 @@ var GalleryCarouselOpen = ({
7751
7757
  !defaultPhoto.imageUrl.includes(".mp4") && !defaultPhoto.imageUrl.includes(".mov") && /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(
7752
7758
  "img",
7753
7759
  {
7760
+ ref: imageRef,
7754
7761
  id,
7755
7762
  src: defaultPhoto.imageUrl,
7756
7763
  crossOrigin: "anonymous",
@@ -7783,7 +7790,7 @@ var GalleryCarouselOpen = ({
7783
7790
  type: "button",
7784
7791
  className: " rounded-md focus:outline-none focus:ring-2 focus:ring-offset-2 z-40",
7785
7792
  onClick: handleNext,
7786
- 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" })
7787
7794
  }
7788
7795
  )
7789
7796
  ] }),
@@ -7800,7 +7807,14 @@ var GalleryCarouselOpen = ({
7800
7807
  "div",
7801
7808
  {
7802
7809
  className: "z-40 text-white hover:cursor-pointer",
7803
- onClick: () => saveRotationChanges(generateBase64ofImage(), id),
7810
+ onClick: () => {
7811
+ const base64 = generateBase64ofImage();
7812
+ saveRotationChanges(base64, id);
7813
+ if (base64) {
7814
+ setDefaultPhoto({ imageUrl: base64, id });
7815
+ }
7816
+ setRotation(0);
7817
+ },
7804
7818
  children: "Save rotation changes"
7805
7819
  }
7806
7820
  ),
@@ -7858,6 +7872,7 @@ var CarouselItemList = (props) => {
7858
7872
  id: galleryItem.id
7859
7873
  })),
7860
7874
  open,
7875
+ imageRotation: 0,
7861
7876
  allowZoom: props.allowZoom,
7862
7877
  selectImageText: props.selectImageText,
7863
7878
  setOpen,
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";
@@ -7242,22 +7242,28 @@ var GalleryCarouselOpen = ({
7242
7242
  setOpen,
7243
7243
  saveRotationChanges,
7244
7244
  selectImage,
7245
- selectImageText
7245
+ selectImageText,
7246
+ imageRotation
7246
7247
  }) => {
7247
7248
  const [defaultPhoto, setDefaultPhoto] = useState14(currentPhoto);
7248
7249
  const [text, setDefaultText] = useState14("");
7249
7250
  const [id, setDefaultId] = useState14("");
7250
- const [rotation, setRotation] = useState14(0);
7251
+ const [rotation, setRotation] = useState14(imageRotation);
7252
+ const imageRef = useRef2(null);
7253
+ const currentPhotoUrl = currentPhoto.imageUrl;
7254
+ const currentPhotoId = currentPhoto.id;
7251
7255
  useEffect8(() => {
7252
- setDefaultPhoto(currentPhoto);
7253
- }, [currentPhoto]);
7256
+ setDefaultPhoto({ imageUrl: currentPhotoUrl, id: currentPhotoId });
7257
+ setRotation(imageRotation);
7258
+ }, [currentPhotoUrl, currentPhotoId, imageRotation]);
7254
7259
  const handlePrevious = () => {
7255
7260
  const currentIndex = list.findIndex(
7256
7261
  (item) => item.url === defaultPhoto.imageUrl
7257
7262
  );
7258
7263
  if (currentIndex > 0) {
7259
7264
  const previousIndex = currentIndex - 1;
7260
- setDefaultPhoto({ imageUrl: list[previousIndex].url });
7265
+ setDefaultPhoto({ imageUrl: list[previousIndex].url, id: list[previousIndex].id });
7266
+ setRotation(0);
7261
7267
  }
7262
7268
  };
7263
7269
  const handleNext = () => {
@@ -7266,12 +7272,13 @@ var GalleryCarouselOpen = ({
7266
7272
  );
7267
7273
  if (currentIndex < list.length - 1) {
7268
7274
  const nextIndex = currentIndex + 1;
7269
- setDefaultPhoto({ imageUrl: list[nextIndex].url });
7275
+ setDefaultPhoto({ imageUrl: list[nextIndex].url, id: list[nextIndex].id });
7276
+ setRotation(0);
7270
7277
  }
7271
7278
  };
7272
7279
  const generateBase64ofImage = () => {
7273
- const img = document.getElementById(id);
7274
- let base64;
7280
+ const img = imageRef.current;
7281
+ if (!img || !img.complete || img.naturalWidth === 0) return null;
7275
7282
  const canvas = document.createElement("canvas");
7276
7283
  const ctx = canvas.getContext("2d");
7277
7284
  if (!ctx) return null;
@@ -7283,8 +7290,7 @@ var GalleryCarouselOpen = ({
7283
7290
  ctx.translate(canvas.width / 2, canvas.height / 2);
7284
7291
  ctx.rotate(radians);
7285
7292
  ctx.drawImage(img, -img.naturalWidth / 2, -img.naturalHeight / 2);
7286
- base64 = canvas.toDataURL("image/jpeg");
7287
- return base64;
7293
+ return canvas.toDataURL("image/jpeg");
7288
7294
  };
7289
7295
  useEffect8(() => {
7290
7296
  const foundPhoto = list.find((list2) => list2.url === defaultPhoto.imageUrl);
@@ -7334,7 +7340,7 @@ var GalleryCarouselOpen = ({
7334
7340
  type: "button",
7335
7341
  className: " rounded-md focus:outline-none focus:ring-2 focus:ring-offset-2 z-40 ",
7336
7342
  onClick: handlePrevious,
7337
- 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" })
7338
7344
  }
7339
7345
  ),
7340
7346
  /* @__PURE__ */ jsx133(
@@ -7383,6 +7389,7 @@ var GalleryCarouselOpen = ({
7383
7389
  !defaultPhoto.imageUrl.includes(".mp4") && !defaultPhoto.imageUrl.includes(".mov") && /* @__PURE__ */ jsx133(
7384
7390
  "img",
7385
7391
  {
7392
+ ref: imageRef,
7386
7393
  id,
7387
7394
  src: defaultPhoto.imageUrl,
7388
7395
  crossOrigin: "anonymous",
@@ -7415,7 +7422,7 @@ var GalleryCarouselOpen = ({
7415
7422
  type: "button",
7416
7423
  className: " rounded-md focus:outline-none focus:ring-2 focus:ring-offset-2 z-40",
7417
7424
  onClick: handleNext,
7418
- 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" })
7419
7426
  }
7420
7427
  )
7421
7428
  ] }),
@@ -7432,7 +7439,14 @@ var GalleryCarouselOpen = ({
7432
7439
  "div",
7433
7440
  {
7434
7441
  className: "z-40 text-white hover:cursor-pointer",
7435
- onClick: () => saveRotationChanges(generateBase64ofImage(), id),
7442
+ onClick: () => {
7443
+ const base64 = generateBase64ofImage();
7444
+ saveRotationChanges(base64, id);
7445
+ if (base64) {
7446
+ setDefaultPhoto({ imageUrl: base64, id });
7447
+ }
7448
+ setRotation(0);
7449
+ },
7436
7450
  children: "Save rotation changes"
7437
7451
  }
7438
7452
  ),
@@ -7490,6 +7504,7 @@ var CarouselItemList = (props) => {
7490
7504
  id: galleryItem.id
7491
7505
  })),
7492
7506
  open,
7507
+ imageRotation: 0,
7493
7508
  allowZoom: props.allowZoom,
7494
7509
  selectImageText: props.selectImageText,
7495
7510
  setOpen,
@@ -7632,10 +7647,10 @@ var FeatureDisabled = () => {
7632
7647
  };
7633
7648
 
7634
7649
  // src/components/Elements/IframeViewer.tsx
7635
- import { useEffect as useEffect9, useRef as useRef2 } from "react";
7650
+ import { useEffect as useEffect9, useRef as useRef3 } from "react";
7636
7651
  import { jsx as jsx138 } from "react/jsx-runtime";
7637
7652
  var IframeViewer = ({ html, className }) => {
7638
- const containerRef = useRef2(null);
7653
+ const containerRef = useRef3(null);
7639
7654
  useEffect9(() => {
7640
7655
  if (containerRef.current) {
7641
7656
  containerRef.current.innerHTML = "";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geowiki/design-system",
3
- "version": "0.16.18",
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.18"
18
+ "@geowiki/core": "0.16.20"
19
19
  },
20
20
  "devDependencies": {
21
21
  "@types/react": "^19.2.14",