@geowiki/design-system 0.16.10-dev.3 → 0.16.10-dev.4

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.d.mts CHANGED
@@ -1120,11 +1120,12 @@ declare const SummaryCard: (props: SummaryCardProps) => react_jsx_runtime.JSX.El
1120
1120
  interface CarouselGalleryItemProps {
1121
1121
  text: string;
1122
1122
  url: string;
1123
+ id?: any;
1123
1124
  }
1124
1125
 
1125
1126
  interface Props$6 {
1126
1127
  galleryItems: CarouselGalleryItemProps[];
1127
- saveRotationChanges?: (base64: string | null) => void;
1128
+ saveRotationChanges?: (base64: string | null, id?: any) => void;
1128
1129
  }
1129
1130
  declare const CarouselItemList: ({ galleryItems, saveRotationChanges }: Props$6) => react_jsx_runtime.JSX.Element;
1130
1131
 
package/dist/index.d.ts CHANGED
@@ -1120,11 +1120,12 @@ declare const SummaryCard: (props: SummaryCardProps) => react_jsx_runtime.JSX.El
1120
1120
  interface CarouselGalleryItemProps {
1121
1121
  text: string;
1122
1122
  url: string;
1123
+ id?: any;
1123
1124
  }
1124
1125
 
1125
1126
  interface Props$6 {
1126
1127
  galleryItems: CarouselGalleryItemProps[];
1127
- saveRotationChanges?: (base64: string | null) => void;
1128
+ saveRotationChanges?: (base64: string | null, id?: any) => void;
1128
1129
  }
1129
1130
  declare const CarouselItemList: ({ galleryItems, saveRotationChanges }: Props$6) => react_jsx_runtime.JSX.Element;
1130
1131
 
