@conloca/cms-spa 0.1.12 → 0.1.14
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.d.mts.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/main.mjs +65 -26
- package/dist/main.mjs.map +1 -1
- package/dist/{puck-DyXDFCcg.mjs → puck-CvjeYQRH.mjs} +193 -167
- package/dist/puck-CvjeYQRH.mjs.map +1 -0
- package/dist/spa/main.css +50 -0
- package/package.json +7 -7
- package/dist/puck-DyXDFCcg.mjs.map +0 -1
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/components/editor/CMSMDXEditor.tsx","../src/components/media/FolderTreeSidebar.tsx","../src/components/media/MediaToolbar.tsx","../src/components/media/MediaLibrary.tsx","../src/components/media/UploadModal.tsx","../src/components/puck/MDXContent.tsx","../src/ui-config.ts"],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/components/editor/CMSMDXEditor.tsx","../src/components/media/FolderTreeSidebar.tsx","../src/components/media/MediaToolbar.tsx","../src/components/media/MediaLibrary.tsx","../src/components/media/UploadModal.tsx","../src/components/puck/MDXContent.tsx","../src/ui-config.ts"],"mappings":";;;;;;;;;UAgQiB,sBAAA;EACf,MAAA;EACA,OAAA;EACA,QAAA;EACA,cAAA;EACA,MAAA,GAAS,OAAA,oBAA2B,OAAA;EACpC,WAAA,GAAc,KAAA,CAAM,SAAA;EACpB,aAAA;AAAA;;;;AAOF;cAAa,iBAAA,EAAmB,KAAA,CAAM,EAAA,CAAG,sBAAA;;;UCxQ/B,sBAAA;EACR,aAAA;EACA,cAAA,GAAiB,IAAA;;EAEjB,gBAAA;AAAA;AAAA,iBA8Cc,iBAAA,CAAA;EAAoB,aAAA;EAAe,cAAA;EAAgB;AAAA,GAAoB,sBAAA,GAAsB,kBAAA,CAAA,GAAA,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BAAA;ENmPrB;EMjPA,WAAA;ENmPA;EMjPA,WAAA;ENmPA;EMjPA,SAAA,GAAY,MAAA,SAAe,cAAA;AAAA;AAAA,iBAoBb,WAAA,CAAY,OAAA,EAAS,OAAA,CAAQ,QAAA"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { _ as configureUI, a as MediaLibrary, c as FolderTreeSidebar, i as UploadModal, n as CMSMDXEditorModal, t as MDXContent } from "./puck-CvjeYQRH.mjs";
|
|
2
2
|
import { setDataSchemas } from "./data-schemas.mjs";
|
|
3
3
|
|
|
4
4
|
export { CMSMDXEditorModal, FolderTreeSidebar, MDXContent, MediaLibrary, UploadModal, configureUI, setDataSchemas };
|
package/dist/main.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as MediaLibrary, b as useDialogState, c as FolderTreeSidebar, d as useBulkDeleteAssets, f as useDeleteAsset, g as useSiteBaseUrl, h as useUpdateAssetMetadata, i as UploadModal, l as cn$1, m as useMoveAssets, n as CMSMDXEditorModal, o as MediaToolbar, p as useFolderTree$1, r as ImagePicker, s as buildAssetServeUrl, t as MDXContent, u as useAssetUsage, v as getUIConfig, x as useClickOutside, y as useErrorModal } from "./puck-CvjeYQRH.mjs";
|
|
2
2
|
import { useDataSchemas } from "./data-schemas.mjs";
|
|
3
3
|
import { usePageSchemas } from "./page-schemas.mjs";
|
|
4
4
|
import { usePuckConfig } from "./puck-config.mjs";
|
|
5
5
|
import React, { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
6
6
|
import { AlertCircle, AlertTriangle, ArrowDownToLine, ArrowRight, Check, ChevronDown, Clock, Code, Code2, Database, Edit, Edit2, ExternalLink, Eye, FileEdit, FileJson, FileText, Folder, FolderInput, FolderOpen, GitBranch, Image, ImageIcon, LayoutDashboard, Loader2, Monitor, MoreVertical, Package, Plus, Save, Settings, Smartphone, Tablet, Trash2, Upload, User, X } from "lucide-react";
|
|
7
|
-
import { ContentAPIClient, getContentAPIClient, localesOf, setContentAPIClient, useBlocks, useCommitChanges, useCreateContent, useCurrentUser, useData, useDataCollections, useDeleteContent, useFolderTree, useGitStatus, useLocalizedContent, usePullChanges, usePushChanges, useSitePages, useSitesConfig, useUpdateLocalized } from "@conloca/content-api-client";
|
|
7
|
+
import { ContentAPIClient, blockEditableSchema, dataEditableSchema, formatFileSize, getContentAPIClient, localesOf, setContentAPIClient, useBlocks, useCommitChanges, useCreateContent, useCurrentUser, useData, useDataCollections, useDataContext, useDeleteContent, useFolderTree, useGitStatus, useLocalizedContent, usePullChanges, usePushChanges, useSitePages, useSitesConfig, useUpdateLocalized } from "@conloca/content-api-client";
|
|
8
8
|
import cn from "clsx";
|
|
9
9
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
-
import { QueryClient, QueryClientProvider
|
|
10
|
+
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
11
11
|
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
|
|
12
12
|
import { createRoot } from "react-dom/client";
|
|
13
13
|
import { BrowserRouter, Link, NavLink, Outlet, Route, Routes, useNavigate, useParams } from "react-router-dom";
|
|
@@ -15,7 +15,6 @@ import * as Select from "@radix-ui/react-select";
|
|
|
15
15
|
import { Puck, resolveAllData, useGetPuck } from "@puckeditor/core";
|
|
16
16
|
import * as Dialog from "@radix-ui/react-dialog";
|
|
17
17
|
import { z } from "zod";
|
|
18
|
-
import { blockEditableSchema, dataEditableSchema, formatFileSize } from "@conloca/content-api";
|
|
19
18
|
|
|
20
19
|
//#region src/components/cards/SectionCard.tsx
|
|
21
20
|
function SectionCard({ to, icon, title, description, count, countLabel, isLoading, testId }) {
|
|
@@ -1434,6 +1433,9 @@ function createMDXConflictMarkers(localMdx, serverMdx) {
|
|
|
1434
1433
|
//#region src/components/dialogs/ConflictDialog.tsx
|
|
1435
1434
|
function ConflictDialog({ conflict, onReload, onForceSave, onCancel, showDiff = false }) {
|
|
1436
1435
|
const [showReloadConfirm, setShowReloadConfirm] = useState(false);
|
|
1436
|
+
useEffect(() => {
|
|
1437
|
+
setShowReloadConfirm(false);
|
|
1438
|
+
}, [conflict]);
|
|
1437
1439
|
if (conflict.success || conflict.reason !== "stale_write") return null;
|
|
1438
1440
|
const { conflictDetails } = conflict;
|
|
1439
1441
|
const hasMetaChanges = conflictDetails?.metaChanged ?? false;
|
|
@@ -1941,13 +1943,7 @@ function PageEditorWrapper({ puckConfig }) {
|
|
|
1941
1943
|
const updateContent = useUpdateLocalized();
|
|
1942
1944
|
const { data: content, isLoading: isLoadingContent, error } = useLocalizedContent(id || "", "en");
|
|
1943
1945
|
const { data: blocksData } = useBlocks();
|
|
1944
|
-
const
|
|
1945
|
-
const { data: dataContextResponse, isLoading: isLoadingDataContext } = useQuery({
|
|
1946
|
-
queryKey: ["data-context", id],
|
|
1947
|
-
queryFn: () => fetch(`${apiBaseUrl}/data-context?pageId=${id}`).then((r) => r.ok ? r.json() : null).catch(() => null),
|
|
1948
|
-
enabled: !!id,
|
|
1949
|
-
retry: false
|
|
1950
|
-
});
|
|
1946
|
+
const { data: dataContextResponse, isLoading: isLoadingDataContext } = useDataContext(id);
|
|
1951
1947
|
const [currentEtag, setCurrentEtag] = useState("");
|
|
1952
1948
|
const [metadataDialogOpen, setMetadataDialogOpen] = useState(false);
|
|
1953
1949
|
const [resolvedPuckData, setResolvedPuckData] = useState(null);
|
|
@@ -3926,6 +3922,9 @@ function FolderOption({ node, depth, selectedFolder, currentFolder, onSelect })
|
|
|
3926
3922
|
}
|
|
3927
3923
|
function MoveFolderDialog({ isOpen, assetCount, currentFolder, onMove, onCancel, isMoving = false }) {
|
|
3928
3924
|
const [selectedFolder, setSelectedFolder] = useState(null);
|
|
3925
|
+
useEffect(() => {
|
|
3926
|
+
if (isOpen) setSelectedFolder(null);
|
|
3927
|
+
}, [isOpen]);
|
|
3929
3928
|
const { data, isLoading } = useFolderTree$1();
|
|
3930
3929
|
const rawTree = data?.tree ?? [];
|
|
3931
3930
|
const tree = rawTree.length === 1 && rawTree[0].path === "/" ? rawTree[0].children : rawTree;
|
|
@@ -4329,8 +4328,9 @@ function MediaPage() {
|
|
|
4329
4328
|
const [showMoveDialog, setShowMoveDialog] = useState(false);
|
|
4330
4329
|
const [showDeleteConfirm, setShowDeleteConfirm] = useState(false);
|
|
4331
4330
|
const [showUploadModal, setShowUploadModal] = useState(false);
|
|
4331
|
+
const [bulkDeleteResult, setBulkDeleteResult] = useState(null);
|
|
4332
4332
|
const moveAssets = useMoveAssets();
|
|
4333
|
-
const
|
|
4333
|
+
const bulkDelete = useBulkDeleteAssets();
|
|
4334
4334
|
const handleToggleSelect = (filename) => {
|
|
4335
4335
|
setSelectedAssets((prev) => {
|
|
4336
4336
|
const next = new Set(prev);
|
|
@@ -4353,15 +4353,14 @@ function MediaPage() {
|
|
|
4353
4353
|
};
|
|
4354
4354
|
const handleBulkDelete = async () => {
|
|
4355
4355
|
const filenames = Array.from(selectedAssets);
|
|
4356
|
-
|
|
4357
|
-
|
|
4358
|
-
|
|
4359
|
-
successCount
|
|
4360
|
-
|
|
4361
|
-
|
|
4362
|
-
|
|
4363
|
-
|
|
4364
|
-
}
|
|
4356
|
+
setBulkDeleteResult(null);
|
|
4357
|
+
const result = await bulkDelete.mutateAsync(filenames);
|
|
4358
|
+
setBulkDeleteResult({
|
|
4359
|
+
success: result.successCount,
|
|
4360
|
+
failed: result.failCount
|
|
4361
|
+
});
|
|
4362
|
+
if (result.successCount > 0) setSelectedAssets(/* @__PURE__ */ new Set());
|
|
4363
|
+
setShowDeleteConfirm(false);
|
|
4365
4364
|
};
|
|
4366
4365
|
const handleBulkMove = (targetFolder) => {
|
|
4367
4366
|
const filenames = Array.from(selectedAssets);
|
|
@@ -4381,6 +4380,11 @@ function MediaPage() {
|
|
|
4381
4380
|
const handleCloseDetail = () => {
|
|
4382
4381
|
setSelectedAsset(null);
|
|
4383
4382
|
};
|
|
4383
|
+
useEffect(() => {
|
|
4384
|
+
if (!bulkDeleteResult) return;
|
|
4385
|
+
const timer = setTimeout(() => setBulkDeleteResult(null), 5e3);
|
|
4386
|
+
return () => clearTimeout(timer);
|
|
4387
|
+
}, [bulkDeleteResult]);
|
|
4384
4388
|
return /* @__PURE__ */ jsxs("div", {
|
|
4385
4389
|
className: "flex h-full",
|
|
4386
4390
|
children: [
|
|
@@ -4412,6 +4416,19 @@ function MediaPage() {
|
|
|
4412
4416
|
onUploadClick: () => setShowUploadModal(true)
|
|
4413
4417
|
})]
|
|
4414
4418
|
}),
|
|
4419
|
+
bulkDeleteResult && /* @__PURE__ */ jsxs("div", {
|
|
4420
|
+
className: cn("mx-6 mt-2 px-4 py-2 rounded text-sm flex items-center justify-between", bulkDeleteResult.failed > 0 ? "bg-amber-50 text-amber-800 border border-amber-200" : "bg-green-50 text-green-800 border border-green-200"),
|
|
4421
|
+
children: [/* @__PURE__ */ jsxs("span", { children: [
|
|
4422
|
+
bulkDeleteResult.success,
|
|
4423
|
+
" deleted",
|
|
4424
|
+
bulkDeleteResult.failed > 0 ? `, ${bulkDeleteResult.failed} failed` : ""
|
|
4425
|
+
] }), /* @__PURE__ */ jsx("button", {
|
|
4426
|
+
type: "button",
|
|
4427
|
+
onClick: () => setBulkDeleteResult(null),
|
|
4428
|
+
className: "ml-4 text-current opacity-60 hover:opacity-100",
|
|
4429
|
+
children: "Dismiss"
|
|
4430
|
+
})]
|
|
4431
|
+
}),
|
|
4415
4432
|
/* @__PURE__ */ jsx("div", {
|
|
4416
4433
|
className: "flex-1 overflow-auto px-6 pt-4 pb-6",
|
|
4417
4434
|
children: /* @__PURE__ */ jsx(MediaLibrary, {
|
|
@@ -4453,7 +4470,7 @@ function MediaPage() {
|
|
|
4453
4470
|
message: `Are you sure you want to delete ${selectedAssets.size} selected asset${selectedAssets.size !== 1 ? "s" : ""}?`,
|
|
4454
4471
|
onConfirm: handleBulkDelete,
|
|
4455
4472
|
onCancel: () => setShowDeleteConfirm(false),
|
|
4456
|
-
isDeleting:
|
|
4473
|
+
isDeleting: bulkDelete.isPending
|
|
4457
4474
|
}),
|
|
4458
4475
|
/* @__PURE__ */ jsx(UploadModal, {
|
|
4459
4476
|
isOpen: showUploadModal,
|
|
@@ -4499,9 +4516,14 @@ function PageList({ selectedSite, selectedLocale: initialLocale } = {}) {
|
|
|
4499
4516
|
hasMultipleLocales: false
|
|
4500
4517
|
});
|
|
4501
4518
|
const { showError, errorModalProps } = useErrorModal();
|
|
4519
|
+
const { buildUrl } = useSiteBaseUrl();
|
|
4502
4520
|
const navigate = useNavigate();
|
|
4503
4521
|
const createContent = useCreateContent();
|
|
4504
4522
|
const deleteContent = useDeleteContent();
|
|
4523
|
+
const getPreviewUrl = (pagePath) => {
|
|
4524
|
+
const previewUrl = buildUrl(pagePath);
|
|
4525
|
+
return `${previewUrl}${previewUrl.includes("?") ? "&" : "?"}_t=${Date.now()}`;
|
|
4526
|
+
};
|
|
4505
4527
|
const currentSite = selectedSite || "default";
|
|
4506
4528
|
const { data, isLoading, error } = useSitePages(currentSite, selectedLocale === "all" ? void 0 : selectedLocale);
|
|
4507
4529
|
const pages = useMemo(() => {
|
|
@@ -4787,16 +4809,33 @@ function PageList({ selectedSite, selectedLocale: initialLocale } = {}) {
|
|
|
4787
4809
|
className: "p-4",
|
|
4788
4810
|
children: /* @__PURE__ */ jsxs("div", {
|
|
4789
4811
|
className: "flex items-center gap-2",
|
|
4790
|
-
children: [/* @__PURE__ */ jsx(FileText, { className: "h-4 w-4 text-grey-04" }), /* @__PURE__ */ jsx("
|
|
4791
|
-
|
|
4812
|
+
children: [/* @__PURE__ */ jsx(FileText, { className: "h-4 w-4 text-grey-04" }), /* @__PURE__ */ jsx("a", {
|
|
4813
|
+
href: buildUrl(page.path),
|
|
4814
|
+
target: "_blank",
|
|
4815
|
+
rel: "noopener noreferrer",
|
|
4816
|
+
className: "font-medium text-azure-04 hover:text-azure-03 hover:underline transition-colors",
|
|
4792
4817
|
"data-testid": `page-title-${page.id}`,
|
|
4818
|
+
onClick: (e) => {
|
|
4819
|
+
e.preventDefault();
|
|
4820
|
+
window.open(getPreviewUrl(page.path), "_blank");
|
|
4821
|
+
},
|
|
4793
4822
|
children: page.title
|
|
4794
4823
|
})]
|
|
4795
4824
|
})
|
|
4796
4825
|
}),
|
|
4797
4826
|
/* @__PURE__ */ jsx("td", {
|
|
4798
|
-
className: "p-4
|
|
4799
|
-
children:
|
|
4827
|
+
className: "p-4",
|
|
4828
|
+
children: /* @__PURE__ */ jsx("a", {
|
|
4829
|
+
href: buildUrl(page.path),
|
|
4830
|
+
target: "_blank",
|
|
4831
|
+
rel: "noopener noreferrer",
|
|
4832
|
+
className: "text-grey-04 hover:text-azure-03 hover:underline transition-colors",
|
|
4833
|
+
onClick: (e) => {
|
|
4834
|
+
e.preventDefault();
|
|
4835
|
+
window.open(getPreviewUrl(page.path), "_blank");
|
|
4836
|
+
},
|
|
4837
|
+
children: page.path
|
|
4838
|
+
})
|
|
4800
4839
|
}),
|
|
4801
4840
|
/* @__PURE__ */ jsx("td", {
|
|
4802
4841
|
className: "p-4",
|