camox 0.32.0 → 0.33.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/dist/components/AuthGate.js +5 -4
  2. package/dist/core/createBlock.d.ts +1 -1
  3. package/dist/core/createBlock.js +88 -108
  4. package/dist/core/hooks/useIsEditable.js +6 -10
  5. package/dist/core/lib/fieldTypes.js +10 -219
  6. package/dist/features/agent-chat/components/AgentChatSidebar.js +172 -0
  7. package/dist/features/agent-chat/components/AgentChatThread.js +14 -15
  8. package/dist/features/preview/CamoxPreview.js +137 -729
  9. package/dist/features/preview/components/{AddBlockSheet.js → AddBlockSidebar.js} +121 -131
  10. package/dist/features/preview/components/AssetFieldEditor.js +107 -82
  11. package/dist/features/preview/components/AssetLightbox.js +14 -13
  12. package/dist/features/preview/components/AssetPickerModal.js +277 -0
  13. package/dist/features/preview/components/BlockActionsPopover.js +18 -24
  14. package/dist/features/preview/components/CreatePageModal.js +6 -6
  15. package/dist/features/preview/components/FieldToolbar.js +64 -127
  16. package/dist/features/preview/components/ItemFieldsEditor.js +98 -125
  17. package/dist/features/preview/components/LeftSidebar.js +64 -0
  18. package/dist/features/preview/components/LinkFieldEditor.js +1 -1
  19. package/dist/features/preview/components/MultipleAssetFieldEditor.js +94 -56
  20. package/dist/features/preview/components/OverlayTracker.js +15 -15
  21. package/dist/features/preview/components/Overlays.js +12 -12
  22. package/dist/features/preview/components/PageEditorSidebar.js +563 -0
  23. package/dist/features/preview/components/PageInfoSidebar.js +1453 -0
  24. package/dist/features/preview/components/PageNavigatorSidebar.js +590 -0
  25. package/dist/features/preview/components/PagePicker.js +3 -3
  26. package/dist/features/preview/components/PageStatusBadge.js +1 -1
  27. package/dist/features/preview/components/PageTree.js +204 -564
  28. package/dist/features/preview/components/PreviewPanel.js +123 -158
  29. package/dist/features/preview/components/PreviewToolbar.js +260 -256
  30. package/dist/features/preview/components/PublishDialog.js +2 -2
  31. package/dist/features/preview/components/RepeatableItemsList.js +2 -2
  32. package/dist/features/preview/components/RightSidebar.js +109 -0
  33. package/dist/features/preview/components/UnlinkAssetButton.js +2 -2
  34. package/dist/features/preview/components/useRepeatableItemActions.js +3 -138
  35. package/dist/features/preview/components/useUpdateBlockPosition.js +1 -1
  36. package/dist/features/preview/previewQueryFns.js +23 -0
  37. package/dist/features/preview/previewStore.js +46 -63
  38. package/dist/features/provider/CamoxProvider.js +255 -70
  39. package/dist/features/provider/useAdminShortcuts.js +5 -48
  40. package/dist/features/routes/pageRoute.js +1 -1
  41. package/dist/features/studio/CamoxStudio.js +6 -5
  42. package/dist/features/studio/components/EnvironmentMenu.js +2 -2
  43. package/dist/features/studio/components/Navbar.js +53 -71
  44. package/dist/features/studio/components/ProjectMenu.js +1 -1
  45. package/dist/features/studio/components/UserButton.js +1 -1
  46. package/dist/features/studio/routes.js +7 -0
  47. package/dist/features/studio/useTheme.js +67 -33
  48. package/dist/features/vite/routeGeneration.js +68 -66
  49. package/dist/hooks/use-file-upload.js +4 -2
  50. package/dist/lib/api-client.js +6 -3
  51. package/dist/lib/auth.js +29 -25
  52. package/dist/lib/queries.js +6 -4
  53. package/dist/lib/utils.js +1 -1
  54. package/dist/studio-overlays.css +1 -1
  55. package/dist/studio.css +1 -1
  56. package/package.json +4 -4
  57. package/dist/features/agent-chat/components/AgentChatSheet.js +0 -207
  58. package/dist/features/preview/components/AssetPickerGrid.js +0 -236
  59. package/dist/features/preview/components/PageContentSheet.js +0 -608
  60. package/dist/features/preview/components/PageMetadataModal.js +0 -908
  61. package/dist/features/preview/components/PreviewSideSheet.js +0 -76
