camox 0.14.0 → 0.14.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.
@@ -767,7 +767,9 @@ function createBlock(options) {
767
767
  const repeaterContext = React.use(RepeaterItemContext);
768
768
  const { filesMap } = useNormalizedData();
769
769
  const rawSource = repeaterContext ? repeaterContext.itemContent[name] : content[name];
770
- const fieldValue = (isFileMarker(rawSource) ? resolveFileMarker(rawSource, filesMap) : rawSource) ?? contentDefaults[String(name)];
770
+ const rawValue = isFileMarker(rawSource) ? resolveFileMarker(rawSource, filesMap) : rawSource;
771
+ const defaultValue = repeaterContext ? repeatableItemDefaults[repeaterContext.arrayFieldName]?.[String(name)] : contentDefaults[String(name)];
772
+ const fieldValue = rawValue ?? defaultValue;
771
773
  const t1 = String(name);
772
774
  let t2;
773
775
  if ($[0] !== blockId || $[1] !== repeaterContext || $[2] !== t1) {
@@ -876,7 +878,7 @@ function createBlock(options) {
876
878
  return t14;
877
879
  };
878
880
  const File = (t0) => {
879
- const $ = c(7);
881
+ const $ = c(8);
880
882
  const { name, children } = t0;
881
883
  const blockContext = React.use(Context);
882
884
  if (!blockContext) throw new Error("File must be used within a Block Component");
@@ -885,8 +887,10 @@ function createBlock(options) {
885
887
  const { filesMap } = useNormalizedData();
886
888
  const rawSource = repeaterContext ? repeaterContext.itemContent[name] : content[name];
887
889
  let t1;
888
- if ($[0] !== children || $[1] !== filesMap || $[2] !== name || $[3] !== rawSource) {
889
- const fieldValue = (isFileMarker(rawSource) ? resolveFileMarker(rawSource, filesMap) : rawSource) ?? contentDefaults[String(name)];
890
+ if ($[0] !== children || $[1] !== filesMap || $[2] !== name || $[3] !== rawSource || $[4] !== repeaterContext) {
891
+ const rawValue = isFileMarker(rawSource) ? resolveFileMarker(rawSource, filesMap) : rawSource;
892
+ const defaultValue = repeaterContext ? repeatableItemDefaults[repeaterContext.arrayFieldName]?.[String(name)] : contentDefaults[String(name)];
893
+ const fieldValue = rawValue ?? defaultValue;
890
894
  t1 = children({
891
895
  href: fieldValue.url,
892
896
  download: fieldValue.filename
@@ -895,14 +899,15 @@ function createBlock(options) {
895
899
  $[1] = filesMap;
896
900
  $[2] = name;
897
901
  $[3] = rawSource;
898
- $[4] = t1;
899
- } else t1 = $[4];
902
+ $[4] = repeaterContext;
903
+ $[5] = t1;
904
+ } else t1 = $[5];
900
905
  let t2;
901
- if ($[5] !== t1) {
906
+ if ($[6] !== t1) {
902
907
  t2 = /* @__PURE__ */ jsx(Fragment, { children: t1 });
903
- $[5] = t1;
904
- $[6] = t2;
905
- } else t2 = $[6];
908
+ $[6] = t1;
909
+ $[7] = t2;
910
+ } else t2 = $[7];
906
911
  return t2;
907
912
  };
908
913
  const RepeaterItemWrapper = (t0) => {
@@ -20,7 +20,7 @@ const AgentChatSheet = () => {
20
20
  className: "flex flex-1 items-center justify-center p-6",
21
21
  children: /* @__PURE__ */ jsx("p", {
22
22
  className: "text-muted-foreground text-center text-sm",
23
- children: "Coming soon"
23
+ children: "Coming soon: MCP server and integrated chat"
24
24
  })
25
25
  });
26
26
  $[1] = t1;
@@ -494,7 +494,7 @@ const PageContentSheet = () => {
494
494
  }
495
495
  })
496
496
  }),
497
- !isViewingAsset && !isViewingLink && /* @__PURE__ */ jsx(ItemFieldsEditor, {
497
+ !isViewingAsset && !isViewingLink && (currentItemId == null || currentItem) && /* @__PURE__ */ jsx(ItemFieldsEditor, {
498
498
  schema: currentSchema,
499
499
  data: currentData,
500
500
  blockId: block.id,
@@ -1,4 +1,5 @@
1
1
  import { previewStore } from "../previewStore.js";
2
+ import { blockQueries } from "../../../lib/queries.js";
2
3
  import { cn } from "../../../lib/utils.js";
3
4
  import { usePageBlocks } from "../../../lib/normalized-data.js";
4
5
  import { useCamoxApp } from "../../provider/components/CamoxAppContext.js";
@@ -7,6 +8,7 @@ import { useUpdateBlockPosition } from "./useUpdateBlockPosition.js";
7
8
  import { BlockActionsPopover } from "./BlockActionsPopover.js";
8
9
  import { usePreviewedPage } from "../CamoxPreview.js";
9
10
  import { c } from "react/compiler-runtime";
11
+ import { useQuery } from "@tanstack/react-query";
10
12
  import { useSelector } from "@xstate/store/react";
11
13
  import * as React from "react";
12
14
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
@@ -137,12 +139,26 @@ const FieldItem = (t0) => {
137
139
  return t9;
138
140
  };
139
141
  const BlockFields = (t0) => {
140
- const $ = c(2);
142
+ const $ = c(4);
141
143
  const { block } = t0;
142
144
  const schemaProperties = useCamoxApp().getBlockById(block.type)?._internal.contentSchema.properties;
143
145
  const selection = useSelector(previewStore, _temp3);
144
146
  const iframeElement = useSelector(previewStore, _temp4);
145
- const selectedFieldName = selection?.type === "block-field" && selection.blockId === block.id ? selection.fieldName : null;
147
+ let t1;
148
+ if ($[0] !== block.id) {
149
+ t1 = blockQueries.get(block.id);
150
+ $[0] = block.id;
151
+ $[1] = t1;
152
+ } else t1 = $[1];
153
+ const { data: blockBundle } = useQuery(t1);
154
+ let selectedFieldName = null;
155
+ if (selection?.type === "block-field" && selection.blockId === block.id) selectedFieldName = selection.fieldName;
156
+ else if ((selection?.type === "item" || selection?.type === "item-field") && selection.blockId === block.id && blockBundle) {
157
+ const itemsById = new Map(blockBundle.repeatableItems.map(_temp5));
158
+ let current = itemsById.get(selection.itemId);
159
+ while (current?.parentItemId != null) current = itemsById.get(current.parentItemId);
160
+ selectedFieldName = current?.fieldName ?? null;
161
+ }
146
162
  const handleFieldClick = (fieldName, fieldType) => {
147
163
  previewStore.send({
148
164
  type: "selectBlockField",
@@ -191,8 +207,8 @@ const BlockFields = (t0) => {
191
207
  iframeElement.contentWindow.postMessage(message_2, "*");
192
208
  }
193
209
  };
194
- const t1 = "my-1 space-y-1 pl-7";
195
- const t2 = Object.keys(schemaProperties ?? {}).map((fieldName_3) => {
210
+ const t2 = "my-1 space-y-1 pl-7";
211
+ const t3 = Object.keys(schemaProperties ?? {}).map((fieldName_3) => {
196
212
  const value = block.content[fieldName_3];
197
213
  const fieldSchema = schemaProperties?.[fieldName_3];
198
214
  if (!fieldSchema) return null;
@@ -211,23 +227,23 @@ const BlockFields = (t0) => {
211
227
  onMouseLeave: () => handleFieldMouseLeave(fieldName_3, isRepeatable_1)
212
228
  }, fieldName_3);
213
229
  });
214
- let t3;
215
- if ($[0] !== t2) {
216
- t3 = /* @__PURE__ */ jsx("ul", {
217
- className: t1,
218
- children: t2
230
+ let t4;
231
+ if ($[2] !== t3) {
232
+ t4 = /* @__PURE__ */ jsx("ul", {
233
+ className: t2,
234
+ children: t3
219
235
  });
220
- $[0] = t2;
221
- $[1] = t3;
222
- } else t3 = $[1];
223
- return t3;
236
+ $[2] = t3;
237
+ $[3] = t4;
238
+ } else t4 = $[3];
239
+ return t4;
224
240
  };
225
241
  function useBlockTreeItem(block, t0) {
226
242
  const $ = c(16);
227
243
  const isDragging = t0 === void 0 ? false : t0;
228
244
  const [ellipsisPopoverOpen, setEllipsisPopoverOpen] = React.useState(false);
229
- const selection = useSelector(previewStore, _temp5);
230
- const iframeElement = useSelector(previewStore, _temp6);
245
+ const selection = useSelector(previewStore, _temp6);
246
+ const iframeElement = useSelector(previewStore, _temp7);
231
247
  const isBlockSelected = selection?.type === "block" && selection.blockId === block.id;
232
248
  const shouldShowHover = !isDragging && !isBlockSelected;
233
249
  const shouldShowActive = isDragging || isBlockSelected;
@@ -296,10 +312,10 @@ function useBlockTreeItem(block, t0) {
296
312
  } else t4 = $[15];
297
313
  return t4;
298
314
  }
299
- function _temp6(state_0) {
315
+ function _temp7(state_0) {
300
316
  return state_0.context.iframeElement;
301
317
  }
302
- function _temp5(state) {
318
+ function _temp6(state) {
303
319
  return state.context.selection;
304
320
  }
305
321
  const BlockTreeItemHeader = (t0) => {
@@ -891,13 +907,13 @@ const PageTree = () => {
891
907
  } else t7 = $[16];
892
908
  let t8;
893
909
  if ($[17] !== pageBlocks) {
894
- t8 = pageBlocks.map(_temp7);
910
+ t8 = pageBlocks.map(_temp8);
895
911
  $[17] = pageBlocks;
896
912
  $[18] = t8;
897
913
  } else t8 = $[18];
898
914
  let t9;
899
915
  if ($[19] !== pageBlocks) {
900
- t9 = pageBlocks.map(_temp8);
916
+ t9 = pageBlocks.map(_temp9);
901
917
  $[19] = pageBlocks;
902
918
  $[20] = t9;
903
919
  } else t9 = $[20];
@@ -993,7 +1009,7 @@ const PageTree = () => {
993
1009
  if ($[43] === Symbol.for("react.memo_cache_sentinel")) {
994
1010
  t16 = /* @__PURE__ */ jsxs(Button, {
995
1011
  variant: "secondary",
996
- onClick: _temp9,
1012
+ onClick: _temp0,
997
1013
  children: [/* @__PURE__ */ jsx(Plus, {}), "Add block"]
998
1014
  });
999
1015
  $[43] = t16;
@@ -1012,13 +1028,16 @@ function _temp3(state) {
1012
1028
  function _temp4(state_0) {
1013
1029
  return state_0.context.iframeElement;
1014
1030
  }
1015
- function _temp7(block_2) {
1031
+ function _temp5(i) {
1032
+ return [i.id, i];
1033
+ }
1034
+ function _temp8(block_2) {
1016
1035
  return String(block_2.id);
1017
1036
  }
1018
- function _temp8(block_3) {
1037
+ function _temp9(block_3) {
1019
1038
  return /* @__PURE__ */ jsx(SortableBlock, { block: block_3 }, String(block_3.id));
1020
1039
  }
1021
- function _temp9() {
1040
+ function _temp0() {
1022
1041
  return previewStore.send({ type: "openAddBlockSheet" });
1023
1042
  }
1024
1043
 
@@ -257,7 +257,13 @@ const RepeatableItemsList = ({ items, blockId, fieldName, minItems, maxItems, sc
257
257
  content: defaultContent,
258
258
  settings: defaultSettings ? { ...defaultSettings } : void 0,
259
259
  nestedItems: nestedItems.length > 0 ? nestedItems : void 0
260
- });
260
+ }, { onSuccess: (created) => {
261
+ previewStore.send({
262
+ type: "selectItem",
263
+ blockId,
264
+ itemId: created.id
265
+ });
266
+ } });
261
267
  };
262
268
  const handleRemoveItem = (itemId) => {
263
269
  deleteRepeatableItem.mutate({ id: itemId });
@@ -100,12 +100,14 @@
100
100
  [data-camox-field-type]
101
101
  )[data-camox-overlay-mode="layout"][data-camox-hovered] {
102
102
  box-shadow: 0 0 0 var(--camox-overlay-width-hover) var(--camox-overlay-layout-color-hover) !important;
103
+ border-radius: 0 !important;
103
104
  }
104
105
 
105
106
  [data-camox-field-id]:not(
106
107
  [data-camox-field-type]
107
108
  )[data-camox-overlay-mode="layout"][data-camox-focused] {
108
109
  box-shadow: 0 0 0 var(--camox-overlay-width-selected) var(--camox-overlay-layout-color-selected) !important;
110
+ border-radius: 0 !important;
109
111
  }
110
112
 
111
113
  /* ---- Embed: z-index above click-interceptor ---- */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "camox",
3
- "version": "0.14.0",
3
+ "version": "0.14.1",
4
4
  "bin": {
5
5
  "camox": "./bin/camox.mjs"
6
6
  },
@@ -98,9 +98,9 @@
98
98
  "react-og-preview": "^0.2.0",
99
99
  "shiki": "^4.0.2",
100
100
  "zod": "^4.3.6",
101
- "@camox/api-contract": "0.14.0",
102
- "@camox/ui": "0.14.0",
103
- "@camox/cli": "0.14.0"
101
+ "@camox/api-contract": "0.14.1",
102
+ "@camox/cli": "0.14.1",
103
+ "@camox/ui": "0.14.1"
104
104
  },
105
105
  "devDependencies": {
106
106
  "@babel/core": "^7.29.0",