@evergis/uilib-gl 1.0.135 → 1.0.136

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.
@@ -19,6 +19,12 @@ export declare type IPreviewProps = ControlText & {
19
19
  isOpen?: boolean;
20
20
  onClose?: VoidFunction;
21
21
  root?: HTMLElement | null;
22
+ /**
23
+ * Обработчик скачивания текущего изображения. Если задан, кнопка «Скачать» вызывает его
24
+ * вместо перехода по `src` — это нужно, когда файл требуется получить в момент клика
25
+ * (например, `src` показывает иконку типа файла, а скачать надо сам документ).
26
+ */
27
+ onDownload?: (image: IPreviewImage, index: number) => void;
22
28
  };
23
29
  export declare type ImageSlideShowType = [{
24
30
  chosenImage: IPreviewImage;
@@ -35,6 +41,7 @@ export interface IPreviewButtonProps {
35
41
  }
36
42
  export declare type IPreviewControlsProps = ControlText & {
37
43
  chosenImage?: IPreviewImage;
44
+ onDownload?: VoidFunction;
38
45
  fullscreen?: boolean;
39
46
  toggleFullscreen?: VoidFunction;
40
47
  close?: VoidFunction;
@@ -26427,11 +26427,16 @@ const PreviewControlsComponent = _ref => {
26427
26427
  fullScreenTitleText,
26428
26428
  closeTitleText,
26429
26429
  prevImgTitleText,
26430
- nextImgTitleText
26430
+ nextImgTitleText,
26431
+ onDownload
26431
26432
  } = _ref;
26432
26433
  return React.createElement(React.Fragment, null, React.createElement(ControlsContainer, null, React.createElement(ControlContainer$1, {
26433
26434
  withPadding: true
26434
- }, chosenImage && React.createElement("a", {
26435
+ }, chosenImage && (onDownload ? React.createElement(IconButton, {
26436
+ title: downloadTitleText || "Скачать",
26437
+ kind: "download",
26438
+ onClick: onDownload
26439
+ }) : React.createElement("a", {
26435
26440
  href: chosenImage.src,
26436
26441
  download: chosenImage.fileName,
26437
26442
  target: "_blank",
@@ -26439,7 +26444,7 @@ const PreviewControlsComponent = _ref => {
26439
26444
  }, React.createElement(IconButton, {
26440
26445
  title: downloadTitleText || "Скачать",
26441
26446
  kind: "download"
26442
- })), React.createElement(IconButton, {
26447
+ }))), React.createElement(IconButton, {
26443
26448
  title: fullScreenTitleText || "На весь экран",
26444
26449
  kind: fullscreen ? "minimize" : "maximize",
26445
26450
  onClick: toggleFullscreen
@@ -26663,7 +26668,8 @@ const PreviewComponent = _ref => {
26663
26668
  closeTitleText,
26664
26669
  prevImgTitleText,
26665
26670
  nextImgTitleText,
26666
- errorTitleText
26671
+ errorTitleText,
26672
+ onDownload
26667
26673
  } = _ref;
26668
26674
  const [{
26669
26675
  chosenImageIndex,
@@ -26686,6 +26692,7 @@ const PreviewComponent = _ref => {
26686
26692
  hasError: true
26687
26693
  } : image), [images, failedSrcs]);
26688
26694
  const decoratedChosenImage = useMemo(() => chosenImage ? decoratedImages[chosenImageIndex] ?? chosenImage : undefined, [chosenImage, chosenImageIndex, decoratedImages]);
26695
+ const handleDownload = useMemo(() => onDownload && decoratedChosenImage ? () => onDownload(decoratedChosenImage, chosenImageIndex) : undefined, [onDownload, decoratedChosenImage, chosenImageIndex]);
26689
26696
  const shouldOpenPreview = useMemo(() => images.length > 0 && isOpen, [images, isOpen]);
26690
26697
  return !shouldOpenPreview ? null : React.createElement(Portal, {
26691
26698
  root: root
@@ -26702,7 +26709,8 @@ const PreviewComponent = _ref => {
26702
26709
  fullScreenTitleText: fullScreenTitleText,
26703
26710
  closeTitleText: closeTitleText,
26704
26711
  prevImgTitleText: prevImgTitleText,
26705
- nextImgTitleText: nextImgTitleText
26712
+ nextImgTitleText: nextImgTitleText,
26713
+ onDownload: handleDownload
26706
26714
  }), React.createElement(PreviewSlideShow, {
26707
26715
  images: decoratedImages,
26708
26716
  chosenImageIndex: chosenImageIndex,