@@ -1,20 +1,17 @@
1
- import { previewStore } from "../previewStore.js";
2
- import { useIsPreviewSheetOpen } from "./PreviewSideSheet.js";
3
- import { cn, formatShortcut } from "../../../lib/utils.js";
1
+ import { cn } from "../../../lib/utils.js";
4
2
  import { isOverlayMessage } from "../overlayMessages.js";
3
+ import { previewStore } from "../previewStore.js";
5
4
  import { FORMAT_FLAGS } from "../../../core/lib/modifierFormats.js";
6
5
  import { TextLinkPopover } from "../../../core/components/lexical/TextLinkPopover.js";
7
- import { useCurrentItemActions } from "./useRepeatableItemActions.js";
8
- import { formatFieldName } from "./ItemFieldsEditor.js";
9
6
  import { c } from "react/compiler-runtime";
10
- import { Kbd } from "@camox/ui/kbd";
11
7
  import { useSelector } from "@xstate/store-react";
12
8
  import * as React from "react";
9
+ import { Kbd } from "@camox/ui/kbd";
13
10
  import { jsx, jsxs } from "react/jsx-runtime";
14
11
  import { Button } from "@camox/ui/button";
12
+ import { Bold, Italic } from "lucide-react";
15
13
  import { ButtonGroup } from "@camox/ui/button-group";
16
14
  import * as Tooltip$1 from "@camox/ui/tooltip";
17
- import { Bold, CircleMinus, CirclePlus, Italic } from "lucide-react";
18
15
  import { FloatingToolbar } from "@camox/ui/floating-toolbar";
19
16
  import { Toggle } from "@camox/ui/toggle";
20
17
 
@@ -33,14 +30,12 @@ const FORMAT_BUTTONS = [{
33
30
  shortcut: "⌘ I"
34
31
  }];
