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.
Files changed (43) hide show
  1. package/dist/core/components/lexical/SidebarLexicalEditor.js +2 -1
  2. package/dist/core/createApp.d.ts +231 -209
  3. package/dist/core/createApp.js +17 -17
  4. package/dist/core/createBlock.d.ts +74 -72
  5. package/dist/core/createBlock.js +274 -267
  6. package/dist/core/createLayout.d.ts +100 -80
  7. package/dist/core/createLayout.js +93 -65
  8. package/dist/features/preview/CamoxPreview.js +76 -54
  9. package/dist/features/preview/components/AddBlockSheet.js +12 -12
  10. package/dist/features/preview/components/AssetFieldEditor.js +1 -1
  11. package/dist/features/preview/components/AssetLightbox.js +1 -1
  12. package/dist/features/preview/components/AssetPickerGrid.js +1 -1
  13. package/dist/features/preview/components/BlockActionsPopover.js +26 -26
  14. package/dist/features/preview/components/BlockErrorBoundary.js +59 -0
  15. package/dist/features/preview/components/{CreatePageSheet.js → CreatePageModal.js} +16 -18
  16. package/dist/features/preview/components/{EditPageSheet.js → EditPageModal.js} +32 -25
  17. package/dist/features/preview/components/Frame.js +1 -1
  18. package/dist/features/preview/components/ItemFieldsEditor.js +134 -98
  19. package/dist/features/preview/components/LinkFieldEditor.js +166 -146
  20. package/dist/features/preview/components/PageContentSheet.js +42 -37
  21. package/dist/features/preview/components/PageLocationFieldset.js +28 -26
  22. package/dist/features/preview/components/PagePicker.js +15 -8
  23. package/dist/features/preview/components/PageTree.js +337 -351
  24. package/dist/features/preview/components/PeekedBlock.js +38 -26
  25. package/dist/features/preview/components/PreviewPanel.js +16 -2
  26. package/dist/features/preview/components/PreviewSideSheet.js +26 -42
  27. package/dist/features/preview/components/RepeatableItemsList.js +7 -7
  28. package/dist/features/preview/previewStore.js +7 -7
  29. package/dist/features/provider/CamoxProvider.js +41 -9
  30. package/dist/features/routes/ogRoute.js +2 -2
  31. package/dist/features/routes/pageRoute.js +1 -1
  32. package/dist/features/studio/components/EnvironmentMenu.js +2 -2
  33. package/dist/features/studio/components/UserButton.js +49 -34
  34. package/dist/features/vite/blockBoilerplate.js +2 -1
  35. package/dist/features/vite/definitionsSync.js +53 -22
  36. package/dist/features/vite/routeGeneration.js +1 -0
  37. package/dist/features/vite/vite.js +51 -7
  38. package/dist/lib/auth.js +6 -4
  39. package/dist/lib/use-project-room.js +25 -13
  40. package/dist/studio-overlays.css +34 -0
  41. package/dist/studio.css +1 -1
  42. package/package.json +4 -4
  43. 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(70);
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] = linkValue.text;
91
- $[13] = t8;
92
- $[14] = t9;
91
+ t9 = [linkValue.text, isTextFocused];
92
+ $[12] = isTextFocused;
93
+ $[13] = linkValue.text;
94
+ $[14] = t8;
95
+ $[15] = t9;
93
96
  } else {
94
- t8 = $[13];
95
- t9 = $[14];
97
+ t8 = $[14];
98
+ t9 = $[15];
96
99
  }
97
100
  React.useEffect(t8, t9);
98
101
  let t10;
99
- if ($[15] !== linkValue.href || $[16] !== linkValue.type) {
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
- $[15] = linkValue.href;
104
- $[16] = linkValue.type;
105
- $[17] = t10;
106
- } else t10 = $[17];
106
+ $[16] = isHrefFocused;
107
+ $[17] = linkValue.href;
108
+ $[18] = linkValue.type;
109
+ $[19] = t10;
110
+ } else t10 = $[19];
107
111
  let t11;
108
- if ($[18] !== linkValue) {
109
- t11 = [linkValue];
110
- $[18] = linkValue;
111
- $[19] = t11;
112
- } else t11 = $[19];
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 ($[20] === Symbol.for("react.memo_cache_sentinel")) {
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
- $[20] = t12;
122
- $[21] = t13;
126
+ $[23] = t12;
127
+ $[24] = t13;
123
128
  } else {
124
- t12 = $[20];
125
- t13 = $[21];
129
+ t12 = $[23];
130
+ t13 = $[24];
126
131
  }
