@sonic-equipment/ui 0.0.104 → 0.0.106

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
@@ -7831,7 +7831,22 @@ function Select({ isDisabled = false, label, onChange, options, placeholder, sel
7831
7831
  var styles$Q = {"modal-overlay":"modal-module-rVFJc","modal-fade":"modal-module-63Uyl","is-full-screen":"modal-module-uwets","modal":"modal-module-6vlFt","content":"modal-module-FJxzx","modal-slide":"modal-module-jkAe7","modal-delayed-fade":"modal-module-WOZ01","close":"modal-module-7zIZE","modal-zoom":"modal-module-aPJ7X"};
7832
7832
 
7833
7833
  function Modal({ children, className, hasCloseButton, isDismissable, isFullScreen, isKeyboardDismissDisabled, isOpen, onOpenChange, shouldCloseOnInteractOutside = true, }) {
7834
- return (jsx(ModalOverlay, { className: clsx(styles$Q['modal-overlay'], className), isDismissable: isDismissable, isKeyboardDismissDisabled: isKeyboardDismissDisabled, isOpen: isOpen, onOpenChange: onOpenChange, shouldCloseOnInteractOutside: () => shouldCloseOnInteractOutside, children: jsxs(Modal$1, { className: clsx(styles$Q.modal, {
7834
+ return (jsx(ModalOverlay, { ref: ref => {
7835
+ ref?.addEventListener('click', e => {
7836
+ if ((!e.target || ref.contains(e.target)) &&
7837
+ ref !== e.target)
7838
+ return;
7839
+ e.preventDefault();
7840
+ e.stopPropagation();
7841
+ });
7842
+ ref?.addEventListener('touchend', e => {
7843
+ if ((!e.target || ref.contains(e.target)) &&
7844
+ ref !== e.target)
7845
+ return;
7846
+ e.preventDefault();
7847
+ e.stopPropagation();
7848
+ });
7849
+ }, className: clsx(styles$Q['modal-overlay'], className), isDismissable: isDismissable, isKeyboardDismissDisabled: isKeyboardDismissDisabled, isOpen: isOpen, onOpenChange: onOpenChange, shouldCloseOnInteractOutside: () => shouldCloseOnInteractOutside, children: jsxs(Modal$1, { className: clsx(styles$Q.modal, {
7835
7850
  [styles$Q['is-full-screen']]: isFullScreen,
7836
7851
  }), children: [hasCloseButton && (jsx("div", { className: styles$Q.close, children: jsx(IconButton, { color: "secondary", isDisabled: !isDismissable, onClick: () => onOpenChange(false), children: jsx(StrokeCloseboxIcon, {}) }) })), jsx("div", { className: styles$Q.content, children: children })] }) }));
7837
7852
  }
@@ -8322,23 +8337,18 @@ var styles$B = {"announcement-provider":"announcement-provider-module-sVIKY","an
8322
8337
 
8323
8338
  function AnnouncementProvider() {
8324
8339
  const languageCode = useLanguageCode();
8340
+ const nodeRef = useRef(null);
8325
8341
  const { data: announcements } = useFetchAnnouncements({
8326
8342
  languageCode,
8327
8343
  });
8328
8344
  const [dismissedIds, setDismissedIds] = useLocalStorage('dismissedAnnouncementIds', []);
8329
8345
  const filteredAnnouncements = announcements?.filter(({ id }) => !dismissedIds.includes(id));
8330
- return (jsx(TransitionGroup, { className: styles$B['announcement-provider'], children: filteredAnnouncements?.map(({ href, id, text, title, type }) => (jsx(CSSTransition, { classNames: {
8346
+ return (jsx(TransitionGroup, { className: styles$B['announcement-provider'], children: filteredAnnouncements?.map(announcement => (jsx(CSSTransition, { classNames: {
8331
8347
  enter: styles$B['announcement-enter'],
8332
8348
  enterActive: styles$B['announcement-enter-active'],
8333
8349
  exit: styles$B['announcement-exit'],
8334
8350
  exitActive: styles$B['announcement-exit-active'],
8335
- }, timeout: 300, children: jsx(ConnectedAnnouncement, { announcement: {
8336
- href,
8337
- id,
8338
- text,
8339
- title,
8340
- type,
8341
- }, onDismiss: id => setDismissedIds(dismissedIds => [...dismissedIds, id]) }) }, id))) }));
8351
+ }, nodeRef: nodeRef, timeout: 300, children: jsx(ConnectedAnnouncement, { announcement: announcement, onDismiss: id => setDismissedIds(dismissedIds => [...dismissedIds, id]) }) }, announcement.id))) }));
8342
8352
  }
8343
8353
 
8344
8354
  var styles$A = {"page-container":"page-container-module-PYmbC","inner-page-container":"page-container-module-uD8GF"};
@@ -8735,19 +8745,35 @@ function ImageLightbox({ images, initialSelectedIndex = 0, variant = 'sm', }) {
8735
8745
  const nextEl = useRef(null);
8736
8746
  const prevEl = useRef(null);
8737
8747
  const mainSwiperRef = useRef(null);
8738
- const [isZoomed, setIsZoomed] = useState(false);
8739
- function handleZoom() {
8740
- setIsZoomed(!isZoomed);
8748
+ const [scrollFromTopPercentage, setScrollFromTopPercentage] = useState(0.5);
8749
+ const { close, isOpen, open } = useDisclosure(false);
8750
+ function handleZoom(e) {
8751
+ const target = e.target;
8752
+ const clientRect = target?.getBoundingClientRect();
8753
+ if (!clientRect)
8754
+ return;
8755
+ const height = clientRect.height;
8756
+ const clientY = e.clientY - clientRect.top;
8757
+ const scrollPercentage = clientY / height;
8758
+ setScrollFromTopPercentage(scrollPercentage);
8759
+ open();
8741
8760
  }
8742
8761
  return (jsxs("div", { className: clsx(styles$q['image-lightbox'], styles$q[variant]), children: [jsx(Swiper, { watchSlidesProgress: true, className: styles$q['thumbs-swiper'], direction: variant === 'sm' ? 'horizontal' : 'vertical', modules: [Thumb], onSwiper: swiper => setThumbsSwiper(swiper), slidesPerView: "auto", spaceBetween: 8, children: images.map((image, index) => (jsx(SwiperSlide, { className: styles$q.slide, children: jsx("div", { className: styles$q.thumb, children: jsx(Image, { className: styles$q.image, fit: "contain", height: 80, image: image, title: "Image", width: 80 }) }) }, index))) }), jsxs("div", { className: styles$q['main-swiper'], children: [jsx(Swiper, { initialSlide: initialSelectedIndex, modules: [Thumb, Navigation], navigation: {
8743
8762
  nextEl: nextEl.current,
8744
8763
  prevEl: prevEl.current,
8745
- }, onActiveIndexChange: swiper => setCurrentIndex(swiper.activeIndex), onBeforeInit: swiper => (mainSwiperRef.current = swiper), slidesPerView: 1, thumbs: { swiper: thumbsSwiper }, children: images.map((image, index) => (jsx(SwiperSlide, { className: styles$q.slide, children: jsx("button", { className: styles$q['active-image'], onClick: handleZoom, type: "button", children: jsx(Image, { className: styles$q.image, fit: "contain", image: image, title: "Image" }) }) }, index))) }), jsx("div", { className: styles$q.pagination, children: jsx(Pagination$1, { contained: true, currentPage: currentIndex + 1, numberOfPages: images.length, onChange: pageNumber => mainSwiperRef.current?.slideTo(pageNumber - 1) }) }), variant === 'lg' && (jsxs(Fragment, { children: [jsx(CarouselNavigationButton, { ref: prevEl, className: clsx(styles$q['navigation-button'], styles$q['navigation-button-prev']), direction: "previous" }), jsx(CarouselNavigationButton, { ref: nextEl, className: clsx(styles$q['navigation-button'], styles$q['navigation-button-next']), direction: "next" })] }))] }), jsx(ZoomImage, { currentImage: images[currentIndex], isZoomed: isZoomed, onClose: handleZoom })] }));
8764
+ }, onActiveIndexChange: swiper => setCurrentIndex(swiper.activeIndex), onBeforeInit: swiper => (mainSwiperRef.current = swiper), slidesPerView: 1, thumbs: { swiper: thumbsSwiper }, children: images.map((image, index) => (jsx(SwiperSlide, { className: styles$q.slide, children: jsx("button", { className: styles$q['active-image'], onClick: handleZoom, type: "button", children: jsx(Image, { className: styles$q.image, fit: "contain", image: image, title: "Image" }) }) }, index))) }), jsx("div", { className: styles$q.pagination, children: jsx(Pagination$1, { contained: true, currentPage: currentIndex + 1, numberOfPages: images.length, onChange: pageNumber => mainSwiperRef.current?.slideTo(pageNumber - 1) }) }), variant === 'lg' && (jsxs(Fragment, { children: [jsx(CarouselNavigationButton, { ref: prevEl, className: clsx(styles$q['navigation-button'], styles$q['navigation-button-prev']), direction: "previous" }), jsx(CarouselNavigationButton, { ref: nextEl, className: clsx(styles$q['navigation-button'], styles$q['navigation-button-next']), direction: "next" })] }))] }), jsx(ZoomImage, { currentImage: images[currentIndex], isZoomed: isOpen, onClose: close, scrollFromTopPercentage: scrollFromTopPercentage })] }));
8746
8765
  }
8747
- function ZoomImage({ currentImage, isZoomed, onClose, }) {
8766
+ function ZoomImage({ currentImage, isZoomed, onClose, scrollFromTopPercentage, }) {
8748
8767
  if (!isZoomed || !currentImage)
8749
8768
  return null;
8750
- return (jsx(Modal, { className: styles$q['zoomed-overlay'], hasCloseButton: true, isDismissable: true, isFullScreen: true, isKeyboardDismissDisabled: false, isOpen: isZoomed, onOpenChange: () => onClose(), children: jsx("div", { className: styles$q['zoomed-container'], onClick: onClose, children: jsx(Image, { className: styles$q['zoomed-image'], image: currentImage, title: currentImage.altText }) }) }));
8769
+ return (jsx(Modal, { className: styles$q['zoomed-overlay'], hasCloseButton: true, isDismissable: true, isFullScreen: true, isKeyboardDismissDisabled: false, isOpen: isZoomed, onOpenChange: onClose, children: jsx("div", { ref: element => {
8770
+ setTimeout(() => {
8771
+ if (!element)
8772
+ return;
8773
+ element.scrollTo(0, element.scrollHeight * scrollFromTopPercentage -
8774
+ element.clientHeight / 2);
8775
+ }, 100);
8776
+ }, className: styles$q['zoomed-container'], onClick: onClose, children: jsx(Image, { className: styles$q['zoomed-image'], image: currentImage, title: currentImage.altText }) }) }));
8751
8777
  }
8752
8778
 
8753
8779
  var styles$p = {"image-lightbox-modal":"product-detail-images-module-N3Ms-"};
@@ -1,5 +1,6 @@
1
1
  import type { StoryObj } from '@storybook/react';
2
2
  import { Announcement } from './announcement';
3
+ import { AnnouncementProvider } from './announcement-provider';
3
4
  declare const meta: {
4
5
  component: typeof Announcement;
5
6
  parameters: {
@@ -14,3 +15,4 @@ export declare const Promo: Story;
14
15
  export declare const Informative: Story;
15
16
  export declare const Notice: Story;
16
17
  export declare const Critical: Story;
18
+ export declare const Connected: StoryObj<typeof AnnouncementProvider>;
package/dist/styles.css CHANGED
@@ -2874,6 +2874,8 @@
2874
2874
 
2875
2875
  .card-carousel-module-DxKOG.card-carousel-module-8uKSt {
2876
2876
  --slide-width: var(--slide-width-narrow);
2877
+
2878
+ max-height: calc(var(--slide-width) * 1.8177);
2877
2879
  }
2878
2880
 
2879
2881
  .card-carousel-module-DxKOG.card-carousel-module-l-ylK {
@@ -2930,6 +2932,8 @@
2930
2932
 
2931
2933
  .card-carousel-module-DxKOG.card-carousel-module-8uKSt {
2932
2934
  --slide-width: var(--slide-width-narrow);
2935
+
2936
+ max-height: calc(var(--slide-width) * 1.8177);
2933
2937
  }
2934
2938
 
2935
2939
  .card-carousel-module-DxKOG.card-carousel-module-l-ylK {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sonic-equipment/ui",
3
- "version": "0.0.104",
3
+ "version": "0.0.106",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -1,10 +0,0 @@
1
- import { ReactNode } from 'react';
2
- import { CarouselProps } from 'carousel/carousel';
3
- interface PromoCardCarouselProps {
4
- cardWidth?: 'normal' | 'narrow' | 'auto';
5
- hasOverflow?: boolean;
6
- promoCards: ReactNode[];
7
- promosPerView?: CarouselProps['slidesPerView'];
8
- }
9
- export declare function PromoCardCarousel({ promoCards }: PromoCardCarouselProps): import("react/jsx-runtime").JSX.Element;
10
- export {};