camox 0.3.0 → 0.3.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.
- package/dist/components/AuthGate.js +2 -1
- package/dist/core/components/AddBlockControlBar.js +117 -44
- package/dist/core/components/lexical/InlineContentEditable.js +37 -17
- package/dist/core/components/lexical/InlineLexicalEditor.js +84 -25
- package/dist/core/components/lexical/SelectionBroadcaster.js +84 -47
- package/dist/core/components/lexical/SidebarLexicalEditor.js +54 -19
- package/dist/core/createBlock.js +1172 -414
- package/dist/core/createLayout.js +48 -16
- package/dist/core/hooks/useFieldSelection.js +24 -13
- package/dist/core/hooks/useIsEditable.js +8 -2
- package/dist/core/hooks/useOverlayMessage.js +51 -20
- package/dist/features/content/CamoxContent.js +239 -107
- package/dist/features/content/components/AssetCard.js +78 -16
- package/dist/features/content/components/AssetCardSkeleton.js +11 -4
- package/dist/features/content/components/ContentSidebar.js +15 -8
- package/dist/features/content/components/UploadDropZone.js +77 -34
- package/dist/features/content/components/UploadProgressDrawer.js +201 -58
- package/dist/features/metadata/sitemap.js +15 -0
- package/dist/features/preview/CamoxPreview.js +447 -179
- package/dist/features/preview/components/AddBlockSheet.js +344 -167
- package/dist/features/preview/components/AgentChatSheet.js +32 -10
- package/dist/features/preview/components/AssetFieldEditor.js +185 -50
- package/dist/features/preview/components/AssetLightbox.js +60 -33
- package/dist/features/preview/components/AssetPickerGrid.js +203 -71
- package/dist/features/preview/components/BlockActionsPopover.js +295 -218
- package/dist/features/preview/components/CreatePageSheet.js +3 -3
- package/dist/features/preview/components/DebouncedFieldEditor.js +80 -23
- package/dist/features/preview/components/EditPageSheet.js +241 -86
- package/dist/features/preview/components/ItemFieldsEditor.js +209 -115
- package/dist/features/preview/components/LinkFieldEditor.js +351 -153
- package/dist/features/preview/components/MultipleAssetFieldEditor.js +245 -92
- package/dist/features/preview/components/OverlayTracker.js +58 -23
- package/dist/features/preview/components/Overlays.js +85 -43
- package/dist/features/preview/components/PageContentSheet.js +18 -18
- package/dist/features/preview/components/PageLocationFieldset.js +229 -63
- package/dist/features/preview/components/PagePicker.js +27 -27
- package/dist/features/preview/components/PageTree.js +921 -319
- package/dist/features/preview/components/PeekedBlock.js +173 -63
- package/dist/features/preview/components/PreviewPanel.js +271 -148
- package/dist/features/preview/components/PreviewSideSheet.js +44 -11
- package/dist/features/preview/components/PreviewToolbar.js +262 -59
- package/dist/features/preview/components/RepeatableItemsList.js +187 -78
- package/dist/features/preview/components/ShikiMarkdown.js +46 -20
- package/dist/features/preview/components/TextFormatToolbar.js +81 -23
- package/dist/features/preview/components/UnlinkAssetButton.js +161 -40
- package/dist/features/preview/components/useUpdateBlockPosition.js +64 -47
- package/dist/features/preview/previewStore.d.ts +2 -2
- package/dist/features/provider/CamoxProvider.js +69 -21
- package/dist/features/provider/actionsStore.d.ts +2 -2
- package/dist/features/provider/components/CamoxAppContext.js +15 -5
- package/dist/features/provider/components/CommandPalette.js +199 -92
- package/dist/features/provider/useAdminShortcuts.js +80 -64
- package/dist/features/routes/pageRoute.js +8 -1
- package/dist/features/studio/CamoxStudio.js +45 -9
- package/dist/features/studio/components/EnvironmentMenu.js +47 -12
- package/dist/features/studio/components/Navbar.js +163 -65
- package/dist/features/studio/components/ProjectMenu.js +263 -82
- package/dist/features/studio/components/UserButton.js +21 -6
- package/dist/features/studio/studioStore.d.ts +2 -2
- package/dist/features/studio/useTheme.js +128 -74
- package/dist/hooks/use-file-upload.js +11 -11
- package/dist/hooks/use-marquee-selection.js +121 -74
- package/dist/lib/auth.js +95 -51
- package/dist/lib/normalized-data.js +103 -30
- package/dist/lib/use-project-room.js +55 -22
- package/dist/studio.css +2 -2
- package/package.json +29 -26
- package/dist/lib/auth.d.ts +0 -2130
- package/dist/lib/auth.d.ts.map +0 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { c } from "react/compiler-runtime";
|
|
1
2
|
import * as React from "react";
|
|
2
3
|
import { jsx } from "react/jsx-runtime";
|
|
3
4
|
//#region src/core/createLayout.tsx
|
|
@@ -14,30 +15,61 @@ function createLayout(options) {
|
|
|
14
15
|
const isLastBefore = block === lastBeforeBlock;
|
|
15
16
|
const isFirstAfter = block === firstAfterBlock;
|
|
16
17
|
const SlotComponent = () => {
|
|
18
|
+
const $ = c(2);
|
|
17
19
|
const ctx = React.use(LayoutContext);
|
|
18
20
|
if (!ctx) throw new Error(`Layout slot "${block.id}" must be rendered inside a LayoutContextProvider`);
|
|
19
21
|
const blockData = ctx.layoutBlocks[block.id];
|
|
20
22
|
if (!blockData) return null;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
23
|
+
let t0;
|
|
24
|
+
bb0: {
|
|
25
|
+
if (isLastBefore) {
|
|
26
|
+
t0 = "";
|
|
27
|
+
break bb0;
|
|
28
|
+
}
|
|
29
|
+
if (isFirstAfter) {
|
|
30
|
+
t0 = null;
|
|
31
|
+
break bb0;
|
|
32
|
+
}
|
|
33
|
+
t0 = void 0;
|
|
34
|
+
}
|
|
35
|
+
let t1;
|
|
36
|
+
if ($[0] !== blockData) {
|
|
37
|
+
t1 = /* @__PURE__ */ jsx(block.Component, {
|
|
38
|
+
blockData,
|
|
39
|
+
mode: "layout",
|
|
40
|
+
showAddBlockTop: isFirstAfter || void 0,
|
|
41
|
+
showAddBlockBottom: isLastBefore || void 0,
|
|
42
|
+
addBlockAfterPosition: t0
|
|
43
|
+
});
|
|
44
|
+
$[0] = blockData;
|
|
45
|
+
$[1] = t1;
|
|
46
|
+
} else t1 = $[1];
|
|
47
|
+
return t1;
|
|
31
48
|
};
|
|
32
49
|
SlotComponent.displayName = `LayoutSlot(${toPascalCase(block.id)})`;
|
|
33
50
|
slotComponents[toPascalCase(block.id)] = SlotComponent;
|
|
34
51
|
}
|
|
35
|
-
const Provider = (
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
52
|
+
const Provider = (t0) => {
|
|
53
|
+
const $ = c(5);
|
|
54
|
+
const { layoutBlocks, children } = t0;
|
|
55
|
+
let t1;
|
|
56
|
+
if ($[0] !== layoutBlocks) {
|
|
57
|
+
t1 = { layoutBlocks };
|
|
58
|
+
$[0] = layoutBlocks;
|
|
59
|
+
$[1] = t1;
|
|
60
|
+
} else t1 = $[1];
|
|
61
|
+
const value = t1;
|
|
62
|
+
let t2;
|
|
63
|
+
if ($[2] !== children || $[3] !== value) {
|
|
64
|
+
t2 = /* @__PURE__ */ jsx(LayoutContext.Provider, {
|
|
65
|
+
value,
|
|
66
|
+
children
|
|
67
|
+
});
|
|
68
|
+
$[2] = children;
|
|
69
|
+
$[3] = value;
|
|
70
|
+
$[4] = t2;
|
|
71
|
+
} else t2 = $[4];
|
|
72
|
+
return t2;
|
|
41
73
|
};
|
|
42
74
|
const blockDefinitions = [...options.blocks.before.map((block) => {
|
|
43
75
|
const bundle = block.getInitialBundle();
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { previewStore } from "../../features/preview/previewStore.js";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
2
3
|
import { useSelector } from "@xstate/store/react";
|
|
3
4
|
//#region src/core/hooks/useFieldSelection.ts
|
|
4
5
|
/**
|
|
@@ -7,19 +8,29 @@ import { useSelector } from "@xstate/store/react";
|
|
|
7
8
|
* Matches when the selection points to this exact field (type + name + optional repeater item).
|
|
8
9
|
*/
|
|
9
10
|
function useFieldSelection(blockId, fieldName, fieldType, repeaterItemId) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
11
|
+
const $ = c(5);
|
|
12
|
+
let t0;
|
|
13
|
+
if ($[0] !== blockId || $[1] !== fieldName || $[2] !== fieldType || $[3] !== repeaterItemId) {
|
|
14
|
+
t0 = (state) => {
|
|
15
|
+
const sel = state.context.selection;
|
|
16
|
+
if (!sel || sel.blockId !== blockId) return false;
|
|
17
|
+
if (sel.type === "block-field") {
|
|
18
|
+
if (repeaterItemId) return false;
|
|
19
|
+
return sel.fieldType === fieldType && sel.fieldName === fieldName;
|
|
20
|
+
}
|
|
21
|
+
if (sel.type === "item-field") {
|
|
22
|
+
if (!repeaterItemId) return false;
|
|
23
|
+
return sel.itemId === repeaterItemId && sel.fieldType === fieldType && sel.fieldName === fieldName;
|
|
24
|
+
}
|
|
25
|
+
return false;
|
|
26
|
+
};
|
|
27
|
+
$[0] = blockId;
|
|
28
|
+
$[1] = fieldName;
|
|
29
|
+
$[2] = fieldType;
|
|
30
|
+
$[3] = repeaterItemId;
|
|
31
|
+
$[4] = t0;
|
|
32
|
+
} else t0 = $[4];
|
|
33
|
+
return useSelector(previewStore, t0);
|
|
23
34
|
}
|
|
24
35
|
//#endregion
|
|
25
36
|
export { useFieldSelection };
|
|
@@ -4,9 +4,15 @@ import { useSelector } from "@xstate/store/react";
|
|
|
4
4
|
//#region src/core/hooks/useIsEditable.ts
|
|
5
5
|
function useIsEditable(mode) {
|
|
6
6
|
const isAuthenticated = useIsAuthenticated();
|
|
7
|
-
const isPresentationMode = useSelector(previewStore,
|
|
8
|
-
const isContentLocked = useSelector(previewStore,
|
|
7
|
+
const isPresentationMode = useSelector(previewStore, _temp);
|
|
8
|
+
const isContentLocked = useSelector(previewStore, _temp2);
|
|
9
9
|
return isAuthenticated && (mode === "site" || mode === "layout") && !isPresentationMode && !isContentLocked;
|
|
10
10
|
}
|
|
11
|
+
function _temp2(state_0) {
|
|
12
|
+
return state_0.context.isContentLocked;
|
|
13
|
+
}
|
|
14
|
+
function _temp(state) {
|
|
15
|
+
return state.context.isPresentationMode;
|
|
16
|
+
}
|
|
11
17
|
//#endregion
|
|
12
18
|
export { useIsEditable };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isOverlayMessage } from "../../features/preview/overlayMessages.js";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
2
3
|
import * as React from "react";
|
|
3
4
|
//#region src/core/hooks/useOverlayMessage.ts
|
|
4
5
|
/**
|
|
@@ -9,29 +10,59 @@ import * as React from "react";
|
|
|
9
10
|
* `match` is undefined.
|
|
10
11
|
*/
|
|
11
12
|
function useOverlayMessage(iframeWindow, enabled, startType, endType, match) {
|
|
13
|
+
const $ = c(9);
|
|
12
14
|
const [active, setActive] = React.useState(false);
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
15
|
+
let t0;
|
|
16
|
+
if ($[0] !== match) {
|
|
17
|
+
t0 = JSON.stringify(match);
|
|
18
|
+
$[0] = match;
|
|
19
|
+
$[1] = t0;
|
|
20
|
+
} else t0 = $[1];
|
|
21
|
+
const matchJson = t0;
|
|
22
|
+
let t1;
|
|
23
|
+
let t2;
|
|
24
|
+
if ($[2] !== enabled || $[3] !== endType || $[4] !== iframeWindow || $[5] !== matchJson || $[6] !== startType) {
|
|
25
|
+
t1 = () => {
|
|
26
|
+
if (!enabled || !iframeWindow) return;
|
|
27
|
+
const matchEntries = Object.entries(JSON.parse(matchJson));
|
|
28
|
+
if (matchEntries.some(_temp)) return;
|
|
29
|
+
const handleMessage = (event) => {
|
|
30
|
+
if (!isOverlayMessage(event.data)) return;
|
|
31
|
+
const data = event.data;
|
|
32
|
+
if (data.type !== startType && data.type !== endType) return;
|
|
33
|
+
if (!matchEntries.every((t3) => {
|
|
34
|
+
const [k, v_0] = t3;
|
|
35
|
+
return data[k] === v_0;
|
|
36
|
+
})) return;
|
|
37
|
+
setActive(data.type === startType);
|
|
38
|
+
};
|
|
39
|
+
iframeWindow.addEventListener("message", handleMessage);
|
|
40
|
+
return () => iframeWindow.removeEventListener("message", handleMessage);
|
|
24
41
|
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
42
|
+
t2 = [
|
|
43
|
+
enabled,
|
|
44
|
+
iframeWindow,
|
|
45
|
+
startType,
|
|
46
|
+
endType,
|
|
47
|
+
matchJson
|
|
48
|
+
];
|
|
49
|
+
$[2] = enabled;
|
|
50
|
+
$[3] = endType;
|
|
51
|
+
$[4] = iframeWindow;
|
|
52
|
+
$[5] = matchJson;
|
|
53
|
+
$[6] = startType;
|
|
54
|
+
$[7] = t1;
|
|
55
|
+
$[8] = t2;
|
|
56
|
+
} else {
|
|
57
|
+
t1 = $[7];
|
|
58
|
+
t2 = $[8];
|
|
59
|
+
}
|
|
60
|
+
React.useEffect(t1, t2);
|
|
34
61
|
return active;
|
|
35
62
|
}
|
|
63
|
+
function _temp(t0) {
|
|
64
|
+
const [, v] = t0;
|
|
65
|
+
return v === void 0;
|
|
66
|
+
}
|
|
36
67
|
//#endregion
|
|
37
68
|
export { useOverlayMessage };
|
|
@@ -8,125 +8,257 @@ import { AssetCard } from "./components/AssetCard.js";
|
|
|
8
8
|
import { useMarqueeSelection } from "../../hooks/use-marquee-selection.js";
|
|
9
9
|
import { AssetCardSkeleton } from "./components/AssetCardSkeleton.js";
|
|
10
10
|
import { ContentSidebar } from "./components/ContentSidebar.js";
|
|
11
|
+
import { c } from "react/compiler-runtime";
|
|
11
12
|
import { useMutation, useQuery } from "@tanstack/react-query";
|
|
12
|
-
import {
|
|
13
|
+
import { useRef, useState } from "react";
|
|
13
14
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
14
15
|
import { Button } from "@camox/ui/button";
|
|
15
16
|
import { PanelContent } from "@camox/ui/panel";
|
|
16
17
|
import { FloatingToolbar } from "@camox/ui/floating-toolbar";
|
|
17
18
|
//#region src/features/content/CamoxContent.tsx
|
|
18
19
|
var CamoxContent = () => {
|
|
20
|
+
const $ = c(49);
|
|
19
21
|
const projectSlug = useProjectSlug();
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
let t0;
|
|
23
|
+
if ($[0] !== projectSlug) {
|
|
24
|
+
t0 = projectQueries.getBySlug(projectSlug);
|
|
25
|
+
$[0] = projectSlug;
|
|
26
|
+
$[1] = t0;
|
|
27
|
+
} else t0 = $[1];
|
|
28
|
+
const { data: project } = useQuery(t0);
|
|
29
|
+
let t1;
|
|
30
|
+
if ($[2] !== project?.id) {
|
|
31
|
+
t1 = fileQueries.list(project?.id ?? 0);
|
|
32
|
+
$[2] = project?.id;
|
|
33
|
+
$[3] = t1;
|
|
34
|
+
} else t1 = $[3];
|
|
35
|
+
const t2 = !!project;
|
|
36
|
+
let t3;
|
|
37
|
+
if ($[4] !== t1 || $[5] !== t2) {
|
|
38
|
+
t3 = {
|
|
39
|
+
...t1,
|
|
40
|
+
enabled: t2
|
|
41
|
+
};
|
|
42
|
+
$[4] = t1;
|
|
43
|
+
$[5] = t2;
|
|
44
|
+
$[6] = t3;
|
|
45
|
+
} else t3 = $[6];
|
|
46
|
+
const { data: files } = useQuery(t3);
|
|
47
|
+
let t4;
|
|
48
|
+
if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
|
|
49
|
+
t4 = /* @__PURE__ */ new Set();
|
|
50
|
+
$[7] = t4;
|
|
51
|
+
} else t4 = $[7];
|
|
52
|
+
const [selectedIds, setSelectedIds] = useState(t4);
|
|
26
53
|
const [lightboxFileId, setLightboxFileId] = useState(null);
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
54
|
+
const t5 = project?.id;
|
|
55
|
+
let t6;
|
|
56
|
+
if ($[8] !== t5) {
|
|
57
|
+
t6 = { projectId: t5 };
|
|
58
|
+
$[8] = t5;
|
|
59
|
+
$[9] = t6;
|
|
60
|
+
} else t6 = $[9];
|
|
61
|
+
const { uploads, uploadFiles, clearAll } = useFileUpload(t6);
|
|
62
|
+
let t7;
|
|
63
|
+
if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
|
|
64
|
+
t7 = {
|
|
65
|
+
...fileMutations.deleteMany(),
|
|
66
|
+
onSuccess: () => setSelectedIds(/* @__PURE__ */ new Set())
|
|
67
|
+
};
|
|
68
|
+
$[10] = t7;
|
|
69
|
+
} else t7 = $[10];
|
|
70
|
+
const deleteFiles = useMutation(t7);
|
|
32
71
|
const containerRef = useRef(null);
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
})
|
|
93
|
-
]
|
|
94
|
-
})
|
|
95
|
-
})
|
|
96
|
-
}),
|
|
97
|
-
/* @__PURE__ */ jsx(UploadProgressDrawer, {
|
|
98
|
-
uploads,
|
|
99
|
-
onClose: clearAll
|
|
100
|
-
}),
|
|
101
|
-
selectedIds.size > 0 && /* @__PURE__ */ jsxs(FloatingToolbar, {
|
|
102
|
-
className: "bottom-4 min-w-xs justify-between gap-4",
|
|
103
|
-
children: [/* @__PURE__ */ jsxs("span", {
|
|
104
|
-
className: "text-muted-foreground",
|
|
105
|
-
children: [
|
|
106
|
-
/* @__PURE__ */ jsx("span", {
|
|
107
|
-
className: "font-semibold",
|
|
108
|
-
children: selectedIds.size
|
|
109
|
-
}),
|
|
110
|
-
" asset",
|
|
111
|
-
selectedIds.size > 1 ? "s" : "",
|
|
112
|
-
" selected"
|
|
113
|
-
]
|
|
114
|
-
}), /* @__PURE__ */ jsx(Button, {
|
|
115
|
-
variant: "destructive",
|
|
116
|
-
disabled: deleteFiles.isPending,
|
|
117
|
-
onClick: () => deleteFiles.mutate({ ids: [...selectedIds].map(Number) }),
|
|
118
|
-
children: deleteFiles.isPending ? "Deleting…" : "Delete"
|
|
119
|
-
})]
|
|
120
|
-
}),
|
|
121
|
-
lightboxFileId && /* @__PURE__ */ jsx(AssetLightbox, {
|
|
122
|
-
open: true,
|
|
123
|
-
onOpenChange: (open) => {
|
|
124
|
-
if (!open) setLightboxFileId(null);
|
|
72
|
+
let t8;
|
|
73
|
+
if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
|
|
74
|
+
t8 = (ids) => setSelectedIds(ids);
|
|
75
|
+
$[11] = t8;
|
|
76
|
+
} else t8 = $[11];
|
|
77
|
+
const { selectionRect, didDragRef, handlers } = useMarqueeSelection(containerRef, t8);
|
|
78
|
+
let t9;
|
|
79
|
+
if ($[12] === Symbol.for("react.memo_cache_sentinel")) {
|
|
80
|
+
t9 = /* @__PURE__ */ jsx(ContentSidebar, {});
|
|
81
|
+
$[12] = t9;
|
|
82
|
+
} else t9 = $[12];
|
|
83
|
+
let t10;
|
|
84
|
+
if ($[13] !== didDragRef) {
|
|
85
|
+
t10 = () => {
|
|
86
|
+
if (didDragRef.current) {
|
|
87
|
+
didDragRef.current = false;
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
setSelectedIds(/* @__PURE__ */ new Set());
|
|
91
|
+
};
|
|
92
|
+
$[13] = didDragRef;
|
|
93
|
+
$[14] = t10;
|
|
94
|
+
} else t10 = $[14];
|
|
95
|
+
let t11;
|
|
96
|
+
if ($[15] !== files) {
|
|
97
|
+
t11 = files === void 0 && /* @__PURE__ */ jsx("div", {
|
|
98
|
+
className: "grid grid-cols-[repeat(auto-fill,minmax(220px,1fr))] gap-4",
|
|
99
|
+
children: Array.from({ length: 12 }, _temp)
|
|
100
|
+
});
|
|
101
|
+
$[15] = files;
|
|
102
|
+
$[16] = t11;
|
|
103
|
+
} else t11 = $[16];
|
|
104
|
+
let t12;
|
|
105
|
+
if ($[17] !== files?.length) {
|
|
106
|
+
t12 = files?.length === 0 && /* @__PURE__ */ jsx("div", {
|
|
107
|
+
className: "flex h-full flex-1 items-center justify-center",
|
|
108
|
+
children: /* @__PURE__ */ jsx("p", {
|
|
109
|
+
className: "text-muted-foreground",
|
|
110
|
+
children: "No assets yet"
|
|
111
|
+
})
|
|
112
|
+
});
|
|
113
|
+
$[17] = files?.length;
|
|
114
|
+
$[18] = t12;
|
|
115
|
+
} else t12 = $[18];
|
|
116
|
+
let t13;
|
|
117
|
+
if ($[19] !== files || $[20] !== selectedIds) {
|
|
118
|
+
t13 = files && files.length > 0 && /* @__PURE__ */ jsx("div", {
|
|
119
|
+
className: "grid grid-cols-[repeat(auto-fill,minmax(220px,1fr))] gap-4",
|
|
120
|
+
children: files.map((file) => /* @__PURE__ */ jsx(AssetCard, {
|
|
121
|
+
file,
|
|
122
|
+
selected: selectedIds.has(String(file.id)),
|
|
123
|
+
onSelect: () => {
|
|
124
|
+
setSelectedIds((prev) => {
|
|
125
|
+
const next = new Set(prev);
|
|
126
|
+
if (next.has(String(file.id))) next.delete(String(file.id));
|
|
127
|
+
else next.add(String(file.id));
|
|
128
|
+
return next;
|
|
129
|
+
});
|
|
125
130
|
},
|
|
126
|
-
|
|
131
|
+
onOpen: () => setLightboxFileId(file.id)
|
|
132
|
+
}, file.id))
|
|
133
|
+
});
|
|
134
|
+
$[19] = files;
|
|
135
|
+
$[20] = selectedIds;
|
|
136
|
+
$[21] = t13;
|
|
137
|
+
} else t13 = $[21];
|
|
138
|
+
let t14;
|
|
139
|
+
if ($[22] !== selectionRect) {
|
|
140
|
+
t14 = selectionRect && /* @__PURE__ */ jsx("div", {
|
|
141
|
+
className: "border-primary bg-primary/10 pointer-events-none absolute z-50 border",
|
|
142
|
+
style: {
|
|
143
|
+
left: selectionRect.left,
|
|
144
|
+
top: selectionRect.top,
|
|
145
|
+
width: selectionRect.width,
|
|
146
|
+
height: selectionRect.height
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
$[22] = selectionRect;
|
|
150
|
+
$[23] = t14;
|
|
151
|
+
} else t14 = $[23];
|
|
152
|
+
let t15;
|
|
153
|
+
if ($[24] !== handlers.onPointerDown || $[25] !== handlers.onPointerMove || $[26] !== handlers.onPointerUp || $[27] !== t10 || $[28] !== t11 || $[29] !== t12 || $[30] !== t13 || $[31] !== t14) {
|
|
154
|
+
t15 = /* @__PURE__ */ jsxs(PanelContent, {
|
|
155
|
+
ref: containerRef,
|
|
156
|
+
className: "relative p-4 select-none",
|
|
157
|
+
onClick: t10,
|
|
158
|
+
onPointerDown: handlers.onPointerDown,
|
|
159
|
+
onPointerMove: handlers.onPointerMove,
|
|
160
|
+
onPointerUp: handlers.onPointerUp,
|
|
161
|
+
children: [
|
|
162
|
+
t11,
|
|
163
|
+
t12,
|
|
164
|
+
t13,
|
|
165
|
+
t14
|
|
166
|
+
]
|
|
167
|
+
});
|
|
168
|
+
$[24] = handlers.onPointerDown;
|
|
169
|
+
$[25] = handlers.onPointerMove;
|
|
170
|
+
$[26] = handlers.onPointerUp;
|
|
171
|
+
$[27] = t10;
|
|
172
|
+
$[28] = t11;
|
|
173
|
+
$[29] = t12;
|
|
174
|
+
$[30] = t13;
|
|
175
|
+
$[31] = t14;
|
|
176
|
+
$[32] = t15;
|
|
177
|
+
} else t15 = $[32];
|
|
178
|
+
let t16;
|
|
179
|
+
if ($[33] !== t15 || $[34] !== uploadFiles) {
|
|
180
|
+
t16 = /* @__PURE__ */ jsx("div", {
|
|
181
|
+
className: "flex min-w-0 flex-1 flex-col",
|
|
182
|
+
children: /* @__PURE__ */ jsx(UploadDropZone, {
|
|
183
|
+
onDrop: uploadFiles,
|
|
184
|
+
className: "flex flex-1 flex-col",
|
|
185
|
+
children: t15
|
|
127
186
|
})
|
|
128
|
-
|
|
129
|
-
|
|
187
|
+
});
|
|
188
|
+
$[33] = t15;
|
|
189
|
+
$[34] = uploadFiles;
|
|
190
|
+
$[35] = t16;
|
|
191
|
+
} else t16 = $[35];
|
|
192
|
+
let t17;
|
|
193
|
+
if ($[36] !== clearAll || $[37] !== uploads) {
|
|
194
|
+
t17 = /* @__PURE__ */ jsx(UploadProgressDrawer, {
|
|
195
|
+
uploads,
|
|
196
|
+
onClose: clearAll
|
|
197
|
+
});
|
|
198
|
+
$[36] = clearAll;
|
|
199
|
+
$[37] = uploads;
|
|
200
|
+
$[38] = t17;
|
|
201
|
+
} else t17 = $[38];
|
|
202
|
+
let t18;
|
|
203
|
+
if ($[39] !== deleteFiles || $[40] !== selectedIds) {
|
|
204
|
+
t18 = selectedIds.size > 0 && /* @__PURE__ */ jsxs(FloatingToolbar, {
|
|
205
|
+
className: "bottom-4 min-w-xs justify-between gap-4",
|
|
206
|
+
children: [/* @__PURE__ */ jsxs("span", {
|
|
207
|
+
className: "text-muted-foreground",
|
|
208
|
+
children: [
|
|
209
|
+
/* @__PURE__ */ jsx("span", {
|
|
210
|
+
className: "font-semibold",
|
|
211
|
+
children: selectedIds.size
|
|
212
|
+
}),
|
|
213
|
+
" asset",
|
|
214
|
+
selectedIds.size > 1 ? "s" : "",
|
|
215
|
+
" selected"
|
|
216
|
+
]
|
|
217
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
218
|
+
variant: "destructive",
|
|
219
|
+
disabled: deleteFiles.isPending,
|
|
220
|
+
onClick: () => deleteFiles.mutate({ ids: [...selectedIds].map(Number) }),
|
|
221
|
+
children: deleteFiles.isPending ? "Deleting…" : "Delete"
|
|
222
|
+
})]
|
|
223
|
+
});
|
|
224
|
+
$[39] = deleteFiles;
|
|
225
|
+
$[40] = selectedIds;
|
|
226
|
+
$[41] = t18;
|
|
227
|
+
} else t18 = $[41];
|
|
228
|
+
let t19;
|
|
229
|
+
if ($[42] !== lightboxFileId) {
|
|
230
|
+
t19 = lightboxFileId && /* @__PURE__ */ jsx(AssetLightbox, {
|
|
231
|
+
open: true,
|
|
232
|
+
onOpenChange: (open) => {
|
|
233
|
+
if (!open) setLightboxFileId(null);
|
|
234
|
+
},
|
|
235
|
+
fileId: lightboxFileId
|
|
236
|
+
});
|
|
237
|
+
$[42] = lightboxFileId;
|
|
238
|
+
$[43] = t19;
|
|
239
|
+
} else t19 = $[43];
|
|
240
|
+
let t20;
|
|
241
|
+
if ($[44] !== t16 || $[45] !== t17 || $[46] !== t18 || $[47] !== t19) {
|
|
242
|
+
t20 = /* @__PURE__ */ jsxs("div", {
|
|
243
|
+
className: "flex flex-1 flex-row",
|
|
244
|
+
children: [
|
|
245
|
+
t9,
|
|
246
|
+
t16,
|
|
247
|
+
t17,
|
|
248
|
+
t18,
|
|
249
|
+
t19
|
|
250
|
+
]
|
|
251
|
+
});
|
|
252
|
+
$[44] = t16;
|
|
253
|
+
$[45] = t17;
|
|
254
|
+
$[46] = t18;
|
|
255
|
+
$[47] = t19;
|
|
256
|
+
$[48] = t20;
|
|
257
|
+
} else t20 = $[48];
|
|
258
|
+
return t20;
|
|
130
259
|
};
|
|
260
|
+
function _temp(_, i) {
|
|
261
|
+
return /* @__PURE__ */ jsx(AssetCardSkeleton, {}, i);
|
|
262
|
+
}
|
|
131
263
|
//#endregion
|
|
132
264
|
export { CamoxContent };
|