camox 0.14.2 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/AuthGate.js +6 -0
- package/dist/core/components/AddBlockControlBar.js +30 -26
- package/dist/core/components/lexical/InlineContentEditable.js +19 -15
- package/dist/core/components/lexical/InlineLexicalEditor.js +62 -42
- package/dist/core/components/lexical/SelectionBroadcaster.js +25 -21
- package/dist/core/components/lexical/SidebarLexicalEditor.js +33 -21
- package/dist/core/createBlock.js +524 -488
- package/dist/core/createLayout.js +40 -28
- package/dist/core/hooks/useFieldSelection.js +12 -8
- package/dist/core/hooks/useIsEditable.js +6 -0
- package/dist/core/hooks/useOverlayMessage.js +19 -15
- package/dist/core/lib/contentType.d.ts +8 -8
- package/dist/core/lib/contentType.js +63 -0
- package/dist/features/content/CamoxContent.js +92 -88
- package/dist/features/content/components/AssetCard.js +46 -42
- package/dist/features/content/components/AssetCardSkeleton.js +8 -4
- package/dist/features/content/components/ContentSidebar.js +8 -4
- package/dist/features/content/components/UploadDropZone.js +31 -27
- package/dist/features/content/components/UploadProgressDrawer.js +98 -90
- package/dist/features/preview/CamoxPreview.js +162 -146
- package/dist/features/preview/components/AddBlockSheet.js +105 -101
- package/dist/features/preview/components/AgentChatSheet.js +74 -21
- package/dist/features/preview/components/AssetFieldEditor.js +98 -90
- package/dist/features/preview/components/AssetLightbox.js +21 -17
- package/dist/features/preview/components/AssetPickerGrid.js +84 -80
- package/dist/features/preview/components/BlockActionsPopover.js +35 -31
- package/dist/features/preview/components/BlockErrorBoundary.js +12 -8
- package/dist/features/preview/components/CreatePageModal.js +1 -1
- package/dist/features/preview/components/DebouncedFieldEditor.js +41 -37
- package/dist/features/preview/components/EditPageModal.js +114 -98
- package/dist/features/preview/components/FieldOverlayStyles.js +8 -4
- package/dist/features/preview/components/FieldToolbar.js +95 -54
- package/dist/features/preview/components/Frame.js +50 -46
- package/dist/features/preview/components/ItemFieldsEditor.js +81 -79
- package/dist/features/preview/components/LinkFieldEditor.js +138 -134
- package/dist/features/preview/components/MultipleAssetFieldEditor.js +105 -97
- package/dist/features/preview/components/OverlayTracker.js +19 -15
- package/dist/features/preview/components/Overlays.js +27 -23
- package/dist/features/preview/components/PageContentSheet.js +54 -4
- package/dist/features/preview/components/PageLocationFieldset.js +113 -109
- package/dist/features/preview/components/PagePicker.js +1 -1
- package/dist/features/preview/components/PageTree.js +443 -399
- package/dist/features/preview/components/PeekedBlock.js +69 -65
- package/dist/features/preview/components/PreviewPanel.js +64 -52
- package/dist/features/preview/components/PreviewSideSheet.js +25 -16
- package/dist/features/preview/components/PreviewToolbar.js +127 -123
- package/dist/features/preview/components/RepeatableItemsList.js +176 -171
- package/dist/features/preview/components/ShikiMarkdown.js +18 -14
- package/dist/features/preview/components/UnlinkAssetButton.js +74 -70
- package/dist/features/preview/components/useRepeatableItemActions.js +266 -0
- package/dist/features/preview/components/useUpdateBlockPosition.js +13 -9
- package/dist/features/provider/CamoxProvider.js +60 -52
- package/dist/features/provider/components/CamoxAppContext.js +10 -6
- package/dist/features/provider/components/CommandPalette.js +77 -69
- package/dist/features/provider/useAdminShortcuts.js +11 -7
- package/dist/features/routes/pageRoute.js +8 -4
- package/dist/features/studio/CamoxStudio.js +23 -19
- package/dist/features/studio/components/EnvironmentMenu.js +32 -28
- package/dist/features/studio/components/Navbar.js +62 -54
- package/dist/features/studio/components/ProjectMenu.js +131 -123
- package/dist/features/studio/components/UserButton.js +15 -11
- package/dist/features/studio/useTheme.js +82 -42
- package/dist/features/vite/definitionsSync.js +5 -5
- package/dist/features/vite/skillGeneration.js +43 -8
- package/dist/features/vite/vite.d.ts +1 -1
- package/dist/features/vite/vite.js +20 -2
- package/dist/hooks/use-marquee-selection.js +36 -32
- package/dist/lib/auth.js +49 -22
- package/dist/lib/normalized-data.js +55 -47
- package/dist/lib/use-project-room.js +22 -18
- package/dist/studio.css +1 -1
- package/package.json +10 -11
- package/skills/camox-block/SKILL.md +4 -0
- package/skills/camox-cli/SKILL.md +142 -0
- package/skills/camox-layout/SKILL.md +4 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { previewStore, selectionItemId } from "../previewStore.js";
|
|
2
2
|
import { repeatableItemMutations } from "../../../lib/queries.js";
|
|
3
3
|
import { cn } from "../../../lib/utils.js";
|
|
4
|
+
import { useRepeatableItemActions } from "./useRepeatableItemActions.js";
|
|
4
5
|
import { c } from "react/compiler-runtime";
|
|
5
6
|
import { useMutation } from "@tanstack/react-query";
|
|
6
7
|
import { useSelector } from "@xstate/store/react";
|
|
7
|
-
import { generateKeyBetween } from "fractional-indexing";
|
|
8
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
9
|
import { Button } from "@camox/ui/button";
|
|
10
10
|
import { Tooltip, TooltipContent, TooltipTrigger } from "@camox/ui/tooltip";
|
|
@@ -16,47 +16,51 @@ import { CSS } from "@dnd-kit/utilities";
|
|
|
16
16
|
|
|
17
17
|
//#region src/features/preview/components/RepeatableItemsList.tsx
|
|
18
18
|
const SortableRepeatableItem = (t0) => {
|
|
19
|
-
const $ = c(
|
|
19
|
+
const $ = c(47);
|
|
20
|
+
if ($[0] !== "4d49cc6148051733fc9bcda7aa88db74588442d3481baf1e20047b618caf419a") {
|
|
21
|
+
for (let $i = 0; $i < 47; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
22
|
+
$[0] = "4d49cc6148051733fc9bcda7aa88db74588442d3481baf1e20047b618caf419a";
|
|
23
|
+
}
|
|
20
24
|
const { item, fieldName, blockId, canRemove, onRemove } = t0;
|
|
21
25
|
const t1 = String(item.id);
|
|
22
26
|
let t2;
|
|
23
|
-
if ($[
|
|
27
|
+
if ($[1] !== t1) {
|
|
24
28
|
t2 = { id: t1 };
|
|
25
|
-
$[
|
|
26
|
-
$[
|
|
27
|
-
} else t2 = $[
|
|
29
|
+
$[1] = t1;
|
|
30
|
+
$[2] = t2;
|
|
31
|
+
} else t2 = $[2];
|
|
28
32
|
const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable(t2);
|
|
29
33
|
let t3;
|
|
30
|
-
if ($[
|
|
34
|
+
if ($[3] !== transform) {
|
|
31
35
|
t3 = CSS.Transform.toString(transform);
|
|
32
|
-
$[
|
|
33
|
-
$[
|
|
34
|
-
} else t3 = $[
|
|
36
|
+
$[3] = transform;
|
|
37
|
+
$[4] = t3;
|
|
38
|
+
} else t3 = $[4];
|
|
35
39
|
const t4 = isDragging ? .5 : 1;
|
|
36
40
|
let t5;
|
|
37
|
-
if ($[
|
|
41
|
+
if ($[5] !== t3 || $[6] !== t4 || $[7] !== transition) {
|
|
38
42
|
t5 = {
|
|
39
43
|
transform: t3,
|
|
40
44
|
transition,
|
|
41
45
|
opacity: t4
|
|
42
46
|
};
|
|
43
|
-
$[
|
|
44
|
-
$[
|
|
45
|
-
$[
|
|
46
|
-
$[
|
|
47
|
-
} else t5 = $[
|
|
47
|
+
$[5] = t3;
|
|
48
|
+
$[6] = t4;
|
|
49
|
+
$[7] = transition;
|
|
50
|
+
$[8] = t5;
|
|
51
|
+
} else t5 = $[8];
|
|
48
52
|
const style = t5;
|
|
49
53
|
let t6;
|
|
50
|
-
if ($[
|
|
54
|
+
if ($[9] !== item.id) {
|
|
51
55
|
t6 = (state) => selectionItemId(state.context.selection) === item.id;
|
|
52
|
-
$[
|
|
53
|
-
$[
|
|
54
|
-
} else t6 = $[
|
|
56
|
+
$[9] = item.id;
|
|
57
|
+
$[10] = t6;
|
|
58
|
+
} else t6 = $[10];
|
|
55
59
|
const isSelected = useSelector(previewStore, t6);
|
|
56
60
|
const iframeElement = useSelector(previewStore, _temp);
|
|
57
61
|
const shouldShowHover = !isDragging && !isSelected;
|
|
58
62
|
let t7;
|
|
59
|
-
if ($[
|
|
63
|
+
if ($[11] !== blockId || $[12] !== iframeElement || $[13] !== item.id) {
|
|
60
64
|
t7 = () => {
|
|
61
65
|
if (!iframeElement?.contentWindow) return;
|
|
62
66
|
const message = {
|
|
@@ -66,14 +70,14 @@ const SortableRepeatableItem = (t0) => {
|
|
|
66
70
|
};
|
|
67
71
|
iframeElement.contentWindow.postMessage(message, "*");
|
|
68
72
|
};
|
|
69
|
-
$[
|
|
70
|
-
$[
|
|
71
|
-
$[
|
|
72
|
-
$[
|
|
73
|
-
} else t7 = $[
|
|
73
|
+
$[11] = blockId;
|
|
74
|
+
$[12] = iframeElement;
|
|
75
|
+
$[13] = item.id;
|
|
76
|
+
$[14] = t7;
|
|
77
|
+
} else t7 = $[14];
|
|
74
78
|
const handleMouseEnter = t7;
|
|
75
79
|
let t8;
|
|
76
|
-
if ($[
|
|
80
|
+
if ($[15] !== blockId || $[16] !== iframeElement || $[17] !== item.id) {
|
|
77
81
|
t8 = () => {
|
|
78
82
|
if (!iframeElement?.contentWindow) return;
|
|
79
83
|
const message_0 = {
|
|
@@ -83,28 +87,28 @@ const SortableRepeatableItem = (t0) => {
|
|
|
83
87
|
};
|
|
84
88
|
iframeElement.contentWindow.postMessage(message_0, "*");
|
|
85
89
|
};
|
|
86
|
-
$[
|
|
87
|
-
$[
|
|
88
|
-
$[
|
|
89
|
-
$[
|
|
90
|
-
} else t8 = $[
|
|
90
|
+
$[15] = blockId;
|
|
91
|
+
$[16] = iframeElement;
|
|
92
|
+
$[17] = item.id;
|
|
93
|
+
$[18] = t8;
|
|
94
|
+
} else t8 = $[18];
|
|
91
95
|
const handleMouseLeave = t8;
|
|
92
96
|
const t9 = shouldShowHover && "hover:bg-accent/75";
|
|
93
97
|
const t10 = isSelected && "bg-accent text-accent-foreground";
|
|
94
98
|
let t11;
|
|
95
|
-
if ($[
|
|
99
|
+
if ($[19] !== t10 || $[20] !== t9) {
|
|
96
100
|
t11 = cn("flex flex-row justify-between items-center gap-2 px-1 py-1 max-w-full rounded-lg text-foreground transition-none group", t9, t10);
|
|
97
|
-
$[
|
|
98
|
-
$[
|
|
99
|
-
$[
|
|
100
|
-
} else t11 = $[
|
|
101
|
+
$[19] = t10;
|
|
102
|
+
$[20] = t9;
|
|
103
|
+
$[21] = t11;
|
|
104
|
+
} else t11 = $[21];
|
|
101
105
|
let t12;
|
|
102
|
-
if ($[
|
|
106
|
+
if ($[22] === Symbol.for("react.memo_cache_sentinel")) {
|
|
103
107
|
t12 = /* @__PURE__ */ jsx(GripVertical, { className: "h-4 w-4" });
|
|
104
|
-
$[
|
|
105
|
-
} else t12 = $[
|
|
108
|
+
$[22] = t12;
|
|
109
|
+
} else t12 = $[22];
|
|
106
110
|
let t13;
|
|
107
|
-
if ($[
|
|
111
|
+
if ($[23] !== attributes || $[24] !== listeners) {
|
|
108
112
|
t13 = /* @__PURE__ */ jsx(Button, {
|
|
109
113
|
type: "button",
|
|
110
114
|
variant: "ghost",
|
|
@@ -114,12 +118,12 @@ const SortableRepeatableItem = (t0) => {
|
|
|
114
118
|
...listeners,
|
|
115
119
|
children: t12
|
|
116
120
|
});
|
|
117
|
-
$[
|
|
118
|
-
$[
|
|
119
|
-
$[
|
|
120
|
-
} else t13 = $[
|
|
121
|
+
$[23] = attributes;
|
|
122
|
+
$[24] = listeners;
|
|
123
|
+
$[25] = t13;
|
|
124
|
+
} else t13 = $[25];
|
|
121
125
|
let t14;
|
|
122
|
-
if ($[
|
|
126
|
+
if ($[26] !== blockId || $[27] !== handleMouseLeave || $[28] !== item.id) {
|
|
123
127
|
t14 = () => {
|
|
124
128
|
handleMouseLeave();
|
|
125
129
|
previewStore.send({
|
|
@@ -128,14 +132,14 @@ const SortableRepeatableItem = (t0) => {
|
|
|
128
132
|
itemId: item.id
|
|
129
133
|
});
|
|
130
134
|
};
|
|
131
|
-
$[
|
|
132
|
-
$[
|
|
133
|
-
$[
|
|
134
|
-
$[
|
|
135
|
-
} else t14 = $[
|
|
135
|
+
$[26] = blockId;
|
|
136
|
+
$[27] = handleMouseLeave;
|
|
137
|
+
$[28] = item.id;
|
|
138
|
+
$[29] = t14;
|
|
139
|
+
} else t14 = $[29];
|
|
136
140
|
const t15 = item.summary || `${fieldName} (${item.id})`;
|
|
137
141
|
let t16;
|
|
138
|
-
if ($[
|
|
142
|
+
if ($[30] !== item.summary || $[31] !== t14 || $[32] !== t15) {
|
|
139
143
|
t16 = /* @__PURE__ */ jsx("div", {
|
|
140
144
|
className: "flex flex-1 items-center gap-1 overflow-x-hidden",
|
|
141
145
|
children: /* @__PURE__ */ jsx("p", {
|
|
@@ -145,13 +149,13 @@ const SortableRepeatableItem = (t0) => {
|
|
|
145
149
|
children: t15
|
|
146
150
|
})
|
|
147
151
|
});
|
|
148
|
-
$[
|
|
149
|
-
$[
|
|
150
|
-
$[
|
|
151
|
-
$[
|
|
152
|
-
} else t16 = $[
|
|
152
|
+
$[30] = item.summary;
|
|
153
|
+
$[31] = t14;
|
|
154
|
+
$[32] = t15;
|
|
155
|
+
$[33] = t16;
|
|
156
|
+
} else t16 = $[33];
|
|
153
157
|
let t17;
|
|
154
|
-
if ($[
|
|
158
|
+
if ($[34] !== canRemove || $[35] !== item.id || $[36] !== onRemove) {
|
|
155
159
|
t17 = canRemove && /* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsx(TooltipTrigger, {
|
|
156
160
|
render: /* @__PURE__ */ jsx(Button, {
|
|
157
161
|
type: "button",
|
|
@@ -168,13 +172,13 @@ const SortableRepeatableItem = (t0) => {
|
|
|
168
172
|
side: "right",
|
|
169
173
|
children: "Remove item"
|
|
170
174
|
})] });
|
|
171
|
-
$[
|
|
172
|
-
$[
|
|
173
|
-
$[
|
|
174
|
-
$[
|
|
175
|
-
} else t17 = $[
|
|
175
|
+
$[34] = canRemove;
|
|
176
|
+
$[35] = item.id;
|
|
177
|
+
$[36] = onRemove;
|
|
178
|
+
$[37] = t17;
|
|
179
|
+
} else t17 = $[37];
|
|
176
180
|
let t18;
|
|
177
|
-
if ($[
|
|
181
|
+
if ($[38] !== handleMouseEnter || $[39] !== handleMouseLeave || $[40] !== setNodeRef || $[41] !== style || $[42] !== t11 || $[43] !== t13 || $[44] !== t16 || $[45] !== t17) {
|
|
178
182
|
t18 = /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs("div", {
|
|
179
183
|
ref: setNodeRef,
|
|
180
184
|
style,
|
|
@@ -187,118 +191,90 @@ const SortableRepeatableItem = (t0) => {
|
|
|
187
191
|
t17
|
|
188
192
|
]
|
|
189
193
|
}) });
|
|
190
|
-
$[
|
|
191
|
-
$[
|
|
192
|
-
$[
|
|
193
|
-
$[
|
|
194
|
-
$[
|
|
195
|
-
$[
|
|
196
|
-
$[
|
|
197
|
-
$[
|
|
198
|
-
$[
|
|
199
|
-
} else t18 = $[
|
|
194
|
+
$[38] = handleMouseEnter;
|
|
195
|
+
$[39] = handleMouseLeave;
|
|
196
|
+
$[40] = setNodeRef;
|
|
197
|
+
$[41] = style;
|
|
198
|
+
$[42] = t11;
|
|
199
|
+
$[43] = t13;
|
|
200
|
+
$[44] = t16;
|
|
201
|
+
$[45] = t17;
|
|
202
|
+
$[46] = t18;
|
|
203
|
+
} else t18 = $[46];
|
|
200
204
|
return t18;
|
|
201
205
|
};
|
|
202
|
-
const RepeatableItemsList = (
|
|
203
|
-
const
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
const
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
if (itemsSchema?.properties) {
|
|
220
|
-
let seedCounter = 0;
|
|
221
|
-
const buildNestedSeeds = (properties, parentTempId) => {
|
|
222
|
-
for (const [nestedFieldName, fieldSchemaDef] of Object.entries(properties)) {
|
|
223
|
-
const fs = fieldSchemaDef;
|
|
224
|
-
if (fs.type !== "array" || !fs.items?.properties) continue;
|
|
225
|
-
const defaultCount = fs.defaultItems ?? fs.minItems ?? 0;
|
|
226
|
-
if (defaultCount <= 0) continue;
|
|
227
|
-
const nestedItemProps = fs.items.properties;
|
|
228
|
-
const nestedContent = {};
|
|
229
|
-
for (const [propName, propSchema] of Object.entries(nestedItemProps)) {
|
|
230
|
-
const ps = propSchema;
|
|
231
|
-
if (ps.type === "array" && ps.items?.properties) continue;
|
|
232
|
-
if ("default" in ps) nestedContent[propName] = ps.default;
|
|
233
|
-
}
|
|
234
|
-
const nestedSettingsDefaults = fs.defaultItemSettings;
|
|
235
|
-
let prevPos = null;
|
|
236
|
-
for (let i = 0; i < defaultCount; i++) {
|
|
237
|
-
const tempId = `nested_${++seedCounter}`;
|
|
238
|
-
const position = generateKeyBetween(prevPos, null);
|
|
239
|
-
prevPos = position;
|
|
240
|
-
nestedItems.push({
|
|
241
|
-
tempId,
|
|
242
|
-
parentTempId,
|
|
243
|
-
fieldName: nestedFieldName,
|
|
244
|
-
content: { ...nestedContent },
|
|
245
|
-
settings: nestedSettingsDefaults ? { ...nestedSettingsDefaults } : void 0,
|
|
246
|
-
position
|
|
247
|
-
});
|
|
248
|
-
buildNestedSeeds(nestedItemProps, tempId);
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
};
|
|
252
|
-
buildNestedSeeds(itemsSchema.properties, null);
|
|
253
|
-
}
|
|
254
|
-
createRepeatableItem.mutate({
|
|
206
|
+
const RepeatableItemsList = (t0) => {
|
|
207
|
+
const $ = c(25);
|
|
208
|
+
if ($[0] !== "4d49cc6148051733fc9bcda7aa88db74588442d3481baf1e20047b618caf419a") {
|
|
209
|
+
for (let $i = 0; $i < 25; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
210
|
+
$[0] = "4d49cc6148051733fc9bcda7aa88db74588442d3481baf1e20047b618caf419a";
|
|
211
|
+
}
|
|
212
|
+
const { items, blockId, fieldName, schema } = t0;
|
|
213
|
+
let t1;
|
|
214
|
+
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
|
|
215
|
+
t1 = repeatableItemMutations.updatePosition();
|
|
216
|
+
$[1] = t1;
|
|
217
|
+
} else t1 = $[1];
|
|
218
|
+
const updateRepeatablePosition = useMutation(t1);
|
|
219
|
+
const t2 = schema;
|
|
220
|
+
let t3;
|
|
221
|
+
if ($[2] !== blockId || $[3] !== fieldName || $[4] !== items.length || $[5] !== t2) {
|
|
222
|
+
t3 = {
|
|
255
223
|
blockId,
|
|
256
224
|
fieldName,
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
225
|
+
arraySchema: t2,
|
|
226
|
+
siblingCount: items.length
|
|
227
|
+
};
|
|
228
|
+
$[2] = blockId;
|
|
229
|
+
$[3] = fieldName;
|
|
230
|
+
$[4] = items.length;
|
|
231
|
+
$[5] = t2;
|
|
232
|
+
$[6] = t3;
|
|
233
|
+
} else t3 = $[6];
|
|
234
|
+
const { canAdd, addItem, canRemove, removeItem } = useRepeatableItemActions(t3);
|
|
235
|
+
let t4;
|
|
236
|
+
if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
|
|
237
|
+
t4 = { coordinateGetter: sortableKeyboardCoordinates };
|
|
238
|
+
$[7] = t4;
|
|
239
|
+
} else t4 = $[7];
|
|
240
|
+
const sensors = useSensors(useSensor(PointerSensor), useSensor(KeyboardSensor, t4));
|
|
241
|
+
let t5;
|
|
242
|
+
if ($[8] !== items || $[9] !== updateRepeatablePosition) {
|
|
243
|
+
t5 = async (event) => {
|
|
244
|
+
const { active, over } = event;
|
|
245
|
+
if (!over || active.id === over.id) return;
|
|
246
|
+
const oldIndex = items.findIndex((item) => String(item.id) === active.id);
|
|
247
|
+
const newIndex = items.findIndex((item_0) => String(item_0.id) === over.id);
|
|
248
|
+
if (oldIndex === -1 || newIndex === -1) return;
|
|
249
|
+
let afterPosition;
|
|
250
|
+
let beforePosition;
|
|
251
|
+
if (oldIndex < newIndex) {
|
|
252
|
+
afterPosition = items[newIndex].position;
|
|
253
|
+
beforePosition = newIndex < items.length - 1 ? items[newIndex + 1].position : void 0;
|
|
254
|
+
} else {
|
|
255
|
+
afterPosition = newIndex > 0 ? items[newIndex - 1].position : void 0;
|
|
256
|
+
beforePosition = items[newIndex].position;
|
|
257
|
+
}
|
|
258
|
+
await updateRepeatablePosition.mutateAsync({
|
|
259
|
+
id: Number(active.id),
|
|
260
|
+
afterPosition,
|
|
261
|
+
beforePosition
|
|
265
262
|
});
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
};
|
|
271
|
-
const
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
const oldIndex = items.findIndex((item) => String(item.id) === active.id);
|
|
276
|
-
const newIndex = items.findIndex((item_0) => String(item_0.id) === over.id);
|
|
277
|
-
if (oldIndex === -1 || newIndex === -1) return;
|
|
278
|
-
let afterPosition;
|
|
279
|
-
let beforePosition;
|
|
280
|
-
if (oldIndex < newIndex) {
|
|
281
|
-
afterPosition = items[newIndex].position;
|
|
282
|
-
beforePosition = newIndex < items.length - 1 ? items[newIndex + 1].position : void 0;
|
|
283
|
-
} else {
|
|
284
|
-
afterPosition = newIndex > 0 ? items[newIndex - 1].position : void 0;
|
|
285
|
-
beforePosition = items[newIndex].position;
|
|
286
|
-
}
|
|
287
|
-
await updateRepeatablePosition.mutateAsync({
|
|
288
|
-
id: Number(active.id),
|
|
289
|
-
afterPosition,
|
|
290
|
-
beforePosition
|
|
291
|
-
});
|
|
292
|
-
};
|
|
293
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
294
|
-
className: "flex flex-col gap-1",
|
|
295
|
-
children: [items.length > 0 && /* @__PURE__ */ jsx(DndContext, {
|
|
263
|
+
};
|
|
264
|
+
$[8] = items;
|
|
265
|
+
$[9] = updateRepeatablePosition;
|
|
266
|
+
$[10] = t5;
|
|
267
|
+
} else t5 = $[10];
|
|
268
|
+
const handleDragEnd = t5;
|
|
269
|
+
let t6;
|
|
270
|
+
if ($[11] !== blockId || $[12] !== canRemove || $[13] !== fieldName || $[14] !== handleDragEnd || $[15] !== items || $[16] !== removeItem || $[17] !== sensors) {
|
|
271
|
+
t6 = items.length > 0 && /* @__PURE__ */ jsx(DndContext, {
|
|
296
272
|
sensors,
|
|
297
273
|
collisionDetection: closestCenter,
|
|
298
274
|
onDragEnd: handleDragEnd,
|
|
299
275
|
modifiers: [restrictToVerticalAxis],
|
|
300
276
|
children: /* @__PURE__ */ jsx(SortableContext, {
|
|
301
|
-
items: items.map(
|
|
277
|
+
items: items.map(_temp2),
|
|
302
278
|
strategy: verticalListSortingStrategy,
|
|
303
279
|
children: /* @__PURE__ */ jsx("ul", {
|
|
304
280
|
className: "flex flex-col gap-1",
|
|
@@ -307,23 +283,52 @@ const RepeatableItemsList = ({ items, blockId, fieldName, minItems, maxItems, sc
|
|
|
307
283
|
blockId,
|
|
308
284
|
fieldName,
|
|
309
285
|
canRemove,
|
|
310
|
-
onRemove:
|
|
286
|
+
onRemove: removeItem
|
|
311
287
|
}, String(item_2.id)))
|
|
312
288
|
})
|
|
313
289
|
})
|
|
314
|
-
})
|
|
290
|
+
});
|
|
291
|
+
$[11] = blockId;
|
|
292
|
+
$[12] = canRemove;
|
|
293
|
+
$[13] = fieldName;
|
|
294
|
+
$[14] = handleDragEnd;
|
|
295
|
+
$[15] = items;
|
|
296
|
+
$[16] = removeItem;
|
|
297
|
+
$[17] = sensors;
|
|
298
|
+
$[18] = t6;
|
|
299
|
+
} else t6 = $[18];
|
|
300
|
+
let t7;
|
|
301
|
+
if ($[19] !== addItem || $[20] !== canAdd) {
|
|
302
|
+
t7 = canAdd && /* @__PURE__ */ jsxs(Button, {
|
|
315
303
|
type: "button",
|
|
316
304
|
variant: "ghost",
|
|
317
305
|
size: "sm",
|
|
318
306
|
className: "text-muted-foreground justify-start self-start",
|
|
319
|
-
onClick:
|
|
307
|
+
onClick: () => addItem(),
|
|
320
308
|
children: [/* @__PURE__ */ jsx(CirclePlus, { className: "h-4 w-4" }), "Add item"]
|
|
321
|
-
})
|
|
322
|
-
|
|
309
|
+
});
|
|
310
|
+
$[19] = addItem;
|
|
311
|
+
$[20] = canAdd;
|
|
312
|
+
$[21] = t7;
|
|
313
|
+
} else t7 = $[21];
|
|
314
|
+
let t8;
|
|
315
|
+
if ($[22] !== t6 || $[23] !== t7) {
|
|
316
|
+
t8 = /* @__PURE__ */ jsxs("div", {
|
|
317
|
+
className: "flex flex-col gap-1",
|
|
318
|
+
children: [t6, t7]
|
|
319
|
+
});
|
|
320
|
+
$[22] = t6;
|
|
321
|
+
$[23] = t7;
|
|
322
|
+
$[24] = t8;
|
|
323
|
+
} else t8 = $[24];
|
|
324
|
+
return t8;
|
|
323
325
|
};
|
|
324
326
|
function _temp(state_0) {
|
|
325
327
|
return state_0.context.iframeElement;
|
|
326
328
|
}
|
|
329
|
+
function _temp2(item_1) {
|
|
330
|
+
return String(item_1.id);
|
|
331
|
+
}
|
|
327
332
|
|
|
328
333
|
//#endregion
|
|
329
334
|
export { RepeatableItemsList };
|
|
@@ -12,12 +12,16 @@ const css = `
|
|
|
12
12
|
}
|
|
13
13
|
`;
|
|
14
14
|
const ShikiMarkdown = (t0) => {
|
|
15
|
-
const $ = c(
|
|
15
|
+
const $ = c(7);
|
|
16
|
+
if ($[0] !== "b223838fb3a1b4481de41582ca6cb14c501b277b861d32801b02a34152f069d4") {
|
|
17
|
+
for (let $i = 0; $i < 7; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
18
|
+
$[0] = "b223838fb3a1b4481de41582ca6cb14c501b277b861d32801b02a34152f069d4";
|
|
19
|
+
}
|
|
16
20
|
const { code } = t0;
|
|
17
21
|
const [html, setHtml] = React.useState("");
|
|
18
22
|
let t1;
|
|
19
23
|
let t2;
|
|
20
|
-
if ($[
|
|
24
|
+
if ($[1] !== code) {
|
|
21
25
|
t1 = () => {
|
|
22
26
|
let cancelled = false;
|
|
23
27
|
codeToHtml(code, {
|
|
@@ -35,29 +39,29 @@ const ShikiMarkdown = (t0) => {
|
|
|
35
39
|
};
|
|
36
40
|
};
|
|
37
41
|
t2 = [code];
|
|
38
|
-
$[
|
|
39
|
-
$[
|
|
40
|
-
$[
|
|
42
|
+
$[1] = code;
|
|
43
|
+
$[2] = t1;
|
|
44
|
+
$[3] = t2;
|
|
41
45
|
} else {
|
|
42
|
-
t1 = $[
|
|
43
|
-
t2 = $[
|
|
46
|
+
t1 = $[2];
|
|
47
|
+
t2 = $[3];
|
|
44
48
|
}
|
|
45
49
|
React.useEffect(t1, t2);
|
|
46
50
|
if (!html) return null;
|
|
47
51
|
let t3;
|
|
48
|
-
if ($[
|
|
52
|
+
if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
|
|
49
53
|
t3 = /* @__PURE__ */ jsx("style", { children: css });
|
|
50
|
-
$[
|
|
51
|
-
} else t3 = $[
|
|
54
|
+
$[4] = t3;
|
|
55
|
+
} else t3 = $[4];
|
|
52
56
|
let t4;
|
|
53
|
-
if ($[
|
|
57
|
+
if ($[5] !== html) {
|
|
54
58
|
t4 = /* @__PURE__ */ jsxs(Fragment, { children: [t3, /* @__PURE__ */ jsx("div", {
|
|
55
59
|
className: "border-input w-full min-w-0 overflow-hidden rounded-md border text-sm [&_code]:font-mono [&_pre]:rounded-md [&_pre]:px-3 [&_pre]:py-2 [&_pre]:break-all [&_pre]:whitespace-pre-wrap",
|
|
56
60
|
dangerouslySetInnerHTML: { __html: html }
|
|
57
61
|
})] });
|
|
58
|
-
$[
|
|
59
|
-
$[
|
|
60
|
-
} else t4 = $[
|
|
62
|
+
$[5] = html;
|
|
63
|
+
$[6] = t4;
|
|
64
|
+
} else t4 = $[6];
|
|
61
65
|
return t4;
|
|
62
66
|
};
|
|
63
67
|
|