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
@@ -9,19 +9,19 @@ import { toast } from "@camox/ui/toaster";
9
9
  import { useMutation, useQuery } from "@tanstack/react-query";
10
10
  import { useSelector } from "@xstate/store/react";
11
11
  import { useEffect } from "react";
12
- import * as Sheet from "@camox/ui/sheet";
13
12
  import { jsx, jsxs } from "react/jsx-runtime";
14
13
  import { Button } from "@camox/ui/button";
15
14
  import { useNavigate } from "@tanstack/react-router";
15
+ import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from "@camox/ui/dialog";
16
16
  import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@camox/ui/select";
17
17
  import { Spinner } from "@camox/ui/spinner";
18
18
  import { Textarea } from "@camox/ui/textarea";
19
19
  import { useForm } from "@tanstack/react-form";
20
20
 
21
- //#region src/features/preview/components/CreatePageSheet.tsx
22
- const CreatePageSheet = () => {
21
+ //#region src/features/preview/components/CreatePageModal.tsx
22
+ const CreatePageModal = () => {
23
23
  const projectSlug = useProjectSlug();
24
- const open = useSelector(previewStore, (state) => state.context.isCreatePageSheetOpen);
24
+ const open = useSelector(previewStore, (state) => state.context.isCreatePageModalOpen);
25
25
  const createPage = useMutation(pageMutations.create());
26
26
  const { data: project } = useQuery(projectQueries.getBySlug(projectSlug));
27
27
  const { data: pages } = useQuery({
@@ -66,7 +66,7 @@ const CreatePageSheet = () => {
66
66
  layoutId: values.value.layoutId,
67
67
  hasContentDescription: !!values.value.contentDescription
68
68
  });
69
- previewStore.send({ type: "closeCreatePageSheet" });
69
+ previewStore.send({ type: "closeCreatePageModal" });
70
70
  form.reset();
71
71
  await new Promise((resolve) => setTimeout(resolve, 50));
72
72
  navigate({ to: fullPath });
@@ -79,23 +79,20 @@ const CreatePageSheet = () => {
79
79
  useEffect(() => {
80
80
  if (layouts && layouts.length > 0 && !form.getFieldValue("layoutId")) form.setFieldValue("layoutId", String(layouts[0].id));
81
81
  }, [layouts, form]);
82
- return /* @__PURE__ */ jsx(Sheet.Sheet, {
82
+ return /* @__PURE__ */ jsx(Dialog, {
83
83
  open,
84
84
  onOpenChange: (value) => {
85
- if (!value) previewStore.send({ type: "closeCreatePageSheet" });
85
+ if (!value) previewStore.send({ type: "closeCreatePageModal" });
86
86
  },
87
- children: /* @__PURE__ */ jsxs(Sheet.SheetContent, {
88
- className: "flex max-h-dvh min-w-[500px] flex-col",
89
- children: [/* @__PURE__ */ jsxs(Sheet.SheetHeader, {
90
- className: "border-border border-b",
91
- children: [/* @__PURE__ */ jsx(Sheet.SheetTitle, { children: "Create page" }), /* @__PURE__ */ jsx(Sheet.SheetDescription, { children: "Fill in the details to create a new page. It will be created as a draft." })]
92
- }), /* @__PURE__ */ jsxs("form", {
87
+ children: /* @__PURE__ */ jsxs(DialogContent, {
88
+ className: "flex max-h-[90vh] flex-col sm:max-w-lg",
89
+ children: [/* @__PURE__ */ jsxs(DialogHeader, { children: [/* @__PURE__ */ jsx(DialogTitle, { children: "Create page" }), /* @__PURE__ */ jsx(DialogDescription, { children: "Fill in the details to create a new page. It will be created as a draft." })] }), /* @__PURE__ */ jsxs("form", {
93
90
  onSubmit: (e) => {
94
91
  e.preventDefault();
95
92
  e.stopPropagation();
96
93
  form.handleSubmit();
97
94
  },
98
- className: "space-y-4 overflow-y-auto px-4 py-4",
95
+ className: "-mx-1 space-y-4 overflow-y-auto px-1 py-2",
99
96
  children: [
100
97
  /* @__PURE__ */ jsx(form.Field, {
101
98
  name: "parentPageId",
@@ -106,7 +103,8 @@ const CreatePageSheet = () => {
106
103
  onParentPageIdChange: parentField.handleChange,
107
104
  pathSegment: pathField.state.value,
108
105
  onPathSegmentChange: pathField.handleChange,
109
- pages
106
+ pages,
107
+ autoFocusPathSegment: true
110
108
  })
111
109
  })
112
110
  }),
@@ -125,11 +123,11 @@ const CreatePageSheet = () => {
125
123
  disabled: layouts != null && layouts.length <= 1,
126
124
  items: layouts?.map((t) => ({
127
125
  value: String(t.id),
128
- label: camoxApp.getLayoutById(t.layoutId)?.title ?? t.layoutId
126
+ label: camoxApp.getLayoutById(t.layoutId)?._internal.title ?? t.layoutId
129
127
  })),
130
128
  children: [/* @__PURE__ */ jsx(SelectTrigger, { children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Select a layout" }) }), /* @__PURE__ */ jsx(SelectContent, { children: layouts?.map((t_0) => /* @__PURE__ */ jsx(SelectItem, {
131
129
  value: String(t_0.id),
132
- children: camoxApp.getLayoutById(t_0.layoutId)?.title ?? t_0.layoutId
130
+ children: camoxApp.getLayoutById(t_0.layoutId)?._internal.title ?? t_0.layoutId
133
131
  }, t_0.id)) })]
134
132
  })]
135
133
  })
@@ -172,4 +170,4 @@ const CreatePageSheet = () => {
172
170
  };
173
171
 
174
172
  //#endregion
175
- export { CreatePageSheet };
173
+ export { CreatePageModal };
@@ -13,30 +13,31 @@ import { toast } from "@camox/ui/toaster";
13
13
  import { useMutation, useQuery } from "@tanstack/react-query";
14
14
  import { useSelector } from "@xstate/store/react";
15
15
  import * as React from "react";
16
- import * as Sheet from "@camox/ui/sheet";
17
16
  import { jsx, jsxs } from "react/jsx-runtime";
18
17
  import { Button } from "@camox/ui/button";
19
18
  import { Tooltip, TooltipContent, TooltipTrigger } from "@camox/ui/tooltip";
20
19
  import { useNavigate } from "@tanstack/react-router";
21
20
  import { Globe, Info } from "lucide-react";
21
+ import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from "@camox/ui/dialog";
22
22
  import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@camox/ui/select";
23
23
  import { Spinner } from "@camox/ui/spinner";
24
24
  import { useForm } from "@tanstack/react-form";
25
+ import { Alert, AlertDescription, AlertTitle } from "@camox/ui/alert";
25
26
  import { Switch } from "@camox/ui/switch";
26
27
 
27
- //#region src/features/preview/components/EditPageSheet.tsx
28
- const EditPageSheet = () => {
28
+ //#region src/features/preview/components/EditPageModal.tsx
29
+ const EditPageModal = () => {
29
30
  const $ = c(2);
30
31
  const editingPageId = useSelector(previewStore, _temp);
31
32
  let t0;
32
33
  if ($[0] !== editingPageId) {
33
- t0 = /* @__PURE__ */ jsx(EditPageSheetContent, { pageId: editingPageId });
34
+ t0 = /* @__PURE__ */ jsx(EditPageModalContent, { pageId: editingPageId });
34
35
  $[0] = editingPageId;
35
36
  $[1] = t0;
36
37
  } else t0 = $[1];
37
38
  return t0;
38
39
  };
39
- const EditPageSheetContent = ({ pageId }) => {
40
+ const EditPageModalContent = ({ pageId }) => {
40
41
  const projectSlug = useProjectSlug();
41
42
  const updatePage = useMutation(pageMutations.update());
42
43
  const setLayout = useMutation(pageMutations.setLayout());
@@ -86,7 +87,7 @@ const EditPageSheetContent = ({ pageId }) => {
86
87
  });
87
88
  const displayName = page.metaTitle ?? formatPathSegment(values.value.pathSegment);
88
89
  toast.success(`Updated ${displayName} page`);
89
- previewStore.send({ type: "closeEditPageSheet" });
90
+ previewStore.send({ type: "closeEditPageModal" });
90
91
  form.reset();
91
92
  navigate({ to: fullPath });
92
93
  } catch (error) {
@@ -113,26 +114,26 @@ const EditPageSheetContent = ({ pageId }) => {
113
114
  const isRootPage = page?.fullPath === "/";
114
115
  const pageLayoutRecord = layouts?.find((l) => l.id === page?.layoutId);
115
116
  const layoutDef = pageLayoutRecord ? camoxApp.getLayoutById(pageLayoutRecord.layoutId) : void 0;
116
- const metaTitle = layoutDef && page ? layoutDef.buildMetaTitle({
117
+ const metaTitle = layoutDef && page ? layoutDef._internal.buildMetaTitle({
117
118
  pageMetaTitle: page.metaTitle ?? "",
118
119
  projectName: project?.name ?? "",
119
120
  pageFullPath: page.fullPath
120
121
  }) : page?.metaTitle ?? "";
121
- return /* @__PURE__ */ jsx(Sheet.Sheet, {
122
+ return /* @__PURE__ */ jsx(Dialog, {
122
123
  open: isOpen,
123
124
  onOpenChange: (value) => {
124
- if (!value) previewStore.send({ type: "closeEditPageSheet" });
125
+ if (!value) previewStore.send({ type: "closeEditPageModal" });
125
126
  },
126
- children: /* @__PURE__ */ jsxs(Sheet.SheetContent, {
127
- className: "min-w-[880px] gap-0 overflow-hidden",
128
- children: [/* @__PURE__ */ jsxs(Sheet.SheetHeader, {
129
- className: "border-border border-b",
130
- children: [/* @__PURE__ */ jsx(Sheet.SheetTitle, { children: "Edit page" }), /* @__PURE__ */ jsx(Sheet.SheetDescription, { children: "Update the page details." })]
127
+ children: /* @__PURE__ */ jsxs(DialogContent, {
128
+ className: "flex max-h-[90vh] flex-col gap-0 overflow-hidden p-0 sm:max-w-5xl",
129
+ children: [/* @__PURE__ */ jsxs(DialogHeader, {
130
+ className: "border-border border-b p-4",
131
+ children: [/* @__PURE__ */ jsx(DialogTitle, { children: "Edit page" }), /* @__PURE__ */ jsx(DialogDescription, { children: "Update the page details." })]
131
132
  }), page && /* @__PURE__ */ jsxs("div", {
132
133
  className: "flex-1 overflow-y-auto",
133
134
  children: [
134
135
  /* @__PURE__ */ jsxs("div", {
135
- className: "border-border grid grid-cols-[200px_1fr] gap-x-8 border-b px-4 py-4",
136
+ className: "border-border grid grid-cols-[200px_1fr] gap-x-16 border-b px-4 py-4",
136
137
  children: [/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("p", {
137
138
  className: "text-sm font-medium",
138
139
  children: "Page structure"
@@ -147,9 +148,13 @@ const EditPageSheetContent = ({ pageId }) => {
147
148
  e.stopPropagation();
148
149
  form.handleSubmit();
149
150
  },
150
- className: "space-y-4",
151
+ className: "-mx-1 space-y-4 px-1",
151
152
  children: [
152
- /* @__PURE__ */ jsx(form.Field, {
153
+ isRootPage ? /* @__PURE__ */ jsxs(Alert, { children: [
154
+ /* @__PURE__ */ jsx(Info, { className: "size-4" }),
155
+ /* @__PURE__ */ jsx(AlertTitle, { children: "Homepage" }),
156
+ /* @__PURE__ */ jsx(AlertDescription, { children: "You can't change the path of the home page." })
157
+ ] }) : /* @__PURE__ */ jsx(form.Field, {
153
158
  name: "parentPageId",
154
159
  children: (parentField) => /* @__PURE__ */ jsx(form.Field, {
155
160
  name: "pathSegment",
@@ -158,7 +163,6 @@ const EditPageSheetContent = ({ pageId }) => {
158
163
  onParentPageIdChange: parentField.handleChange,
159
164
  pathSegment: pathField.state.value,
160
165
  onPathSegmentChange: pathField.handleChange,
161
- disabled: isRootPage,
162
166
  pages,
163
167
  excludePageId: page.id
164
168
  })
@@ -173,11 +177,11 @@ const EditPageSheetContent = ({ pageId }) => {
173
177
  onValueChange: (value_0) => field.handleChange(Number(value_0)),
174
178
  items: layouts.map((t) => ({
175
179
  value: String(t.id),
176
- label: camoxApp.getLayoutById(t.layoutId)?.title ?? t.layoutId
180
+ label: camoxApp.getLayoutById(t.layoutId)?._internal.title ?? t.layoutId
177
181
  })),
178
182
  children: [/* @__PURE__ */ jsx(SelectTrigger, { children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Select a layout" }) }), /* @__PURE__ */ jsx(SelectContent, { children: layouts.map((t_0) => /* @__PURE__ */ jsx(SelectItem, {
179
183
  value: String(t_0.id),
180
- children: camoxApp.getLayoutById(t_0.layoutId)?.title ?? t_0.layoutId
184
+ children: camoxApp.getLayoutById(t_0.layoutId)?._internal.title ?? t_0.layoutId
181
185
  }, t_0.id)) })]
182
186
  })]
183
187
  })
@@ -202,7 +206,7 @@ const EditPageSheetContent = ({ pageId }) => {
202
206
  })]
203
207
  }),
204
208
  /* @__PURE__ */ jsxs("div", {
205
- className: "grid grid-cols-[200px_1fr] gap-x-8 px-4 py-4",
209
+ className: "grid grid-cols-[200px_1fr] gap-x-16 px-4 py-4",
206
210
  children: [/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("p", {
207
211
  className: "text-sm font-medium",
208
212
  children: "SEO data"
@@ -263,7 +267,7 @@ const EditPageSheetContent = ({ pageId }) => {
263
267
  })]
264
268
  }),
265
269
  /* @__PURE__ */ jsxs("div", {
266
- className: "border-border grid grid-cols-[200px_1fr] gap-x-8 border-t px-4 py-4",
270
+ className: "border-border grid grid-cols-[200px_1fr] gap-x-16 border-t px-4 py-4",
267
271
  children: [/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("p", {
268
272
  className: "text-sm font-medium",
269
273
  children: "Markdown content"
@@ -298,7 +302,10 @@ const SearchEnginePreview = (t0) => {
298
302
  if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
299
303
  t2 = /* @__PURE__ */ jsxs("div", {
300
304
  className: "flex items-center gap-1.5",
301
- children: [t1, /* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsx(TooltipTrigger, { render: /* @__PURE__ */ jsx(Info, { className: "text-muted-foreground size-3.5" }) }), /* @__PURE__ */ jsx(TooltipContent, { children: "Titles are cropped after 60 characters and descriptions after 155, like Google typically does." })] })]
305
+ children: [t1, /* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsx(TooltipTrigger, {
306
+ delay: 50,
307
+ render: /* @__PURE__ */ jsx(Info, { className: "text-muted-foreground size-3.5" })
308
+ }), /* @__PURE__ */ jsx(TooltipContent, { children: "Titles are cropped after 60 characters and descriptions after 155, like Google typically does." })] })]
302
309
  });
303
310
  $[1] = t2;
304
311
  } else t2 = $[1];
@@ -462,7 +469,7 @@ const SocialPreviewSection = (t0) => {
462
469
  t11 = /* @__PURE__ */ jsxs("div", {
463
470
  className: "space-y-2 pt-2",
464
471
  children: [t2, /* @__PURE__ */ jsxs("div", {
465
- className: "border-border overflow-hidden rounded-lg border",
472
+ className: "border-border max-w-xl overflow-hidden rounded-lg border",
466
473
  children: [t3, t10]
467
474
  })]
468
475
  });
@@ -521,4 +528,4 @@ function _temp(state) {
521
528
  }
522
529
 
523
530
  //#endregion
524
- export { EditPageSheet };
531
+ export { EditPageModal };
@@ -67,7 +67,7 @@ const Frame = (t0) => {
67
67
  if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
68
68
  t4 = () => {
69
69
  const checkForOpenPopup = () => {
70
- setHasOpenPopup(document.body.querySelector(":scope > [data-open]") !== null);
70
+ setHasOpenPopup(document.body.querySelector("[data-base-ui-portal] [data-open]") !== null);
71
71
  };
72
72
  checkForOpenPopup();
73
73
  const observer = new MutationObserver(checkForOpenPopup);
@@ -30,8 +30,8 @@ const getSchemaFieldsInOrder = (schema) => {
30
30
  });
31
31
  };
32
32
  const ItemFieldsEditor = (t0) => {
33
- const $ = c(38);
34
- const { schema, data, blockId, itemId, onFieldChange, postToIframe, filesMap, itemsMap } = t0;
33
+ const $ = c(46);
34
+ const { schema, data, blockId, itemId, onFieldChange, postToIframe, filesMap, itemsMap, fieldIdPrefix, autoFocusFieldName } = t0;
35
35
  let t1;
36
36
  if ($[0] !== schema) {
37
37
  t1 = getSchemaFieldsInOrder(schema);
@@ -44,7 +44,7 @@ const ItemFieldsEditor = (t0) => {
44
44
  let t2;
45
45
  if ($[2] !== blockId || $[3] !== itemId) {
46
46
  t2 = (fieldName) => {
47
- if (itemId) return `${blockId}__${itemId}__${fieldName}`;
47
+ if (itemId != null) return `${blockId}__${itemId}__${fieldName}`;
48
48
  return `${blockId}__${fieldName}`;
49
49
  };
50
50
  $[2] = blockId;
@@ -53,96 +53,130 @@ const ItemFieldsEditor = (t0) => {
53
53
  } else t2 = $[4];
54
54
  const getFieldId = t2;
55
55
  let t3;
56
- if ($[5] !== fields) {
57
- t3 = fields.filter(_temp).map(_temp2);
58
- $[5] = fields;
56
+ if ($[5] !== fieldIdPrefix) {
57
+ t3 = (fieldName_0) => `${fieldIdPrefix}-${fieldName_0}`;
58
+ $[5] = fieldIdPrefix;
59
59
  $[6] = t3;
60
60
  } else t3 = $[6];
61
- const scalarFields = t3;
62
- let values;
63
- if ($[7] !== data || $[8] !== scalarFields) {
64
- values = {};
65
- for (const fieldName_0 of scalarFields) values[fieldName_0] = data[fieldName_0] ?? "";
66
- $[7] = data;
67
- $[8] = scalarFields;
68
- $[9] = values;
69
- } else values = $[9];
70
- const defaultValues = values;
61
+ const getFieldElementId = t3;
71
62
  let t4;
72
- if ($[10] !== defaultValues) {
73
- t4 = { defaultValues };
74
- $[10] = defaultValues;
75
- $[11] = t4;
76
- } else t4 = $[11];
77
- const form = useForm(t4);
63
+ if ($[7] !== autoFocusFieldName || $[8] !== fieldIdPrefix) {
64
+ t4 = {
65
+ fieldName: autoFocusFieldName,
66
+ prefix: fieldIdPrefix
67
+ };
68
+ $[7] = autoFocusFieldName;
69
+ $[8] = fieldIdPrefix;
70
+ $[9] = t4;
71
+ } else t4 = $[9];
72
+ const initialAutoFocusRef = React.useRef(t4);
78
73
  let t5;
79
74
  let t6;
80
- if ($[12] !== defaultValues || $[13] !== form) {
75
+ if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
81
76
  t5 = () => {
82
- form.update({ defaultValues });
77
+ const { fieldName: fieldName_1, prefix } = initialAutoFocusRef.current;
78
+ if (!fieldName_1) return;
79
+ document.getElementById(`${prefix}-${fieldName_1}`)?.focus();
83
80
  };
84
- t6 = [defaultValues, form];
85
- $[12] = defaultValues;
86
- $[13] = form;
87
- $[14] = t5;
88
- $[15] = t6;
81
+ t6 = [];
82
+ $[10] = t5;
83
+ $[11] = t6;
89
84
  } else {
90
- t5 = $[14];
91
- t6 = $[15];
85
+ t5 = $[10];
86
+ t6 = $[11];
92
87
  }
93
- React.useEffect(t5, t6);
88
+ React.useLayoutEffect(t5, t6);
94
89
  let t7;
90
+ if ($[12] !== fields) {
91
+ t7 = fields.filter(_temp).map(_temp2);
92
+ $[12] = fields;
93
+ $[13] = t7;
94
+ } else t7 = $[13];
95
+ const scalarFields = t7;
96
+ let values;
97
+ if ($[14] !== data || $[15] !== scalarFields) {
98
+ values = {};
99
+ for (const fieldName_2 of scalarFields) values[fieldName_2] = data[fieldName_2] ?? "";
100
+ $[14] = data;
101
+ $[15] = scalarFields;
102
+ $[16] = values;
103
+ } else values = $[16];
104
+ const defaultValues = values;
95
105
  let t8;
96
- if ($[16] !== postToIframe) {
97
- t7 = () => () => {
106
+ if ($[17] !== defaultValues) {
107
+ t8 = { defaultValues };
108
+ $[17] = defaultValues;
109
+ $[18] = t8;
110
+ } else t8 = $[18];
111
+ const form = useForm(t8);
112
+ let t10;
113
+ let t9;
114
+ if ($[19] !== defaultValues || $[20] !== form) {
115
+ t9 = () => {
116
+ form.update({ defaultValues });
117
+ };
118
+ t10 = [defaultValues, form];
119
+ $[19] = defaultValues;
120
+ $[20] = form;
121
+ $[21] = t10;
122
+ $[22] = t9;
123
+ } else {
124
+ t10 = $[21];
125
+ t9 = $[22];
126
+ }
127
+ React.useEffect(t9, t10);
128
+ let t11;
129
+ let t12;
130
+ if ($[23] !== postToIframe) {
131
+ t11 = () => () => {
98
132
  if (timerRef.current) clearTimeout(timerRef.current);
99
133
  if (focusedFieldIdRef.current) postToIframe({
100
134
  type: "CAMOX_FOCUS_FIELD_END",
101
135
  fieldId: focusedFieldIdRef.current
102
136
  });
103
137
  };
104
- t8 = [postToIframe];
105
- $[16] = postToIframe;
106
- $[17] = t7;
107
- $[18] = t8;
138
+ t12 = [postToIframe];
139
+ $[23] = postToIframe;
140
+ $[24] = t11;
141
+ $[25] = t12;
108
142
  } else {
109
- t7 = $[17];
110
- t8 = $[18];
143
+ t11 = $[24];
144
+ t12 = $[25];
111
145
  }
112
- React.useEffect(t7, t8);
113
- let t10;
114
- let t9;
115
- if ($[19] !== blockId || $[20] !== data || $[21] !== fields || $[22] !== filesMap || $[23] !== form || $[24] !== getFieldId || $[25] !== itemId || $[26] !== itemsMap || $[27] !== onFieldChange || $[28] !== postToIframe || $[29] !== schema) {
116
- const handleScalarChange = (fieldName_1, value, fieldApi) => {
146
+ React.useEffect(t11, t12);
147
+ let t13;
148
+ let t14;
149
+ if ($[26] !== blockId || $[27] !== data || $[28] !== fields || $[29] !== filesMap || $[30] !== form || $[31] !== getFieldElementId || $[32] !== getFieldId || $[33] !== itemId || $[34] !== itemsMap || $[35] !== onFieldChange || $[36] !== postToIframe || $[37] !== schema) {
150
+ const handleScalarChange = (fieldName_3, value, fieldApi) => {
117
151
  fieldApi.handleChange(value);
118
152
  if (timerRef.current) clearTimeout(timerRef.current);
119
153
  timerRef.current = window.setTimeout(() => {
120
- onFieldChange(fieldName_1, value);
154
+ onFieldChange(fieldName_3, value);
121
155
  }, 500);
122
156
  };
123
- const handleFieldFocus = (fieldName_2, fieldType) => {
124
- const fieldId = getFieldId(fieldName_2);
157
+ const handleFieldFocus = (fieldName_4, fieldType) => {
158
+ const fieldId = getFieldId(fieldName_4);
125
159
  focusedFieldIdRef.current = fieldId;
126
160
  postToIframe({
127
161
  type: "CAMOX_FOCUS_FIELD",
128
162
  fieldId
129
163
  });
130
- if (itemId) previewStore.send({
164
+ if (itemId != null) previewStore.send({
131
165
  type: "selectItemField",
132
166
  blockId,
133
167
  itemId,
134
- fieldName: fieldName_2,
168
+ fieldName: fieldName_4,
135
169
  fieldType
136
170
  });
137
171
  else previewStore.send({
138
172
  type: "selectBlockField",
139
173
  blockId,
140
- fieldName: fieldName_2,
174
+ fieldName: fieldName_4,
141
175
  fieldType
142
176
  });
143
177
  };
144
- const handleFieldBlur = (fieldName_3) => {
145
- const fieldId_0 = getFieldId(fieldName_3);
178
+ const handleFieldBlur = (fieldName_5) => {
179
+ const fieldId_0 = getFieldId(fieldName_5);
146
180
  focusedFieldIdRef.current = null;
147
181
  postToIframe({
148
182
  type: "CAMOX_FOCUS_FIELD_END",
@@ -152,30 +186,30 @@ const ItemFieldsEditor = (t0) => {
152
186
  if (!focusedFieldIdRef.current) previewStore.send({ type: "selectParent" });
153
187
  });
154
188
  };
155
- let t11;
156
- if ($[32] !== blockId || $[33] !== itemId) {
157
- t11 = (fieldName_4, fieldType_0) => {
158
- if (itemId) previewStore.send({
189
+ let t15;
190
+ if ($[40] !== blockId || $[41] !== itemId) {
191
+ t15 = (fieldName_6, fieldType_0) => {
192
+ if (itemId != null) previewStore.send({
159
193
  type: "selectItemField",
160
194
  blockId,
161
195
  itemId,
162
- fieldName: fieldName_4,
196
+ fieldName: fieldName_6,
163
197
  fieldType: fieldType_0
164
198
  });
165
199
  else previewStore.send({
166
200
  type: "selectBlockField",
167
201
  blockId,
168
- fieldName: fieldName_4,
202
+ fieldName: fieldName_6,
169
203
  fieldType: fieldType_0
170
204
  });
171
205
  };
172
- $[32] = blockId;
173
- $[33] = itemId;
174
- $[34] = t11;
175
- } else t11 = $[34];
176
- const drillIntoField = t11;
177
- t9 = "space-y-4 px-4 py-4";
178
- t10 = fields.map((field) => {
206
+ $[40] = blockId;
207
+ $[41] = itemId;
208
+ $[42] = t15;
209
+ } else t15 = $[42];
210
+ const drillIntoField = t15;
211
+ t13 = "space-y-4 px-4 py-4";
212
+ t14 = fields.map((field) => {
179
213
  const label = field.label ?? formatFieldName(field.name);
180
214
  const fieldId_1 = getFieldId(field.name);
181
215
  if (field.fieldType === "String") return /* @__PURE__ */ jsx(form.Field, {
@@ -191,9 +225,10 @@ const ItemFieldsEditor = (t0) => {
191
225
  fieldId: fieldId_1
192
226
  }),
193
227
  children: [/* @__PURE__ */ jsx(Label, {
194
- htmlFor: field.name,
228
+ htmlFor: getFieldElementId(field.name),
195
229
  children: label
196
230
  }), /* @__PURE__ */ jsx(SidebarLexicalEditor, {
231
+ id: getFieldElementId(field.name),
197
232
  value: fieldApi_0.state.value,
198
233
  onChange: (value_0) => handleScalarChange(field.name, value_0, fieldApi_0),
199
234
  onFocus: () => handleFieldFocus(field.name, field.fieldType),
@@ -214,10 +249,10 @@ const ItemFieldsEditor = (t0) => {
214
249
  fieldId: fieldId_1
215
250
  }),
216
251
  children: [/* @__PURE__ */ jsx(Label, {
217
- htmlFor: field.name,
252
+ htmlFor: getFieldElementId(field.name),
218
253
  children: label
219
254
  }), /* @__PURE__ */ jsx(Input, {
220
- id: field.name,
255
+ id: getFieldElementId(field.name),
221
256
  type: "url",
222
257
  value: fieldApi_1.state.value,
223
258
  onChange: (e) => handleScalarChange(field.name, e.target.value, fieldApi_1),
@@ -260,12 +295,12 @@ const ItemFieldsEditor = (t0) => {
260
295
  className: "space-y-2",
261
296
  onMouseEnter: () => postToIframe({
262
297
  type: "CAMOX_HOVER_REPEATER",
263
- blockId,
298
+ blockId: String(blockId),
264
299
  fieldName: field.name
265
300
  }),
266
301
  onMouseLeave: () => postToIframe({
267
302
  type: "CAMOX_HOVER_REPEATER_END",
268
- blockId,
303
+ blockId: String(blockId),
269
304
  fieldName: field.name
270
305
  }),
271
306
  children: [/* @__PURE__ */ jsx(Label, { children: label }), /* @__PURE__ */ jsxs("button", {
@@ -289,12 +324,12 @@ const ItemFieldsEditor = (t0) => {
289
324
  className: "space-y-2",
290
325
  onMouseEnter: () => postToIframe({
291
326
  type: "CAMOX_HOVER_REPEATER",
292
- blockId,
327
+ blockId: String(blockId),
293
328
  fieldName: field.name
294
329
  }),
295
330
  onMouseLeave: () => postToIframe({
296
331
  type: "CAMOX_HOVER_REPEATER_END",
297
- blockId,
332
+ blockId: String(blockId),
298
333
  fieldName: field.name
299
334
  }),
300
335
  children: [/* @__PURE__ */ jsx(Label, { children: label }), /* @__PURE__ */ jsxs("button", {
@@ -376,34 +411,35 @@ const ItemFieldsEditor = (t0) => {
376
411
  }
377
412
  return null;
378
413
  });
379
- $[19] = blockId;
380
- $[20] = data;
381
- $[21] = fields;
382
- $[22] = filesMap;
383
- $[23] = form;
384
- $[24] = getFieldId;
385
- $[25] = itemId;
386
- $[26] = itemsMap;
387
- $[27] = onFieldChange;
388
- $[28] = postToIframe;
389
- $[29] = schema;
390
- $[30] = t10;
391
- $[31] = t9;
414
+ $[26] = blockId;
415
+ $[27] = data;
416
+ $[28] = fields;
417
+ $[29] = filesMap;
418
+ $[30] = form;
419
+ $[31] = getFieldElementId;
420
+ $[32] = getFieldId;
421
+ $[33] = itemId;
422
+ $[34] = itemsMap;
423
+ $[35] = onFieldChange;
424
+ $[36] = postToIframe;
425
+ $[37] = schema;
426
+ $[38] = t13;
427
+ $[39] = t14;
392
428
  } else {
393
- t10 = $[30];
394
- t9 = $[31];
429
+ t13 = $[38];
430
+ t14 = $[39];
395
431
  }
396
- let t11;
397
- if ($[35] !== t10 || $[36] !== t9) {
398
- t11 = /* @__PURE__ */ jsx("form", {
399
- className: t9,
400
- children: t10
432
+ let t15;
433
+ if ($[43] !== t13 || $[44] !== t14) {
434
+ t15 = /* @__PURE__ */ jsx("form", {
435
+ className: t13,
436
+ children: t14
401
437
  });
402
- $[35] = t10;
403
- $[36] = t9;
404
- $[37] = t11;
405
- } else t11 = $[37];
406
- return t11;
438
+ $[43] = t13;
439
+ $[44] = t14;
440
+ $[45] = t15;
441
+ } else t15 = $[45];
442
+ return t15;
407
443
  };
408
444
  function _temp(f) {
409
445
  return f.fieldType === "String" || f.fieldType === "Embed";