@cntrl-site/components 0.1.20 → 0.1.21

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.
@@ -1,9 +1,10 @@
1
- interface SliderProps {
1
+ import { CommonComponentProps } from '../props';
2
+ type SliderProps = {
2
3
  settings: SliderSettings;
3
4
  content: SliderItem[];
4
5
  styles: SliderStyles;
5
6
  isEditor?: boolean;
6
- }
7
+ } & CommonComponentProps;
7
8
  export declare function ControlSlider({ settings, content, styles: sliderStyles, isEditor }: SliderProps): import("react/jsx-runtime").JSX.Element;
8
9
  type SliderItem = {
9
10
  image: {
@@ -0,0 +1,3 @@
1
+ export type CommonComponentProps = {
2
+ metadata?: Record<string, any>;
3
+ };
package/dist/index.js CHANGED
@@ -1905,7 +1905,7 @@ const LightboxGallery = ({ settings, content, styles: styles2, portalId, activeE
1905
1905
  )
1906
1906
  ] });
1907
1907
  };
1908
- const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId, isEditor }) => {
1908
+ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId, isEditor, metadata }) => {
1909
1909
  const [currentIndex, setCurrentIndex] = react.useState(0);
1910
1910
  const [splideKey, setSplideKey] = react.useState(0);
1911
1911
  const [isClosing, setIsClosing] = react.useState(false);
@@ -1922,6 +1922,7 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
1922
1922
  const hasDraggedRef = react.useRef(false);
1923
1923
  const { appear, triggers, slider, thumbnail, controls, area, imageCaption, layout } = settings.lightboxBlock;
1924
1924
  const { appearClass, backdropAppearClass, backdropDisappearClass, disappearClass } = getAnimationClasses(appear.type, appear.direction);
1925
+ const itemId = (metadata == null ? void 0 : metadata.itemId) ?? null;
1925
1926
  react.useEffect(() => {
1926
1927
  const handleLayoutChange = () => {
1927
1928
  setTimeout(() => {
@@ -2059,7 +2060,8 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
2059
2060
  setIsClosing(false);
2060
2061
  setAnimationFinished(false);
2061
2062
  setThumbnailDimensions({});
2062
- const event = new CustomEvent("page-overlay");
2063
+ if (!itemId) return;
2064
+ const event = new CustomEvent("page-overlay", { detail: { itemId } });
2063
2065
  window.dispatchEvent(event);
2064
2066
  }
2065
2067
  return () => {
@@ -2069,7 +2071,7 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
2069
2071
  }
2070
2072
  setAnimationFinished(false);
2071
2073
  };
2072
- }, [isOpen]);
2074
+ }, [isOpen, itemId]);
2073
2075
  react.useEffect(() => {
2074
2076
  if (prevSliderTypeRef.current !== null && prevSliderTypeRef.current !== slider.type) {
2075
2077
  setSplideKey((prev) => prev + 1);
package/dist/index.mjs CHANGED
@@ -1903,7 +1903,7 @@ const LightboxGallery = ({ settings, content, styles: styles2, portalId, activeE
1903
1903
  )
1904
1904
  ] });
1905
1905
  };
1906
- const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId, isEditor }) => {
1906
+ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId, isEditor, metadata }) => {
1907
1907
  const [currentIndex, setCurrentIndex] = useState(0);
1908
1908
  const [splideKey, setSplideKey] = useState(0);
1909
1909
  const [isClosing, setIsClosing] = useState(false);
@@ -1920,6 +1920,7 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
1920
1920
  const hasDraggedRef = useRef(false);
1921
1921
  const { appear, triggers, slider, thumbnail, controls, area, imageCaption, layout } = settings.lightboxBlock;
1922
1922
  const { appearClass, backdropAppearClass, backdropDisappearClass, disappearClass } = getAnimationClasses(appear.type, appear.direction);
1923
+ const itemId = (metadata == null ? void 0 : metadata.itemId) ?? null;
1923
1924
  useEffect(() => {
1924
1925
  const handleLayoutChange = () => {
1925
1926
  setTimeout(() => {
@@ -2057,7 +2058,8 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
2057
2058
  setIsClosing(false);
2058
2059
  setAnimationFinished(false);
2059
2060
  setThumbnailDimensions({});
2060
- const event = new CustomEvent("page-overlay");
2061
+ if (!itemId) return;
2062
+ const event = new CustomEvent("page-overlay", { detail: { itemId } });
2061
2063
  window.dispatchEvent(event);
2062
2064
  }
2063
2065
  return () => {
@@ -2067,7 +2069,7 @@ const Lightbox = ({ isOpen, onClose, content, lightboxStyles, settings, portalId
2067
2069
  }
2068
2070
  setAnimationFinished(false);
2069
2071
  };
2070
- }, [isOpen]);
2072
+ }, [isOpen, itemId]);
2071
2073
  useEffect(() => {
2072
2074
  if (prevSliderTypeRef.current !== null && prevSliderTypeRef.current !== slider.type) {
2073
2075
  setSplideKey((prev) => prev + 1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cntrl-site/components",
3
- "version": "0.1.20",
3
+ "version": "0.1.21",
4
4
  "description": "Custom components for control editor and public websites.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",