camox 0.40.0 → 0.41.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 (108) hide show
  1. package/dist/components/PlatformLabel.js +62 -0
  2. package/dist/core/components/lexical/GradientNode.js +126 -0
  3. package/dist/core/components/lexical/InlineLexicalEditor.js +37 -56
  4. package/dist/core/components/lexical/InlineStylesPlugin.js +183 -0
  5. package/dist/core/components/lexical/SelectionBroadcaster.js +49 -46
  6. package/dist/core/components/lexical/SidebarLexicalEditor.js +197 -151
  7. package/dist/core/components/lexical/editorConfig.js +25 -7
  8. package/dist/core/components/lexical/selectTextLink.js +21 -0
  9. package/dist/core/createApp.d.ts +30 -17
  10. package/dist/core/createApp.js +14 -3
  11. package/dist/core/createBlock.d.ts +2 -2
  12. package/dist/core/createBlock.js +17 -28
  13. package/dist/core/createLayout.d.ts +48 -4
  14. package/dist/core/createLayout.js +51 -23
  15. package/dist/core/derivedRoutes.js +36 -0
  16. package/dist/core/editing/BlockEditingRuntime.js +4 -4
  17. package/dist/core/editing/CompleteBlockEditingRuntime.js +5 -5
  18. package/dist/core/editing/createEditableBlock.d.ts +9 -8
  19. package/dist/core/editing/createEditableBlock.js +265 -403
  20. package/dist/core/hooks/useIsEditable.js +4 -7
  21. package/dist/core/hooks/useRequireDraftSource.js +7 -11
  22. package/dist/core/lib/lexicalReact.d.ts +1 -26
  23. package/dist/core/lib/lexicalReact.js +46 -60
  24. package/dist/core/lib/lexicalState.js +164 -81
  25. package/dist/core/lib/modifierFormats.js +4 -15
  26. package/dist/core/lib/textStyles.d.ts +27 -0
  27. package/dist/core/lib/textStyles.js +47 -0
  28. package/dist/features/navigation/navigation.d.ts +2 -0
  29. package/dist/features/navigation/navigation.js +51 -46
  30. package/dist/features/page/DerivedPageContent.js +61 -0
  31. package/dist/features/page/PublishedPageContent.js +52 -83
  32. package/dist/features/page/SharedLayoutContent.js +66 -0
  33. package/dist/features/preview/CamoxPreview.d.ts +16 -1
  34. package/dist/features/preview/CamoxPreview.js +246 -290
  35. package/dist/features/preview/DerivedPreview.js +134 -0
  36. package/dist/features/preview/EditablePageExperience.js +25 -8
  37. package/dist/features/preview/components/AddBlockSidebar.js +43 -33
  38. package/dist/features/preview/components/AssetLightbox.js +1 -1
  39. package/dist/features/preview/components/BlockActionsPopover.js +8 -8
  40. package/dist/features/preview/components/BlockThumbnail.js +192 -0
  41. package/dist/features/preview/components/CreatePageModal.js +123 -115
  42. package/dist/features/preview/components/DerivedLayoutDialog.js +100 -0
  43. package/dist/features/preview/components/DerivedLayoutSidebar.d.ts +5 -0
  44. package/dist/features/preview/components/DerivedLayoutSidebar.js +160 -0
  45. package/dist/features/preview/components/DerivedPageInfoSidebar.js +57 -0
  46. package/dist/features/preview/components/FieldToolbar.js +42 -20
  47. package/dist/features/preview/components/Frame.js +133 -140
  48. package/dist/features/preview/components/LeftSidebar.js +42 -38
  49. package/dist/features/preview/components/LinkFieldEditor.js +3 -4
  50. package/dist/features/preview/components/MobilePreviewDrawer.js +4 -4
  51. package/dist/features/preview/components/Overlays.js +59 -47
  52. package/dist/features/preview/components/PageEditorSidebar.js +194 -203
  53. package/dist/features/preview/components/PageInfoSidebar.js +63 -55
  54. package/dist/features/preview/components/PageNavigatorSidebar.js +34 -483
  55. package/dist/features/preview/components/PagePicker.js +205 -153
  56. package/dist/features/preview/components/PageTree.js +366 -340
  57. package/dist/features/preview/components/PreviewActivation.js +78 -0
  58. package/dist/features/preview/components/PreviewPanel.js +98 -68
  59. package/dist/features/preview/components/PreviewToolbar.js +224 -241
  60. package/dist/features/preview/components/PreviewToolbarSpacer.js +43 -0
  61. package/dist/features/preview/components/PublicationRow.js +425 -0
  62. package/dist/features/preview/components/PublishDialog.js +180 -97
  63. package/dist/features/preview/components/RightSidebar.js +19 -34
  64. package/dist/features/preview/components/previewStyles.js +8 -0
  65. package/dist/features/preview/components/useUpdateBlockPosition.js +7 -13
  66. package/dist/features/preview/previewConstants.js +8 -0
  67. package/dist/features/preview/previewStore.js +18 -39
  68. package/dist/features/preview/publication.js +71 -0
  69. package/dist/features/provider/AuthenticatedCamoxProvider.js +2 -1
  70. package/dist/features/provider/CoreCamoxProvider.js +11 -2
  71. package/dist/features/provider/LocalhostPreviewProvider.js +6 -7
  72. package/dist/features/provider/useAdminShortcuts.js +5 -4
  73. package/dist/features/routes/pageRuntime.d.ts +10 -0
  74. package/dist/features/routes/pageRuntime.js +7 -9
  75. package/dist/features/runtime/PreviewDocumentContext.js +7 -0
  76. package/dist/features/runtime/RuntimeChrome.js +149 -0
  77. package/dist/features/runtime/SharedChromeContext.js +7 -0
  78. package/dist/features/runtime/navigationRequest.js +21 -0
  79. package/dist/features/runtime/navigationTarget.js +23 -0
  80. package/dist/features/runtime/pageApp.js +196 -121
  81. package/dist/features/runtime/pageNavigation.js +79 -130
  82. package/dist/features/runtime/runtime.d.ts +11 -0
  83. package/dist/features/runtime/runtime.js +183 -47
  84. package/dist/features/runtime/studioApp.d.ts +2 -11
  85. package/dist/features/runtime/studioApp.js +14 -177
  86. package/dist/features/studio/CamoxStudio.js +27 -13
  87. package/dist/features/studio/components/Navbar.js +80 -74
  88. package/dist/features/studio/components/UserButton.js +4 -4
  89. package/dist/features/studio/studioTheme.js +25 -0
  90. package/dist/features/studio/useTheme.js +94 -109
  91. package/dist/features/vite/appGeneration.js +12 -3
  92. package/dist/features/vite/definitionsSync.js +4 -2
  93. package/dist/features/vite/layoutGeneration.js +38 -0
  94. package/dist/features/vite/runtimeDev.js +3 -1
  95. package/dist/lib/auth.js +15 -13
  96. package/dist/lib/normalized-data.js +4 -4
  97. package/dist/lib/platform.js +13 -0
  98. package/dist/lib/utils.js +90 -38
  99. package/dist/studio-overlays.css +5 -40
  100. package/dist/studio.css +1 -1
  101. package/package.json +8 -4
  102. package/skills/camox/SKILL.md +2 -0
  103. package/skills/camox/references/block-definitions.md +31 -12
  104. package/skills/camox/references/layout-definitions.md +2 -0
  105. package/dist/core/lib/modifiers.js +0 -24
  106. package/dist/features/preview/components/DraftSwitchDialog.js +0 -66
  107. package/dist/features/preview/previewQueryFns.js +0 -23
  108. package/dist/features/runtime/studioNavigation.js +0 -120
