camox 0.3.0 → 0.4.0
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.d.ts.map +1 -1
- package/dist/features/studio/components/ProjectMenu.js +284 -83
- 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/features/vite/definitionsSync.d.ts +7 -12
- package/dist/features/vite/definitionsSync.d.ts.map +1 -1
- package/dist/features/vite/definitionsSync.js +5 -16
- package/dist/features/vite/vite.d.ts +0 -3
- package/dist/features/vite/vite.d.ts.map +1 -1
- package/dist/features/vite/vite.js +1 -2
- 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
|
@@ -6,6 +6,7 @@ import { usePageBlocks } from "../../../lib/normalized-data.js";
|
|
|
6
6
|
import { useCamoxApp } from "../../provider/components/CamoxAppContext.js";
|
|
7
7
|
import { trackClientEvent } from "../../../lib/analytics-client.js";
|
|
8
8
|
import { usePreviewedPage } from "../CamoxPreview.js";
|
|
9
|
+
import { c } from "react/compiler-runtime";
|
|
9
10
|
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
10
11
|
import { useSelector } from "@xstate/store/react";
|
|
11
12
|
import { generateKeyBetween } from "fractional-indexing";
|
|
@@ -18,189 +19,365 @@ import { InfoIcon } from "lucide-react";
|
|
|
18
19
|
import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList } from "@camox/ui/command";
|
|
19
20
|
//#region src/features/preview/components/AddBlockSheet.tsx
|
|
20
21
|
var AddBlockSheet = () => {
|
|
22
|
+
const $ = c(58);
|
|
21
23
|
const [highlightedValue, setHighlightedValue] = React.useState("");
|
|
22
24
|
const queryClient = useQueryClient();
|
|
23
25
|
const { pathname } = useLocation();
|
|
24
|
-
const pagePathname = useSelector(previewStore,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
26
|
+
const pagePathname = useSelector(previewStore, _temp) ?? pathname;
|
|
27
|
+
let t0;
|
|
28
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
29
|
+
t0 = blockMutations.create();
|
|
30
|
+
$[0] = t0;
|
|
31
|
+
} else t0 = $[0];
|
|
32
|
+
let t1;
|
|
33
|
+
if ($[1] !== pagePathname || $[2] !== queryClient) {
|
|
34
|
+
t1 = {
|
|
35
|
+
...t0,
|
|
36
|
+
onMutate: (variables) => {
|
|
37
|
+
const pageQueryKey = queryKeys.pages.getByPath(pagePathname);
|
|
38
|
+
const previousPage = queryClient.getQueryData(pageQueryKey);
|
|
39
|
+
if (!previousPage) return {};
|
|
40
|
+
const blockIds = previousPage.page.blockIds;
|
|
41
|
+
const pageBlocks = blockIds.map((id) => queryClient.getQueryData(queryKeys.blocks.get(id))?.block).filter(_temp2);
|
|
42
|
+
const { afterPosition } = variables;
|
|
43
|
+
let position;
|
|
44
|
+
if (afterPosition == null) {
|
|
45
|
+
const lastBlock = pageBlocks[pageBlocks.length - 1];
|
|
46
|
+
position = generateKeyBetween(lastBlock?.position ?? null, null);
|
|
47
|
+
} else if (afterPosition === "") {
|
|
48
|
+
const firstBlock = pageBlocks[0];
|
|
49
|
+
position = generateKeyBetween(null, firstBlock?.position ?? null);
|
|
50
|
+
} else {
|
|
51
|
+
let afterIndex = -1;
|
|
52
|
+
for (let i = pageBlocks.length - 1; i >= 0; i--) if (String(pageBlocks[i].position) <= afterPosition) {
|
|
53
|
+
afterIndex = i;
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
const nextBlock = afterIndex >= 0 ? pageBlocks[afterIndex + 1] : pageBlocks[0];
|
|
57
|
+
position = generateKeyBetween(afterIndex >= 0 ? pageBlocks[afterIndex].position : null, nextBlock?.position ?? null);
|
|
46
58
|
}
|
|
47
|
-
const
|
|
48
|
-
|
|
59
|
+
const now = Date.now();
|
|
60
|
+
const optimisticId = -now;
|
|
61
|
+
const optimisticBlock = {
|
|
62
|
+
id: optimisticId,
|
|
63
|
+
pageId: variables.pageId,
|
|
64
|
+
layoutId: null,
|
|
65
|
+
type: variables.type,
|
|
66
|
+
content: variables.content,
|
|
67
|
+
settings: variables.settings ?? null,
|
|
68
|
+
placement: null,
|
|
69
|
+
summary: "",
|
|
70
|
+
position,
|
|
71
|
+
createdAt: now,
|
|
72
|
+
updatedAt: now
|
|
73
|
+
};
|
|
74
|
+
queryClient.setQueryData(queryKeys.blocks.get(optimisticId), {
|
|
75
|
+
block: optimisticBlock,
|
|
76
|
+
repeatableItems: [],
|
|
77
|
+
files: []
|
|
78
|
+
});
|
|
79
|
+
const insertIndex = pageBlocks.findIndex((b_0) => b_0.position > position);
|
|
80
|
+
const newBlockIds = [...blockIds];
|
|
81
|
+
if (insertIndex === -1) newBlockIds.push(optimisticId);
|
|
82
|
+
else newBlockIds.splice(insertIndex, 0, optimisticId);
|
|
83
|
+
queryClient.setQueryData(pageQueryKey, {
|
|
84
|
+
...previousPage,
|
|
85
|
+
page: {
|
|
86
|
+
...previousPage.page,
|
|
87
|
+
blockIds: newBlockIds
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
queryClient.cancelQueries({ queryKey: pageQueryKey });
|
|
91
|
+
return {
|
|
92
|
+
previousPage,
|
|
93
|
+
optimisticId
|
|
94
|
+
};
|
|
95
|
+
},
|
|
96
|
+
onError: (_error, _variables, context) => {
|
|
97
|
+
if (context?.previousPage) queryClient.setQueryData(queryKeys.pages.getByPath(pagePathname), context.previousPage);
|
|
98
|
+
if (context?.optimisticId) queryClient.removeQueries({ queryKey: queryKeys.blocks.get(context.optimisticId) });
|
|
99
|
+
},
|
|
100
|
+
onSettled: () => {
|
|
101
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.pages.getByPath(pagePathname) });
|
|
49
102
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
type: variables.type,
|
|
57
|
-
content: variables.content,
|
|
58
|
-
settings: variables.settings ?? null,
|
|
59
|
-
placement: null,
|
|
60
|
-
summary: "",
|
|
61
|
-
position,
|
|
62
|
-
createdAt: now,
|
|
63
|
-
updatedAt: now
|
|
64
|
-
};
|
|
65
|
-
queryClient.setQueryData(queryKeys.blocks.get(optimisticId), {
|
|
66
|
-
block: optimisticBlock,
|
|
67
|
-
repeatableItems: [],
|
|
68
|
-
files: []
|
|
69
|
-
});
|
|
70
|
-
const insertIndex = pageBlocks.findIndex((b) => b.position > position);
|
|
71
|
-
const newBlockIds = [...blockIds];
|
|
72
|
-
if (insertIndex === -1) newBlockIds.push(optimisticId);
|
|
73
|
-
else newBlockIds.splice(insertIndex, 0, optimisticId);
|
|
74
|
-
queryClient.setQueryData(pageQueryKey, {
|
|
75
|
-
...previousPage,
|
|
76
|
-
page: {
|
|
77
|
-
...previousPage.page,
|
|
78
|
-
blockIds: newBlockIds
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
queryClient.cancelQueries({ queryKey: pageQueryKey });
|
|
82
|
-
return {
|
|
83
|
-
previousPage,
|
|
84
|
-
optimisticId
|
|
85
|
-
};
|
|
86
|
-
},
|
|
87
|
-
onError: (_error, _variables, context) => {
|
|
88
|
-
if (context?.previousPage) queryClient.setQueryData(queryKeys.pages.getByPath(pagePathname), context.previousPage);
|
|
89
|
-
if (context?.optimisticId) queryClient.removeQueries({ queryKey: queryKeys.blocks.get(context.optimisticId) });
|
|
90
|
-
},
|
|
91
|
-
onSettled: () => {
|
|
92
|
-
queryClient.invalidateQueries({ queryKey: queryKeys.pages.getByPath(pagePathname) });
|
|
93
|
-
}
|
|
94
|
-
});
|
|
103
|
+
};
|
|
104
|
+
$[1] = pagePathname;
|
|
105
|
+
$[2] = queryClient;
|
|
106
|
+
$[3] = t1;
|
|
107
|
+
} else t1 = $[3];
|
|
108
|
+
const createBlock = useMutation(t1);
|
|
95
109
|
const projectSlug = useProjectSlug();
|
|
96
|
-
|
|
97
|
-
|
|
110
|
+
let t2;
|
|
111
|
+
if ($[4] !== projectSlug) {
|
|
112
|
+
t2 = projectQueries.getBySlug(projectSlug);
|
|
113
|
+
$[4] = projectSlug;
|
|
114
|
+
$[5] = t2;
|
|
115
|
+
} else t2 = $[5];
|
|
116
|
+
const { data: project } = useQuery(t2);
|
|
117
|
+
const availableBlocks = useCamoxApp().getBlocks().filter(_temp3);
|
|
98
118
|
const page = usePreviewedPage();
|
|
99
|
-
const { pageBlocks } = usePageBlocks(page);
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
119
|
+
const { pageBlocks: pageBlocks_0 } = usePageBlocks(page);
|
|
120
|
+
let t3;
|
|
121
|
+
if ($[6] !== project?.id) {
|
|
122
|
+
t3 = blockQueries.getUsageCounts(project?.id ?? 0);
|
|
123
|
+
$[6] = project?.id;
|
|
124
|
+
$[7] = t3;
|
|
125
|
+
} else t3 = $[7];
|
|
126
|
+
const t4 = !!project;
|
|
127
|
+
let t5;
|
|
128
|
+
if ($[8] !== t3 || $[9] !== t4) {
|
|
129
|
+
t5 = {
|
|
130
|
+
...t3,
|
|
131
|
+
enabled: t4
|
|
132
|
+
};
|
|
133
|
+
$[8] = t3;
|
|
134
|
+
$[9] = t4;
|
|
135
|
+
$[10] = t5;
|
|
136
|
+
} else t5 = $[10];
|
|
137
|
+
const { data: t6 } = useQuery(t5);
|
|
138
|
+
let t7;
|
|
139
|
+
if ($[11] !== t6) {
|
|
140
|
+
t7 = t6 === void 0 ? {} : t6;
|
|
141
|
+
$[11] = t6;
|
|
142
|
+
$[12] = t7;
|
|
143
|
+
} else t7 = $[12];
|
|
144
|
+
const totalCounts = t7;
|
|
145
|
+
let t8;
|
|
146
|
+
if ($[13] !== page || $[14] !== pageBlocks_0) {
|
|
147
|
+
bb0: {
|
|
148
|
+
const counts = {};
|
|
149
|
+
if (!page) {
|
|
150
|
+
t8 = counts;
|
|
151
|
+
break bb0;
|
|
152
|
+
}
|
|
153
|
+
for (const block of pageBlocks_0) counts[block.type] = (counts[block.type] ?? 0) + 1;
|
|
154
|
+
t8 = counts;
|
|
155
|
+
}
|
|
156
|
+
$[13] = page;
|
|
157
|
+
$[14] = pageBlocks_0;
|
|
158
|
+
$[15] = t8;
|
|
159
|
+
} else t8 = $[15];
|
|
160
|
+
const pageCounts = t8;
|
|
161
|
+
const isOpen = useSelector(previewStore, _temp4);
|
|
162
|
+
const peekedBlockPosition = useSelector(previewStore, _temp5);
|
|
163
|
+
let t9;
|
|
164
|
+
if ($[16] !== createBlock || $[17] !== page || $[18] !== pageBlocks_0 || $[19] !== peekedBlockPosition) {
|
|
165
|
+
t9 = async (block_0) => {
|
|
166
|
+
if (!page) return;
|
|
167
|
+
const afterPosition_0 = peekedBlockPosition === "" ? "" : peekedBlockPosition ?? pageBlocks_0[pageBlocks_0.length - 1]?.position;
|
|
168
|
+
const bundle = block_0.getInitialBundle();
|
|
169
|
+
const { id: blockId } = await createBlock.mutateAsync({
|
|
170
|
+
pageId: page.page.id,
|
|
171
|
+
type: block_0.id,
|
|
172
|
+
content: bundle.content,
|
|
173
|
+
settings: bundle.settings,
|
|
174
|
+
afterPosition: afterPosition_0,
|
|
175
|
+
repeatableItems: bundle.repeatableItems
|
|
176
|
+
});
|
|
177
|
+
trackClientEvent("block_added", {
|
|
178
|
+
projectId: page.page.projectId,
|
|
179
|
+
blockType: block_0.id
|
|
180
|
+
});
|
|
181
|
+
previewStore.send({
|
|
182
|
+
type: "focusCreatedBlock",
|
|
183
|
+
blockId: String(blockId)
|
|
184
|
+
});
|
|
185
|
+
previewStore.send({ type: "exitPeekedBlock" });
|
|
186
|
+
};
|
|
187
|
+
$[16] = createBlock;
|
|
188
|
+
$[17] = page;
|
|
189
|
+
$[18] = pageBlocks_0;
|
|
190
|
+
$[19] = peekedBlockPosition;
|
|
191
|
+
$[20] = t9;
|
|
192
|
+
} else t9 = $[20];
|
|
193
|
+
const handleAddBlock = t9;
|
|
194
|
+
let t10;
|
|
195
|
+
if ($[21] !== pageBlocks_0 || $[22] !== peekedBlockPosition) {
|
|
196
|
+
t10 = (block_1) => {
|
|
197
|
+
const afterPosition_1 = peekedBlockPosition === "" ? "" : peekedBlockPosition ?? pageBlocks_0[pageBlocks_0.length - 1]?.position;
|
|
198
|
+
previewStore.send({
|
|
199
|
+
type: "setPeekedBlock",
|
|
200
|
+
block: block_1,
|
|
201
|
+
afterPosition: afterPosition_1
|
|
202
|
+
});
|
|
203
|
+
};
|
|
204
|
+
$[21] = pageBlocks_0;
|
|
205
|
+
$[22] = peekedBlockPosition;
|
|
206
|
+
$[23] = t10;
|
|
207
|
+
} else t10 = $[23];
|
|
208
|
+
const handlePreviewBlock = t10;
|
|
142
209
|
const handleValueChange = (value) => {
|
|
143
210
|
setHighlightedValue(value);
|
|
144
|
-
const
|
|
145
|
-
if (
|
|
211
|
+
const block_2 = availableBlocks.find((b_2) => b_2.title === value);
|
|
212
|
+
if (block_2) handlePreviewBlock(block_2);
|
|
146
213
|
else previewStore.send({ type: "clearPeekedBlock" });
|
|
147
214
|
};
|
|
148
|
-
const handleOpenChange =
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
215
|
+
const handleOpenChange = _temp6;
|
|
216
|
+
let t11;
|
|
217
|
+
let t12;
|
|
218
|
+
if ($[24] !== isOpen) {
|
|
219
|
+
t11 = () => {
|
|
220
|
+
if (isOpen) setHighlightedValue("");
|
|
221
|
+
};
|
|
222
|
+
t12 = [isOpen];
|
|
223
|
+
$[24] = isOpen;
|
|
224
|
+
$[25] = t11;
|
|
225
|
+
$[26] = t12;
|
|
226
|
+
} else {
|
|
227
|
+
t11 = $[25];
|
|
228
|
+
t12 = $[26];
|
|
229
|
+
}
|
|
230
|
+
React.useEffect(t11, t12);
|
|
231
|
+
let t13;
|
|
232
|
+
if ($[27] !== pageCounts || $[28] !== totalCounts) {
|
|
233
|
+
t13 = (blockId_0) => {
|
|
234
|
+
const total = totalCounts[blockId_0] ?? 0;
|
|
235
|
+
if (total === 0) return "Never used";
|
|
236
|
+
const page_0 = pageCounts[blockId_0] ?? "none";
|
|
237
|
+
return `${total} use${total > 1 ? "s" : ""} (${page_0} here)`;
|
|
238
|
+
};
|
|
239
|
+
$[27] = pageCounts;
|
|
240
|
+
$[28] = totalCounts;
|
|
241
|
+
$[29] = t13;
|
|
242
|
+
} else t13 = $[29];
|
|
243
|
+
const displayCount = t13;
|
|
244
|
+
const T0 = PreviewSideSheet;
|
|
245
|
+
const t14 = "flex flex-col gap-0";
|
|
246
|
+
let t15;
|
|
247
|
+
if ($[30] === Symbol.for("react.memo_cache_sentinel")) {
|
|
248
|
+
t15 = /* @__PURE__ */ jsxs(Sheet.SheetHeader, {
|
|
165
249
|
className: "border-border border-b",
|
|
166
250
|
children: [/* @__PURE__ */ jsx(Sheet.SheetTitle, { children: "Add new block" }), /* @__PURE__ */ jsx(Sheet.SheetDescription, { children: "Search and select a block to add to the page." })]
|
|
167
|
-
})
|
|
168
|
-
|
|
169
|
-
|
|
251
|
+
});
|
|
252
|
+
$[30] = t15;
|
|
253
|
+
} else t15 = $[30];
|
|
254
|
+
const t16 = "flex-1 overflow-auto p-2";
|
|
255
|
+
const T1 = Command;
|
|
256
|
+
const t17 = "bg-background overflow-visible";
|
|
257
|
+
const t18 = _temp7;
|
|
258
|
+
let t19;
|
|
259
|
+
if ($[31] === Symbol.for("react.memo_cache_sentinel")) {
|
|
260
|
+
t19 = /* @__PURE__ */ jsx(CommandInput, {
|
|
261
|
+
placeholder: "Search blocks...",
|
|
262
|
+
autoFocus: true,
|
|
263
|
+
wrapperClassName: "border border-input rounded-md shadow-xs focus-within:border-ring focus-within:ring-ring/50 focus-within:ring-[3px]"
|
|
264
|
+
});
|
|
265
|
+
$[31] = t19;
|
|
266
|
+
} else t19 = $[31];
|
|
267
|
+
const T2 = CommandList;
|
|
268
|
+
const t20 = "mt-1 max-h-full";
|
|
269
|
+
let t21;
|
|
270
|
+
if ($[32] === Symbol.for("react.memo_cache_sentinel")) {
|
|
271
|
+
t21 = /* @__PURE__ */ jsx(CommandEmpty, { children: "No blocks found." });
|
|
272
|
+
$[32] = t21;
|
|
273
|
+
} else t21 = $[32];
|
|
274
|
+
const T3 = CommandGroup;
|
|
275
|
+
let t22;
|
|
276
|
+
if ($[33] !== totalCounts) {
|
|
277
|
+
t22 = (a, b_3) => (totalCounts[b_3.id] ?? 0) - (totalCounts[a.id] ?? 0);
|
|
278
|
+
$[33] = totalCounts;
|
|
279
|
+
$[34] = t22;
|
|
280
|
+
} else t22 = $[34];
|
|
281
|
+
let t23;
|
|
282
|
+
if ($[35] !== displayCount || $[36] !== handleAddBlock) {
|
|
283
|
+
t23 = (block_3) => /* @__PURE__ */ jsxs(CommandItem, {
|
|
284
|
+
value: block_3.title,
|
|
285
|
+
onSelect: () => {
|
|
286
|
+
handleAddBlock(block_3);
|
|
287
|
+
},
|
|
288
|
+
className: "group flex items-center justify-between gap-2",
|
|
289
|
+
children: [/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("span", { children: block_3.title }), /* @__PURE__ */ jsx("span", {
|
|
290
|
+
className: "text-muted-foreground block",
|
|
291
|
+
children: displayCount(block_3.id)
|
|
292
|
+
})] }), /* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsx(TooltipTrigger, {
|
|
293
|
+
className: "hidden group-focus-within:flex group-hover:flex",
|
|
294
|
+
children: /* @__PURE__ */ jsx(InfoIcon, {})
|
|
295
|
+
}), /* @__PURE__ */ jsx(TooltipContent, {
|
|
296
|
+
className: "max-w-[300px]",
|
|
297
|
+
side: "right",
|
|
298
|
+
children: block_3.description
|
|
299
|
+
})] })]
|
|
300
|
+
}, block_3.id);
|
|
301
|
+
$[35] = displayCount;
|
|
302
|
+
$[36] = handleAddBlock;
|
|
303
|
+
$[37] = t23;
|
|
304
|
+
} else t23 = $[37];
|
|
305
|
+
const t24 = availableBlocks.sort(t22).map(t23);
|
|
306
|
+
let t25;
|
|
307
|
+
if ($[38] !== T3 || $[39] !== t24) {
|
|
308
|
+
t25 = /* @__PURE__ */ jsx(T3, { children: t24 });
|
|
309
|
+
$[38] = T3;
|
|
310
|
+
$[39] = t24;
|
|
311
|
+
$[40] = t25;
|
|
312
|
+
} else t25 = $[40];
|
|
313
|
+
let t26;
|
|
314
|
+
if ($[41] !== T2 || $[42] !== t21 || $[43] !== t25) {
|
|
315
|
+
t26 = /* @__PURE__ */ jsxs(T2, {
|
|
316
|
+
className: t20,
|
|
317
|
+
children: [t21, t25]
|
|
318
|
+
});
|
|
319
|
+
$[41] = T2;
|
|
320
|
+
$[42] = t21;
|
|
321
|
+
$[43] = t25;
|
|
322
|
+
$[44] = t26;
|
|
323
|
+
} else t26 = $[44];
|
|
324
|
+
let t27;
|
|
325
|
+
if ($[45] !== T1 || $[46] !== handleValueChange || $[47] !== highlightedValue || $[48] !== t18 || $[49] !== t19 || $[50] !== t26) {
|
|
326
|
+
t27 = /* @__PURE__ */ jsx("div", {
|
|
327
|
+
className: t16,
|
|
328
|
+
children: /* @__PURE__ */ jsxs(T1, {
|
|
170
329
|
value: highlightedValue,
|
|
171
330
|
onValueChange: handleValueChange,
|
|
172
|
-
className:
|
|
173
|
-
onKeyDown:
|
|
174
|
-
|
|
175
|
-
},
|
|
176
|
-
children: [/* @__PURE__ */ jsx(CommandInput, {
|
|
177
|
-
placeholder: "Search blocks...",
|
|
178
|
-
autoFocus: true,
|
|
179
|
-
wrapperClassName: "border border-input rounded-md shadow-xs focus-within:border-ring focus-within:ring-ring/50 focus-within:ring-[3px]"
|
|
180
|
-
}), /* @__PURE__ */ jsxs(CommandList, {
|
|
181
|
-
className: "mt-1 max-h-full",
|
|
182
|
-
children: [/* @__PURE__ */ jsx(CommandEmpty, { children: "No blocks found." }), /* @__PURE__ */ jsx(CommandGroup, { children: availableBlocks.sort((a, b) => (totalCounts[b.id] ?? 0) - (totalCounts[a.id] ?? 0)).map((block) => /* @__PURE__ */ jsxs(CommandItem, {
|
|
183
|
-
value: block.title,
|
|
184
|
-
onSelect: () => {
|
|
185
|
-
handleAddBlock(block);
|
|
186
|
-
},
|
|
187
|
-
className: "group flex items-center justify-between gap-2",
|
|
188
|
-
children: [/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("span", { children: block.title }), /* @__PURE__ */ jsx("span", {
|
|
189
|
-
className: "text-muted-foreground block",
|
|
190
|
-
children: displayCount(block.id)
|
|
191
|
-
})] }), /* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsx(TooltipTrigger, {
|
|
192
|
-
className: "hidden group-focus-within:flex group-hover:flex",
|
|
193
|
-
children: /* @__PURE__ */ jsx(InfoIcon, {})
|
|
194
|
-
}), /* @__PURE__ */ jsx(TooltipContent, {
|
|
195
|
-
className: "max-w-[300px]",
|
|
196
|
-
side: "right",
|
|
197
|
-
children: block.description
|
|
198
|
-
})] })]
|
|
199
|
-
}, block.id)) })]
|
|
200
|
-
})]
|
|
331
|
+
className: t17,
|
|
332
|
+
onKeyDown: t18,
|
|
333
|
+
children: [t19, t26]
|
|
201
334
|
})
|
|
202
|
-
})
|
|
203
|
-
|
|
335
|
+
});
|
|
336
|
+
$[45] = T1;
|
|
337
|
+
$[46] = handleValueChange;
|
|
338
|
+
$[47] = highlightedValue;
|
|
339
|
+
$[48] = t18;
|
|
340
|
+
$[49] = t19;
|
|
341
|
+
$[50] = t26;
|
|
342
|
+
$[51] = t27;
|
|
343
|
+
} else t27 = $[51];
|
|
344
|
+
let t28;
|
|
345
|
+
if ($[52] !== T0 || $[53] !== handleOpenChange || $[54] !== isOpen || $[55] !== t15 || $[56] !== t27) {
|
|
346
|
+
t28 = /* @__PURE__ */ jsxs(T0, {
|
|
347
|
+
open: isOpen,
|
|
348
|
+
onOpenChange: handleOpenChange,
|
|
349
|
+
className: t14,
|
|
350
|
+
children: [t15, t27]
|
|
351
|
+
});
|
|
352
|
+
$[52] = T0;
|
|
353
|
+
$[53] = handleOpenChange;
|
|
354
|
+
$[54] = isOpen;
|
|
355
|
+
$[55] = t15;
|
|
356
|
+
$[56] = t27;
|
|
357
|
+
$[57] = t28;
|
|
358
|
+
} else t28 = $[57];
|
|
359
|
+
return t28;
|
|
204
360
|
};
|
|
361
|
+
function _temp(state) {
|
|
362
|
+
return state.context.peekedPagePathname;
|
|
363
|
+
}
|
|
364
|
+
function _temp2(b) {
|
|
365
|
+
return b != null;
|
|
366
|
+
}
|
|
367
|
+
function _temp3(b_1) {
|
|
368
|
+
return !b_1.layoutOnly;
|
|
369
|
+
}
|
|
370
|
+
function _temp4(state_0) {
|
|
371
|
+
return state_0.context.isAddBlockSheetOpen;
|
|
372
|
+
}
|
|
373
|
+
function _temp5(state_1) {
|
|
374
|
+
return state_1.context.peekedBlockPosition;
|
|
375
|
+
}
|
|
376
|
+
function _temp6(open) {
|
|
377
|
+
if (!open) previewStore.send({ type: "closeAddBlockSheet" });
|
|
378
|
+
}
|
|
379
|
+
function _temp7(e) {
|
|
380
|
+
if (e.key === "Escape") previewStore.send({ type: "closeAddBlockSheet" });
|
|
381
|
+
}
|
|
205
382
|
//#endregion
|
|
206
383
|
export { AddBlockSheet };
|
|
@@ -1,24 +1,46 @@
|
|
|
1
1
|
import { previewStore } from "../previewStore.js";
|
|
2
2
|
import { PreviewSideSheet, Sheet } from "./PreviewSideSheet.js";
|
|
3
|
+
import { c } from "react/compiler-runtime";
|
|
3
4
|
import { useSelector } from "@xstate/store/react";
|
|
4
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
6
|
//#region src/features/preview/components/AgentChatSheet.tsx
|
|
6
7
|
var AgentChatSheet = () => {
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
const $ = c(4);
|
|
9
|
+
const isOpen = useSelector(previewStore, _temp);
|
|
10
|
+
const handleOpenChange = _temp2;
|
|
11
|
+
let t0;
|
|
12
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
13
|
+
t0 = /* @__PURE__ */ jsxs(Sheet.SheetHeader, { children: [/* @__PURE__ */ jsx(Sheet.SheetTitle, { children: "Agent Chat" }), /* @__PURE__ */ jsx(Sheet.SheetDescription, { children: "Describe the changes you'd like to make to this page." })] });
|
|
14
|
+
$[0] = t0;
|
|
15
|
+
} else t0 = $[0];
|
|
16
|
+
let t1;
|
|
17
|
+
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
|
|
18
|
+
t1 = /* @__PURE__ */ jsx("div", {
|
|
15
19
|
className: "flex flex-1 items-center justify-center p-6",
|
|
16
20
|
children: /* @__PURE__ */ jsx("p", {
|
|
17
21
|
className: "text-muted-foreground text-center text-sm",
|
|
18
22
|
children: "Coming soon"
|
|
19
23
|
})
|
|
20
|
-
})
|
|
21
|
-
|
|
24
|
+
});
|
|
25
|
+
$[1] = t1;
|
|
26
|
+
} else t1 = $[1];
|
|
27
|
+
let t2;
|
|
28
|
+
if ($[2] !== isOpen) {
|
|
29
|
+
t2 = /* @__PURE__ */ jsxs(PreviewSideSheet, {
|
|
30
|
+
open: isOpen,
|
|
31
|
+
onOpenChange: handleOpenChange,
|
|
32
|
+
children: [t0, t1]
|
|
33
|
+
});
|
|
34
|
+
$[2] = isOpen;
|
|
35
|
+
$[3] = t2;
|
|
36
|
+
} else t2 = $[3];
|
|
37
|
+
return t2;
|
|
22
38
|
};
|
|
39
|
+
function _temp(state) {
|
|
40
|
+
return state.context.isAgentChatSheetOpen;
|
|
41
|
+
}
|
|
42
|
+
function _temp2(open) {
|
|
43
|
+
if (!open) previewStore.send({ type: "closeAgentChatSheet" });
|
|
44
|
+
}
|
|
23
45
|
//#endregion
|
|
24
46
|
export { AgentChatSheet };
|