@qwanyx/carousel 0.1.5 → 0.1.7

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
@@ -749,11 +749,21 @@ function Thumbnails({
749
749
  // src/components/Carousel.tsx
750
750
  var import_jsx_runtime3 = require("react/jsx-runtime");
751
751
  function extractSlideUrl(slide) {
752
- const layer = slide.layers?.[0];
753
- if (!layer) return void 0;
754
- const imageObj = layer.objects?.find((obj) => obj.type === "image");
755
- if (imageObj && "src" in imageObj) {
756
- return imageObj.src;
752
+ for (const layer of slide.layers || []) {
753
+ for (const obj of layer.objects || []) {
754
+ if ("src" in obj && typeof obj.src === "string") {
755
+ return obj.src;
756
+ }
757
+ if ("url" in obj && typeof obj.url === "string") {
758
+ return obj.url;
759
+ }
760
+ }
761
+ }
762
+ if (slide.url) {
763
+ return slide.url;
764
+ }
765
+ if (slide.src) {
766
+ return slide.src;
757
767
  }
758
768
  return void 0;
759
769
  }
@@ -1187,13 +1197,47 @@ var Carousel = (0, import_react4.forwardRef)(
1187
1197
  children: isFullscreen ? "\u22A0" : "\u229E"
1188
1198
  }
1189
1199
  ),
1200
+ currentSlide && (getSlideUrl || extractSlideUrl(currentSlide)) && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1201
+ "button",
1202
+ {
1203
+ className: "qc-carousel__download-slide",
1204
+ onClick: () => {
1205
+ const url = getSlideUrl ? getSlideUrl(currentSlide) : extractSlideUrl(currentSlide);
1206
+ if (url) {
1207
+ const link = document.createElement("a");
1208
+ link.href = url;
1209
+ link.download = currentSlide.name || `slide-${currentIndex + 1}`;
1210
+ link.target = "_blank";
1211
+ document.body.appendChild(link);
1212
+ link.click();
1213
+ document.body.removeChild(link);
1214
+ }
1215
+ },
1216
+ "aria-label": "Download",
1217
+ title: "Download",
1218
+ style: {
1219
+ width: "40px",
1220
+ height: "40px",
1221
+ borderRadius: "8px",
1222
+ border: "none",
1223
+ backgroundColor: "rgba(0,0,0,0.5)",
1224
+ color: "white",
1225
+ cursor: "pointer",
1226
+ display: "flex",
1227
+ alignItems: "center",
1228
+ justifyContent: "center",
1229
+ fontSize: "18px"
1230
+ },
1231
+ children: "\u2B07"
1232
+ }
1233
+ ),
1190
1234
  currentSlide && (getSlideUrl || extractSlideUrl(currentSlide)) && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1191
1235
  "button",
1192
1236
  {
1193
1237
  className: "qc-carousel__copy-slide",
1194
1238
  onClick: () => handleCopySlide(currentSlide),
1195
- "aria-label": "Copy image URL",
1196
- title: "Copy image URL",
1239
+ "aria-label": "Copy URL",
1240
+ title: "Copy URL",
1197
1241
  style: {
1198
1242
  width: "40px",
1199
1243
  height: "40px",
package/dist/index.mjs CHANGED
@@ -714,11 +714,21 @@ function Thumbnails({
714
714
  // src/components/Carousel.tsx
715
715
  import { Fragment as Fragment2, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
716
716
  function extractSlideUrl(slide) {
717
- const layer = slide.layers?.[0];
718
- if (!layer) return void 0;
719
- const imageObj = layer.objects?.find((obj) => obj.type === "image");
720
- if (imageObj && "src" in imageObj) {
721
- return imageObj.src;
717
+ for (const layer of slide.layers || []) {
718
+ for (const obj of layer.objects || []) {
719
+ if ("src" in obj && typeof obj.src === "string") {
720
+ return obj.src;
721
+ }
722
+ if ("url" in obj && typeof obj.url === "string") {
723
+ return obj.url;
724
+ }
725
+ }
726
+ }
727
+ if (slide.url) {
728
+ return slide.url;
729
+ }
730
+ if (slide.src) {
731
+ return slide.src;
722
732
  }
723
733
  return void 0;
724
734
  }
@@ -1152,13 +1162,47 @@ var Carousel = forwardRef(
1152
1162
  children: isFullscreen ? "\u22A0" : "\u229E"
1153
1163
  }
1154
1164
  ),
1165
+ currentSlide && (getSlideUrl || extractSlideUrl(currentSlide)) && /* @__PURE__ */ jsx3(
1166
+ "button",
1167
+ {
1168
+ className: "qc-carousel__download-slide",
1169
+ onClick: () => {
1170
+ const url = getSlideUrl ? getSlideUrl(currentSlide) : extractSlideUrl(currentSlide);
1171
+ if (url) {
1172
+ const link = document.createElement("a");
1173
+ link.href = url;
1174
+ link.download = currentSlide.name || `slide-${currentIndex + 1}`;
1175
+ link.target = "_blank";
1176
+ document.body.appendChild(link);
1177
+ link.click();
1178
+ document.body.removeChild(link);
1179
+ }
1180
+ },
1181
+ "aria-label": "Download",
1182
+ title: "Download",
1183
+ style: {
1184
+ width: "40px",
1185
+ height: "40px",
1186
+ borderRadius: "8px",
1187
+ border: "none",
1188
+ backgroundColor: "rgba(0,0,0,0.5)",
1189
+ color: "white",
1190
+ cursor: "pointer",
1191
+ display: "flex",
1192
+ alignItems: "center",
1193
+ justifyContent: "center",
1194
+ fontSize: "18px"
1195
+ },
1196
+ children: "\u2B07"
1197
+ }
1198
+ ),
1155
1199
  currentSlide && (getSlideUrl || extractSlideUrl(currentSlide)) && /* @__PURE__ */ jsx3(
1156
1200
  "button",
1157
1201
  {
1158
1202
  className: "qc-carousel__copy-slide",
1159
1203
  onClick: () => handleCopySlide(currentSlide),
1160
- "aria-label": "Copy image URL",
1161
- title: "Copy image URL",
1204
+ "aria-label": "Copy URL",
1205
+ title: "Copy URL",
1162
1206
  style: {
1163
1207
  width: "40px",
1164
1208
  height: "40px",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qwanyx/carousel",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"