camox 0.9.0 → 0.10.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/core/components/lexical/SidebarLexicalEditor.js +2 -1
- package/dist/core/createApp.d.ts +231 -209
- package/dist/core/createApp.js +17 -17
- package/dist/core/createBlock.d.ts +74 -72
- package/dist/core/createBlock.js +274 -267
- package/dist/core/createLayout.d.ts +100 -80
- package/dist/core/createLayout.js +93 -65
- package/dist/features/preview/CamoxPreview.js +76 -54
- package/dist/features/preview/components/AddBlockSheet.js +12 -12
- package/dist/features/preview/components/AssetFieldEditor.js +1 -1
- package/dist/features/preview/components/AssetLightbox.js +1 -1
- package/dist/features/preview/components/AssetPickerGrid.js +1 -1
- package/dist/features/preview/components/BlockActionsPopover.js +26 -26
- package/dist/features/preview/components/BlockErrorBoundary.js +59 -0
- package/dist/features/preview/components/{CreatePageSheet.js → CreatePageModal.js} +16 -18
- package/dist/features/preview/components/{EditPageSheet.js → EditPageModal.js} +32 -25
- package/dist/features/preview/components/Frame.js +1 -1
- package/dist/features/preview/components/ItemFieldsEditor.js +134 -98
- package/dist/features/preview/components/LinkFieldEditor.js +166 -146
- package/dist/features/preview/components/PageContentSheet.js +42 -37
- package/dist/features/preview/components/PageLocationFieldset.js +28 -26
- package/dist/features/preview/components/PagePicker.js +15 -8
- package/dist/features/preview/components/PageTree.js +337 -351
- package/dist/features/preview/components/PeekedBlock.js +38 -26
- package/dist/features/preview/components/PreviewPanel.js +16 -2
- package/dist/features/preview/components/PreviewSideSheet.js +26 -42
- package/dist/features/preview/components/RepeatableItemsList.js +7 -7
- package/dist/features/preview/previewStore.js +7 -7
- package/dist/features/provider/CamoxProvider.js +41 -9
- package/dist/features/routes/ogRoute.js +2 -2
- package/dist/features/routes/pageRoute.js +1 -1
- package/dist/features/studio/components/EnvironmentMenu.js +2 -2
- package/dist/features/studio/components/UserButton.js +49 -34
- package/dist/features/vite/blockBoilerplate.js +2 -1
- package/dist/features/vite/definitionsSync.js +53 -22
- package/dist/features/vite/routeGeneration.js +1 -0
- package/dist/features/vite/vite.js +51 -7
- package/dist/lib/auth.js +6 -4
- package/dist/lib/use-project-room.js +25 -13
- package/dist/studio-overlays.css +34 -0
- package/dist/studio.css +1 -1
- package/package.json +4 -4
- package/skills/camox-layout/SKILL.md +34 -30
|
@@ -24,7 +24,7 @@ const normalizeLinkValue = (value) => {
|
|
|
24
24
|
return value;
|
|
25
25
|
};
|
|
26
26
|
const LinkFieldEditor = (t0) => {
|
|
27
|
-
const $ = c(
|
|
27
|
+
const $ = c(75);
|
|
28
28
|
const { fieldName, linkValue: rawLinkValue, onSave } = t0;
|
|
29
29
|
let t1;
|
|
30
30
|
if ($[0] !== rawLinkValue) {
|
|
@@ -36,6 +36,8 @@ const LinkFieldEditor = (t0) => {
|
|
|
36
36
|
const timerRef = React.useRef(null);
|
|
37
37
|
const [text, setText] = React.useState(linkValue.text);
|
|
38
38
|
const [href, setHref] = React.useState(linkValue.type === "external" ? linkValue.href : "");
|
|
39
|
+
const [isTextFocused, setIsTextFocused] = React.useState(false);
|
|
40
|
+
const [isHrefFocused, setIsHrefFocused] = React.useState(false);
|
|
39
41
|
const linkValueRef = React.useRef(linkValue);
|
|
40
42
|
const [pagePickerOpen, setPagePickerOpen] = React.useState(false);
|
|
41
43
|
const projectSlug = useProjectSlug();
|
|
@@ -82,51 +84,54 @@ const LinkFieldEditor = (t0) => {
|
|
|
82
84
|
React.useEffect(t6, t7);
|
|
83
85
|
let t8;
|
|
84
86
|
let t9;
|
|
85
|
-
if ($[12] !== linkValue.text) {
|
|
87
|
+
if ($[12] !== isTextFocused || $[13] !== linkValue.text) {
|
|
86
88
|
t8 = () => {
|
|
87
|
-
setText(linkValue.text);
|
|
89
|
+
if (!isTextFocused) setText(linkValue.text);
|
|
88
90
|
};
|
|
89
|
-
t9 = [linkValue.text];
|
|
90
|
-
$[12] =
|
|
91
|
-
$[13] =
|
|
92
|
-
$[14] =
|
|
91
|
+
t9 = [linkValue.text, isTextFocused];
|
|
92
|
+
$[12] = isTextFocused;
|
|
93
|
+
$[13] = linkValue.text;
|
|
94
|
+
$[14] = t8;
|
|
95
|
+
$[15] = t9;
|
|
93
96
|
} else {
|
|
94
|
-
t8 = $[
|
|
95
|
-
t9 = $[
|
|
97
|
+
t8 = $[14];
|
|
98
|
+
t9 = $[15];
|
|
96
99
|
}
|
|
97
100
|
React.useEffect(t8, t9);
|
|
98
101
|
let t10;
|
|
99
|
-
if ($[
|
|
102
|
+
if ($[16] !== isHrefFocused || $[17] !== linkValue.href || $[18] !== linkValue.type) {
|
|
100
103
|
t10 = () => {
|
|
101
|
-
if (linkValue.type === "external") setHref(linkValue.href);
|
|
104
|
+
if (linkValue.type === "external" && !isHrefFocused) setHref(linkValue.href);
|
|
102
105
|
};
|
|
103
|
-
$[
|
|
104
|
-
$[
|
|
105
|
-
$[
|
|
106
|
-
|
|
106
|
+
$[16] = isHrefFocused;
|
|
107
|
+
$[17] = linkValue.href;
|
|
108
|
+
$[18] = linkValue.type;
|
|
109
|
+
$[19] = t10;
|
|
110
|
+
} else t10 = $[19];
|
|
107
111
|
let t11;
|
|
108
|
-
if ($[
|
|
109
|
-
t11 = [linkValue];
|
|
110
|
-
$[
|
|
111
|
-
$[
|
|
112
|
-
|
|
112
|
+
if ($[20] !== isHrefFocused || $[21] !== linkValue) {
|
|
113
|
+
t11 = [linkValue, isHrefFocused];
|
|
114
|
+
$[20] = isHrefFocused;
|
|
115
|
+
$[21] = linkValue;
|
|
116
|
+
$[22] = t11;
|
|
117
|
+
} else t11 = $[22];
|
|
113
118
|
React.useEffect(t10, t11);
|
|
114
119
|
let t12;
|
|
115
120
|
let t13;
|
|
116
|
-
if ($[
|
|
121
|
+
if ($[23] === Symbol.for("react.memo_cache_sentinel")) {
|
|
117
122
|
t12 = () => () => {
|
|
118
123
|
if (timerRef.current) clearTimeout(timerRef.current);
|
|
119
124
|
};
|
|
120
125
|
t13 = [];
|
|
121
|
-
$[
|
|
122
|
-
$[
|
|
126
|
+
$[23] = t12;
|
|
127
|
+
$[24] = t13;
|
|
123
128
|
} else {
|
|
124
|
-
t12 = $[
|
|
125
|
-
t13 = $[
|
|
129
|
+
t12 = $[23];
|
|
130
|
+
t13 = $[24];
|
|
126
131
|
}
|
|
127
132
|
React.useEffect(t12, t13);
|
|
128
133
|
let t14;
|
|
129
|
-
if ($[
|
|
134
|
+
if ($[25] !== fieldName || $[26] !== onSave) {
|
|
130
135
|
t14 = (value) => {
|
|
131
136
|
if (timerRef.current) clearTimeout(timerRef.current);
|
|
132
137
|
timerRef.current = window.setTimeout(() => {
|
|
@@ -136,13 +141,13 @@ const LinkFieldEditor = (t0) => {
|
|
|
136
141
|
});
|
|
137
142
|
}, 500);
|
|
138
143
|
};
|
|
139
|
-
$[
|
|
140
|
-
$[
|
|
141
|
-
$[
|
|
142
|
-
} else t14 = $[
|
|
144
|
+
$[25] = fieldName;
|
|
145
|
+
$[26] = onSave;
|
|
146
|
+
$[27] = t14;
|
|
147
|
+
} else t14 = $[27];
|
|
143
148
|
const handleTextChange = t14;
|
|
144
149
|
let t15;
|
|
145
|
-
if ($[
|
|
150
|
+
if ($[28] !== fieldName || $[29] !== onSave) {
|
|
146
151
|
t15 = (value_0) => {
|
|
147
152
|
if (timerRef.current) clearTimeout(timerRef.current);
|
|
148
153
|
timerRef.current = window.setTimeout(() => {
|
|
@@ -152,13 +157,13 @@ const LinkFieldEditor = (t0) => {
|
|
|
152
157
|
});
|
|
153
158
|
}, 500);
|
|
154
159
|
};
|
|
155
|
-
$[
|
|
156
|
-
$[
|
|
157
|
-
$[
|
|
158
|
-
} else t15 = $[
|
|
160
|
+
$[28] = fieldName;
|
|
161
|
+
$[29] = onSave;
|
|
162
|
+
$[30] = t15;
|
|
163
|
+
} else t15 = $[30];
|
|
159
164
|
const handleHrefChange = t15;
|
|
160
165
|
let t16;
|
|
161
|
-
if ($[
|
|
166
|
+
if ($[31] !== fieldName || $[32] !== onSave) {
|
|
162
167
|
t16 = (mode) => {
|
|
163
168
|
if (mode === "page") onSave(fieldName, {
|
|
164
169
|
type: "page",
|
|
@@ -173,13 +178,13 @@ const LinkFieldEditor = (t0) => {
|
|
|
173
178
|
newTab: linkValueRef.current.newTab
|
|
174
179
|
});
|
|
175
180
|
};
|
|
176
|
-
$[
|
|
177
|
-
$[
|
|
178
|
-
$[
|
|
179
|
-
} else t16 = $[
|
|
181
|
+
$[31] = fieldName;
|
|
182
|
+
$[32] = onSave;
|
|
183
|
+
$[33] = t16;
|
|
184
|
+
} else t16 = $[33];
|
|
180
185
|
const handleModeChange = t16;
|
|
181
186
|
let t17;
|
|
182
|
-
if ($[
|
|
187
|
+
if ($[34] !== fieldName || $[35] !== onSave) {
|
|
183
188
|
t17 = (pageId) => {
|
|
184
189
|
onSave(fieldName, {
|
|
185
190
|
type: "page",
|
|
@@ -189,64 +194,77 @@ const LinkFieldEditor = (t0) => {
|
|
|
189
194
|
});
|
|
190
195
|
setPagePickerOpen(false);
|
|
191
196
|
};
|
|
192
|
-
$[
|
|
193
|
-
$[
|
|
194
|
-
$[
|
|
195
|
-
} else t17 = $[
|
|
197
|
+
$[34] = fieldName;
|
|
198
|
+
$[35] = onSave;
|
|
199
|
+
$[36] = t17;
|
|
200
|
+
} else t17 = $[36];
|
|
196
201
|
const handlePageSelect = t17;
|
|
197
202
|
const t18 = "grid gap-3";
|
|
198
203
|
const t19 = `${fieldName}-text`;
|
|
199
204
|
let t20;
|
|
200
|
-
if ($[
|
|
205
|
+
if ($[37] !== t19) {
|
|
201
206
|
t20 = /* @__PURE__ */ jsx(Label, {
|
|
202
207
|
htmlFor: t19,
|
|
203
208
|
children: "Text"
|
|
204
209
|
});
|
|
205
|
-
$[
|
|
206
|
-
$[
|
|
207
|
-
} else t20 = $[
|
|
210
|
+
$[37] = t19;
|
|
211
|
+
$[38] = t20;
|
|
212
|
+
} else t20 = $[38];
|
|
208
213
|
const t21 = `${fieldName}-text`;
|
|
209
214
|
let t22;
|
|
210
|
-
if ($[
|
|
215
|
+
if ($[39] !== handleTextChange) {
|
|
211
216
|
t22 = (e) => {
|
|
212
217
|
setText(e.target.value);
|
|
213
218
|
handleTextChange(e.target.value);
|
|
214
219
|
};
|
|
215
|
-
$[
|
|
216
|
-
$[
|
|
217
|
-
} else t22 = $[
|
|
220
|
+
$[39] = handleTextChange;
|
|
221
|
+
$[40] = t22;
|
|
222
|
+
} else t22 = $[40];
|
|
218
223
|
let t23;
|
|
219
|
-
|
|
220
|
-
|
|
224
|
+
let t24;
|
|
225
|
+
if ($[41] === Symbol.for("react.memo_cache_sentinel")) {
|
|
226
|
+
t23 = () => setIsTextFocused(true);
|
|
227
|
+
t24 = () => setIsTextFocused(false);
|
|
228
|
+
$[41] = t23;
|
|
229
|
+
$[42] = t24;
|
|
230
|
+
} else {
|
|
231
|
+
t23 = $[41];
|
|
232
|
+
t24 = $[42];
|
|
233
|
+
}
|
|
234
|
+
let t25;
|
|
235
|
+
if ($[43] !== t21 || $[44] !== t22 || $[45] !== text) {
|
|
236
|
+
t25 = /* @__PURE__ */ jsx(Input, {
|
|
221
237
|
id: t21,
|
|
222
238
|
value: text,
|
|
223
239
|
onChange: t22,
|
|
240
|
+
onFocus: t23,
|
|
241
|
+
onBlur: t24,
|
|
224
242
|
autoFocus: true
|
|
225
243
|
});
|
|
226
|
-
$[
|
|
227
|
-
$[
|
|
228
|
-
$[
|
|
229
|
-
$[
|
|
230
|
-
} else
|
|
231
|
-
let
|
|
232
|
-
if ($[
|
|
233
|
-
|
|
244
|
+
$[43] = t21;
|
|
245
|
+
$[44] = t22;
|
|
246
|
+
$[45] = text;
|
|
247
|
+
$[46] = t25;
|
|
248
|
+
} else t25 = $[46];
|
|
249
|
+
let t26;
|
|
250
|
+
if ($[47] !== t20 || $[48] !== t25) {
|
|
251
|
+
t26 = /* @__PURE__ */ jsxs("div", {
|
|
234
252
|
className: "grid gap-1.5",
|
|
235
|
-
children: [t20,
|
|
253
|
+
children: [t20, t25]
|
|
236
254
|
});
|
|
237
|
-
$[
|
|
238
|
-
$[
|
|
239
|
-
$[
|
|
240
|
-
} else
|
|
241
|
-
const
|
|
242
|
-
let
|
|
243
|
-
if ($[
|
|
244
|
-
|
|
245
|
-
$[
|
|
246
|
-
} else
|
|
247
|
-
let
|
|
248
|
-
if ($[
|
|
249
|
-
|
|
255
|
+
$[47] = t20;
|
|
256
|
+
$[48] = t25;
|
|
257
|
+
$[49] = t26;
|
|
258
|
+
} else t26 = $[49];
|
|
259
|
+
const t27 = "grid gap-1.5";
|
|
260
|
+
let t28;
|
|
261
|
+
if ($[50] === Symbol.for("react.memo_cache_sentinel")) {
|
|
262
|
+
t28 = /* @__PURE__ */ jsx(Label, { children: "Destination" });
|
|
263
|
+
$[50] = t28;
|
|
264
|
+
} else t28 = $[50];
|
|
265
|
+
let t29;
|
|
266
|
+
if ($[51] === Symbol.for("react.memo_cache_sentinel")) {
|
|
267
|
+
t29 = /* @__PURE__ */ jsxs(TabsList, {
|
|
250
268
|
className: "w-full",
|
|
251
269
|
children: [/* @__PURE__ */ jsx(TabsTrigger, {
|
|
252
270
|
value: "page",
|
|
@@ -256,20 +274,20 @@ const LinkFieldEditor = (t0) => {
|
|
|
256
274
|
children: "URL"
|
|
257
275
|
})]
|
|
258
276
|
});
|
|
259
|
-
$[
|
|
260
|
-
} else
|
|
261
|
-
let
|
|
262
|
-
if ($[
|
|
263
|
-
|
|
277
|
+
$[51] = t29;
|
|
278
|
+
} else t29 = $[51];
|
|
279
|
+
let t30;
|
|
280
|
+
if ($[52] !== handleModeChange || $[53] !== linkValue.type) {
|
|
281
|
+
t30 = /* @__PURE__ */ jsx(Tabs, {
|
|
264
282
|
value: linkValue.type,
|
|
265
283
|
onValueChange: handleModeChange,
|
|
266
|
-
children:
|
|
284
|
+
children: t29
|
|
267
285
|
});
|
|
268
|
-
$[
|
|
269
|
-
$[
|
|
270
|
-
$[
|
|
271
|
-
} else
|
|
272
|
-
const
|
|
286
|
+
$[52] = handleModeChange;
|
|
287
|
+
$[53] = linkValue.type;
|
|
288
|
+
$[54] = t30;
|
|
289
|
+
} else t30 = $[54];
|
|
290
|
+
const t31 = linkValue.type === "page" ? /* @__PURE__ */ jsxs(Popover, {
|
|
273
291
|
open: pagePickerOpen,
|
|
274
292
|
onOpenChange: setPagePickerOpen,
|
|
275
293
|
children: [/* @__PURE__ */ jsxs(PopoverTrigger, {
|
|
@@ -311,84 +329,86 @@ const LinkFieldEditor = (t0) => {
|
|
|
311
329
|
onChange: (e_0) => {
|
|
312
330
|
setHref(e_0.target.value);
|
|
313
331
|
handleHrefChange(e_0.target.value);
|
|
314
|
-
}
|
|
332
|
+
},
|
|
333
|
+
onFocus: () => setIsHrefFocused(true),
|
|
334
|
+
onBlur: () => setIsHrefFocused(false)
|
|
315
335
|
});
|
|
316
|
-
let
|
|
317
|
-
if ($[
|
|
318
|
-
|
|
319
|
-
className:
|
|
336
|
+
let t32;
|
|
337
|
+
if ($[55] !== t28 || $[56] !== t30 || $[57] !== t31) {
|
|
338
|
+
t32 = /* @__PURE__ */ jsxs("div", {
|
|
339
|
+
className: t27,
|
|
320
340
|
children: [
|
|
321
|
-
t26,
|
|
322
341
|
t28,
|
|
323
|
-
|
|
342
|
+
t30,
|
|
343
|
+
t31
|
|
324
344
|
]
|
|
325
345
|
});
|
|
326
|
-
$[
|
|
327
|
-
$[
|
|
328
|
-
$[
|
|
329
|
-
$[
|
|
330
|
-
} else
|
|
331
|
-
const
|
|
332
|
-
let
|
|
333
|
-
if ($[
|
|
334
|
-
|
|
346
|
+
$[55] = t28;
|
|
347
|
+
$[56] = t30;
|
|
348
|
+
$[57] = t31;
|
|
349
|
+
$[58] = t32;
|
|
350
|
+
} else t32 = $[58];
|
|
351
|
+
const t33 = `${fieldName}-newtab`;
|
|
352
|
+
let t34;
|
|
353
|
+
if ($[59] !== fieldName || $[60] !== onSave) {
|
|
354
|
+
t34 = (checked) => {
|
|
335
355
|
onSave(fieldName, {
|
|
336
356
|
...linkValueRef.current,
|
|
337
357
|
newTab: checked
|
|
338
358
|
});
|
|
339
359
|
};
|
|
340
|
-
$[
|
|
341
|
-
$[
|
|
342
|
-
$[
|
|
343
|
-
} else
|
|
344
|
-
let
|
|
345
|
-
if ($[
|
|
346
|
-
|
|
347
|
-
id:
|
|
360
|
+
$[59] = fieldName;
|
|
361
|
+
$[60] = onSave;
|
|
362
|
+
$[61] = t34;
|
|
363
|
+
} else t34 = $[61];
|
|
364
|
+
let t35;
|
|
365
|
+
if ($[62] !== linkValue.newTab || $[63] !== t33 || $[64] !== t34) {
|
|
366
|
+
t35 = /* @__PURE__ */ jsx(Switch, {
|
|
367
|
+
id: t33,
|
|
348
368
|
checked: linkValue.newTab,
|
|
349
|
-
onCheckedChange:
|
|
369
|
+
onCheckedChange: t34
|
|
350
370
|
});
|
|
351
|
-
$[
|
|
352
|
-
$[
|
|
353
|
-
$[
|
|
354
|
-
$[
|
|
355
|
-
} else
|
|
356
|
-
const
|
|
357
|
-
let
|
|
358
|
-
if ($[
|
|
359
|
-
|
|
360
|
-
htmlFor:
|
|
371
|
+
$[62] = linkValue.newTab;
|
|
372
|
+
$[63] = t33;
|
|
373
|
+
$[64] = t34;
|
|
374
|
+
$[65] = t35;
|
|
375
|
+
} else t35 = $[65];
|
|
376
|
+
const t36 = `${fieldName}-newtab`;
|
|
377
|
+
let t37;
|
|
378
|
+
if ($[66] !== t36) {
|
|
379
|
+
t37 = /* @__PURE__ */ jsx(Label, {
|
|
380
|
+
htmlFor: t36,
|
|
361
381
|
children: "Open in new tab"
|
|
362
382
|
});
|
|
363
|
-
$[
|
|
364
|
-
$[
|
|
365
|
-
} else
|
|
366
|
-
let
|
|
367
|
-
if ($[
|
|
368
|
-
|
|
383
|
+
$[66] = t36;
|
|
384
|
+
$[67] = t37;
|
|
385
|
+
} else t37 = $[67];
|
|
386
|
+
let t38;
|
|
387
|
+
if ($[68] !== t35 || $[69] !== t37) {
|
|
388
|
+
t38 = /* @__PURE__ */ jsxs("div", {
|
|
369
389
|
className: "flex items-center gap-2",
|
|
370
|
-
children: [
|
|
390
|
+
children: [t35, t37]
|
|
371
391
|
});
|
|
372
|
-
$[
|
|
373
|
-
$[
|
|
374
|
-
$[
|
|
375
|
-
} else
|
|
376
|
-
let
|
|
377
|
-
if ($[
|
|
378
|
-
|
|
392
|
+
$[68] = t35;
|
|
393
|
+
$[69] = t37;
|
|
394
|
+
$[70] = t38;
|
|
395
|
+
} else t38 = $[70];
|
|
396
|
+
let t39;
|
|
397
|
+
if ($[71] !== t26 || $[72] !== t32 || $[73] !== t38) {
|
|
398
|
+
t39 = /* @__PURE__ */ jsxs("form", {
|
|
379
399
|
className: t18,
|
|
380
400
|
children: [
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
401
|
+
t26,
|
|
402
|
+
t32,
|
|
403
|
+
t38
|
|
384
404
|
]
|
|
385
405
|
});
|
|
386
|
-
$[
|
|
387
|
-
$[
|
|
388
|
-
$[
|
|
389
|
-
$[
|
|
390
|
-
} else
|
|
391
|
-
return
|
|
406
|
+
$[71] = t26;
|
|
407
|
+
$[72] = t32;
|
|
408
|
+
$[73] = t38;
|
|
409
|
+
$[74] = t39;
|
|
410
|
+
} else t39 = $[74];
|
|
411
|
+
return t39;
|
|
392
412
|
};
|
|
393
413
|
|
|
394
414
|
//#endregion
|
|
@@ -85,10 +85,9 @@ const PageContentSheet = () => {
|
|
|
85
85
|
const currentItemId = selectionItemId(selection);
|
|
86
86
|
const fieldInfo = selectionField(selection);
|
|
87
87
|
const page = usePreviewedPage();
|
|
88
|
-
const numericBlockId = blockId ? Number(blockId) : void 0;
|
|
89
88
|
const { data: blockBundle } = useQuery({
|
|
90
|
-
...blockQueries.get(
|
|
91
|
-
enabled:
|
|
89
|
+
...blockQueries.get(blockId),
|
|
90
|
+
enabled: blockId != null
|
|
92
91
|
});
|
|
93
92
|
const block = blockBundle?.block ?? null;
|
|
94
93
|
const itemsMap = React.useMemo(() => new Map((blockBundle?.repeatableItems ?? []).map((i) => [i.id, i])), [blockBundle?.repeatableItems]);
|
|
@@ -108,18 +107,18 @@ const PageContentSheet = () => {
|
|
|
108
107
|
]);
|
|
109
108
|
const blockDef = block ? camoxApp.getBlockById(block.type) : null;
|
|
110
109
|
const settingsFields = React.useMemo(() => {
|
|
111
|
-
return blockDef ? getSettingsFields(blockDef.settingsSchema) : [];
|
|
110
|
+
return blockDef ? getSettingsFields(blockDef._internal.settingsSchema) : [];
|
|
112
111
|
}, [blockDef]);
|
|
113
112
|
const currentSchema = React.useMemo(() => {
|
|
114
113
|
if (!blockDef) return null;
|
|
115
|
-
if (
|
|
116
|
-
return getSchemaForItem(blockDef.contentSchema,
|
|
114
|
+
if (currentItemId == null) return blockDef._internal.contentSchema;
|
|
115
|
+
return getSchemaForItem(blockDef._internal.contentSchema, currentItemId, itemsMap);
|
|
117
116
|
}, [
|
|
118
117
|
blockDef,
|
|
119
118
|
currentItemId,
|
|
120
119
|
itemsMap
|
|
121
120
|
]);
|
|
122
|
-
const currentItem = currentItemId ? itemsMap.get(
|
|
121
|
+
const currentItem = currentItemId != null ? itemsMap.get(currentItemId) : null;
|
|
123
122
|
const rawCurrentData = currentItem ? currentItem.content : block?.content ?? {};
|
|
124
123
|
const currentData = React.useMemo(() => {
|
|
125
124
|
const resolveFile = (marker) => {
|
|
@@ -180,17 +179,21 @@ const PageContentSheet = () => {
|
|
|
180
179
|
block,
|
|
181
180
|
page?.page.projectId
|
|
182
181
|
]);
|
|
183
|
-
const
|
|
184
|
-
const
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
}, [
|
|
182
|
+
const fieldIdPrefix = React.useId();
|
|
183
|
+
const autoFocusFieldName = React.useMemo(() => {
|
|
184
|
+
if ((selection?.type === "block-field" || selection?.type === "item-field") && (selection.fieldType === "String" || selection.fieldType === "Embed")) return selection.fieldName;
|
|
185
|
+
const properties = currentSchema?.properties;
|
|
186
|
+
if (!properties) return null;
|
|
187
|
+
for (const name of Object.keys(properties)) {
|
|
188
|
+
const ft = properties[name]?.fieldType;
|
|
189
|
+
if (ft === "String" || ft === "Embed") return name;
|
|
190
|
+
}
|
|
191
|
+
return null;
|
|
192
|
+
}, [selection, currentSchema]);
|
|
193
|
+
const getInitialFocus = React.useCallback(() => {
|
|
194
|
+
if (!autoFocusFieldName) return null;
|
|
195
|
+
return document.getElementById(`${fieldIdPrefix}-${autoFocusFieldName}`);
|
|
196
|
+
}, [autoFocusFieldName, fieldIdPrefix]);
|
|
194
197
|
React.useEffect(() => {
|
|
195
198
|
const action = {
|
|
196
199
|
id: "open-content-sheet",
|
|
@@ -223,34 +226,34 @@ const PageContentSheet = () => {
|
|
|
223
226
|
});
|
|
224
227
|
}, [block, updateContent]);
|
|
225
228
|
const handleItemFieldChange = React.useCallback((fieldName_0, value_2) => {
|
|
226
|
-
if (
|
|
229
|
+
if (currentItemId == null) return;
|
|
227
230
|
updateRepeatableContent.mutate({
|
|
228
|
-
id:
|
|
231
|
+
id: currentItemId,
|
|
229
232
|
content: { [fieldName_0]: value_2 }
|
|
230
233
|
});
|
|
231
234
|
}, [currentItemId, updateRepeatableContent]);
|
|
232
|
-
const activeFieldChangeHandler = currentItemId ? handleItemFieldChange : handleBlockFieldChange;
|
|
235
|
+
const activeFieldChangeHandler = currentItemId != null ? handleItemFieldChange : handleBlockFieldChange;
|
|
233
236
|
const handleOpenChange = (open) => {
|
|
234
237
|
if (open) return;
|
|
235
238
|
if (block && autoFocusFieldName) postToIframe({
|
|
236
239
|
type: "CAMOX_FOCUS_FIELD_END",
|
|
237
|
-
fieldId: currentItemId ? `${
|
|
240
|
+
fieldId: currentItemId != null ? `${block.id}__${currentItemId}__${autoFocusFieldName}` : `${block.id}__${autoFocusFieldName}`
|
|
238
241
|
});
|
|
239
|
-
if (block && currentItemId) postToIframe({
|
|
242
|
+
if (block && currentItemId != null) postToIframe({
|
|
240
243
|
type: "CAMOX_HOVER_REPEATER_ITEM_END",
|
|
241
244
|
blockId: String(block.id),
|
|
242
|
-
itemId: currentItemId
|
|
245
|
+
itemId: String(currentItemId)
|
|
243
246
|
});
|
|
244
247
|
previewStore.send({ type: "closeBlockContentSheet" });
|
|
245
248
|
};
|
|
246
|
-
const ancestorChain = React.useMemo(() => currentItemId ? buildAncestorChain(
|
|
249
|
+
const ancestorChain = React.useMemo(() => currentItemId != null ? buildAncestorChain(currentItemId, itemsMap) : [], [currentItemId, itemsMap]);
|
|
247
250
|
if (!block || !blockDef || !currentSchema) return null;
|
|
248
251
|
const fieldHasOwnView = fieldInfo ? fieldTypesDictionary[fieldInfo.fieldType].hasOwnView : false;
|
|
249
252
|
const isAtBlockLevel = ancestorChain.length === 0 && !fieldHasOwnView;
|
|
250
253
|
return /* @__PURE__ */ jsxs(PreviewSideSheet, {
|
|
251
254
|
open: isOpen,
|
|
252
255
|
onOpenChange: handleOpenChange,
|
|
253
|
-
|
|
256
|
+
initialFocus: getInitialFocus,
|
|
254
257
|
className: "flex flex-col gap-0",
|
|
255
258
|
children: [/* @__PURE__ */ jsxs(Sheet.SheetHeader, {
|
|
256
259
|
className: "border-border border-b",
|
|
@@ -263,14 +266,14 @@ const PageContentSheet = () => {
|
|
|
263
266
|
className: "min-w-0",
|
|
264
267
|
children: isAtBlockLevel ? /* @__PURE__ */ jsx(BreadcrumbPage, {
|
|
265
268
|
className: "truncate",
|
|
266
|
-
children: blockDef.title
|
|
269
|
+
children: blockDef._internal.title
|
|
267
270
|
}) : /* @__PURE__ */ jsx(BreadcrumbLink, {
|
|
268
271
|
className: "cursor-pointer",
|
|
269
272
|
onClick: () => previewStore.send({
|
|
270
273
|
type: "setFocusedBlock",
|
|
271
|
-
blockId:
|
|
274
|
+
blockId: block.id
|
|
272
275
|
}),
|
|
273
|
-
children: blockDef.title
|
|
276
|
+
children: blockDef._internal.title
|
|
274
277
|
})
|
|
275
278
|
}),
|
|
276
279
|
ancestorChain.length > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -282,8 +285,8 @@ const PageContentSheet = () => {
|
|
|
282
285
|
children: ancestorChain.slice(0, -1).map((ancestor) => /* @__PURE__ */ jsx(DropdownMenuItem, {
|
|
283
286
|
onClick: () => previewStore.send({
|
|
284
287
|
type: "selectItem",
|
|
285
|
-
blockId:
|
|
286
|
-
itemId:
|
|
288
|
+
blockId: block.id,
|
|
289
|
+
itemId: ancestor.id
|
|
287
290
|
}),
|
|
288
291
|
children: ancestor.summary || formatFieldName(ancestor.fieldName)
|
|
289
292
|
}, ancestor.id))
|
|
@@ -352,14 +355,16 @@ const PageContentSheet = () => {
|
|
|
352
355
|
!isViewingAsset && !isViewingLink && /* @__PURE__ */ jsx(ItemFieldsEditor, {
|
|
353
356
|
schema: currentSchema,
|
|
354
357
|
data: currentData,
|
|
355
|
-
blockId:
|
|
358
|
+
blockId: block.id,
|
|
356
359
|
itemId: currentItemId ?? void 0,
|
|
357
360
|
onFieldChange: activeFieldChangeHandler,
|
|
358
361
|
postToIframe,
|
|
359
362
|
filesMap,
|
|
360
|
-
itemsMap
|
|
361
|
-
|
|
362
|
-
|
|
363
|
+
itemsMap,
|
|
364
|
+
fieldIdPrefix,
|
|
365
|
+
autoFocusFieldName
|
|
366
|
+
}, currentItemId ?? `block-${block.id}`),
|
|
367
|
+
currentItemId == null && !fieldHasOwnView && settingsFields.length > 0 && /* @__PURE__ */ jsxs("div", {
|
|
363
368
|
className: "border-border space-y-4 border-t px-4 py-4",
|
|
364
369
|
children: [/* @__PURE__ */ jsx(Label, {
|
|
365
370
|
className: "text-muted-foreground",
|
|
@@ -368,7 +373,7 @@ const PageContentSheet = () => {
|
|
|
368
373
|
const label = field.label ?? formatFieldName(field.name);
|
|
369
374
|
const settingsValues = block.settings ?? {};
|
|
370
375
|
if (field.fieldType === "Enum") {
|
|
371
|
-
const value_4 = settingsValues[field.name] ?? (blockDef.settingsSchema?.properties?.[field.name])?.default ?? "";
|
|
376
|
+
const value_4 = settingsValues[field.name] ?? (blockDef._internal.settingsSchema?.properties?.[field.name])?.default ?? "";
|
|
372
377
|
return /* @__PURE__ */ jsxs("div", {
|
|
373
378
|
className: "space-y-2",
|
|
374
379
|
children: [/* @__PURE__ */ jsx(Label, {
|
|
@@ -393,7 +398,7 @@ const PageContentSheet = () => {
|
|
|
393
398
|
}, field.name);
|
|
394
399
|
}
|
|
395
400
|
if (field.fieldType === "Boolean") {
|
|
396
|
-
const checked = settingsValues[field.name] ?? (blockDef.settingsSchema?.properties?.[field.name])?.default ?? false;
|
|
401
|
+
const checked = settingsValues[field.name] ?? (blockDef._internal.settingsSchema?.properties?.[field.name])?.default ?? false;
|
|
397
402
|
return /* @__PURE__ */ jsxs("div", {
|
|
398
403
|
className: "flex items-center justify-between",
|
|
399
404
|
children: [/* @__PURE__ */ jsx(Label, {
|