35
32
  const FieldToolbar = () => {
36
- const $ = c(38);
37
- if ($[0] !== "8a2b2d9ef81221d4535d05947c07828197adc9a5cdfe31ce4861c6c95ece3e43") {
38
- for (let $i = 0; $i < 38; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
39
- $[0] = "8a2b2d9ef81221d4535d05947c07828197adc9a5cdfe31ce4861c6c95ece3e43";
33
+ const $ = c(28);
34
+ if ($[0] !== "bee72c888eb7fec22d667ab73801a7ed4c0292a3149ebb46febb13e2bf2d9bc3") {
35
+ for (let $i = 0; $i < 28; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
36
+ $[0] = "bee72c888eb7fec22d667ab73801a7ed4c0292a3149ebb46febb13e2bf2d9bc3";
40
37
  }
41
38
  const iframeElement = useSelector(previewStore, _temp);
42
- const selection = useSelector(previewStore, _temp2);
43
- const isAnySideSheetOpen = useIsPreviewSheetOpen();
44
39
  const [hasSelection, setHasSelection] = React.useState(false);
45
40
  const [activeFormats, setActiveFormats] = React.useState(0);
46
41
  const [linkTarget, setLinkTarget] = React.useState(null);
@@ -121,81 +116,19 @@ const FieldToolbar = () => {
121
116
  $[9] = t5;
122
117
  } else t5 = $[9];
123
118
  const unlinkText = t5;
124
- const isOnField = selection?.type === "block-field" || selection?.type === "item-field";
125
- const isOnItemField = selection?.type === "item-field";
126
- const isVisible = isOnField && !isAnySideSheetOpen;
127
- const { canAdd, addItem, canRemove, removeItem, currentItem } = useCurrentItemActions(isOnItemField ? selection.blockId : null, isOnItemField ? selection.itemId : null);
128
- let t6;
129
- if ($[10] !== selection) {
130
- t6 = () => {
131
- if (!selection) return;
132
- previewStore.send({
133
- type: "openBlockContentSheet",
134
- blockId: selection.blockId
135
- });
136
- };
137
- $[10] = selection;
138
- $[11] = t6;
139
- } else t6 = $[11];
140
- const handleEditInForm = t6;
141
- const handleToolbarMouseDown = _temp3;
142
- const t7 = isVisible ? "opacity-100 translate-y-0" : "opacity-0 pointer-events-none translate-y-2";
119
+ const isVisible = hasSelection || linkPopoverOpen;
120
+ const handleToolbarMouseDown = _temp2;
121
+ const t6 = isVisible ? "opacity-100 translate-y-0" : "opacity-0 pointer-events-none translate-y-2";
122
+ let t7;
123
+ if ($[10] !== t6) {
124
+ t7 = cn("bottom-17 gap-2", t6);
125
+ $[10] = t6;
126
+ $[11] = t7;
127
+ } else t7 = $[11];
143
128
  let t8;
144
- if ($[12] !== t7) {
145
- t8 = cn("bottom-17 gap-2", t7);
146
- $[12] = t7;
147
- $[13] = t8;
148
- } else t8 = $[13];
149
- let t9;
150
- if ($[14] === Symbol.for("react.memo_cache_sentinel")) {
151
- t9 = formatShortcut({
152
- key: "j",
153
- withAlt: true
154
- });
155
- $[14] = t9;
156
- } else t9 = $[14];
157
- let t10;
158
- if ($[15] !== handleEditInForm) {
159
- t10 = /* @__PURE__ */ jsxs(Button, {
160
- variant: "outline",
161
- onClick: handleEditInForm,
162
- children: ["Edit in form", t9]
163
- });
164
- $[15] = handleEditInForm;
165
- $[16] = t10;
166
- } else t10 = $[16];
167
- let t11;
168
- if ($[17] !== addItem || $[18] !== canAdd || $[19] !== canRemove || $[20] !== currentItem || $[21] !== isOnItemField || $[22] !== removeItem) {
169
- t11 = isOnItemField && currentItem && (canAdd || canRemove) && /* @__PURE__ */ jsx(Tooltip$1.TooltipProvider, {
170
- delay: 0,
171
- children: /* @__PURE__ */ jsxs(ButtonGroup, { children: [canAdd && /* @__PURE__ */ jsxs(Tooltip$1.Tooltip, { children: [/* @__PURE__ */ jsx(Tooltip$1.TooltipTrigger, {
172
- render: /* @__PURE__ */ jsx(Button, {
173
- variant: "outline",
174
- size: "icon",
175
- onClick: () => addItem({ afterPosition: currentItem.position })
176
- }),
177
- children: /* @__PURE__ */ jsx(CirclePlus, {})
178
- }), /* @__PURE__ */ jsxs(Tooltip$1.TooltipContent, { children: ["Add item to ", formatFieldName(currentItem.fieldName)] })] }), canRemove && /* @__PURE__ */ jsxs(Tooltip$1.Tooltip, { children: [/* @__PURE__ */ jsx(Tooltip$1.TooltipTrigger, {
179
- render: /* @__PURE__ */ jsx(Button, {
180
- variant: "outline",
181
- size: "icon",
182
- onClick: () => removeItem(currentItem.id, { onSuccess: _temp4 })
183
- }),
184
- children: /* @__PURE__ */ jsx(CircleMinus, {})
185
- }), /* @__PURE__ */ jsxs(Tooltip$1.TooltipContent, { children: ["Remove item from ", formatFieldName(currentItem.fieldName)] })] })] })
186
- });
187
- $[17] = addItem;
188
- $[18] = canAdd;
189
- $[19] = canRemove;
190
- $[20] = currentItem;
191
- $[21] = isOnItemField;
192
- $[22] = removeItem;
193
- $[23] = t11;
194
- } else t11 = $[23];
195
- let t12;
196
- if ($[24] !== activeFormats || $[25] !== hasSelection || $[26] !== linkPopoverOpen || $[27] !== linkTarget || $[28] !== selectedText || $[29] !== sendFormat || $[30] !== sendTextLink || $[31] !== unlinkText) {
197
- t12 = hasSelection && /* @__PURE__ */ jsxs(ButtonGroup, { children: [FORMAT_BUTTONS.map((t13) => {
198
- const { key, flag, icon: Icon, label, shortcut } = t13;
129
+ if ($[12] !== activeFormats || $[13] !== sendFormat) {
130
+ t8 = FORMAT_BUTTONS.map((t9) => {
131
+ const { key, flag, icon: Icon, label, shortcut } = t9;
199
132
  const isActive = !!(activeFormats & flag);
200
133
  return /* @__PURE__ */ jsxs(Tooltip$1.Tooltip, { children: [/* @__PURE__ */ jsx(Tooltip$1.TooltipTrigger, {
201
134
  render: /* @__PURE__ */ jsx(Toggle, {
@@ -210,55 +143,62 @@ const FieldToolbar = () => {
210
143
  " ",
211
144
  /* @__PURE__ */ jsx(Kbd, { children: shortcut })
212
145
  ] })] }, key);
213
- }), /* @__PURE__ */ jsx(TextLinkPopover, {
146
+ });
147
+ $[12] = activeFormats;
148
+ $[13] = sendFormat;
149
+ $[14] = t8;
150
+ } else t8 = $[14];
151
+ let t9;
152
+ if ($[15] === Symbol.for("react.memo_cache_sentinel")) {
153
+ t9 = /* @__PURE__ */ jsx(Button, {
154
+ variant: "outline",
155
+ size: "icon",
156
+ "aria-label": "Add link"
157
+ });
158
+ $[15] = t9;
159
+ } else t9 = $[15];
160
+ let t10;
161
+ if ($[16] !== linkPopoverOpen || $[17] !== linkTarget || $[18] !== selectedText || $[19] !== sendTextLink || $[20] !== unlinkText) {
162
+ t10 = /* @__PURE__ */ jsx(TextLinkPopover, {
214
163
  open: linkPopoverOpen,
215
164
  onOpenChange: handleLinkPopoverOpenChange,
216
- trigger: /* @__PURE__ */ jsx(Button, {
217
- variant: "outline",
218
- size: "icon",
219
- "aria-label": "Add link"
220
- }),
165
+ trigger: t9,
221
166
  text: selectedText,
222
167
  target: linkTarget,
223
168
  onSave: sendTextLink,
224
169
  onUnlink: unlinkText
225
- })] });
226
- $[24] = activeFormats;
227
- $[25] = hasSelection;
228
- $[26] = linkPopoverOpen;
229
- $[27] = linkTarget;
230
- $[28] = selectedText;
231
- $[29] = sendFormat;
232
- $[30] = sendTextLink;
233
- $[31] = unlinkText;
234
- $[32] = t12;
235
- } else t12 = $[32];
236
- let t13;
237
- if ($[33] !== t10 || $[34] !== t11 || $[35] !== t12 || $[36] !== t8) {
238
- t13 = /* @__PURE__ */ jsxs(FloatingToolbar, {
170
+ });
171
+ $[16] = linkPopoverOpen;
172
+ $[17] = linkTarget;
173
+ $[18] = selectedText;
174
+ $[19] = sendTextLink;
175
+ $[20] = unlinkText;
176
+ $[21] = t10;
177
+ } else t10 = $[21];
178
+ let t11;
179
+ if ($[22] !== t10 || $[23] !== t8) {
180
+ t11 = /* @__PURE__ */ jsxs(ButtonGroup, { children: [t8, t10] });
181
+ $[22] = t10;
182
+ $[23] = t8;
183
+ $[24] = t11;
184
+ } else t11 = $[24];
185
+ let t12;
186
+ if ($[25] !== t11 || $[26] !== t7) {
187
+ t12 = /* @__PURE__ */ jsx(FloatingToolbar, {
239
188
  onMouseDown: handleToolbarMouseDown,
240
- className: t8,
241
- children: [
242
- t10,
243
- t11,
244
- t12
245
- ]
189
+ className: t7,
190
+ children: t11
246
191
  });
247
- $[33] = t10;
248
- $[34] = t11;
249
- $[35] = t12;
250
- $[36] = t8;
251
- $[37] = t13;
252
- } else t13 = $[37];
253
- return t13;
192
+ $[25] = t11;
193
+ $[26] = t7;
194
+ $[27] = t12;
195
+ } else t12 = $[27];
196
+ return t12;
254
197
  };
255
198
  function _temp(state) {
256
199
  return state.context.iframeElement;
257
200
  }
258
- function _temp2(state_0) {
259
- return state_0.context.selection;
260
- }
261
- function _temp3(event_0) {
201
+ function _temp2(event_0) {
262
202
  const target_0 = event_0.target;
263
203
  if (!(target_0 instanceof HTMLElement)) {
264
204
  event_0.preventDefault();
@@ -267,9 +207,6 @@ function _temp3(event_0) {
267
207
  if (target_0.closest("input, select, textarea, button, [role='combobox']")) return;
268
208
  event_0.preventDefault();
269
209
  }
270
- function _temp4() {
271
- return previewStore.send({ type: "selectParent" });
272
- }
273
210
 
274
211
  //#endregion
275
212
  export { FieldToolbar };
@@ -30,9 +30,9 @@ const getSchemaFieldsInOrder = (schema) => {
30
30
  };
31
31
  const DrillRow = (t0) => {
32
32
  const $ = c(28);
33
- if ($[0] !== "10d7e880adc2a5d4d4076a1bdf35fee064c2b42cd42d45b2991c5ebaf6c4d95d") {
33
+ if ($[0] !== "44742e36c00267829eb7bcad0f4d0df91633b9d7bdc99a829f13e3d1db5d9c2b") {
34
34
  for (let $i = 0; $i < 28; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
35
- $[0] = "10d7e880adc2a5d4d4076a1bdf35fee064c2b42cd42d45b2991c5ebaf6c4d95d";
35
+ $[0] = "44742e36c00267829eb7bcad0f4d0df91633b9d7bdc99a829f13e3d1db5d9c2b";
36
36
  }
37
37
  const { label, preview, Icon, onClick, hover, postToIframe } = t0;
38
38
  let t1;
@@ -134,12 +134,12 @@ const DrillRow = (t0) => {
134
134
  return t7;
135
135
  };
136
136
  const ItemFieldsEditor = (t0) => {
137
- const $ = c(47);
138
- if ($[0] !== "10d7e880adc2a5d4d4076a1bdf35fee064c2b42cd42d45b2991c5ebaf6c4d95d") {
139
- for (let $i = 0; $i < 47; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
140
- $[0] = "10d7e880adc2a5d4d4076a1bdf35fee064c2b42cd42d45b2991c5ebaf6c4d95d";
137
+ const $ = c(42);
138
+ if ($[0] !== "44742e36c00267829eb7bcad0f4d0df91633b9d7bdc99a829f13e3d1db5d9c2b") {
139
+ for (let $i = 0; $i < 42; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
140
+ $[0] = "44742e36c00267829eb7bcad0f4d0df91633b9d7bdc99a829f13e3d1db5d9c2b";
141
141
  }
142
- const { schema, data, blockId, itemId, onFieldChange, postToIframe, filesMap, itemsMap, fieldIdPrefix, autoFocusFieldName } = t0;
142
+ const { schema, data, blockId, itemId, onFieldChange, postToIframe, filesMap, itemsMap, fieldIdPrefix } = t0;
143
143
  let t1;
144
144
  if ($[1] !== schema) {
145
145
  t1 = getSchemaFieldsInOrder(schema);
@@ -168,102 +168,75 @@ const ItemFieldsEditor = (t0) => {
168
168
  } else t3 = $[7];
169
169
  const getFieldElementId = t3;
170
170
  let t4;
171
- if ($[8] !== autoFocusFieldName || $[9] !== fieldIdPrefix) {
172
- t4 = {
173
- fieldName: autoFocusFieldName,
174
- prefix: fieldIdPrefix
175
- };
176
- $[8] = autoFocusFieldName;
177
- $[9] = fieldIdPrefix;
178
- $[10] = t4;
179
- } else t4 = $[10];
180
- const initialAutoFocusRef = React.useRef(t4);
181
- let t5;
182
- let t6;
183
- if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
184
- t5 = () => {
185
- const { fieldName: fieldName_1, prefix } = initialAutoFocusRef.current;
186
- if (!fieldName_1) return;
187
- document.getElementById(`${prefix}-${fieldName_1}`)?.focus();
188
- };
189
- t6 = [];
190
- $[11] = t5;
191
- $[12] = t6;
192
- } else {
193
- t5 = $[11];
194
- t6 = $[12];
195
- }
196
- React.useLayoutEffect(t5, t6);
197
- let t7;
198
- if ($[13] !== fields) {
199
- t7 = fields.filter(_temp).map(_temp2);
200
- $[13] = fields;
201
- $[14] = t7;
202
- } else t7 = $[14];
203
- const scalarFields = t7;
171
+ if ($[8] !== fields) {
172
+ t4 = fields.filter(_temp).map(_temp2);
173
+ $[8] = fields;
174
+ $[9] = t4;
175
+ } else t4 = $[9];
176
+ const scalarFields = t4;
204
177
  let values;
205
- if ($[15] !== data || $[16] !== scalarFields) {
178
+ if ($[10] !== data || $[11] !== scalarFields) {
206
179
  values = {};
207
- for (const fieldName_2 of scalarFields) values[fieldName_2] = data[fieldName_2] ?? "";
208
- $[15] = data;
209
- $[16] = scalarFields;
210
- $[17] = values;
211
- } else values = $[17];
180
+ for (const fieldName_1 of scalarFields) values[fieldName_1] = data[fieldName_1] ?? "";
181
+ $[10] = data;
182
+ $[11] = scalarFields;
183
+ $[12] = values;
184
+ } else values = $[12];
212
185
  const defaultValues = values;
213
- let t8;
214
- if ($[18] !== defaultValues) {
215
- t8 = { defaultValues };
216
- $[18] = defaultValues;
217
- $[19] = t8;
218
- } else t8 = $[19];
219
- const form = useForm(t8);
220
- let t10;
221
- let t9;
222
- if ($[20] !== defaultValues || $[21] !== form) {
223
- t9 = () => {
186
+ let t5;
187
+ if ($[13] !== defaultValues) {
188
+ t5 = { defaultValues };
189
+ $[13] = defaultValues;
190
+ $[14] = t5;
191
+ } else t5 = $[14];
192
+ const form = useForm(t5);
193
+ let t6;
194
+ let t7;
195
+ if ($[15] !== defaultValues || $[16] !== form) {
196
+ t6 = () => {
224
197
  form.update({ defaultValues });
225
198
  };
226
- t10 = [defaultValues, form];
227
- $[20] = defaultValues;
228
- $[21] = form;
229
- $[22] = t10;
230
- $[23] = t9;
199
+ t7 = [defaultValues, form];
200
+ $[15] = defaultValues;
201
+ $[16] = form;
202
+ $[17] = t6;
203
+ $[18] = t7;
231
204
  } else {
232
- t10 = $[22];
233
- t9 = $[23];
205
+ t6 = $[17];
206
+ t7 = $[18];
234
207
  }
235
- React.useEffect(t9, t10);
236
- let t11;
237
- let t12;
238
- if ($[24] !== postToIframe) {
239
- t11 = () => () => {
208
+ React.useEffect(t6, t7);
209
+ let t8;
210
+ let t9;
211
+ if ($[19] !== postToIframe) {
212
+ t8 = () => () => {
240
213
  if (timerRef.current) clearTimeout(timerRef.current);
241
214
  if (focusedFieldIdRef.current) postToIframe({
242
215
  type: "CAMOX_FOCUS_FIELD_END",
243
216
  fieldId: focusedFieldIdRef.current
244
217
  });
245
218
  };
246
- t12 = [postToIframe];
247
- $[24] = postToIframe;
248
- $[25] = t11;
249
- $[26] = t12;
219
+ t9 = [postToIframe];
220
+ $[19] = postToIframe;
221
+ $[20] = t8;
222
+ $[21] = t9;
250
223
  } else {
251
- t11 = $[25];
252
- t12 = $[26];
224
+ t8 = $[20];
225
+ t9 = $[21];
253
226
  }
254
- React.useEffect(t11, t12);
255
- let t13;
256
- let t14;
257
- if ($[27] !== blockId || $[28] !== data || $[29] !== fields || $[30] !== filesMap || $[31] !== form || $[32] !== getFieldElementId || $[33] !== getFieldId || $[34] !== itemId || $[35] !== itemsMap || $[36] !== onFieldChange || $[37] !== postToIframe || $[38] !== schema) {
258
- const handleScalarChange = (fieldName_3, value, fieldApi) => {
227
+ React.useEffect(t8, t9);
228
+ let t10;
229
+ let t11;
230
+ if ($[22] !== blockId || $[23] !== data || $[24] !== fields || $[25] !== filesMap || $[26] !== form || $[27] !== getFieldElementId || $[28] !== getFieldId || $[29] !== itemId || $[30] !== itemsMap || $[31] !== onFieldChange || $[32] !== postToIframe || $[33] !== schema) {
231
+ const handleScalarChange = (fieldName_2, value, fieldApi) => {
259
232
  fieldApi.handleChange(value);
260
233
  if (timerRef.current) clearTimeout(timerRef.current);
261
234
  timerRef.current = window.setTimeout(() => {
262
- onFieldChange(fieldName_3, value);
235
+ onFieldChange(fieldName_2, value);
263
236
  }, 500);
264
237
  };
265
- const handleFieldFocus = (fieldName_4, fieldType) => {
266
- const fieldId = getFieldId(fieldName_4);
238
+ const handleFieldFocus = (fieldName_3, fieldType) => {
239
+ const fieldId = getFieldId(fieldName_3);
267
240
  focusedFieldIdRef.current = fieldId;
268
241
  postToIframe({
269
242
  type: "CAMOX_FOCUS_FIELD",
@@ -273,18 +246,18 @@ const ItemFieldsEditor = (t0) => {
273
246
  type: "selectItemField",
274
247
  blockId,
275
248
  itemId,
276
- fieldName: fieldName_4,
249
+ fieldName: fieldName_3,
277
250
  fieldType
278
251
  });
279
252
  else previewStore.send({
280
253
  type: "selectBlockField",
281
254
  blockId,
282
- fieldName: fieldName_4,
255
+ fieldName: fieldName_3,
283
256
  fieldType
284
257
  });
285
258
  };
286
- const handleFieldBlur = (fieldName_5) => {
287
- const fieldId_0 = getFieldId(fieldName_5);
259
+ const handleFieldBlur = (fieldName_4) => {
260
+ const fieldId_0 = getFieldId(fieldName_4);
288
261
  focusedFieldIdRef.current = null;
289
262
  postToIframe({
290
263
  type: "CAMOX_FOCUS_FIELD_END",
@@ -294,30 +267,30 @@ const ItemFieldsEditor = (t0) => {
294
267
  if (!focusedFieldIdRef.current) previewStore.send({ type: "selectParent" });
295
268
  });
296
269
  };
297
- let t15;
298
- if ($[41] !== blockId || $[42] !== itemId) {
299
- t15 = (fieldName_6, fieldType_0) => {
270
+ let t12;
271
+ if ($[36] !== blockId || $[37] !== itemId) {
272
+ t12 = (fieldName_5, fieldType_0) => {
300
273
  if (itemId != null) previewStore.send({
301
274
  type: "selectItemField",
302
275
  blockId,
303
276
  itemId,
304
- fieldName: fieldName_6,
277
+ fieldName: fieldName_5,
305
278
  fieldType: fieldType_0
306
279
  });
307
280
  else previewStore.send({
308
281
  type: "selectBlockField",
309
282
  blockId,
310
- fieldName: fieldName_6,
283
+ fieldName: fieldName_5,
311
284
  fieldType: fieldType_0
312
285
  });
313
286
  };
314
- $[41] = blockId;
315
- $[42] = itemId;
316
- $[43] = t15;
317
- } else t15 = $[43];
318
- const drillIntoField = t15;
319
- t13 = "space-y-4 px-4 py-4";
320
- t14 = fields.map((field) => {
287
+ $[36] = blockId;
288
+ $[37] = itemId;
289
+ $[38] = t12;
290
+ } else t12 = $[38];
291
+ const drillIntoField = t12;
292
+ t10 = "space-y-4 px-2 py-4";
293
+ t11 = fields.map((field) => {
321
294
  const label = field.label ?? formatFieldName(field.name);
322
295
  const fieldId_1 = getFieldId(field.name);
323
296
  if (field.fieldType === "String") return /* @__PURE__ */ jsx(form.Field, {
@@ -451,35 +424,35 @@ const ItemFieldsEditor = (t0) => {
451
424
  }
452
425
  return null;
453
426
  });
454
- $[27] = blockId;
455
- $[28] = data;
456
- $[29] = fields;
457
- $[30] = filesMap;
458
- $[31] = form;
459
- $[32] = getFieldElementId;
460
- $[33] = getFieldId;
461
- $[34] = itemId;
462
- $[35] = itemsMap;
463
- $[36] = onFieldChange;
464
- $[37] = postToIframe;
465
- $[38] = schema;
466
- $[39] = t13;
467
- $[40] = t14;
427
+ $[22] = blockId;
428
+ $[23] = data;
429
+ $[24] = fields;
430
+ $[25] = filesMap;
431
+ $[26] = form;
432
+ $[27] = getFieldElementId;
433
+ $[28] = getFieldId;
434
+ $[29] = itemId;
435
+ $[30] = itemsMap;
436
+ $[31] = onFieldChange;
437
+ $[32] = postToIframe;
438
+ $[33] = schema;
439
+ $[34] = t10;
440
+ $[35] = t11;
468
441
  } else {
469
- t13 = $[39];
470
- t14 = $[40];
442
+ t10 = $[34];
443
+ t11 = $[35];
471
444
  }
472
- let t15;
473
- if ($[44] !== t13 || $[45] !== t14) {
474
- t15 = /* @__PURE__ */ jsx("form", {
475
- className: t13,
476
- children: t14
445
+ let t12;
446
+ if ($[39] !== t10 || $[40] !== t11) {
447
+ t12 = /* @__PURE__ */ jsx("form", {
448
+ className: t10,
449
+ children: t11
477
450
  });
478
- $[44] = t13;
479
- $[45] = t14;
480
- $[46] = t15;
481
- } else t15 = $[46];
482
- return t15;
451
+ $[39] = t10;
452
+ $[40] = t11;
453
+ $[41] = t12;
454
+ } else t12 = $[41];
455
+ return t12;
483
456
  };
484
457
  function _temp(f) {
485
458
  return f.fieldType === "String" || f.fieldType === "Embed";
@@ -0,0 +1,64 @@
1
+ import { previewStore } from "../previewStore.js";
2
+ import { AddBlockSidebar } from "./AddBlockSidebar.js";
3
+ import { PageNavigatorSidebar } from "./PageNavigatorSidebar.js";
4
+ import { c } from "react/compiler-runtime";
5
+ import { useSelector } from "@xstate/store-react";
6
+ import { jsx, jsxs } from "react/jsx-runtime";
7
+
8
+ //#region src/features/preview/components/LeftSidebar.tsx
9
+ const getLeftSidebarRoute = ({ isAddBlockSidebarOpen }) => {
10
+ if (isAddBlockSidebarOpen) return { type: "add-block" };
11
+ return { type: "page-navigator" };
12
+ };
13
+ const LeftSidebar = (t0) => {
14
+ const $ = c(12);
15
+ if ($[0] !== "f683caf1e19043e2a8ec108ed89c22771f4e771637dbf0249087f015011f6726") {
16
+ for (let $i = 0; $i < 12; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
17
+ $[0] = "f683caf1e19043e2a8ec108ed89c22771f4e771637dbf0249087f015011f6726";
18
+ }
19
+ const { page } = t0;
20
+ const isAddBlockSidebarOpen = useSelector(previewStore, _temp);
21
+ let t1;
22
+ if ($[1] !== isAddBlockSidebarOpen) {
23
+ t1 = getLeftSidebarRoute({ isAddBlockSidebarOpen });
24
+ $[1] = isAddBlockSidebarOpen;
25
+ $[2] = t1;
26
+ } else t1 = $[2];
27
+ const route = t1;
28
+ let t2;
29
+ if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
30
+ t2 = { width: 250 };
31
+ $[3] = t2;
32
+ } else t2 = $[3];
33
+ let t3;
34
+ if ($[4] !== route.type) {
35
+ t3 = route.type === "add-block" && /* @__PURE__ */ jsx(AddBlockSidebar, {});
36
+ $[4] = route.type;
37
+ $[5] = t3;
38
+ } else t3 = $[5];
39
+ let t4;
40
+ if ($[6] !== page || $[7] !== route.type) {
41
+ t4 = route.type === "page-navigator" && /* @__PURE__ */ jsx(PageNavigatorSidebar, { page });
42
+ $[6] = page;
43
+ $[7] = route.type;
44
+ $[8] = t4;
45
+ } else t4 = $[8];
46
+ let t5;
47
+ if ($[9] !== t3 || $[10] !== t4) {
48
+ t5 = /* @__PURE__ */ jsxs("aside", {
49
+ className: "flex shrink-0 flex-col border-r-2",
50
+ style: t2,
51
+ children: [t3, t4]
52
+ });
53
+ $[9] = t3;
54
+ $[10] = t4;
55
+ $[11] = t5;
56
+ } else t5 = $[11];
57
+ return t5;
58
+ };
59
+ function _temp(state) {
60
+ return state.context.isAddBlockSidebarOpen;
61
+ }
62
+
63
+ //#endregion
64
+ export { LeftSidebar };
@@ -10,9 +10,9 @@ import { useQuery } from "@tanstack/react-query";
10
10
  import * as React from "react";
11
11
  import { jsx, jsxs } from "react/jsx-runtime";
12
12
  import { Button } from "@camox/ui/button";
13
- import { Switch } from "@camox/ui/switch";
14
13
  import { Check, ChevronsUpDown } from "lucide-react";
15
14
  import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList } from "@camox/ui/command";
15
+ import { Switch } from "@camox/ui/switch";
16
16
  import { Tabs, TabsList, TabsTrigger } from "@camox/ui/tabs";
17
17
 
18
18
  //#region src/features/preview/components/LinkFieldEditor.tsx