limbo-component 1.8.4 → 1.8.5
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.cjs.js +2 -2
- package/dist/limbo.cjs.map +1 -1
- package/dist/limbo.es.js +41 -17
- package/dist/limbo.es.map +1 -1
- package/dist/limbo.min.js +2 -2
- package/dist/limbo.min.js.map +1 -1
- package/dist/limbo.umd.js +2 -2
- package/dist/limbo.umd.js.map +1 -1
- package/dist/types/App.d.ts.map +1 -1
- package/dist/types/components/CropperView.d.ts.map +1 -1
- package/dist/types/core/LimboCore.d.ts.map +1 -1
- package/dist/types/core/ModalManager.d.ts.map +1 -1
- package/dist/types/hooks/useImages.d.ts +1 -1
- package/dist/types/hooks/useImages.d.ts.map +1 -1
- package/dist/types/services/apiClient.d.ts +1 -0
- package/dist/types/services/apiClient.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/limbo.es.js
CHANGED
|
@@ -12635,9 +12635,11 @@ let globalConfig = {
|
|
|
12635
12635
|
token: null,
|
|
12636
12636
|
// JWT token (opcional, generado automáticamente)
|
|
12637
12637
|
authMode: null,
|
|
12638
|
-
// "session" | "manual"
|
|
12638
|
+
// "session" | "manual" | "jwt"
|
|
12639
12639
|
tokenEndpoint: null,
|
|
12640
12640
|
// Endpoint para obtener token (configurable)
|
|
12641
|
+
tokenProvider: null,
|
|
12642
|
+
// Custom function to provide JWT token
|
|
12641
12643
|
prod: false
|
|
12642
12644
|
};
|
|
12643
12645
|
function configureApiClient(config) {
|
|
@@ -12663,7 +12665,17 @@ async function getHeaders({ isFormData = false, useJWT = true, customHeaders = {
|
|
|
12663
12665
|
}
|
|
12664
12666
|
let token = globalConfig.token;
|
|
12665
12667
|
if (useJWT) {
|
|
12666
|
-
if (globalConfig.authMode === "
|
|
12668
|
+
if (globalConfig.authMode === "jwt" && globalConfig.tokenProvider && !token) {
|
|
12669
|
+
try {
|
|
12670
|
+
console.log("🔑 Calling tokenProvider...");
|
|
12671
|
+
token = await globalConfig.tokenProvider();
|
|
12672
|
+
console.log("✅ Token obtained from tokenProvider");
|
|
12673
|
+
globalConfig.token = token;
|
|
12674
|
+
} catch (error) {
|
|
12675
|
+
console.error("❌ tokenProvider failed:", error);
|
|
12676
|
+
throw new Error("Failed to obtain token from tokenProvider: " + error.message);
|
|
12677
|
+
}
|
|
12678
|
+
} else if (globalConfig.authMode === "session" && !token) {
|
|
12667
12679
|
try {
|
|
12668
12680
|
const baseUrl = getBaseUrl(globalConfig);
|
|
12669
12681
|
const endpoint = globalConfig.tokenEndpoint || "/auth/token";
|
|
@@ -12691,7 +12703,8 @@ async function getHeaders({ isFormData = false, useJWT = true, customHeaders = {
|
|
|
12691
12703
|
} else {
|
|
12692
12704
|
console.warn("⚠️ No JWT token available:", {
|
|
12693
12705
|
authMode: globalConfig.authMode,
|
|
12694
|
-
hasPublicKey: !!globalConfig.publicKey
|
|
12706
|
+
hasPublicKey: !!globalConfig.publicKey,
|
|
12707
|
+
hasTokenProvider: !!globalConfig.tokenProvider
|
|
12695
12708
|
});
|
|
12696
12709
|
}
|
|
12697
12710
|
}
|
|
@@ -19474,9 +19487,13 @@ function CropperView({
|
|
|
19474
19487
|
const saveCurrentCropState = useCallback(() => {
|
|
19475
19488
|
if (!cropper.manager || !state.isReady) return;
|
|
19476
19489
|
try {
|
|
19490
|
+
if (!cropper.manager.transform) {
|
|
19491
|
+
console.warn("Transform manager not available");
|
|
19492
|
+
return null;
|
|
19493
|
+
}
|
|
19477
19494
|
const currentCropData = cropData ? { ...cropData } : null;
|
|
19478
|
-
const currentZoom = cropper.manager.transform.getZoom();
|
|
19479
|
-
const currentRotation = cropper.manager.transform.getRotation();
|
|
19495
|
+
const currentZoom = typeof cropper.manager.transform.getZoom === "function" ? cropper.manager.transform.getZoom() : 1;
|
|
19496
|
+
const currentRotation = typeof cropper.manager.transform.getRotation === "function" ? cropper.manager.transform.getRotation() : 0;
|
|
19480
19497
|
const savedState = {
|
|
19481
19498
|
cropData: currentCropData,
|
|
19482
19499
|
transforms: {
|
|
@@ -19918,9 +19935,9 @@ function CropperView({
|
|
|
19918
19935
|
}
|
|
19919
19936
|
}, [imageInfo, state.isReady, cropConfig.mandatoryCrops.length, crops]);
|
|
19920
19937
|
useEffect(() => {
|
|
19921
|
-
if (!cropper.manager || !cropper.manager.utils) return;
|
|
19938
|
+
if (!cropper.manager || !cropper.manager.utils || !cropper.manager.transform) return;
|
|
19922
19939
|
try {
|
|
19923
|
-
const currentZoom = cropper.manager.transform.getZoom();
|
|
19940
|
+
const currentZoom = typeof cropper.manager.transform.getZoom === "function" ? cropper.manager.transform.getZoom() : 1;
|
|
19924
19941
|
const info = {
|
|
19925
19942
|
current: currentZoom,
|
|
19926
19943
|
isZoomedIn: currentZoom > 1,
|
|
@@ -20017,10 +20034,10 @@ function CropperView({
|
|
|
20017
20034
|
children: "Cancelar"
|
|
20018
20035
|
}
|
|
20019
20036
|
),
|
|
20020
|
-
/* @__PURE__ */ jsx(
|
|
20037
|
+
onDelete && /* @__PURE__ */ jsx(
|
|
20021
20038
|
"button",
|
|
20022
20039
|
{
|
|
20023
|
-
onClick: () => onDelete
|
|
20040
|
+
onClick: () => onDelete(image),
|
|
20024
20041
|
disabled: deleting | creatingVariant,
|
|
20025
20042
|
className: "limbo-btn limbo-btn-danger px-4 sm:py-1 h-min flex-1 sm:flex-initial",
|
|
20026
20043
|
"aria-label": `Eliminar imagen ${image.filename}`,
|
|
@@ -20091,7 +20108,7 @@ function CropperView({
|
|
|
20091
20108
|
}
|
|
20092
20109
|
),
|
|
20093
20110
|
/* @__PURE__ */ jsxs("div", { className: "flex-1 min-w-0", children: [
|
|
20094
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
20111
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
20095
20112
|
/* @__PURE__ */ jsx("span", { className: "text-sm font-medium text-gray-800 truncate", children: activeCrop.label === crop.label && crop.required === false ? /* @__PURE__ */ jsx(
|
|
20096
20113
|
"input",
|
|
20097
20114
|
{
|
|
@@ -21179,15 +21196,19 @@ function useDeleteImage() {
|
|
|
21179
21196
|
}
|
|
21180
21197
|
const cache = /* @__PURE__ */ new Map();
|
|
21181
21198
|
const CACHE_TTL = 10 * 60 * 1e3;
|
|
21182
|
-
function useImages(apiKey, prod = false, params = {}) {
|
|
21199
|
+
function useImages(apiKey, prod = false, params = {}, enabled = true) {
|
|
21183
21200
|
const [images, setImages] = useState([]);
|
|
21184
|
-
const [loading, setLoading] = useState(
|
|
21201
|
+
const [loading, setLoading] = useState(enabled);
|
|
21185
21202
|
const [error, setError] = useState(null);
|
|
21186
21203
|
const [pagination, setPagination] = useState(null);
|
|
21187
21204
|
const [retryCount, setRetryCount] = useState(0);
|
|
21188
21205
|
const MAX_RETRIES = 3;
|
|
21189
21206
|
const paramsKey = useMemo(() => JSON.stringify(params), [params]);
|
|
21190
21207
|
useEffect(() => {
|
|
21208
|
+
if (!enabled) {
|
|
21209
|
+
setLoading(false);
|
|
21210
|
+
return;
|
|
21211
|
+
}
|
|
21191
21212
|
const cacheKey = `${paramsKey}`;
|
|
21192
21213
|
const cached = cache.get(cacheKey);
|
|
21193
21214
|
const now = Date.now();
|
|
@@ -21233,7 +21254,7 @@ function useImages(apiKey, prod = false, params = {}) {
|
|
|
21233
21254
|
return () => {
|
|
21234
21255
|
isMounted = false;
|
|
21235
21256
|
};
|
|
21236
|
-
}, [apiKey, prod, paramsKey, retryCount, params]);
|
|
21257
|
+
}, [apiKey, prod, paramsKey, retryCount, params, enabled]);
|
|
21237
21258
|
const invalidateCache = () => {
|
|
21238
21259
|
cache.delete(`${paramsKey}`);
|
|
21239
21260
|
};
|
|
@@ -21385,6 +21406,7 @@ function App({
|
|
|
21385
21406
|
...galleryFilters.dateFrom && { dateFrom: galleryFilters.dateFrom },
|
|
21386
21407
|
...galleryFilters.dateTo && { dateTo: galleryFilters.dateTo }
|
|
21387
21408
|
};
|
|
21409
|
+
const shouldFetchImages = activeFeatures.includes("gallery");
|
|
21388
21410
|
const {
|
|
21389
21411
|
images,
|
|
21390
21412
|
loading: loadingImages,
|
|
@@ -21392,7 +21414,7 @@ function App({
|
|
|
21392
21414
|
pagination,
|
|
21393
21415
|
invalidateCache,
|
|
21394
21416
|
setImages
|
|
21395
|
-
} = useImages(apiKey, prod, apiParams);
|
|
21417
|
+
} = useImages(apiKey, prod, apiParams, shouldFetchImages);
|
|
21396
21418
|
const { refreshVariants } = useImageVariants();
|
|
21397
21419
|
const handleVariantCreated = (assetId, variantData) => {
|
|
21398
21420
|
refreshVariants(assetId);
|
|
@@ -23213,8 +23235,8 @@ class Modal {
|
|
|
23213
23235
|
const sizeClasses = {
|
|
23214
23236
|
small: isMobile ? "width: 100%; height: 100%;" : "max-width: 400px;",
|
|
23215
23237
|
medium: isMobile ? "width: 100%; height: 100%;" : "max-width: 600px;",
|
|
23216
|
-
large: isMobile ? "width: 100%; height: 100%;" : "max-width:
|
|
23217
|
-
xlarge: isMobile ? "width: 100%; height: 100%;" : "max-width:
|
|
23238
|
+
large: isMobile ? "width: 100%; height: 100%;" : "max-width: 1300px;",
|
|
23239
|
+
xlarge: isMobile ? "width: 100%; height: 100%;" : "max-width: 90dvw;"
|
|
23218
23240
|
};
|
|
23219
23241
|
const baseStyles = isMobile ? `
|
|
23220
23242
|
position: fixed;
|
|
@@ -24850,7 +24872,9 @@ class LimboCore {
|
|
|
24850
24872
|
token: options.token,
|
|
24851
24873
|
// Solo para authMode: "manual"
|
|
24852
24874
|
authMode: options.authMode || "manual",
|
|
24853
|
-
// "session" | "manual"
|
|
24875
|
+
// "session" | "manual" | "jwt"
|
|
24876
|
+
tokenProvider: options.tokenProvider,
|
|
24877
|
+
// Custom function to provide JWT token
|
|
24854
24878
|
prod: options.prod || false,
|
|
24855
24879
|
mode: options.mode || "embed",
|
|
24856
24880
|
// "embed" | "modal"
|