limbo-component 1.6.6 → 1.6.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/limbo.es.js CHANGED
@@ -30628,6 +30628,8 @@ function adaptAssetsListFromV2(v2Response) {
30628
30628
  height: asset.height,
30629
30629
  upload_date: asset.upload_date || asset.created_at,
30630
30630
  processing_status: asset.processing_status || asset.status,
30631
+ // Variantes
30632
+ variants: asset.variants_count ? adaptVariantsFromV2(asset.variants) || adaptVariantsFromV2(asset.image_variants) || [] : [],
30631
30633
  // URL principal - handle multiple URL formats from different backend responses
30632
30634
  url: makeAbsoluteUrl(
30633
30635
  asset.master_url || asset.master?.url_signed || asset.urls?.original || asset.url
@@ -30681,6 +30683,23 @@ function adaptVariantsListFromV2(v2Response) {
30681
30683
  });
30682
30684
  return { result: legacyVariants };
30683
30685
  }
30686
+ function adaptVariantsFromV2(v2Variants) {
30687
+ if (!Array.isArray(v2Variants)) {
30688
+ return [];
30689
+ }
30690
+ return v2Variants.map((variant) => ({
30691
+ id: variant.id,
30692
+ name: variant.name,
30693
+ width: variant.width,
30694
+ height: variant.height,
30695
+ format: variant.output_format,
30696
+ file_size: variant.file_size,
30697
+ crop_params: variant.crop_params,
30698
+ url: makeAbsoluteUrl(variant.url),
30699
+ expires_at: variant.expires_at,
30700
+ created_at: variant.created_at
30701
+ }));
30702
+ }
30684
30703
  function adaptUploadFromV2(v2Response) {
30685
30704
  if (!v2Response?.success || !v2Response?.data) {
30686
30705
  return { result: null };
@@ -31012,13 +31031,19 @@ function ImageVariantsModal({
31012
31031
  }
31013
31032
  };
31014
31033
  const handleDownloadVariant = (variant) => {
31015
- accessibilityManager?.announce(`Descargando variante ${variant.name}`);
31016
- const a = document.createElement("a");
31017
- a.href = variant.url;
31018
- a.download = `${image.filename}_${variant.name}.${variant.format}`;
31019
- document.body.appendChild(a);
31020
- a.click();
31021
- document.body.removeChild(a);
31034
+ accessibilityManager?.announce(`Descargando ${image.filename}`);
31035
+ fetch(image.url || image.path, { mode: "cors" }).then((resp) => resp.blob()).then((blob) => {
31036
+ const url = window.URL.createObjectURL(blob);
31037
+ const a = document.createElement("a");
31038
+ a.href = url;
31039
+ a.download = `${variant.name}.${variant.format}`;
31040
+ document.body.appendChild(a);
31041
+ a.click();
31042
+ setTimeout(() => {
31043
+ window.URL.revokeObjectURL(url);
31044
+ document.body.removeChild(a);
31045
+ }, 100);
31046
+ });
31022
31047
  };
31023
31048
  const handleViewVariant = (variant) => {
31024
31049
  accessibilityManager?.announce(
@@ -31042,15 +31067,20 @@ function ImageVariantsModal({
31042
31067
  }
31043
31068
  };
31044
31069
  const handleDownloadOriginal = () => {
31045
- accessibilityManager?.announce(
31046
- `Descargando imagen original ${image.filename}`
31047
- );
31048
- const a = document.createElement("a");
31049
- a.href = image.url;
31050
- a.download = image.filename;
31051
- document.body.appendChild(a);
31052
- a.click();
31053
- document.body.removeChild(a);
31070
+ accessibilityManager?.announce(`Descargando ${image.filename}`);
31071
+ fetch(image.url || image.path, { mode: "cors" }).then((resp) => resp.blob()).then((blob) => {
31072
+ const url = window.URL.createObjectURL(blob);
31073
+ const a = document.createElement("a");
31074
+ const filename = image.filename.split(".")[0];
31075
+ a.href = url;
31076
+ a.download = `${filename || "image"}.webp`;
31077
+ document.body.appendChild(a);
31078
+ a.click();
31079
+ setTimeout(() => {
31080
+ window.URL.revokeObjectURL(url);
31081
+ document.body.removeChild(a);
31082
+ }, 100);
31083
+ });
31054
31084
  };
31055
31085
  const handleDeleteOriginal = async () => {
31056
31086
  if (!onDelete) return;
@@ -31277,7 +31307,7 @@ function ImageVariantsModal({
31277
31307
  {
31278
31308
  src: variant.url,
31279
31309
  alt: variant.name || variant.filename || `Variante ${variant.id}`,
31280
- loading: "lazy",
31310
+ loading: "eager",
31281
31311
  onError: () => handleVariantImageError(variant.id),
31282
31312
  style: {
31283
31313
  display: hasImageError ? "none" : "block"
@@ -31460,8 +31490,9 @@ function ImageCard({
31460
31490
  fetch(image.url || image.path, { mode: "cors" }).then((resp) => resp.blob()).then((blob) => {
31461
31491
  const url = window.URL.createObjectURL(blob);
31462
31492
  const a = document.createElement("a");
31493
+ const filename = image.filename.split(".")[0];
31463
31494
  a.href = url;
31464
- a.download = image.filename || "imagen.jpg";
31495
+ a.download = `${filename || "image"}.webp`;
31465
31496
  document.body.appendChild(a);
31466
31497
  a.click();
31467
31498
  setTimeout(() => {
@@ -31552,7 +31583,7 @@ function ImageCard({
31552
31583
  className: `limbo-image-card flex flex-col items-center cursor-pointer relative transition ${isDeleting ? "opacity-50" : ""} ${isMobile ? "limbo-image-card--mobile" : ""}`,
31553
31584
  onClick: handleImageClick,
31554
31585
  onKeyDown: handleKeyDown,
31555
- title: isMobile ? "Toque para ver imagen" : "Haga click en la imagen para ver preview en nueva pestaña (Enter/Space para abrir, D descargar, C copiar, Delete eliminar, X recortar)",
31586
+ title: isMobile ? "Toque para ver imagen" : "Haga click en la imagen para ver preview en nueva pestaña",
31556
31587
  role: "button",
31557
31588
  tabIndex: 0,
31558
31589
  "aria-label": `Imagen ${image.filename}. ${image.width}x${image.height} px`,
@@ -31743,6 +31774,7 @@ function ImageCard({
31743
31774
  "img",
31744
31775
  {
31745
31776
  src: image.url || image.path,
31777
+ loading: "eager",
31746
31778
  alt: image.filename,
31747
31779
  className: "w-full object-cover rounded aspect-square",
31748
31780
  sizes: `height: ${thumbnailSize * 6}px,width: ${thumbnailSize * 6}px`,
@@ -37015,13 +37047,16 @@ function CropperView({
37015
37047
  const { refs, state, transform, selection, utils } = cropper;
37016
37048
  const { canvasRef, imageRef, selectionRef } = refs;
37017
37049
  const { cropData, imageInfo, canExport, transformVersion } = state;
37018
- const effectiveImageInfo = useMemo(() => imageInfo || {
37019
- naturalWidth: image.width || 1920,
37020
- // Usar dimensiones de la imagen prop como fallback
37021
- naturalHeight: image.height || 1080,
37022
- currentWidth: image.width || 1920,
37023
- currentHeight: image.height || 1080
37024
- }, [imageInfo, image.width, image.height]);
37050
+ const effectiveImageInfo = useMemo(
37051
+ () => imageInfo || {
37052
+ naturalWidth: image.width || 1920,
37053
+ // Usar dimensiones de la imagen prop como fallback
37054
+ naturalHeight: image.height || 1080,
37055
+ currentWidth: image.width || 1920,
37056
+ currentHeight: image.height || 1080
37057
+ },
37058
+ [imageInfo, image.width, image.height]
37059
+ );
37025
37060
  const toggleGrid = useCallback(() => setShowGrid((v) => !v), []);
37026
37061
  const toggleShade = useCallback(() => setShade((v) => !v), []);
37027
37062
  const toggleTips = useCallback(() => setShowTips((v) => !v), []);
@@ -37133,15 +37168,21 @@ function CropperView({
37133
37168
  try {
37134
37169
  if (!cropData || !effectiveImageInfo) {
37135
37170
  console.error("❌ Datos faltantes:", { cropData, effectiveImageInfo });
37136
- throw new Error(`No hay datos de recorte disponibles. CropData: ${!!cropData}, ImageInfo: ${!!effectiveImageInfo}`);
37171
+ throw new Error(
37172
+ `No hay datos de recorte disponibles. CropData: ${!!cropData}, ImageInfo: ${!!effectiveImageInfo}`
37173
+ );
37137
37174
  }
37138
37175
  if (!cropData.x && cropData.x !== 0 || !cropData.y && cropData.y !== 0 || !cropData.width || !cropData.height) {
37139
37176
  console.error("❌ CropData inválido:", cropData);
37140
- throw new Error("Los datos de recorte no tienen las propiedades esperadas");
37177
+ throw new Error(
37178
+ "Los datos de recorte no tienen las propiedades esperadas"
37179
+ );
37141
37180
  }
37142
37181
  if (!effectiveImageInfo.naturalWidth || !effectiveImageInfo.naturalHeight) {
37143
37182
  console.error("❌ ImageInfo inválido:", effectiveImageInfo);
37144
- throw new Error("Los datos de imagen no tienen las dimensiones esperadas");
37183
+ throw new Error(
37184
+ "Los datos de imagen no tienen las dimensiones esperadas"
37185
+ );
37145
37186
  }
37146
37187
  const { x, y, width, height } = cropData;
37147
37188
  const { naturalWidth, naturalHeight } = effectiveImageInfo;
@@ -37187,7 +37228,6 @@ function CropperView({
37187
37228
  }, [
37188
37229
  canExport,
37189
37230
  cropData,
37190
- imageInfo,
37191
37231
  effectiveImageInfo,
37192
37232
  image.filename,
37193
37233
  image.id,
@@ -38256,7 +38296,7 @@ function useImages(apiKey, prod = false, params = {}) {
38256
38296
  try {
38257
38297
  const data = await listAssets(params);
38258
38298
  if (!isMounted) return;
38259
- const result = data.result || [];
38299
+ const result = data.result || data.data || [];
38260
38300
  const paginationData = data.pagination || null;
38261
38301
  setImages(result);
38262
38302
  setPagination(paginationData);
@@ -41890,7 +41930,7 @@ const Limbo = new LimboCore();
41890
41930
  if (typeof window !== "undefined") {
41891
41931
  window.Limbo = Limbo;
41892
41932
  }
41893
- const PUBLIC_KEY = "pk_9fcfdd91a14755cc68d0e11a14269554";
41933
+ const PUBLIC_KEY = "pk_e464fd744106b7a8d63d453c4bd02582";
41894
41934
  if (typeof window !== "undefined" && document.querySelector("#root")) {
41895
41935
  Limbo.configure({
41896
41936
  prod: false,