package/dist/index.js CHANGED
@@ -7545,9 +7545,9 @@ var VideoPlayer = (props) => {
7545
7545
 
7546
7546
  // src/components/DesignElements/Carousel/CarouselGalleryItem.tsx
7547
7547
  var import_jsx_runtime133 = require("react/jsx-runtime");
7548
- var CarouselGalleryItem = ({ text, url }) => {
7548
+ var CarouselGalleryItem = ({ text, url, id }) => {
7549
7549
  return /* @__PURE__ */ (0, import_jsx_runtime133.jsxs)(import_jsx_runtime133.Fragment, { children: [
7550
- !url.includes(".mp4") && !url.includes(".mov") && /* @__PURE__ */ (0, import_jsx_runtime133.jsxs)("div", { className: "aspect-square sm:w-auto bg-center relative flex group ", children: [
7550
+ !url.includes(".mp4") && !url.includes(".mov") && /* @__PURE__ */ (0, import_jsx_runtime133.jsxs)("div", { className: "aspect-square sm:w-auto bg-center relative flex group ", id, children: [
7551
7551
  /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(
7552
7552
  ImageElement,
7553
7553
  {
@@ -7560,7 +7560,7 @@ var CarouselGalleryItem = ({ text, url }) => {
7560
7560
  /* @__PURE__ */ (0, import_jsx_runtime133.jsx)("div", { className: " absolute bottom-6 opacity-0 group-hover:opacity-100", children: /* @__PURE__ */ (0, import_jsx_runtime133.jsx)("div", { className: " mx-6 text-white text-base leading-[120%] line-clamp-4", children: text }) })
7561
7561
  ] }),
7562
7562
  (url.includes(".mp4") || url.includes(".mov")) && /* @__PURE__ */ (0, import_jsx_runtime133.jsxs)("div", { className: " max-w-sm aspect-square relative group cursor-pointer overflow-hidden rounded-xl", children: [
7563
- /* @__PURE__ */ (0, import_jsx_runtime133.jsx)("div", { className: "transition-all duration-300 group-hover:brightness-50", children: /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(
7563
+ /* @__PURE__ */ (0, import_jsx_runtime133.jsx)("div", { className: "transition-all duration-300 group-hover:brightness-50", id, children: /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(
7564
7564
  VideoPlayer,
7565
7565
  {
7566
7566
  url,
@@ -7612,20 +7612,21 @@ var GalleryCarouselOpen = ({
7612
7612
  }
7613
7613
  };
7614
7614
  const generateBase64ofImage = () => {
7615
- const img = new Image();
7615
+ const img = document.getElementById(defaultPhoto.id);
7616
7616
  let base64;
7617
- img.src = defaultPhoto.imageUrl;
7618
- img.crossOrigin = "anonymous";
7619
7617
  const canvas = document.createElement("canvas");
7620
7618
  const ctx = canvas.getContext("2d");
7621
7619
  if (!ctx) return null;
7622
- canvas.width = img.height;
7623
- canvas.height = img.width;
7620
+ const radians = rotation * Math.PI / 180;
7621
+ const sin = Math.abs(Math.sin(radians));
7622
+ const cos = Math.abs(Math.cos(radians));
7623
+ canvas.width = img.naturalWidth * cos + img.naturalHeight * sin;
7624
+ canvas.height = img.naturalWidth * sin + img.naturalHeight * cos;
7624
7625
  ctx.translate(canvas.width / 2, canvas.height / 2);
7625
- ctx.rotate(rotation * Math.PI / 180);
7626
- ctx.drawImage(img, -img.width / 2, -img.height / 2);
7626
+ ctx.rotate(radians);
7627
+ ctx.drawImage(img, -img.naturalWidth / 2, -img.naturalHeight / 2);
7627
7628
  base64 = canvas.toDataURL("image/jpeg");
7628
- return base64 != null ? base64 : null;
7629
+ return base64;
7629
7630
  };
7630
7631
  (0, import_react25.useEffect)(() => {
7631
7632
  const foundPhoto = list.find((list2) => list2.url === defaultPhoto.imageUrl);
@@ -7681,7 +7682,9 @@ var GalleryCarouselOpen = ({
7681
7682
  !defaultPhoto.imageUrl.includes(".mp4") && !defaultPhoto.imageUrl.includes(".mov") && /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(
7682
7683
  "img",
7683
7684
  {
7685
+ id: defaultPhoto.id,
7684
7686
  src: defaultPhoto.imageUrl,
7687
+ crossOrigin: "anonymous",
7685
7688
  alt: "Description",
7686
7689
  style: { maxWidth: "100%", maxHeight: "95vh", transform: `rotate(${rotation}deg)` },
7687
7690
  className: " p-4"
@@ -7690,6 +7693,7 @@ var GalleryCarouselOpen = ({
7690
7693
  (defaultPhoto.imageUrl.includes(".mp4") || defaultPhoto.imageUrl.includes(".mov")) && /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(
7691
7694
  "video",
7692
7695
  {
7696
+ id: defaultPhoto.id,
7693
7697
  src: defaultPhoto.imageUrl,
7694
7698
  controls: true,
7695
7699
  preload: "metadata",
@@ -7718,11 +7722,11 @@ var GalleryCarouselOpen = ({
7718
7722
  setRotation(rotation + 90);
7719
7723
  } })
7720
7724
  ] }),
7721
- saveRotationChanges && !defaultPhoto.imageUrl.includes(".mp4") && defaultPhoto.imageUrl.includes(".mov") && /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(
7725
+ saveRotationChanges && !defaultPhoto.imageUrl.includes(".mp4") && !defaultPhoto.imageUrl.includes(".mov") && /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(
7722
7726
  "div",
7723
7727
  {
7724
7728
  className: "z-40 text-white hover:cursor-pointer",
7725
- onClick: () => saveRotationChanges(generateBase64ofImage()),
7729
+ onClick: () => saveRotationChanges(generateBase64ofImage(), defaultPhoto.id),
7726
7730
  children: "Save rotation changes"
7727
7731
  }
7728
7732
  )
@@ -7738,9 +7742,11 @@ var import_jsx_runtime135 = require("react/jsx-runtime");
7738
7742
  var CarouselItemList = ({ galleryItems, saveRotationChanges }) => {
7739
7743
  const [open, setOpen] = (0, import_react26.useState)(false);
7740
7744
  const [selectedItemId, setSelectedItemId] = (0, import_react26.useState)("");
7741
- const handleOpenGallery = (id) => {
7745
+ const [selectedImageId, setSelectedImageId] = (0, import_react26.useState)(null);
7746
+ const handleOpenGallery = (id, imageId) => {
7742
7747
  setOpen(true);
7743
7748
  setSelectedItemId(id);
7749
+ setSelectedImageId(imageId);
7744
7750
  };
7745
7751
  return /* @__PURE__ */ (0, import_jsx_runtime135.jsxs)("div", { children: [
7746
7752
  /* @__PURE__ */ (0, import_jsx_runtime135.jsxs)(Carousel, { className: "w-full px-8", children: [
@@ -7748,8 +7754,8 @@ var CarouselItemList = ({ galleryItems, saveRotationChanges }) => {
7748
7754
  "div",
7749
7755
  {
7750
7756
  className: "flex aspect-square items-center justify-center cursor-pointer",
7751
- onClick: () => handleOpenGallery(galleryItem.url),
7752
- children: /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(CarouselGalleryItem, { text: galleryItem.text, url: galleryItem.url })
7757
+ onClick: () => handleOpenGallery(galleryItem.url, galleryItem.id),
7758
+ children: /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(CarouselGalleryItem, { text: galleryItem.text, url: galleryItem.url, id: galleryItem.id })
7753
7759
  }
7754
7760
  ) }) }, index)) }),
7755
7761
  /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(CarouselPrevious, {}),
@@ -7758,10 +7764,11 @@ var CarouselItemList = ({ galleryItems, saveRotationChanges }) => {
7758
7764
  /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(
7759
7765
  GalleryCarouselOpen,
7760
7766
  {
7761
- currentPhoto: { imageUrl: selectedItemId },
7767
+ currentPhoto: { imageUrl: selectedItemId, id: selectedImageId },
7762
7768
  list: galleryItems.map((galleryItem) => ({
7763
7769
  url: galleryItem.url,
7764
- text: galleryItem.text
7770
+ text: galleryItem.text,
7771
+ id: galleryItem.id
7765
7772
  })),
7766
7773
  open,
7767
7774
  setOpen,
package/dist/index.mjs CHANGED
@@ -5975,7 +5975,7 @@ import { ChevronDownIcon } from "@heroicons/react/20/solid";
5975
5975
  import { Link as Link3 } from "@geowiki/core";
5976
5976
 
5977
5977
  // src/components/Elements/ImageElement.tsx
5978
- import { Image as Image3 } from "@geowiki/core";
5978
+ import { Image as Image2 } from "@geowiki/core";
5979
5979
  import { jsx as jsx118 } from "react/jsx-runtime";
5980
5980
  var ImageElement = ({
5981
5981
  src,
@@ -5988,7 +5988,7 @@ var ImageElement = ({
5988
5988
  if (width && height) {
5989
5989
  if (!showPlaceholder)
5990
5990
  return /* @__PURE__ */ jsx118(
5991
- Image3,
5991
+ Image2,
5992
5992
  {
5993
5993
  className,
5994
5994
  src,
@@ -6000,7 +6000,7 @@ var ImageElement = ({
6000
6000
  }
6001
6001
  );
6002
6002
  return /* @__PURE__ */ jsx118(
6003
- Image3,
6003
+ Image2,
6004
6004
  {
6005
6005
  className,
6006
6006
  src,
@@ -6015,7 +6015,7 @@ var ImageElement = ({
6015
6015
  }
6016
6016
  if (!showPlaceholder)
6017
6017
  return /* @__PURE__ */ jsx118(
6018
- Image3,
6018
+ Image2,
6019
6019
  {
6020
6020
  className,
6021
6021
  src,
@@ -6027,7 +6027,7 @@ var ImageElement = ({
6027
6027
  }
6028
6028
  );
6029
6029
  return /* @__PURE__ */ jsx118("div", { className, children: /* @__PURE__ */ jsx118(
6030
- Image3,
6030
+ Image2,
6031
6031
  {
6032
6032
  className: "rounded-xl",
6033
6033
  src,
@@ -7178,9 +7178,9 @@ var VideoPlayer = (props) => {
7178
7178
 
7179
7179
  // src/components/DesignElements/Carousel/CarouselGalleryItem.tsx
7180
7180
  import { Fragment as Fragment9, jsx as jsx132, jsxs as jsxs57 } from "react/jsx-runtime";
7181
- var CarouselGalleryItem = ({ text, url }) => {
7181
+ var CarouselGalleryItem = ({ text, url, id }) => {
7182
7182
  return /* @__PURE__ */ jsxs57(Fragment9, { children: [
7183
- !url.includes(".mp4") && !url.includes(".mov") && /* @__PURE__ */ jsxs57("div", { className: "aspect-square sm:w-auto bg-center relative flex group ", children: [
7183
+ !url.includes(".mp4") && !url.includes(".mov") && /* @__PURE__ */ jsxs57("div", { className: "aspect-square sm:w-auto bg-center relative flex group ", id, children: [
7184
7184
  /* @__PURE__ */ jsx132(
7185
7185
  ImageElement,
7186
7186
  {
@@ -7193,7 +7193,7 @@ var CarouselGalleryItem = ({ text, url }) => {
7193
7193
  /* @__PURE__ */ jsx132("div", { className: " absolute bottom-6 opacity-0 group-hover:opacity-100", children: /* @__PURE__ */ jsx132("div", { className: " mx-6 text-white text-base leading-[120%] line-clamp-4", children: text }) })
7194
7194
  ] }),
7195
7195
  (url.includes(".mp4") || url.includes(".mov")) && /* @__PURE__ */ jsxs57("div", { className: " max-w-sm aspect-square relative group cursor-pointer overflow-hidden rounded-xl", children: [
7196
- /* @__PURE__ */ jsx132("div", { className: "transition-all duration-300 group-hover:brightness-50", children: /* @__PURE__ */ jsx132(
7196
+ /* @__PURE__ */ jsx132("div", { className: "transition-all duration-300 group-hover:brightness-50", id, children: /* @__PURE__ */ jsx132(
7197
7197
  VideoPlayer,
7198
7198
  {
7199
7199
  url,
@@ -7245,20 +7245,21 @@ var GalleryCarouselOpen = ({
7245
7245
  }
7246
7246
  };
7247
7247
  const generateBase64ofImage = () => {
7248
- const img = new Image();
7248
+ const img = document.getElementById(defaultPhoto.id);
7249
7249
  let base64;
7250
- img.src = defaultPhoto.imageUrl;
7251
- img.crossOrigin = "anonymous";
7252
7250
  const canvas = document.createElement("canvas");
7253
7251
  const ctx = canvas.getContext("2d");
7254
7252
  if (!ctx) return null;
7255
- canvas.width = img.height;
7256
- canvas.height = img.width;
7253
+ const radians = rotation * Math.PI / 180;
7254
+ const sin = Math.abs(Math.sin(radians));
7255
+ const cos = Math.abs(Math.cos(radians));
7256
+ canvas.width = img.naturalWidth * cos + img.naturalHeight * sin;
7257
+ canvas.height = img.naturalWidth * sin + img.naturalHeight * cos;
7257
7258
  ctx.translate(canvas.width / 2, canvas.height / 2);
7258
- ctx.rotate(rotation * Math.PI / 180);
7259
- ctx.drawImage(img, -img.width / 2, -img.height / 2);
7259
+ ctx.rotate(radians);
7260
+ ctx.drawImage(img, -img.naturalWidth / 2, -img.naturalHeight / 2);
7260
7261
  base64 = canvas.toDataURL("image/jpeg");
7261
- return base64 != null ? base64 : null;
7262
+ return base64;
7262
7263
  };
7263
7264
  useEffect8(() => {
7264
7265
  const foundPhoto = list.find((list2) => list2.url === defaultPhoto.imageUrl);
@@ -7314,7 +7315,9 @@ var GalleryCarouselOpen = ({
7314
7315
  !defaultPhoto.imageUrl.includes(".mp4") && !defaultPhoto.imageUrl.includes(".mov") && /* @__PURE__ */ jsx133(
7315
7316
  "img",
7316
7317
  {
7318
+ id: defaultPhoto.id,
7317
7319
  src: defaultPhoto.imageUrl,
7320
+ crossOrigin: "anonymous",
7318
7321
  alt: "Description",
7319
7322
  style: { maxWidth: "100%", maxHeight: "95vh", transform: `rotate(${rotation}deg)` },
7320
7323
  className: " p-4"
@@ -7323,6 +7326,7 @@ var GalleryCarouselOpen = ({
7323
7326
  (defaultPhoto.imageUrl.includes(".mp4") || defaultPhoto.imageUrl.includes(".mov")) && /* @__PURE__ */ jsx133(
7324
7327
  "video",
7325
7328
  {
7329
+ id: defaultPhoto.id,
7326
7330
  src: defaultPhoto.imageUrl,
7327
7331
  controls: true,
7328
7332
  preload: "metadata",
@@ -7351,11 +7355,11 @@ var GalleryCarouselOpen = ({
7351
7355
  setRotation(rotation + 90);
7352
7356
  } })
7353
7357
  ] }),
7354
- saveRotationChanges && !defaultPhoto.imageUrl.includes(".mp4") && defaultPhoto.imageUrl.includes(".mov") && /* @__PURE__ */ jsx133(
7358
+ saveRotationChanges && !defaultPhoto.imageUrl.includes(".mp4") && !defaultPhoto.imageUrl.includes(".mov") && /* @__PURE__ */ jsx133(
7355
7359
  "div",
7356
7360
  {
7357
7361
  className: "z-40 text-white hover:cursor-pointer",
7358
- onClick: () => saveRotationChanges(generateBase64ofImage()),
7362
+ onClick: () => saveRotationChanges(generateBase64ofImage(), defaultPhoto.id),
7359
7363
  children: "Save rotation changes"
7360
7364
  }
7361
7365
  )
@@ -7371,9 +7375,11 @@ import { jsx as jsx134, jsxs as jsxs59 } from "react/jsx-runtime";
7371
7375
  var CarouselItemList = ({ galleryItems, saveRotationChanges }) => {
7372
7376
  const [open, setOpen] = useState15(false);
7373
7377
  const [selectedItemId, setSelectedItemId] = useState15("");
7374
- const handleOpenGallery = (id) => {
7378
+ const [selectedImageId, setSelectedImageId] = useState15(null);
7379
+ const handleOpenGallery = (id, imageId) => {
7375
7380
  setOpen(true);
7376
7381
  setSelectedItemId(id);
7382
+ setSelectedImageId(imageId);
7377
7383
  };
7378
7384
  return /* @__PURE__ */ jsxs59("div", { children: [
7379
7385
  /* @__PURE__ */ jsxs59(Carousel, { className: "w-full px-8", children: [
@@ -7381,8 +7387,8 @@ var CarouselItemList = ({ galleryItems, saveRotationChanges }) => {
7381
7387
  "div",
7382
7388
  {
7383
7389
  className: "flex aspect-square items-center justify-center cursor-pointer",
7384
- onClick: () => handleOpenGallery(galleryItem.url),
7385
- children: /* @__PURE__ */ jsx134(CarouselGalleryItem, { text: galleryItem.text, url: galleryItem.url })
7390
+ onClick: () => handleOpenGallery(galleryItem.url, galleryItem.id),
7391
+ children: /* @__PURE__ */ jsx134(CarouselGalleryItem, { text: galleryItem.text, url: galleryItem.url, id: galleryItem.id })
7386
7392
  }
7387
7393
  ) }) }, index)) }),
7388
7394
  /* @__PURE__ */ jsx134(CarouselPrevious, {}),
@@ -7391,10 +7397,11 @@ var CarouselItemList = ({ galleryItems, saveRotationChanges }) => {
7391
7397
  /* @__PURE__ */ jsx134(
7392
7398
  GalleryCarouselOpen,
7393
7399
  {
7394
- currentPhoto: { imageUrl: selectedItemId },
7400
+ currentPhoto: { imageUrl: selectedItemId, id: selectedImageId },
7395
7401
  list: galleryItems.map((galleryItem) => ({
7396
7402
  url: galleryItem.url,
7397
- text: galleryItem.text
7403
+ text: galleryItem.text,
7404
+ id: galleryItem.id
7398
7405
  })),
7399
7406
  open,
7400
7407
  setOpen,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geowiki/design-system",
3
- "version": "0.16.10-dev.3",
3
+ "version": "0.16.10-dev.4",
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.10-dev.3"
18
+ "@geowiki/core": "0.16.10-dev.4"
19
19
  },
20
20
  "devDependencies": {
21
21
  "@types/react": "^19.2.14",