@@ -1,35 +1,29 @@
1
1
  import { usePageBlocks } from "../../../lib/normalized-data.js";
2
- import { previewStore } from "../previewStore.js";
2
+ import { previewStore, selectIsEditMode } from "../previewStore.js";
3
3
  import { isOverlayMessage } from "../overlayMessages.js";
4
4
  import { usePreviewedPage } from "../CamoxPreview.js";
5
5
  import { c } from "react/compiler-runtime";
6
6
  import * as React from "react";
7
+ import { jsx } from "react/jsx-runtime";
7
8
  import { useSelector } from "@xstate/store-react";
8
9
 
9
10
  //#region src/features/preview/components/Overlays.tsx
10
- const Overlays = (t0) => {
11
- const $ = c(15);
12
- if ($[0] !== "a159f5febae53b051adcfa6973022c237bd738c0db1dc2c0c91aace28d405412") {
13
- for (let $i = 0; $i < 15; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
14
- $[0] = "a159f5febae53b051adcfa6973022c237bd738c0db1dc2c0c91aace28d405412";
11
+ function CuratedAddBlockListener() {
12
+ const $ = c(4);
13
+ if ($[0] !== "4124232297ed208895aa29251e0b658d39227311caca40cca61d1b2baedf5559") {
14
+ for (let $i = 0; $i < 4; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
15
+ $[0] = "4124232297ed208895aa29251e0b658d39227311caca40cca61d1b2baedf5559";
15
16
  }
16
- const { iframeElement } = t0;
17
- const isPageEditorSidebarOpen = useSelector(previewStore, _temp);
18
- const selection = useSelector(previewStore, _temp2);
19
- const peekedBlock = useSelector(previewStore, _temp3);
20
- const page = usePreviewedPage();
21
- const { pageBlocks } = usePageBlocks(page);
17
+ const { pageBlocks } = usePageBlocks(usePreviewedPage());
18
+ let t0;
22
19
  let t1;
23
20
  if ($[1] !== pageBlocks) {
24
- t1 = () => {
21
+ t0 = () => {
25
22
  const handleMessage = (event) => {
26
23
  if (!isOverlayMessage(event.data)) return;
27
24
  const message = event.data;
28
25
  if (message.type === "CAMOX_ADD_BLOCK_REQUEST") {
29
- if (previewStore.getSnapshot().context.previewSource !== "draft") {
30
- previewStore.send({ type: "requestDraftSwitch" });
31
- return;
32
- }
26
+ if (!selectIsEditMode(previewStore.getSnapshot())) return;
33
27
  const { blockPosition, insertPosition } = message;
34
28
  let afterPosition = null;
35
29
  if (message.afterPosition !== void 0) afterPosition = message.afterPosition;
@@ -49,19 +43,31 @@ const Overlays = (t0) => {
49
43
  window.addEventListener("message", handleMessage);
50
44
  return () => window.removeEventListener("message", handleMessage);
51
45
  };
46
+ t1 = [pageBlocks];
52
47
  $[1] = pageBlocks;
53
- $[2] = t1;
54
- } else t1 = $[2];
48
+ $[2] = t0;
49
+ $[3] = t1;
50
+ } else {
51
+ t0 = $[2];
52
+ t1 = $[3];
53
+ }
54
+ React.useEffect(t0, t1);
55
+ return null;
56
+ }
57
+ const Overlays = (t0) => {
58
+ const $ = c(13);
59
+ if ($[0] !== "4124232297ed208895aa29251e0b658d39227311caca40cca61d1b2baedf5559") {
60
+ for (let $i = 0; $i < 13; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
61
+ $[0] = "4124232297ed208895aa29251e0b658d39227311caca40cca61d1b2baedf5559";
62
+ }
63
+ const { iframeElement, canAddBlocks: t1 } = t0;
64
+ const canAddBlocks = t1 === void 0 ? false : t1;
65
+ const isPageEditorSidebarOpen = useSelector(previewStore, _temp);
66
+ const selection = useSelector(previewStore, _temp2);
67
+ const peekedBlock = useSelector(previewStore, _temp3);
55
68
  let t2;
56
- if ($[3] !== page) {
57
- t2 = [page];
58
- $[3] = page;
59
- $[4] = t2;
60
- } else t2 = $[4];
61
- React.useEffect(t1, t2);
62
- let t3;
63
- if ($[5] !== iframeElement?.contentWindow || $[6] !== isPageEditorSidebarOpen || $[7] !== peekedBlock || $[8] !== selection) {
64
- t3 = () => {
69
+ if ($[1] !== iframeElement?.contentWindow || $[2] !== isPageEditorSidebarOpen || $[3] !== peekedBlock || $[4] !== selection) {
70
+ t2 = () => {
65
71
  if (isPageEditorSidebarOpen) return;
66
72
  if (peekedBlock) return;
67
73
  if (!selection) return;
@@ -69,34 +75,40 @@ const Overlays = (t0) => {
69
75
  if (selection.fieldType !== "String") return;
70
76
  const blockId = selection.blockId;
71
77
  const fieldName = selection.fieldName;
72
- const message_0 = {
78
+ const message = {
73
79
  type: "CAMOX_FOCUS_FIELD",
74
80
  fieldId: selection.type === "item-field" ? `${blockId}__${selection.itemId}__${fieldName}` : `${blockId}__${fieldName}`
75
81
  };
76
- iframeElement?.contentWindow?.postMessage(message_0, "*");
82
+ iframeElement?.contentWindow?.postMessage(message, "*");
77
83
  };
78
- $[5] = iframeElement?.contentWindow;
79
- $[6] = isPageEditorSidebarOpen;
80
- $[7] = peekedBlock;
81
- $[8] = selection;
82
- $[9] = t3;
83
- } else t3 = $[9];
84
- let t4;
85
- if ($[10] !== iframeElement || $[11] !== isPageEditorSidebarOpen || $[12] !== peekedBlock || $[13] !== selection) {
86
- t4 = [
84
+ $[1] = iframeElement?.contentWindow;
85
+ $[2] = isPageEditorSidebarOpen;
86
+ $[3] = peekedBlock;
87
+ $[4] = selection;
88
+ $[5] = t2;
89
+ } else t2 = $[5];
90
+ let t3;
91
+ if ($[6] !== iframeElement || $[7] !== isPageEditorSidebarOpen || $[8] !== peekedBlock || $[9] !== selection) {
92
+ t3 = [
87
93
  selection,
88
94
  isPageEditorSidebarOpen,
89
95
  peekedBlock,
90
96
  iframeElement
91
97
  ];
92
- $[10] = iframeElement;
93
- $[11] = isPageEditorSidebarOpen;
94
- $[12] = peekedBlock;
95
- $[13] = selection;
96
- $[14] = t4;
97
- } else t4 = $[14];
98
- React.useEffect(t3, t4);
99
- return null;
98
+ $[6] = iframeElement;
99
+ $[7] = isPageEditorSidebarOpen;
100
+ $[8] = peekedBlock;
101
+ $[9] = selection;
102
+ $[10] = t3;
103
+ } else t3 = $[10];
104
+ React.useEffect(t2, t3);
105
+ let t4;
106
+ if ($[11] !== canAddBlocks) {
107
+ t4 = canAddBlocks ? /* @__PURE__ */ jsx(CuratedAddBlockListener, {}) : null;
108
+ $[11] = canAddBlocks;
109
+ $[12] = t4;
110
+ } else t4 = $[12];
111
+ return t4;
100
112
  };
101
113
  function _temp(state) {
102
114
  return state.context.isPageEditorSidebarOpen;
@@ -98,7 +98,6 @@ const PageEditorSidebar = () => {
98
98
  const requireDraft = useRequireDraftSource();
99
99
  const selection = useSelector(previewStore, (state) => state.context.selection);
100
100
  const iframeElement = useSelector(previewStore, (state_0) => state_0.context.iframeElement);
101
- const isReadOnly = useSelector(previewStore, (state_1) => state_1.context.previewSource) !== "draft";
102
101
  const postToIframe = React.useCallback((message) => {
103
102
  if (!iframeElement?.contentWindow) return;
104
103
  iframeElement.contentWindow.postMessage(message, "*");
@@ -359,213 +358,205 @@ const PageEditorSidebar = () => {
359
358
  })
360
359
  })
361
360
  })
362
- }), /* @__PURE__ */ jsxs("div", {
361
+ }), /* @__PURE__ */ jsx("div", {
363
362
  className: "relative flex-1 overflow-auto",
364
- children: [isReadOnly && /* @__PURE__ */ jsx("button", {
365
- type: "button",
366
- "aria-label": "Switch to draft to edit",
367
- className: "absolute inset-0 z-10 h-full w-full cursor-not-allowed",
368
- onClick: () => previewStore.send({ type: "requestDraftSwitch" })
369
- }), /* @__PURE__ */ jsx("div", {
370
- className: cn(isReadOnly && "pointer-events-none opacity-50"),
371
- children: isItemLoading ? /* @__PURE__ */ jsx("div", {
372
- className: "flex h-full items-center justify-center py-12",
373
- children: /* @__PURE__ */ jsx(Spinner, {})
374
- }) : /* @__PURE__ */ jsxs(Fragment, { children: [
375
- currentItemId == null && !fieldHasOwnView && settingsFields.length > 0 && /* @__PURE__ */ jsxs("div", {
376
- className: "border-border space-y-4 border-b px-2 py-4",
377
- children: [/* @__PURE__ */ jsx(Label, {
378
- className: "text-muted-foreground",
379
- children: "Settings"
380
- }), settingsFields.map((field) => {
381
- const label = field.label ?? formatFieldName(field.name);
382
- const settingsValues = block.settings ?? {};
383
- if (field.fieldType === "Enum") {
384
- const value_3 = settingsValues[field.name] ?? (blockDef._internal.settingsSchema?.properties?.[field.name])?.default ?? "";
385
- return /* @__PURE__ */ jsxs("div", {
386
- className: "space-y-2",
387
- children: [/* @__PURE__ */ jsx(Label, {
388
- htmlFor: `setting-${field.name}`,
389
- children: label
390
- }), /* @__PURE__ */ jsxs(Select, {
391
- value: value_3,
392
- onValueChange: (newValue) => {
393
- if (!requireDraft()) return;
394
- sessionDirtyRef.current = true;
395
- updateSettings.mutate({
396
- id: block.id,
397
- settings: { [field.name]: newValue }
398
- });
399
- },
400
- children: [/* @__PURE__ */ jsx(SelectTrigger, {
401
- id: `setting-${field.name}`,
402
- children: /* @__PURE__ */ jsx(SelectValue, {})
403
- }), /* @__PURE__ */ jsx(SelectContent, { children: field.enumValues?.map((enumValue) => /* @__PURE__ */ jsx(SelectItem, {
404
- value: enumValue,
405
- children: field.enumLabels?.[enumValue] ?? enumValue
406
- }, enumValue)) })]
407
- })]
408
- }, field.name);
409
- }
410
- if (field.fieldType === "Boolean") {
411
- const checked = settingsValues[field.name] ?? (blockDef._internal.settingsSchema?.properties?.[field.name])?.default ?? false;
412
- return /* @__PURE__ */ jsxs("div", {
413
- className: "flex items-center justify-between",
414
- children: [/* @__PURE__ */ jsx(Label, {
415
- htmlFor: `setting-${field.name}`,
416
- children: label
417
- }), /* @__PURE__ */ jsx(Switch, {
363
+ children: /* @__PURE__ */ jsx("div", { children: isItemLoading ? /* @__PURE__ */ jsx("div", {
364
+ className: "flex h-full items-center justify-center py-12",
365
+ children: /* @__PURE__ */ jsx(Spinner, {})
366
+ }) : /* @__PURE__ */ jsxs(Fragment, { children: [
367
+ currentItemId == null && !fieldHasOwnView && settingsFields.length > 0 && /* @__PURE__ */ jsxs("div", {
368
+ className: "border-border space-y-4 border-b px-2 py-4",
369
+ children: [/* @__PURE__ */ jsx(Label, {
370
+ className: "text-muted-foreground",
371
+ children: "Settings"
372
+ }), settingsFields.map((field) => {
373
+ const label = field.label ?? formatFieldName(field.name);
374
+ const settingsValues = block.settings ?? {};
375
+ if (field.fieldType === "Enum") {
376
+ const value_3 = settingsValues[field.name] ?? (blockDef._internal.settingsSchema?.properties?.[field.name])?.default ?? "";
377
+ return /* @__PURE__ */ jsxs("div", {
378
+ className: "space-y-2",
379
+ children: [/* @__PURE__ */ jsx(Label, {
380
+ htmlFor: `setting-${field.name}`,
381
+ children: label
382
+ }), /* @__PURE__ */ jsxs(Select, {
383
+ value: value_3,
384
+ onValueChange: (newValue) => {
385
+ if (!requireDraft()) return;
386
+ sessionDirtyRef.current = true;
387
+ updateSettings.mutate({
388
+ id: block.id,
389
+ settings: { [field.name]: newValue }
390
+ });
391
+ },
392
+ children: [/* @__PURE__ */ jsx(SelectTrigger, {
418
393
  id: `setting-${field.name}`,
419
- checked,
420
- onCheckedChange: (newValue_0) => {
421
- if (!requireDraft()) return;
422
- sessionDirtyRef.current = true;
423
- updateSettings.mutate({
424
- id: block.id,
425
- settings: { [field.name]: newValue_0 }
426
- });
427
- }
428
- })]
429
- }, field.name);
430
- }
431
- return null;
432
- })]
433
- }),
434
- currentItemId != null && !fieldHasOwnView && itemSettingsFields.length > 0 && /* @__PURE__ */ jsxs("div", {
435
- className: "border-border space-y-4 border-b px-2 py-4",
436
- children: [/* @__PURE__ */ jsx(Label, {
437
- className: "text-muted-foreground",
438
- children: "Settings"
439
- }), itemSettingsFields.map((field_0) => {
440
- const label_0 = field_0.label ?? formatFieldName(field_0.name);
441
- const itemSettingsValues = currentItem?.settings ?? {};
442
- const itemSettingsSchemaProps = itemArraySchema?.itemSettingsSchema?.properties;
443
- if (field_0.fieldType === "Enum") {
444
- const value_4 = itemSettingsValues[field_0.name] ?? itemSettingsSchemaProps?.[field_0.name]?.default ?? "";
445
- return /* @__PURE__ */ jsxs("div", {
446
- className: "space-y-2",
447
- children: [/* @__PURE__ */ jsx(Label, {
448
- htmlFor: `item-setting-${field_0.name}`,
449
- children: label_0
450
- }), /* @__PURE__ */ jsxs(Select, {
451
- value: value_4,
452
- onValueChange: (newValue_1) => {
453
- if (!requireDraft()) return;
454
- sessionDirtyRef.current = true;
455
- updateRepeatableSettings.mutate({
456
- id: currentItemId,
457
- settings: { [field_0.name]: newValue_1 }
458
- });
459
- },
460
- children: [/* @__PURE__ */ jsx(SelectTrigger, {
461
- id: `item-setting-${field_0.name}`,
462
- children: /* @__PURE__ */ jsx(SelectValue, {})
463
- }), /* @__PURE__ */ jsx(SelectContent, { children: field_0.enumValues?.map((enumValue_0) => /* @__PURE__ */ jsx(SelectItem, {
464
- value: enumValue_0,
465
- children: field_0.enumLabels?.[enumValue_0] ?? enumValue_0
466
- }, enumValue_0)) })]
467
- })]
468
- }, field_0.name);
469
- }
470
- if (field_0.fieldType === "Boolean") {
471
- const checked_0 = itemSettingsValues[field_0.name] ?? itemSettingsSchemaProps?.[field_0.name]?.default ?? false;
472
- return /* @__PURE__ */ jsxs("div", {
473
- className: "flex items-center justify-between",
474
- children: [/* @__PURE__ */ jsx(Label, {
475
- htmlFor: `item-setting-${field_0.name}`,
476
- children: label_0
477
- }), /* @__PURE__ */ jsx(Switch, {
394
+ children: /* @__PURE__ */ jsx(SelectValue, {})
395
+ }), /* @__PURE__ */ jsx(SelectContent, { children: field.enumValues?.map((enumValue) => /* @__PURE__ */ jsx(SelectItem, {
396
+ value: enumValue,
397
+ children: field.enumLabels?.[enumValue] ?? enumValue
398
+ }, enumValue)) })]
399
+ })]
400
+ }, field.name);
401
+ }
402
+ if (field.fieldType === "Boolean") {
403
+ const checked = settingsValues[field.name] ?? (blockDef._internal.settingsSchema?.properties?.[field.name])?.default ?? false;
404
+ return /* @__PURE__ */ jsxs("div", {
405
+ className: "flex items-center justify-between",
406
+ children: [/* @__PURE__ */ jsx(Label, {
407
+ htmlFor: `setting-${field.name}`,
408
+ children: label
409
+ }), /* @__PURE__ */ jsx(Switch, {
410
+ id: `setting-${field.name}`,
411
+ checked,
412
+ onCheckedChange: (newValue_0) => {
413
+ if (!requireDraft()) return;
414
+ sessionDirtyRef.current = true;
415
+ updateSettings.mutate({
416
+ id: block.id,
417
+ settings: { [field.name]: newValue_0 }
418
+ });
419
+ }
420
+ })]
421
+ }, field.name);
422
+ }
423
+ return null;
424
+ })]
425
+ }),
426
+ currentItemId != null && !fieldHasOwnView && itemSettingsFields.length > 0 && /* @__PURE__ */ jsxs("div", {
427
+ className: "border-border space-y-4 border-b px-2 py-4",
428
+ children: [/* @__PURE__ */ jsx(Label, {
429
+ className: "text-muted-foreground",
430
+ children: "Settings"
431
+ }), itemSettingsFields.map((field_0) => {
432
+ const label_0 = field_0.label ?? formatFieldName(field_0.name);
433
+ const itemSettingsValues = currentItem?.settings ?? {};
434
+ const itemSettingsSchemaProps = itemArraySchema?.itemSettingsSchema?.properties;
435
+ if (field_0.fieldType === "Enum") {
436
+ const value_4 = itemSettingsValues[field_0.name] ?? itemSettingsSchemaProps?.[field_0.name]?.default ?? "";
437
+ return /* @__PURE__ */ jsxs("div", {
438
+ className: "space-y-2",
439
+ children: [/* @__PURE__ */ jsx(Label, {
440
+ htmlFor: `item-setting-${field_0.name}`,
441
+ children: label_0
442
+ }), /* @__PURE__ */ jsxs(Select, {
443
+ value: value_4,
444
+ onValueChange: (newValue_1) => {
445
+ if (!requireDraft()) return;
446
+ sessionDirtyRef.current = true;
447
+ updateRepeatableSettings.mutate({
448
+ id: currentItemId,
449
+ settings: { [field_0.name]: newValue_1 }
450
+ });
451
+ },
452
+ children: [/* @__PURE__ */ jsx(SelectTrigger, {
478
453
  id: `item-setting-${field_0.name}`,
479
- checked: checked_0,
480
- onCheckedChange: (newValue_2) => {
481
- if (!requireDraft()) return;
482
- sessionDirtyRef.current = true;
483
- updateRepeatableSettings.mutate({
484
- id: currentItemId,
485
- settings: { [field_0.name]: newValue_2 }
486
- });
487
- }
488
- })]
489
- }, field_0.name);
490
- }
491
- return null;
492
- })]
493
- }),
494
- isViewingAsset && assetFieldName && isMultipleAsset && /* @__PURE__ */ jsx(MultipleAssetFieldEditor, {
495
- fieldName: assetFieldName,
496
- assetType,
497
- currentData,
498
- onFieldChange: activeFieldChangeHandler
499
- }),
500
- isViewingAsset && assetFieldName && !isMultipleAsset && /* @__PURE__ */ jsx(SingleAssetFieldEditor, {
501
- fieldName: assetFieldName,
502
- assetType,
503
- currentData,
504
- onFieldChange: activeFieldChangeHandler
505
- }),
506
- !isViewingAsset && isViewingLink && linkFieldName && /* @__PURE__ */ jsx("div", {
507
- className: "px-2 py-4",
508
- children: /* @__PURE__ */ jsx(LinkFieldEditor, {
509
- fieldName: linkFieldName,
510
- linkValue: currentData[linkFieldName] ?? {
511
- type: "external",
512
- text: "",
513
- href: "",
514
- newTab: false
454
+ children: /* @__PURE__ */ jsx(SelectValue, {})
455
+ }), /* @__PURE__ */ jsx(SelectContent, { children: field_0.enumValues?.map((enumValue_0) => /* @__PURE__ */ jsx(SelectItem, {
456
+ value: enumValue_0,
457
+ children: field_0.enumLabels?.[enumValue_0] ?? enumValue_0
458
+ }, enumValue_0)) })]
459
+ })]
460
+ }, field_0.name);
461
+ }
462
+ if (field_0.fieldType === "Boolean") {
463
+ const checked_0 = itemSettingsValues[field_0.name] ?? itemSettingsSchemaProps?.[field_0.name]?.default ?? false;
464
+ return /* @__PURE__ */ jsxs("div", {
465
+ className: "flex items-center justify-between",
466
+ children: [/* @__PURE__ */ jsx(Label, {
467
+ htmlFor: `item-setting-${field_0.name}`,
468
+ children: label_0
469
+ }), /* @__PURE__ */ jsx(Switch, {
470
+ id: `item-setting-${field_0.name}`,
471
+ checked: checked_0,
472
+ onCheckedChange: (newValue_2) => {
473
+ if (!requireDraft()) return;
474
+ sessionDirtyRef.current = true;
475
+ updateRepeatableSettings.mutate({
476
+ id: currentItemId,
477
+ settings: { [field_0.name]: newValue_2 }
478
+ });
479
+ }
480
+ })]
481
+ }, field_0.name);
482
+ }
483
+ return null;
484
+ })]
485
+ }),
486
+ isViewingAsset && assetFieldName && isMultipleAsset && /* @__PURE__ */ jsx(MultipleAssetFieldEditor, {
487
+ fieldName: assetFieldName,
488
+ assetType,
489
+ currentData,
490
+ onFieldChange: activeFieldChangeHandler
491
+ }),
492
+ isViewingAsset && assetFieldName && !isMultipleAsset && /* @__PURE__ */ jsx(SingleAssetFieldEditor, {
493
+ fieldName: assetFieldName,
494
+ assetType,
495
+ currentData,
496
+ onFieldChange: activeFieldChangeHandler
497
+ }),
498
+ !isViewingAsset && isViewingLink && linkFieldName && /* @__PURE__ */ jsx("div", {
499
+ className: "px-2 py-4",
500
+ children: /* @__PURE__ */ jsx(LinkFieldEditor, {
501
+ fieldName: linkFieldName,
502
+ linkValue: currentData[linkFieldName] ?? {
503
+ type: "external",
504
+ text: "",
505
+ href: "",
506
+ newTab: false
507
+ },
508
+ onSave: (fieldName_1, value_5) => {
509
+ activeFieldChangeHandler(fieldName_1, value_5);
510
+ }
511
+ })
512
+ }),
513
+ !isViewingAsset && !isViewingLink && (currentItemId == null || currentItem) && /* @__PURE__ */ jsx(ItemFieldsEditor, {
514
+ schema: currentSchema,
515
+ data: currentData,
516
+ blockId: block.id,
517
+ itemId: currentItemId ?? void 0,
518
+ onFieldChange: activeFieldChangeHandler,
519
+ postToIframe,
520
+ filesMap,
521
+ itemsMap,
522
+ fieldIdPrefix
523
+ }, currentItemId ?? `block-${block.id}`),
524
+ !isViewingAsset && !isViewingLink && currentItemId != null && currentItem && /* @__PURE__ */ jsxs("div", {
525
+ className: "border-border flex items-center gap-1 border-t px-2 py-4",
526
+ children: [
527
+ canAddSibling && /* @__PURE__ */ jsxs(Button, {
528
+ type: "button",
529
+ variant: "ghost",
530
+ size: "sm",
531
+ className: "text-muted-foreground justify-start",
532
+ onClick: () => {
533
+ if (!requireDraft()) return;
534
+ addSibling({ afterPosition: currentItem.position });
515
535
  },
516
- onSave: (fieldName_1, value_5) => {
517
- activeFieldChangeHandler(fieldName_1, value_5);
518
- }
536
+ children: [/* @__PURE__ */ jsx(CirclePlus, { className: "h-4 w-4" }), "Add item"]
537
+ }),
538
+ canRemoveCurrent && /* @__PURE__ */ jsxs(Button, {
539
+ type: "button",
540
+ variant: "ghost",
541
+ size: "sm",
542
+ className: "text-muted-foreground justify-start",
543
+ onClick: () => {
544
+ if (!requireDraft()) return;
545
+ removeCurrent(currentItemId, { onSuccess: () => previewStore.send({ type: "selectParent" }) });
546
+ },
547
+ children: [/* @__PURE__ */ jsx(CircleMinus, { className: "h-4 w-4" }), "Remove item"]
548
+ }),
549
+ /* @__PURE__ */ jsxs(Button, {
550
+ type: "button",
551
+ variant: "ghost",
552
+ size: "sm",
553
+ className: "text-muted-foreground justify-start",
554
+ onClick: () => previewStore.send({ type: "selectParent" }),
555
+ children: [/* @__PURE__ */ jsx(CornerLeftUp, { className: "h-4 w-4" }), "Select parent"]
519
556
  })
520
- }),
521
- !isViewingAsset && !isViewingLink && (currentItemId == null || currentItem) && /* @__PURE__ */ jsx(ItemFieldsEditor, {
522
- schema: currentSchema,
523
- data: currentData,
524
- blockId: block.id,
525
- itemId: currentItemId ?? void 0,
526
- onFieldChange: activeFieldChangeHandler,
527
- postToIframe,
528
- filesMap,
529
- itemsMap,
530
- fieldIdPrefix
531
- }, currentItemId ?? `block-${block.id}`),
532
- !isViewingAsset && !isViewingLink && currentItemId != null && currentItem && /* @__PURE__ */ jsxs("div", {
533
- className: "border-border flex items-center gap-1 border-t px-2 py-4",
534
- children: [
535
- canAddSibling && /* @__PURE__ */ jsxs(Button, {
536
- type: "button",
537
- variant: "ghost",
538
- size: "sm",
539
- className: "text-muted-foreground justify-start",
540
- onClick: () => {
541
- if (!requireDraft()) return;
542
- addSibling({ afterPosition: currentItem.position });
543
- },
544
- children: [/* @__PURE__ */ jsx(CirclePlus, { className: "h-4 w-4" }), "Add item"]
545
- }),
546
- canRemoveCurrent && /* @__PURE__ */ jsxs(Button, {
547
- type: "button",
548
- variant: "ghost",
549
- size: "sm",
550
- className: "text-muted-foreground justify-start",
551
- onClick: () => {
552
- if (!requireDraft()) return;
553
- removeCurrent(currentItemId, { onSuccess: () => previewStore.send({ type: "selectParent" }) });
554
- },
555
- children: [/* @__PURE__ */ jsx(CircleMinus, { className: "h-4 w-4" }), "Remove item"]
556
- }),
557
- /* @__PURE__ */ jsxs(Button, {
558
- type: "button",
559
- variant: "ghost",
560
- size: "sm",
561
- className: "text-muted-foreground justify-start",
562
- onClick: () => previewStore.send({ type: "selectParent" }),
563
- children: [/* @__PURE__ */ jsx(CornerLeftUp, { className: "h-4 w-4" }), "Select parent"]
564
- })
565
- ]
566
- })
567
- ] })
568
- })]
557
+ ]
558
+ })
559
+ ] }) })
569
560
  })] });
570
561
  };
571
562