yet-another-react-lightbox 3.5.0 → 3.5.1

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.
@@ -3,15 +3,17 @@ import { createIcon, IconButton, isImageSlide, useLightboxProps, useLightboxStat
3
3
  import { saveAs } from "./FileSaver.js";
4
4
  const DownloadIcon = createIcon("DownloadIcon", React.createElement("path", { d: "M18 15v3H6v-3H4v3c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2v-3h-2zm-1-4-1.41-1.41L13 12.17V4h-2v8.17L8.41 9.59 7 11l5 5 5-5z" }));
5
5
  export function DownloadButton() {
6
- const { render } = useLightboxProps();
7
- const { currentSlide } = useLightboxState();
6
+ const { render, on } = useLightboxProps();
7
+ const { currentSlide, currentIndex } = useLightboxState();
8
8
  if (render.buttonDownload) {
9
9
  return React.createElement(React.Fragment, null, render.buttonDownload());
10
10
  }
11
11
  const downloadUrl = (currentSlide === null || currentSlide === void 0 ? void 0 : currentSlide.downloadUrl) || (currentSlide && isImageSlide(currentSlide) ? currentSlide.src : undefined);
12
12
  return (React.createElement(IconButton, { label: "Download", icon: DownloadIcon, renderIcon: render.iconDownload, disabled: !downloadUrl, onClick: () => {
13
+ var _a;
13
14
  if (downloadUrl) {
14
15
  saveAs(downloadUrl, currentSlide === null || currentSlide === void 0 ? void 0 : currentSlide.downloadFilename);
16
+ (_a = on.download) === null || _a === void 0 ? void 0 : _a.call(on, { index: currentIndex });
15
17
  }
16
18
  } }));
17
19
  }
@@ -13,6 +13,12 @@ declare module "../../types.js" {
13
13
  /** render custom Download icon */
14
14
  iconDownload?: RenderFunction;
15
15
  }
16
+ interface Callbacks {
17
+ download?: Callback<DownloadCallbackProps>;
18
+ }
19
+ interface DownloadCallbackProps {
20
+ index: number;
21
+ }
16
22
  interface ToolbarButtonKeys {
17
23
  [PLUGIN_DOWNLOAD]: null;
18
24
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yet-another-react-lightbox",
3
- "version": "3.5.0",
3
+ "version": "3.5.1",
4
4
  "description": "Modern React lightbox component",
5
5
  "author": "Igor Danchenko",
6
6
  "license": "MIT",