127
132
  React.useEffect(t12, t13);
128
133
  let t14;
129
- if ($[22] !== fieldName || $[23] !== onSave) {
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
- $[22] = fieldName;
140
- $[23] = onSave;
141
- $[24] = t14;
142
- } else t14 = $[24];
144
+ $[25] = fieldName;
145
+ $[26] = onSave;
146
+ $[27] = t14;
147
+ } else t14 = $[27];
143
148
  const handleTextChange = t14;
144
149
  let t15;
145
- if ($[25] !== fieldName || $[26] !== onSave) {
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
- $[25] = fieldName;
156
- $[26] = onSave;
157
- $[27] = t15;
158
- } else t15 = $[27];
160
+ $[28] = fieldName;
161
+ $[29] = onSave;
162
+ $[30] = t15;
163
+ } else t15 = $[30];
159
164
  const handleHrefChange = t15;
160
165
  let t16;
161
- if ($[28] !== fieldName || $[29] !== onSave) {
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
- $[28] = fieldName;
177
- $[29] = onSave;
178
- $[30] = t16;
179
- } else t16 = $[30];
181
+ $[31] = fieldName;
182
+ $[32] = onSave;
183
+ $[33] = t16;
184
+ } else t16 = $[33];
180
185
  const handleModeChange = t16;
181
186
  let t17;
182
- if ($[31] !== fieldName || $[32] !== onSave) {
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
- $[31] = fieldName;
193
- $[32] = onSave;
194
- $[33] = t17;
195
- } else t17 = $[33];
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 ($[34] !== t19) {
205
+ if ($[37] !== t19) {
201
206
  t20 = /* @__PURE__ */ jsx(Label, {
202
207
  htmlFor: t19,
203
208
  children: "Text"
204
209
  });
205
- $[34] = t19;
206
- $[35] = t20;
207
- } else t20 = $[35];
210
+ $[37] = t19;
211
+ $[38] = t20;
212
+ } else t20 = $[38];
208
213
  const t21 = `${fieldName}-text`;
209
214
  let t22;
210
- if ($[36] !== handleTextChange) {
215
+ if ($[39] !== handleTextChange) {
211
216
  t22 = (e) => {
212
217
  setText(e.target.value);
213
218
  handleTextChange(e.target.value);
214
219
  };
215
- $[36] = handleTextChange;
216
- $[37] = t22;
217
- } else t22 = $[37];
220
+ $[39] = handleTextChange;
221
+ $[40] = t22;
222
+ } else t22 = $[40];
218
223
  let t23;
