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.
- package/dist/components/PlatformLabel.js +62 -0
- package/dist/core/components/lexical/GradientNode.js +126 -0
- package/dist/core/components/lexical/InlineLexicalEditor.js +37 -56
- package/dist/core/components/lexical/InlineStylesPlugin.js +183 -0
- package/dist/core/components/lexical/SelectionBroadcaster.js +49 -46
- package/dist/core/components/lexical/SidebarLexicalEditor.js +197 -151
- package/dist/core/components/lexical/editorConfig.js +25 -7
- package/dist/core/components/lexical/selectTextLink.js +21 -0
- package/dist/core/createApp.d.ts +30 -17
- package/dist/core/createApp.js +14 -3
- package/dist/core/createBlock.d.ts +2 -2
- package/dist/core/createBlock.js +17 -28
- package/dist/core/createLayout.d.ts +48 -4
- package/dist/core/createLayout.js +51 -23
- package/dist/core/derivedRoutes.js +36 -0
- package/dist/core/editing/BlockEditingRuntime.js +4 -4
- package/dist/core/editing/CompleteBlockEditingRuntime.js +5 -5
- package/dist/core/editing/createEditableBlock.d.ts +9 -8
- package/dist/core/editing/createEditableBlock.js +265 -403
- package/dist/core/hooks/useIsEditable.js +4 -7
- package/dist/core/hooks/useRequireDraftSource.js +7 -11
- package/dist/core/lib/lexicalReact.d.ts +1 -26
- package/dist/core/lib/lexicalReact.js +46 -60
- package/dist/core/lib/lexicalState.js +164 -81
- package/dist/core/lib/modifierFormats.js +4 -15
- package/dist/core/lib/textStyles.d.ts +27 -0
- package/dist/core/lib/textStyles.js +47 -0
- package/dist/features/navigation/navigation.d.ts +2 -0
- package/dist/features/navigation/navigation.js +51 -46
- package/dist/features/page/DerivedPageContent.js +61 -0
- package/dist/features/page/PublishedPageContent.js +52 -83
- package/dist/features/page/SharedLayoutContent.js +66 -0
- package/dist/features/preview/CamoxPreview.d.ts +16 -1
- package/dist/features/preview/CamoxPreview.js +246 -290
- package/dist/features/preview/DerivedPreview.js +134 -0
- package/dist/features/preview/EditablePageExperience.js +25 -8
- package/dist/features/preview/components/AddBlockSidebar.js +43 -33
- package/dist/features/preview/components/AssetLightbox.js +1 -1
- package/dist/features/preview/components/BlockActionsPopover.js +8 -8
- package/dist/features/preview/components/BlockThumbnail.js +192 -0
- package/dist/features/preview/components/CreatePageModal.js +123 -115
- package/dist/features/preview/components/DerivedLayoutDialog.js +100 -0
- package/dist/features/preview/components/DerivedLayoutSidebar.d.ts +5 -0
- package/dist/features/preview/components/DerivedLayoutSidebar.js +160 -0
- package/dist/features/preview/components/DerivedPageInfoSidebar.js +57 -0
- package/dist/features/preview/components/FieldToolbar.js +42 -20
- package/dist/features/preview/components/Frame.js +133 -140
- package/dist/features/preview/components/LeftSidebar.js +42 -38
- package/dist/features/preview/components/LinkFieldEditor.js +3 -4
- package/dist/features/preview/components/MobilePreviewDrawer.js +4 -4
- package/dist/features/preview/components/Overlays.js +59 -47
- package/dist/features/preview/components/PageEditorSidebar.js +194 -203
- package/dist/features/preview/components/PageInfoSidebar.js +63 -55
- package/dist/features/preview/components/PageNavigatorSidebar.js +34 -483
- package/dist/features/preview/components/PagePicker.js +205 -153
- package/dist/features/preview/components/PageTree.js +366 -340
- package/dist/features/preview/components/PreviewActivation.js +78 -0
- package/dist/features/preview/components/PreviewPanel.js +98 -68
- package/dist/features/preview/components/PreviewToolbar.js +224 -241
- package/dist/features/preview/components/PreviewToolbarSpacer.js +43 -0
- package/dist/features/preview/components/PublicationRow.js +425 -0
- package/dist/features/preview/components/PublishDialog.js +180 -97
- package/dist/features/preview/components/RightSidebar.js +19 -34
- package/dist/features/preview/components/previewStyles.js +8 -0
- package/dist/features/preview/components/useUpdateBlockPosition.js +7 -13
- package/dist/features/preview/previewConstants.js +8 -0
- package/dist/features/preview/previewStore.js +18 -39
- package/dist/features/preview/publication.js +71 -0
- package/dist/features/provider/AuthenticatedCamoxProvider.js +2 -1
- package/dist/features/provider/CoreCamoxProvider.js +11 -2
- package/dist/features/provider/LocalhostPreviewProvider.js +6 -7
- package/dist/features/provider/useAdminShortcuts.js +5 -4
- package/dist/features/routes/pageRuntime.d.ts +10 -0
- package/dist/features/routes/pageRuntime.js +7 -9
- package/dist/features/runtime/PreviewDocumentContext.js +7 -0
- package/dist/features/runtime/RuntimeChrome.js +149 -0
- package/dist/features/runtime/SharedChromeContext.js +7 -0
- package/dist/features/runtime/navigationRequest.js +21 -0
- package/dist/features/runtime/navigationTarget.js +23 -0
- package/dist/features/runtime/pageApp.js +196 -121
- package/dist/features/runtime/pageNavigation.js +79 -130
- package/dist/features/runtime/runtime.d.ts +11 -0
- package/dist/features/runtime/runtime.js +183 -47
- package/dist/features/runtime/studioApp.d.ts +2 -11
- package/dist/features/runtime/studioApp.js +14 -177
- package/dist/features/studio/CamoxStudio.js +27 -13
- package/dist/features/studio/components/Navbar.js +80 -74
- package/dist/features/studio/components/UserButton.js +4 -4
- package/dist/features/studio/studioTheme.js +25 -0
- package/dist/features/studio/useTheme.js +94 -109
- package/dist/features/vite/appGeneration.js +12 -3
- package/dist/features/vite/definitionsSync.js +4 -2
- package/dist/features/vite/layoutGeneration.js +38 -0
- package/dist/features/vite/runtimeDev.js +3 -1
- package/dist/lib/auth.js +15 -13
- package/dist/lib/normalized-data.js +4 -4
- package/dist/lib/platform.js +13 -0
- package/dist/lib/utils.js +90 -38
- package/dist/studio-overlays.css +5 -40
- package/dist/studio.css +1 -1
- package/package.json +8 -4
- package/skills/camox/SKILL.md +2 -0
- package/skills/camox/references/block-definitions.md +31 -12
- package/skills/camox/references/layout-definitions.md +2 -0
- package/dist/core/lib/modifiers.js +0 -24
- package/dist/features/preview/components/DraftSwitchDialog.js +0 -66
- package/dist/features/preview/previewQueryFns.js +0 -23
- 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
|
-
|
|
11
|
-
const $ = c(
|
|
12
|
-
if ($[0] !== "
|
|
13
|
-
for (let $i = 0; $i <
|
|
14
|
-
$[0] = "
|
|
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 {
|
|
17
|
-
|
|
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
|
-
|
|
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()
|
|
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] =
|
|
54
|
-
|
|
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] !==
|
|
57
|
-
t2 =
|
|
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
|
|
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(
|
|
82
|
+
iframeElement?.contentWindow?.postMessage(message, "*");
|
|
77
83
|
};
|
|
78
|
-
$[
|
|
79
|
-
$[
|
|
80
|
-
$[
|
|
81
|
-
$[
|
|
82
|
-
$[
|
|
83
|
-
} else
|
|
84
|
-
let
|
|
85
|
-
if ($[
|
|
86
|
-
|
|
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
|
-
$[
|
|
93
|
-
$[
|
|
94
|
-
$[
|
|
95
|
-
$[
|
|
96
|
-
$[
|
|
97
|
-
} else
|
|
98
|
-
React.useEffect(
|
|
99
|
-
|
|
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__ */
|
|
361
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
363
362
|
className: "relative flex-1 overflow-auto",
|
|
364
|
-
children:
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
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
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
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
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
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
|
-
|
|
517
|
-
|
|
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
|
-
|
|
522
|
-
|
|
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
|
|