219
- if ($[38] !== t21 || $[39] !== t22 || $[40] !== text) {
220
- t23 = /* @__PURE__ */ jsx(Input, {
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
- $[38] = t21;
227
- $[39] = t22;
228
- $[40] = text;
229
- $[41] = t23;
230
- } else t23 = $[41];
231
- let t24;
232
- if ($[42] !== t20 || $[43] !== t23) {
233
- t24 = /* @__PURE__ */ jsxs("div", {
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, t23]
253
+ children: [t20, t25]
236
254
  });
237
- $[42] = t20;
238
- $[43] = t23;
239
- $[44] = t24;
240
- } else t24 = $[44];
241
- const t25 = "grid gap-1.5";
242
- let t26;
243
- if ($[45] === Symbol.for("react.memo_cache_sentinel")) {
244
- t26 = /* @__PURE__ */ jsx(Label, { children: "Destination" });
245
- $[45] = t26;
246
- } else t26 = $[45];
247
- let t27;
248
- if ($[46] === Symbol.for("react.memo_cache_sentinel")) {
249
- t27 = /* @__PURE__ */ jsxs(TabsList, {
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
- $[46] = t27;
260
- } else t27 = $[46];
261
- let t28;
262
- if ($[47] !== handleModeChange || $[48] !== linkValue.type) {
263
- t28 = /* @__PURE__ */ jsx(Tabs, {
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: t27
284
+ children: t29
267
285
  });
268
- $[47] = handleModeChange;
269
- $[48] = linkValue.type;
270
- $[49] = t28;
271
- } else t28 = $[49];
272
- const t29 = linkValue.type === "page" ? /* @__PURE__ */ jsxs(Popover, {
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 t30;
317
- if ($[50] !== t26 || $[51] !== t28 || $[52] !== t29) {
318
- t30 = /* @__PURE__ */ jsxs("div", {
319
- className: t25,
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
- t29
342
+ t30,
343
+ t31
324
344
  ]
325
345
  });
326
- $[50] = t26;
327
- $[51] = t28;
328
- $[52] = t29;
329
- $[53] = t30;
330
- } else t30 = $[53];
331
- const t31 = `${fieldName}-newtab`;
332
- let t32;
333
- if ($[54] !== fieldName || $[55] !== onSave) {
334
- t32 = (checked) => {
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
- $[54] = fieldName;
341
- $[55] = onSave;
342
- $[56] = t32;
343
- } else t32 = $[56];
344
- let t33;
345
- if ($[57] !== linkValue.newTab || $[58] !== t31 || $[59] !== t32) {
346
- t33 = /* @__PURE__ */ jsx(Switch, {
347
- id: t31,
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: t32
369
+ onCheckedChange: t34
350
370
  });
351
- $[57] = linkValue.newTab;
352
- $[58] = t31;
353
- $[59] = t32;
354
- $[60] = t33;
355
- } else t33 = $[60];
356
- const t34 = `${fieldName}-newtab`;
357
- let t35;
358
- if ($[61] !== t34) {
359
- t35 = /* @__PURE__ */ jsx(Label, {
360
- htmlFor: t34,
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
- $[61] = t34;
364
- $[62] = t35;
365
- } else t35 = $[62];
366
- let t36;
367
- if ($[63] !== t33 || $[64] !== t35) {
368
- t36 = /* @__PURE__ */ jsxs("div", {
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: [t33, t35]
390
+ children: [t35, t37]
371
391
  });
372
- $[63] = t33;
373
- $[64] = t35;
374
- $[65] = t36;
375
- } else t36 = $[65];
376
- let t37;
377
- if ($[66] !== t24 || $[67] !== t30 || $[68] !== t36) {
378
- t37 = /* @__PURE__ */ jsxs("form", {
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
- t24,
382
- t30,
383
- t36
401
+ t26,
402
+ t32,
403
+ t38
384
404
  ]
385
405
  });
386
- $[66] = t24;
387
- $[67] = t30;
388
- $[68] = t36;
389
- $[69] = t37;
390
- } else t37 = $[69];
391
- return t37;
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(numericBlockId),
91
- enabled: numericBlockId != null
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 (!currentItemId) return blockDef.contentSchema;
116
- return getSchemaForItem(blockDef.contentSchema, Number(currentItemId), itemsMap);
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(Number(currentItemId)) : null;
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 autoFocusFieldName = selection?.type === "block-field" && selection.fieldType === "String" ? selection.fieldName : null;
184
- const handleOpenAutoFocus = React.useCallback((e) => {
185
- e.preventDefault();
186
- if (!autoFocusFieldName) return;
187
- setTimeout(() => {
188
- const element = document.getElementById(autoFocusFieldName);
189
- if (!element) return;
190
- element.focus();
191
- element.select();
192
- }, 100);
193
- }, [autoFocusFieldName]);
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 (!currentItemId) return;
229
+ if (currentItemId == null) return;
227
230
  updateRepeatableContent.mutate({
228
- id: Number(currentItemId),
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 ? `${String(block.id)}__${currentItemId}__${autoFocusFieldName}` : `${String(block.id)}__${autoFocusFieldName}`
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(Number(currentItemId), itemsMap) : [], [currentItemId, itemsMap]);
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
- onOpenAutoFocus: handleOpenAutoFocus,
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: String(block.id)
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: String(block.id),
286
- itemId: String(ancestor.id)
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: String(block.id),
358
+ blockId: block.id,
356
359
  itemId: currentItemId ?? void 0,
357
360
  onFieldChange: activeFieldChangeHandler,
358
361
  postToIframe,
359
362
  filesMap,
360
- itemsMap
361
- }),
362
- !currentItemId && !fieldHasOwnView && settingsFields.length > 0 && /* @__PURE__ */ jsxs("div", {
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, {