@setzkasten-cms/ui 0.4.4 → 0.4.6
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/index.js +533 -325
- package/package.json +2 -2
- package/src/fields/array-field-renderer.tsx +97 -10
- package/src/fields/color-field-renderer.tsx +116 -0
- package/src/fields/date-field-renderer.tsx +39 -0
- package/src/fields/field-renderer.tsx +4 -0
- package/src/styles/admin.css +128 -0
package/dist/index.js
CHANGED
|
@@ -258,7 +258,7 @@ function createAppStore() {
|
|
|
258
258
|
}
|
|
259
259
|
|
|
260
260
|
// src/fields/field-renderer.tsx
|
|
261
|
-
import { memo as
|
|
261
|
+
import { memo as memo12 } from "react";
|
|
262
262
|
|
|
263
263
|
// src/fields/text-field-renderer.tsx
|
|
264
264
|
import { memo, useCallback as useCallback2, useEffect, useRef as useRef2, useState } from "react";
|
|
@@ -807,7 +807,7 @@ var IconFieldRenderer = memo5(function IconFieldRenderer2({
|
|
|
807
807
|
});
|
|
808
808
|
|
|
809
809
|
// src/fields/array-field-renderer.tsx
|
|
810
|
-
import { memo as memo6, useCallback as useCallback4 } from "react";
|
|
810
|
+
import { memo as memo6, useCallback as useCallback4, useState as useState3, useRef as useRef4 } from "react";
|
|
811
811
|
import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
812
812
|
var ArrayFieldRenderer = memo6(function ArrayFieldRenderer2({
|
|
813
813
|
field,
|
|
@@ -816,7 +816,12 @@ var ArrayFieldRenderer = memo6(function ArrayFieldRenderer2({
|
|
|
816
816
|
}) {
|
|
817
817
|
const arrayField = field;
|
|
818
818
|
const { value, setValue } = useField(store, path);
|
|
819
|
+
const [collapsedItems, setCollapsedItems] = useState3(/* @__PURE__ */ new Set());
|
|
820
|
+
const [dragIndex, setDragIndex] = useState3(null);
|
|
821
|
+
const [dragOverIndex, setDragOverIndex] = useState3(null);
|
|
822
|
+
const dragCounter = useRef4(0);
|
|
819
823
|
const items = value ?? [];
|
|
824
|
+
const isGrid = arrayField.layout === "grid";
|
|
820
825
|
const addItem = useCallback4(() => {
|
|
821
826
|
const defaultValue = arrayField.itemField.defaultValue ?? (arrayField.itemField.type === "object" ? {} : arrayField.itemField.type === "text" ? "" : arrayField.itemField.type === "number" ? 0 : arrayField.itemField.type === "boolean" ? false : null);
|
|
822
827
|
setValue([...items, defaultValue]);
|
|
@@ -829,6 +834,7 @@ var ArrayFieldRenderer = memo6(function ArrayFieldRenderer2({
|
|
|
829
834
|
);
|
|
830
835
|
const moveItem = useCallback4(
|
|
831
836
|
(from, to) => {
|
|
837
|
+
if (from === to) return;
|
|
832
838
|
const newItems = [...items];
|
|
833
839
|
const [moved] = newItems.splice(from, 1);
|
|
834
840
|
newItems.splice(to, 0, moved);
|
|
@@ -836,8 +842,53 @@ var ArrayFieldRenderer = memo6(function ArrayFieldRenderer2({
|
|
|
836
842
|
},
|
|
837
843
|
[items, setValue]
|
|
838
844
|
);
|
|
845
|
+
const toggleCollapse = useCallback4((index) => {
|
|
846
|
+
setCollapsedItems((prev) => {
|
|
847
|
+
const next = new Set(prev);
|
|
848
|
+
if (next.has(index)) next.delete(index);
|
|
849
|
+
else next.add(index);
|
|
850
|
+
return next;
|
|
851
|
+
});
|
|
852
|
+
}, []);
|
|
853
|
+
const handleDragStart = useCallback4((e, index) => {
|
|
854
|
+
setDragIndex(index);
|
|
855
|
+
e.dataTransfer.effectAllowed = "move";
|
|
856
|
+
e.dataTransfer.setData("text/plain", String(index));
|
|
857
|
+
}, []);
|
|
858
|
+
const handleDragEnter = useCallback4((index) => {
|
|
859
|
+
dragCounter.current++;
|
|
860
|
+
setDragOverIndex(index);
|
|
861
|
+
}, []);
|
|
862
|
+
const handleDragLeave = useCallback4(() => {
|
|
863
|
+
dragCounter.current--;
|
|
864
|
+
if (dragCounter.current === 0) {
|
|
865
|
+
setDragOverIndex(null);
|
|
866
|
+
}
|
|
867
|
+
}, []);
|
|
868
|
+
const handleDragOver = useCallback4((e) => {
|
|
869
|
+
e.preventDefault();
|
|
870
|
+
e.dataTransfer.dropEffect = "move";
|
|
871
|
+
}, []);
|
|
872
|
+
const handleDrop = useCallback4(
|
|
873
|
+
(e, toIndex) => {
|
|
874
|
+
e.preventDefault();
|
|
875
|
+
dragCounter.current = 0;
|
|
876
|
+
if (dragIndex !== null) {
|
|
877
|
+
moveItem(dragIndex, toIndex);
|
|
878
|
+
}
|
|
879
|
+
setDragIndex(null);
|
|
880
|
+
setDragOverIndex(null);
|
|
881
|
+
},
|
|
882
|
+
[dragIndex, moveItem]
|
|
883
|
+
);
|
|
884
|
+
const handleDragEnd = useCallback4(() => {
|
|
885
|
+
dragCounter.current = 0;
|
|
886
|
+
setDragIndex(null);
|
|
887
|
+
setDragOverIndex(null);
|
|
888
|
+
}, []);
|
|
839
889
|
const canAdd = arrayField.maxItems === void 0 || items.length < arrayField.maxItems;
|
|
840
890
|
const canRemove = arrayField.minItems === void 0 || items.length > arrayField.minItems;
|
|
891
|
+
const gridStyle = isGrid ? { gridTemplateColumns: `repeat(${arrayField.gridColumns}, 1fr)` } : void 0;
|
|
841
892
|
return /* @__PURE__ */ jsxs6("div", { className: "sk-field sk-field--array", children: [
|
|
842
893
|
/* @__PURE__ */ jsx7("div", { className: "sk-array__header", children: /* @__PURE__ */ jsxs6("label", { className: "sk-field__label", children: [
|
|
843
894
|
arrayField.label,
|
|
@@ -847,33 +898,59 @@ var ArrayFieldRenderer = memo6(function ArrayFieldRenderer2({
|
|
|
847
898
|
")"
|
|
848
899
|
] })
|
|
849
900
|
] }) }),
|
|
850
|
-
/* @__PURE__ */ jsx7(
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
901
|
+
/* @__PURE__ */ jsx7(
|
|
902
|
+
"div",
|
|
903
|
+
{
|
|
904
|
+
className: `sk-array__items ${isGrid ? "sk-array__items--grid" : ""}`,
|
|
905
|
+
style: gridStyle,
|
|
906
|
+
children: items.map((_, index) => {
|
|
907
|
+
const itemLabel = arrayField.itemLabel ? arrayField.itemLabel(items[index], index) : `#${index + 1}`;
|
|
908
|
+
const isCollapsed = arrayField.collapsible && collapsedItems.has(index);
|
|
909
|
+
const isDragging = dragIndex === index;
|
|
910
|
+
const isDragOver = dragOverIndex === index && dragIndex !== index;
|
|
911
|
+
return /* @__PURE__ */ jsxs6(
|
|
912
|
+
"div",
|
|
913
|
+
{
|
|
914
|
+
className: `sk-array__item ${isDragging ? "sk-array__item--dragging" : ""} ${isDragOver ? "sk-array__item--dragover" : ""}`,
|
|
915
|
+
draggable: true,
|
|
916
|
+
onDragStart: (e) => handleDragStart(e, index),
|
|
917
|
+
onDragEnter: () => handleDragEnter(index),
|
|
918
|
+
onDragLeave: handleDragLeave,
|
|
919
|
+
onDragOver: handleDragOver,
|
|
920
|
+
onDrop: (e) => handleDrop(e, index),
|
|
921
|
+
onDragEnd: handleDragEnd,
|
|
922
|
+
children: [
|
|
923
|
+
/* @__PURE__ */ jsxs6("div", { className: "sk-array__item-header", children: [
|
|
924
|
+
/* @__PURE__ */ jsx7("span", { className: "sk-array__item-drag", title: "Ziehen zum Sortieren", children: "\u283F" }),
|
|
925
|
+
/* @__PURE__ */ jsx7("span", { className: "sk-array__item-label", children: itemLabel }),
|
|
926
|
+
/* @__PURE__ */ jsxs6("div", { className: "sk-array__item-actions", children: [
|
|
927
|
+
!isGrid && index > 0 && /* @__PURE__ */ jsx7("button", { type: "button", className: "sk-button sk-button--sm", onClick: () => moveItem(index, index - 1), title: "Nach oben", children: "\u2191" }),
|
|
928
|
+
!isGrid && index < items.length - 1 && /* @__PURE__ */ jsx7("button", { type: "button", className: "sk-button sk-button--sm", onClick: () => moveItem(index, index + 1), title: "Nach unten", children: "\u2193" }),
|
|
929
|
+
arrayField.collapsible && /* @__PURE__ */ jsx7("button", { type: "button", className: "sk-button sk-button--sm", onClick: () => toggleCollapse(index), title: isCollapsed ? "Aufklappen" : "Zuklappen", children: isCollapsed ? "\u25B8" : "\u25BE" }),
|
|
930
|
+
canRemove && /* @__PURE__ */ jsx7("button", { type: "button", className: "sk-button sk-button--sm sk-button--danger", onClick: () => removeItem(index), title: "Entfernen", children: "\xD7" })
|
|
931
|
+
] })
|
|
932
|
+
] }),
|
|
933
|
+
!isCollapsed && /* @__PURE__ */ jsx7(
|
|
934
|
+
FieldRenderer,
|
|
935
|
+
{
|
|
936
|
+
field: arrayField.itemField,
|
|
937
|
+
path: [...path, index],
|
|
938
|
+
store
|
|
939
|
+
}
|
|
940
|
+
)
|
|
941
|
+
]
|
|
942
|
+
},
|
|
943
|
+
index
|
|
944
|
+
);
|
|
945
|
+
})
|
|
946
|
+
}
|
|
947
|
+
),
|
|
871
948
|
canAdd && /* @__PURE__ */ jsx7("button", { type: "button", className: "sk-button sk-button--sm sk-array__add", onClick: addItem, children: "+ Hinzuf\xFCgen" })
|
|
872
949
|
] });
|
|
873
950
|
});
|
|
874
951
|
|
|
875
952
|
// src/fields/object-field-renderer.tsx
|
|
876
|
-
import { memo as memo7, useState as
|
|
953
|
+
import { memo as memo7, useState as useState4 } from "react";
|
|
877
954
|
import { jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
878
955
|
var ObjectFieldRenderer = memo7(function ObjectFieldRenderer2({
|
|
879
956
|
field,
|
|
@@ -881,7 +958,7 @@ var ObjectFieldRenderer = memo7(function ObjectFieldRenderer2({
|
|
|
881
958
|
store
|
|
882
959
|
}) {
|
|
883
960
|
const objField = field;
|
|
884
|
-
const [collapsed, setCollapsed] =
|
|
961
|
+
const [collapsed, setCollapsed] = useState4(false);
|
|
885
962
|
return /* @__PURE__ */ jsxs7("div", { className: "sk-field sk-field--object", children: [
|
|
886
963
|
/* @__PURE__ */ jsxs7("div", { className: "sk-field__object-header", children: [
|
|
887
964
|
/* @__PURE__ */ jsx8("label", { className: "sk-field__label", children: objField.label }),
|
|
@@ -908,7 +985,7 @@ var ObjectFieldRenderer = memo7(function ObjectFieldRenderer2({
|
|
|
908
985
|
});
|
|
909
986
|
|
|
910
987
|
// src/fields/image-field-renderer.tsx
|
|
911
|
-
import { memo as memo8, useCallback as useCallback5, useRef as
|
|
988
|
+
import { memo as memo8, useCallback as useCallback5, useRef as useRef5, useState as useState5 } from "react";
|
|
912
989
|
import { jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
913
990
|
function previewUrl(assets, path) {
|
|
914
991
|
return assets.getPreviewUrl?.(path) ?? assets.getUrl(path);
|
|
@@ -935,13 +1012,13 @@ var ImageFieldRenderer = memo8(function ImageFieldRenderer2({
|
|
|
935
1012
|
const imgField = field;
|
|
936
1013
|
const { value, errors, setValue, touch } = useField(store, path);
|
|
937
1014
|
const assets = useAssets();
|
|
938
|
-
const fileInputRef =
|
|
939
|
-
const [uploading, setUploading] =
|
|
940
|
-
const [dragOver, setDragOver] =
|
|
941
|
-
const [showBrowser, setShowBrowser] =
|
|
942
|
-
const [browserScope, setBrowserScope] =
|
|
943
|
-
const [existing, setExisting] =
|
|
944
|
-
const [loadingExisting, setLoadingExisting] =
|
|
1015
|
+
const fileInputRef = useRef5(null);
|
|
1016
|
+
const [uploading, setUploading] = useState5(false);
|
|
1017
|
+
const [dragOver, setDragOver] = useState5(false);
|
|
1018
|
+
const [showBrowser, setShowBrowser] = useState5(false);
|
|
1019
|
+
const [browserScope, setBrowserScope] = useState5("directory");
|
|
1020
|
+
const [existing, setExisting] = useState5([]);
|
|
1021
|
+
const [loadingExisting, setLoadingExisting] = useState5(false);
|
|
945
1022
|
const imageValue = value;
|
|
946
1023
|
const acceptStr = imgField.accept.map((ext) => `.${ext}`).join(",");
|
|
947
1024
|
const selectedThumbUrl = imageValue?.path && assets.getPreviewUrl ? assets.getPreviewUrl(imageValue.path) : imageValue?.path || void 0;
|
|
@@ -1111,10 +1188,139 @@ var ImageFieldRenderer = memo8(function ImageFieldRenderer2({
|
|
|
1111
1188
|
] });
|
|
1112
1189
|
});
|
|
1113
1190
|
|
|
1114
|
-
// src/fields/
|
|
1191
|
+
// src/fields/date-field-renderer.tsx
|
|
1115
1192
|
import { memo as memo9 } from "react";
|
|
1116
1193
|
import { jsx as jsx10, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1117
|
-
var
|
|
1194
|
+
var DateFieldRenderer = memo9(function DateFieldRenderer2({
|
|
1195
|
+
field,
|
|
1196
|
+
path,
|
|
1197
|
+
store
|
|
1198
|
+
}) {
|
|
1199
|
+
const dateField = field;
|
|
1200
|
+
const { value, errors, setValue, touch } = useField(store, path);
|
|
1201
|
+
const inputType = dateField.includeTime ? "datetime-local" : "date";
|
|
1202
|
+
return /* @__PURE__ */ jsxs9("div", { className: "sk-field sk-field--date", children: [
|
|
1203
|
+
/* @__PURE__ */ jsx10("label", { className: "sk-field__label", children: dateField.label }),
|
|
1204
|
+
dateField.description && /* @__PURE__ */ jsx10("p", { className: "sk-field__description", children: dateField.description }),
|
|
1205
|
+
/* @__PURE__ */ jsx10(
|
|
1206
|
+
"input",
|
|
1207
|
+
{
|
|
1208
|
+
className: "sk-field__input",
|
|
1209
|
+
type: inputType,
|
|
1210
|
+
value: value ?? "",
|
|
1211
|
+
onChange: (e) => setValue(e.target.value),
|
|
1212
|
+
onBlur: touch,
|
|
1213
|
+
min: dateField.min,
|
|
1214
|
+
max: dateField.max,
|
|
1215
|
+
"aria-label": dateField.label
|
|
1216
|
+
}
|
|
1217
|
+
),
|
|
1218
|
+
errors.length > 0 && /* @__PURE__ */ jsx10("div", { className: "sk-field__errors", children: errors.map((err3, i) => /* @__PURE__ */ jsx10("p", { className: "sk-field__error", children: err3 }, i)) })
|
|
1219
|
+
] });
|
|
1220
|
+
});
|
|
1221
|
+
|
|
1222
|
+
// src/fields/color-field-renderer.tsx
|
|
1223
|
+
import { memo as memo10, useState as useState6, useCallback as useCallback6, useRef as useRef6, useEffect as useEffect3 } from "react";
|
|
1224
|
+
import { jsx as jsx11, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1225
|
+
var ColorFieldRenderer = memo10(function ColorFieldRenderer2({
|
|
1226
|
+
field,
|
|
1227
|
+
path,
|
|
1228
|
+
store
|
|
1229
|
+
}) {
|
|
1230
|
+
const colorField = field;
|
|
1231
|
+
const { value, errors, setValue, touch } = useField(store, path);
|
|
1232
|
+
const [showPicker, setShowPicker] = useState6(false);
|
|
1233
|
+
const containerRef = useRef6(null);
|
|
1234
|
+
const currentColor = value || "#000000";
|
|
1235
|
+
useEffect3(() => {
|
|
1236
|
+
if (!showPicker) return;
|
|
1237
|
+
const handleClick = (e) => {
|
|
1238
|
+
if (containerRef.current && !containerRef.current.contains(e.target)) {
|
|
1239
|
+
setShowPicker(false);
|
|
1240
|
+
}
|
|
1241
|
+
};
|
|
1242
|
+
document.addEventListener("mousedown", handleClick);
|
|
1243
|
+
return () => document.removeEventListener("mousedown", handleClick);
|
|
1244
|
+
}, [showPicker]);
|
|
1245
|
+
const handleColorInput = useCallback6(
|
|
1246
|
+
(e) => {
|
|
1247
|
+
setValue(e.target.value);
|
|
1248
|
+
},
|
|
1249
|
+
[setValue]
|
|
1250
|
+
);
|
|
1251
|
+
const handleHexInput = useCallback6(
|
|
1252
|
+
(e) => {
|
|
1253
|
+
let hex = e.target.value;
|
|
1254
|
+
if (!hex.startsWith("#")) hex = "#" + hex;
|
|
1255
|
+
if (/^#[0-9a-fA-F]{6}$/.test(hex)) {
|
|
1256
|
+
setValue(hex);
|
|
1257
|
+
}
|
|
1258
|
+
},
|
|
1259
|
+
[setValue]
|
|
1260
|
+
);
|
|
1261
|
+
const handlePresetClick = useCallback6(
|
|
1262
|
+
(preset) => {
|
|
1263
|
+
setValue(preset);
|
|
1264
|
+
},
|
|
1265
|
+
[setValue]
|
|
1266
|
+
);
|
|
1267
|
+
return /* @__PURE__ */ jsxs10("div", { className: "sk-field sk-field--color", ref: containerRef, children: [
|
|
1268
|
+
/* @__PURE__ */ jsx11("label", { className: "sk-field__label", children: colorField.label }),
|
|
1269
|
+
colorField.description && /* @__PURE__ */ jsx11("p", { className: "sk-field__description", children: colorField.description }),
|
|
1270
|
+
/* @__PURE__ */ jsxs10("div", { className: "sk-color__row", children: [
|
|
1271
|
+
/* @__PURE__ */ jsx11(
|
|
1272
|
+
"button",
|
|
1273
|
+
{
|
|
1274
|
+
type: "button",
|
|
1275
|
+
className: "sk-color__swatch",
|
|
1276
|
+
style: { backgroundColor: currentColor },
|
|
1277
|
+
onClick: () => setShowPicker(!showPicker),
|
|
1278
|
+
"aria-label": "Farbe w\xE4hlen"
|
|
1279
|
+
}
|
|
1280
|
+
),
|
|
1281
|
+
/* @__PURE__ */ jsx11(
|
|
1282
|
+
"input",
|
|
1283
|
+
{
|
|
1284
|
+
className: "sk-field__input sk-color__hex",
|
|
1285
|
+
type: "text",
|
|
1286
|
+
value: currentColor,
|
|
1287
|
+
onChange: handleHexInput,
|
|
1288
|
+
onBlur: touch,
|
|
1289
|
+
placeholder: "#000000",
|
|
1290
|
+
maxLength: 7,
|
|
1291
|
+
"aria-label": colorField.label
|
|
1292
|
+
}
|
|
1293
|
+
)
|
|
1294
|
+
] }),
|
|
1295
|
+
showPicker && /* @__PURE__ */ jsx11("div", { className: "sk-color__picker", children: /* @__PURE__ */ jsx11(
|
|
1296
|
+
"input",
|
|
1297
|
+
{
|
|
1298
|
+
type: "color",
|
|
1299
|
+
className: "sk-color__native",
|
|
1300
|
+
value: currentColor,
|
|
1301
|
+
onChange: handleColorInput
|
|
1302
|
+
}
|
|
1303
|
+
) }),
|
|
1304
|
+
colorField.presets.length > 0 && /* @__PURE__ */ jsx11("div", { className: "sk-color__presets", children: colorField.presets.map((preset) => /* @__PURE__ */ jsx11(
|
|
1305
|
+
"button",
|
|
1306
|
+
{
|
|
1307
|
+
type: "button",
|
|
1308
|
+
className: `sk-color__preset ${preset === currentColor ? "sk-color__preset--active" : ""}`,
|
|
1309
|
+
style: { backgroundColor: preset },
|
|
1310
|
+
onClick: () => handlePresetClick(preset),
|
|
1311
|
+
title: preset,
|
|
1312
|
+
"aria-label": `Farbe ${preset}`
|
|
1313
|
+
},
|
|
1314
|
+
preset
|
|
1315
|
+
)) }),
|
|
1316
|
+
errors.length > 0 && /* @__PURE__ */ jsx11("div", { className: "sk-field__errors", children: errors.map((err3, i) => /* @__PURE__ */ jsx11("p", { className: "sk-field__error", children: err3 }, i)) })
|
|
1317
|
+
] });
|
|
1318
|
+
});
|
|
1319
|
+
|
|
1320
|
+
// src/fields/override-field-renderer.tsx
|
|
1321
|
+
import { memo as memo11 } from "react";
|
|
1322
|
+
import { jsx as jsx12, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1323
|
+
var OverrideFieldRenderer = memo11(function OverrideFieldRenderer2({
|
|
1118
1324
|
field,
|
|
1119
1325
|
path,
|
|
1120
1326
|
store
|
|
@@ -1126,12 +1332,12 @@ var OverrideFieldRenderer = memo9(function OverrideFieldRenderer2({
|
|
|
1126
1332
|
const toggleActive = () => {
|
|
1127
1333
|
setValue({ ...overrideValue, active: !isActive });
|
|
1128
1334
|
};
|
|
1129
|
-
return /* @__PURE__ */
|
|
1130
|
-
/* @__PURE__ */
|
|
1131
|
-
/* @__PURE__ */
|
|
1132
|
-
/* @__PURE__ */
|
|
1335
|
+
return /* @__PURE__ */ jsxs11("div", { className: "sk-field sk-field--override", "data-active": isActive || void 0, children: [
|
|
1336
|
+
/* @__PURE__ */ jsx12("div", { className: "sk-field__override-header", children: /* @__PURE__ */ jsxs11("label", { className: "sk-field__toggle", children: [
|
|
1337
|
+
/* @__PURE__ */ jsx12("input", { type: "checkbox", checked: isActive, onChange: toggleActive }),
|
|
1338
|
+
/* @__PURE__ */ jsx12("span", { className: "sk-field__toggle-label", children: overrideField.label })
|
|
1133
1339
|
] }) }),
|
|
1134
|
-
isActive && /* @__PURE__ */
|
|
1340
|
+
isActive && /* @__PURE__ */ jsx12("div", { className: "sk-field__override-fields", children: Object.entries(overrideField.fields).map(([key, childField]) => /* @__PURE__ */ jsx12(
|
|
1135
1341
|
FieldRenderer,
|
|
1136
1342
|
{
|
|
1137
1343
|
field: childField,
|
|
@@ -1144,7 +1350,7 @@ var OverrideFieldRenderer = memo9(function OverrideFieldRenderer2({
|
|
|
1144
1350
|
});
|
|
1145
1351
|
|
|
1146
1352
|
// src/fields/field-renderer.tsx
|
|
1147
|
-
import { jsx as
|
|
1353
|
+
import { jsx as jsx13, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
1148
1354
|
var rendererMap = {
|
|
1149
1355
|
text: TextFieldRenderer,
|
|
1150
1356
|
number: NumberFieldRenderer,
|
|
@@ -1154,27 +1360,29 @@ var rendererMap = {
|
|
|
1154
1360
|
array: ArrayFieldRenderer,
|
|
1155
1361
|
object: ObjectFieldRenderer,
|
|
1156
1362
|
image: ImageFieldRenderer,
|
|
1363
|
+
date: DateFieldRenderer,
|
|
1364
|
+
color: ColorFieldRenderer,
|
|
1157
1365
|
override: OverrideFieldRenderer
|
|
1158
1366
|
};
|
|
1159
|
-
var FieldRenderer =
|
|
1367
|
+
var FieldRenderer = memo12(function FieldRenderer2({
|
|
1160
1368
|
field,
|
|
1161
1369
|
path,
|
|
1162
1370
|
store
|
|
1163
1371
|
}) {
|
|
1164
1372
|
const Renderer = rendererMap[field.type];
|
|
1165
1373
|
if (!Renderer) {
|
|
1166
|
-
return /* @__PURE__ */
|
|
1374
|
+
return /* @__PURE__ */ jsxs12("div", { style: { color: "#ef4444", padding: "8px", fontSize: "14px" }, children: [
|
|
1167
1375
|
"Unknown field type: ",
|
|
1168
1376
|
field.type
|
|
1169
1377
|
] });
|
|
1170
1378
|
}
|
|
1171
|
-
return /* @__PURE__ */
|
|
1379
|
+
return /* @__PURE__ */ jsx13(Renderer, { field, path, store });
|
|
1172
1380
|
});
|
|
1173
1381
|
|
|
1174
1382
|
// src/components/entry-form.tsx
|
|
1175
|
-
import { memo as
|
|
1176
|
-
import { jsx as
|
|
1177
|
-
var EntryForm =
|
|
1383
|
+
import { memo as memo13, useEffect as useEffect4, useMemo as useMemo4 } from "react";
|
|
1384
|
+
import { jsx as jsx14, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
1385
|
+
var EntryForm = memo13(function EntryForm2({
|
|
1178
1386
|
schema,
|
|
1179
1387
|
initialValues,
|
|
1180
1388
|
draftValues,
|
|
@@ -1182,7 +1390,7 @@ var EntryForm = memo11(function EntryForm2({
|
|
|
1182
1390
|
storeRef
|
|
1183
1391
|
}) {
|
|
1184
1392
|
const store = useMemo4(() => createFormStore(), []);
|
|
1185
|
-
|
|
1393
|
+
useEffect4(() => {
|
|
1186
1394
|
if (storeRef) {
|
|
1187
1395
|
storeRef.current = store;
|
|
1188
1396
|
}
|
|
@@ -1192,7 +1400,7 @@ var EntryForm = memo11(function EntryForm2({
|
|
|
1192
1400
|
}
|
|
1193
1401
|
};
|
|
1194
1402
|
}, [store, storeRef]);
|
|
1195
|
-
|
|
1403
|
+
useEffect4(() => {
|
|
1196
1404
|
store.getState().init(schema, initialValues, draftValues);
|
|
1197
1405
|
}, [store, schema, initialValues, draftValues]);
|
|
1198
1406
|
const handleSave = () => {
|
|
@@ -1201,8 +1409,8 @@ var EntryForm = memo11(function EntryForm2({
|
|
|
1201
1409
|
onSave(values);
|
|
1202
1410
|
}
|
|
1203
1411
|
};
|
|
1204
|
-
return /* @__PURE__ */
|
|
1205
|
-
/* @__PURE__ */
|
|
1412
|
+
return /* @__PURE__ */ jsxs13("div", { className: "sk-entry-form", children: [
|
|
1413
|
+
/* @__PURE__ */ jsx14("div", { className: "sk-entry-form__fields", children: Object.entries(schema).map(([key, field]) => /* @__PURE__ */ jsx14(
|
|
1206
1414
|
FieldRenderer,
|
|
1207
1415
|
{
|
|
1208
1416
|
field,
|
|
@@ -1211,13 +1419,13 @@ var EntryForm = memo11(function EntryForm2({
|
|
|
1211
1419
|
},
|
|
1212
1420
|
key
|
|
1213
1421
|
)) }),
|
|
1214
|
-
onSave && /* @__PURE__ */
|
|
1422
|
+
onSave && /* @__PURE__ */ jsx14("div", { className: "sk-entry-form__actions", children: /* @__PURE__ */ jsx14("button", { type: "button", className: "sk-button sk-button--primary", onClick: handleSave, children: "Speichern" }) })
|
|
1215
1423
|
] });
|
|
1216
1424
|
});
|
|
1217
1425
|
|
|
1218
1426
|
// src/components/entry-list.tsx
|
|
1219
|
-
import { useEffect as
|
|
1220
|
-
import { jsx as
|
|
1427
|
+
import { useEffect as useEffect5, useState as useState7, useCallback as useCallback7 } from "react";
|
|
1428
|
+
import { jsx as jsx15, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
1221
1429
|
function EntryList({
|
|
1222
1430
|
collection,
|
|
1223
1431
|
label,
|
|
@@ -1226,9 +1434,9 @@ function EntryList({
|
|
|
1226
1434
|
selectedSlug
|
|
1227
1435
|
}) {
|
|
1228
1436
|
const repository = useRepository();
|
|
1229
|
-
const [entries, setEntries] =
|
|
1230
|
-
const [loading, setLoading] =
|
|
1231
|
-
const loadEntries =
|
|
1437
|
+
const [entries, setEntries] = useState7([]);
|
|
1438
|
+
const [loading, setLoading] = useState7(true);
|
|
1439
|
+
const loadEntries = useCallback7(async () => {
|
|
1232
1440
|
setLoading(true);
|
|
1233
1441
|
const result = await repository.listEntries(collection);
|
|
1234
1442
|
if (result.ok) {
|
|
@@ -1236,10 +1444,10 @@ function EntryList({
|
|
|
1236
1444
|
}
|
|
1237
1445
|
setLoading(false);
|
|
1238
1446
|
}, [repository, collection]);
|
|
1239
|
-
|
|
1447
|
+
useEffect5(() => {
|
|
1240
1448
|
loadEntries();
|
|
1241
1449
|
}, [loadEntries]);
|
|
1242
|
-
const handleDelete =
|
|
1450
|
+
const handleDelete = useCallback7(
|
|
1243
1451
|
async (slug) => {
|
|
1244
1452
|
if (!confirm(`"${slug}" wirklich l\xF6schen?`)) return;
|
|
1245
1453
|
const result = await repository.deleteEntry(collection, slug);
|
|
@@ -1250,16 +1458,16 @@ function EntryList({
|
|
|
1250
1458
|
[repository, collection, loadEntries]
|
|
1251
1459
|
);
|
|
1252
1460
|
if (loading) {
|
|
1253
|
-
return /* @__PURE__ */
|
|
1254
|
-
/* @__PURE__ */
|
|
1255
|
-
/* @__PURE__ */
|
|
1461
|
+
return /* @__PURE__ */ jsxs14("div", { className: "sk-entry-list sk-entry-list--loading", children: [
|
|
1462
|
+
/* @__PURE__ */ jsx15("div", { className: "sk-entry-list__header", children: /* @__PURE__ */ jsx15("h2", { className: "sk-entry-list__title", children: label }) }),
|
|
1463
|
+
/* @__PURE__ */ jsx15("div", { className: "sk-entry-list__empty", children: "Lade..." })
|
|
1256
1464
|
] });
|
|
1257
1465
|
}
|
|
1258
|
-
return /* @__PURE__ */
|
|
1259
|
-
/* @__PURE__ */
|
|
1260
|
-
/* @__PURE__ */
|
|
1261
|
-
/* @__PURE__ */
|
|
1262
|
-
/* @__PURE__ */
|
|
1466
|
+
return /* @__PURE__ */ jsxs14("div", { className: "sk-entry-list", children: [
|
|
1467
|
+
/* @__PURE__ */ jsxs14("div", { className: "sk-entry-list__header", children: [
|
|
1468
|
+
/* @__PURE__ */ jsx15("h2", { className: "sk-entry-list__title", children: label }),
|
|
1469
|
+
/* @__PURE__ */ jsx15("span", { className: "sk-entry-list__count", children: entries.length }),
|
|
1470
|
+
/* @__PURE__ */ jsx15(
|
|
1263
1471
|
"button",
|
|
1264
1472
|
{
|
|
1265
1473
|
type: "button",
|
|
@@ -1269,9 +1477,9 @@ function EntryList({
|
|
|
1269
1477
|
}
|
|
1270
1478
|
)
|
|
1271
1479
|
] }),
|
|
1272
|
-
entries.length === 0 ? /* @__PURE__ */
|
|
1273
|
-
/* @__PURE__ */
|
|
1274
|
-
/* @__PURE__ */
|
|
1480
|
+
entries.length === 0 ? /* @__PURE__ */ jsxs14("div", { className: "sk-entry-list__empty", children: [
|
|
1481
|
+
/* @__PURE__ */ jsx15("p", { children: "Noch keine Eintr\xE4ge." }),
|
|
1482
|
+
/* @__PURE__ */ jsx15(
|
|
1275
1483
|
"button",
|
|
1276
1484
|
{
|
|
1277
1485
|
type: "button",
|
|
@@ -1280,24 +1488,24 @@ function EntryList({
|
|
|
1280
1488
|
children: "Ersten Eintrag erstellen"
|
|
1281
1489
|
}
|
|
1282
1490
|
)
|
|
1283
|
-
] }) : /* @__PURE__ */
|
|
1491
|
+
] }) : /* @__PURE__ */ jsx15("ul", { className: "sk-entry-list__items", role: "list", children: entries.map((entry) => /* @__PURE__ */ jsxs14(
|
|
1284
1492
|
"li",
|
|
1285
1493
|
{
|
|
1286
1494
|
className: `sk-entry-list__item ${entry.slug === selectedSlug ? "sk-entry-list__item--active" : ""}`,
|
|
1287
1495
|
children: [
|
|
1288
|
-
/* @__PURE__ */
|
|
1496
|
+
/* @__PURE__ */ jsxs14(
|
|
1289
1497
|
"button",
|
|
1290
1498
|
{
|
|
1291
1499
|
type: "button",
|
|
1292
1500
|
className: "sk-entry-list__item-btn",
|
|
1293
1501
|
onClick: () => onSelect(entry.slug),
|
|
1294
1502
|
children: [
|
|
1295
|
-
/* @__PURE__ */
|
|
1296
|
-
/* @__PURE__ */
|
|
1503
|
+
/* @__PURE__ */ jsx15("span", { className: "sk-entry-list__item-name", children: entry.name }),
|
|
1504
|
+
/* @__PURE__ */ jsx15("span", { className: "sk-entry-list__item-slug", children: entry.slug })
|
|
1297
1505
|
]
|
|
1298
1506
|
}
|
|
1299
1507
|
),
|
|
1300
|
-
/* @__PURE__ */
|
|
1508
|
+
/* @__PURE__ */ jsx15(
|
|
1301
1509
|
"button",
|
|
1302
1510
|
{
|
|
1303
1511
|
type: "button",
|
|
@@ -1319,16 +1527,16 @@ function EntryList({
|
|
|
1319
1527
|
}
|
|
1320
1528
|
|
|
1321
1529
|
// src/components/collection-view.tsx
|
|
1322
|
-
import { useState as
|
|
1323
|
-
import { jsx as
|
|
1530
|
+
import { useState as useState8, useCallback as useCallback8, useRef as useRef7 } from "react";
|
|
1531
|
+
import { jsx as jsx16, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
1324
1532
|
function CollectionView({ collectionKey, collection }) {
|
|
1325
1533
|
const repository = useRepository();
|
|
1326
|
-
const [selectedSlug, setSelectedSlug] =
|
|
1327
|
-
const [entryData, setEntryData] =
|
|
1328
|
-
const [loading, setLoading] =
|
|
1329
|
-
const [creating, setCreating] =
|
|
1330
|
-
const formStoreRef =
|
|
1331
|
-
const loadEntry =
|
|
1534
|
+
const [selectedSlug, setSelectedSlug] = useState8(null);
|
|
1535
|
+
const [entryData, setEntryData] = useState8(null);
|
|
1536
|
+
const [loading, setLoading] = useState8(false);
|
|
1537
|
+
const [creating, setCreating] = useState8(false);
|
|
1538
|
+
const formStoreRef = useRef7(null);
|
|
1539
|
+
const loadEntry = useCallback8(
|
|
1332
1540
|
async (slug) => {
|
|
1333
1541
|
setLoading(true);
|
|
1334
1542
|
setCreating(false);
|
|
@@ -1341,12 +1549,12 @@ function CollectionView({ collectionKey, collection }) {
|
|
|
1341
1549
|
},
|
|
1342
1550
|
[repository, collectionKey]
|
|
1343
1551
|
);
|
|
1344
|
-
const handleCreate =
|
|
1552
|
+
const handleCreate = useCallback8(() => {
|
|
1345
1553
|
setSelectedSlug(null);
|
|
1346
1554
|
setEntryData({});
|
|
1347
1555
|
setCreating(true);
|
|
1348
1556
|
}, []);
|
|
1349
|
-
const handleSave =
|
|
1557
|
+
const handleSave = useCallback8(
|
|
1350
1558
|
async (values) => {
|
|
1351
1559
|
const slug = creating ? prompt("Slug f\xFCr den neuen Eintrag:") : selectedSlug;
|
|
1352
1560
|
if (!slug) return;
|
|
@@ -1361,8 +1569,8 @@ function CollectionView({ collectionKey, collection }) {
|
|
|
1361
1569
|
},
|
|
1362
1570
|
[repository, collectionKey, selectedSlug, creating]
|
|
1363
1571
|
);
|
|
1364
|
-
return /* @__PURE__ */
|
|
1365
|
-
/* @__PURE__ */
|
|
1572
|
+
return /* @__PURE__ */ jsxs15("div", { className: "sk-collection-view", children: [
|
|
1573
|
+
/* @__PURE__ */ jsx16("div", { className: "sk-collection-view__list", children: /* @__PURE__ */ jsx16(
|
|
1366
1574
|
EntryList,
|
|
1367
1575
|
{
|
|
1368
1576
|
collection: collectionKey,
|
|
@@ -1372,9 +1580,9 @@ function CollectionView({ collectionKey, collection }) {
|
|
|
1372
1580
|
selectedSlug: selectedSlug ?? void 0
|
|
1373
1581
|
}
|
|
1374
1582
|
) }),
|
|
1375
|
-
/* @__PURE__ */
|
|
1376
|
-
/* @__PURE__ */
|
|
1377
|
-
/* @__PURE__ */
|
|
1583
|
+
/* @__PURE__ */ jsx16("div", { className: "sk-collection-view__editor", children: loading ? /* @__PURE__ */ jsx16("div", { className: "sk-empty", children: /* @__PURE__ */ jsx16("p", { children: "Lade Eintrag..." }) }) : entryData !== null ? /* @__PURE__ */ jsxs15("div", { children: [
|
|
1584
|
+
/* @__PURE__ */ jsx16("div", { className: "sk-collection-view__editor-header", children: /* @__PURE__ */ jsx16("h3", { children: creating ? "Neuer Eintrag" : selectedSlug }) }),
|
|
1585
|
+
/* @__PURE__ */ jsx16(
|
|
1378
1586
|
EntryForm,
|
|
1379
1587
|
{
|
|
1380
1588
|
schema: collection.fields,
|
|
@@ -1384,19 +1592,19 @@ function CollectionView({ collectionKey, collection }) {
|
|
|
1384
1592
|
},
|
|
1385
1593
|
selectedSlug ?? "new"
|
|
1386
1594
|
)
|
|
1387
|
-
] }) : /* @__PURE__ */
|
|
1595
|
+
] }) : /* @__PURE__ */ jsx16("div", { className: "sk-empty", children: /* @__PURE__ */ jsx16("p", { children: "W\xE4hle einen Eintrag aus der Liste oder erstelle einen neuen." }) }) })
|
|
1388
1596
|
] });
|
|
1389
1597
|
}
|
|
1390
1598
|
|
|
1391
1599
|
// src/components/admin-app.tsx
|
|
1392
|
-
import { useState as
|
|
1600
|
+
import { useState as useState11, useEffect as useEffect8 } from "react";
|
|
1393
1601
|
|
|
1394
1602
|
// src/components/page-builder.tsx
|
|
1395
|
-
import { useState as
|
|
1603
|
+
import { useState as useState10, useEffect as useEffect7, useCallback as useCallback10, useRef as useRef8, useSyncExternalStore } from "react";
|
|
1396
1604
|
|
|
1397
1605
|
// src/components/toast.tsx
|
|
1398
|
-
import { useState as
|
|
1399
|
-
import { jsx as
|
|
1606
|
+
import { useState as useState9, useCallback as useCallback9, createContext as createContext2, useContext as useContext2 } from "react";
|
|
1607
|
+
import { jsx as jsx17, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
1400
1608
|
var ToastContext = createContext2({ toast: () => {
|
|
1401
1609
|
} });
|
|
1402
1610
|
function useToast() {
|
|
@@ -1404,17 +1612,17 @@ function useToast() {
|
|
|
1404
1612
|
}
|
|
1405
1613
|
var nextId = 0;
|
|
1406
1614
|
function ToastProvider({ children }) {
|
|
1407
|
-
const [toasts, setToasts] =
|
|
1408
|
-
const toast =
|
|
1615
|
+
const [toasts, setToasts] = useState9([]);
|
|
1616
|
+
const toast = useCallback9((message, type = "info") => {
|
|
1409
1617
|
const id = nextId++;
|
|
1410
1618
|
setToasts((prev) => [...prev, { id, message, type }]);
|
|
1411
1619
|
setTimeout(() => {
|
|
1412
1620
|
setToasts((prev) => prev.filter((t) => t.id !== id));
|
|
1413
1621
|
}, 3e3);
|
|
1414
1622
|
}, []);
|
|
1415
|
-
return /* @__PURE__ */
|
|
1623
|
+
return /* @__PURE__ */ jsxs16(ToastContext.Provider, { value: { toast }, children: [
|
|
1416
1624
|
children,
|
|
1417
|
-
toasts.length > 0 && /* @__PURE__ */
|
|
1625
|
+
toasts.length > 0 && /* @__PURE__ */ jsx17("div", { className: "sk-toast-container", children: toasts.map((t) => /* @__PURE__ */ jsx17("div", { className: `sk-toast sk-toast--${t.type}`, children: t.message }, t.id)) })
|
|
1418
1626
|
] });
|
|
1419
1627
|
}
|
|
1420
1628
|
|
|
@@ -1457,7 +1665,7 @@ import {
|
|
|
1457
1665
|
Redo2,
|
|
1458
1666
|
Trash2
|
|
1459
1667
|
} from "lucide-react";
|
|
1460
|
-
import { Fragment as Fragment3, jsx as
|
|
1668
|
+
import { Fragment as Fragment3, jsx as jsx18, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
1461
1669
|
var ICON_MAP = {
|
|
1462
1670
|
layout: LayoutGrid,
|
|
1463
1671
|
star: Star,
|
|
@@ -1481,11 +1689,11 @@ var ICON_MAP = {
|
|
|
1481
1689
|
users: Users
|
|
1482
1690
|
};
|
|
1483
1691
|
function useDraggable() {
|
|
1484
|
-
const [offset, setOffset] =
|
|
1485
|
-
const dragging =
|
|
1486
|
-
const start =
|
|
1487
|
-
const startOffset =
|
|
1488
|
-
const onMouseDown =
|
|
1692
|
+
const [offset, setOffset] = useState10({ x: 0, y: 0 });
|
|
1693
|
+
const dragging = useRef8(false);
|
|
1694
|
+
const start = useRef8({ x: 0, y: 0 });
|
|
1695
|
+
const startOffset = useRef8({ x: 0, y: 0 });
|
|
1696
|
+
const onMouseDown = useCallback10((e) => {
|
|
1489
1697
|
const target = e.target;
|
|
1490
1698
|
if (target.closest("button") || target.closest("input") || target.closest("select")) return;
|
|
1491
1699
|
if (!target.closest(".sk-pb__nav-header, .sk-pb__slide-over-header, .sk-pb__drag-handle")) return;
|
|
@@ -1508,20 +1716,20 @@ function useDraggable() {
|
|
|
1508
1716
|
document.addEventListener("mousemove", onMouseMove);
|
|
1509
1717
|
document.addEventListener("mouseup", onMouseUp);
|
|
1510
1718
|
}, [offset]);
|
|
1511
|
-
const reset =
|
|
1719
|
+
const reset = useCallback10(() => setOffset({ x: 0, y: 0 }), []);
|
|
1512
1720
|
const hasMoved = offset.x !== 0 || offset.y !== 0;
|
|
1513
1721
|
const style = hasMoved ? { transform: `translate(${offset.x}px, ${offset.y}px)` } : void 0;
|
|
1514
1722
|
return { onMouseDown, style, offset, reset, hasMoved };
|
|
1515
1723
|
}
|
|
1516
1724
|
function useResizable(defaultWidth, minW = 280, maxW = 800, minH = 200, maxH = 900) {
|
|
1517
|
-
const [width, setWidth] =
|
|
1518
|
-
const [height, setHeight] =
|
|
1519
|
-
const resizing =
|
|
1520
|
-
const startMouse =
|
|
1521
|
-
const startW =
|
|
1522
|
-
const startH =
|
|
1523
|
-
const mode =
|
|
1524
|
-
const onResizeStart =
|
|
1725
|
+
const [width, setWidth] = useState10(defaultWidth);
|
|
1726
|
+
const [height, setHeight] = useState10(0);
|
|
1727
|
+
const resizing = useRef8(false);
|
|
1728
|
+
const startMouse = useRef8({ x: 0, y: 0 });
|
|
1729
|
+
const startW = useRef8(defaultWidth);
|
|
1730
|
+
const startH = useRef8(0);
|
|
1731
|
+
const mode = useRef8("bl");
|
|
1732
|
+
const onResizeStart = useCallback10((e, corner) => {
|
|
1525
1733
|
e.preventDefault();
|
|
1526
1734
|
e.stopPropagation();
|
|
1527
1735
|
resizing.current = true;
|
|
@@ -1548,7 +1756,7 @@ function useResizable(defaultWidth, minW = 280, maxW = 800, minH = 200, maxH = 9
|
|
|
1548
1756
|
document.addEventListener("mousemove", onMouseMove);
|
|
1549
1757
|
document.addEventListener("mouseup", onMouseUp);
|
|
1550
1758
|
}, [width, height, minW, maxW, minH, maxH]);
|
|
1551
|
-
const reset =
|
|
1759
|
+
const reset = useCallback10(() => {
|
|
1552
1760
|
setWidth(defaultWidth);
|
|
1553
1761
|
setHeight(0);
|
|
1554
1762
|
}, [defaultWidth]);
|
|
@@ -1559,31 +1767,31 @@ function PageBuilder({ pageKey = "index", pages = [], onPageChange, onExit }) {
|
|
|
1559
1767
|
const config = useConfig();
|
|
1560
1768
|
const repository = useRepository();
|
|
1561
1769
|
const { toast } = useToast();
|
|
1562
|
-
const [pageConfig, setPageConfig] =
|
|
1563
|
-
const [visibleSection, setVisibleSection] =
|
|
1564
|
-
const [editingSection, setEditingSection] =
|
|
1565
|
-
const [editorOpen, setEditorOpen] =
|
|
1566
|
-
const [viewport, setViewport] =
|
|
1567
|
-
const [loading, setLoading] =
|
|
1568
|
-
const [previewKey, setPreviewKey] =
|
|
1569
|
-
const [configDirty, setConfigDirty] =
|
|
1570
|
-
const [savingConfig, setSavingConfig] =
|
|
1571
|
-
const [configSha, setConfigSha] =
|
|
1572
|
-
const [navCollapsed, setNavCollapsed] =
|
|
1573
|
-
const [editorCollapsed, setEditorCollapsed] =
|
|
1574
|
-
const [dragIndex, setDragIndex] =
|
|
1575
|
-
const [dragOverIndex, setDragOverIndex] =
|
|
1576
|
-
const iframeRef =
|
|
1577
|
-
const navRef =
|
|
1578
|
-
const scrollAfterLoadRef =
|
|
1579
|
-
const draftCacheRef =
|
|
1770
|
+
const [pageConfig, setPageConfig] = useState10(null);
|
|
1771
|
+
const [visibleSection, setVisibleSection] = useState10(null);
|
|
1772
|
+
const [editingSection, setEditingSection] = useState10(null);
|
|
1773
|
+
const [editorOpen, setEditorOpen] = useState10(false);
|
|
1774
|
+
const [viewport, setViewport] = useState10("compact");
|
|
1775
|
+
const [loading, setLoading] = useState10(true);
|
|
1776
|
+
const [previewKey, setPreviewKey] = useState10(0);
|
|
1777
|
+
const [configDirty, setConfigDirty] = useState10(false);
|
|
1778
|
+
const [savingConfig, setSavingConfig] = useState10(false);
|
|
1779
|
+
const [configSha, setConfigSha] = useState10();
|
|
1780
|
+
const [navCollapsed, setNavCollapsed] = useState10(true);
|
|
1781
|
+
const [editorCollapsed, setEditorCollapsed] = useState10(false);
|
|
1782
|
+
const [dragIndex, setDragIndex] = useState10(null);
|
|
1783
|
+
const [dragOverIndex, setDragOverIndex] = useState10(null);
|
|
1784
|
+
const iframeRef = useRef8(null);
|
|
1785
|
+
const navRef = useRef8(null);
|
|
1786
|
+
const scrollAfterLoadRef = useRef8(null);
|
|
1787
|
+
const draftCacheRef = useRef8({});
|
|
1580
1788
|
const navDrag = useDraggable();
|
|
1581
1789
|
const editorDrag = useDraggable();
|
|
1582
1790
|
const editorResize = useResizable(380);
|
|
1583
|
-
const [compactSplit, setCompactSplit] =
|
|
1791
|
+
const [compactSplit, setCompactSplit] = useState10(66);
|
|
1584
1792
|
const compactSplitDefault = 66;
|
|
1585
|
-
const pbRef =
|
|
1586
|
-
const onSplitDragStart =
|
|
1793
|
+
const pbRef = useRef8(null);
|
|
1794
|
+
const onSplitDragStart = useCallback10((e) => {
|
|
1587
1795
|
e.preventDefault();
|
|
1588
1796
|
const root = pbRef.current;
|
|
1589
1797
|
if (!root) return;
|
|
@@ -1604,7 +1812,7 @@ function PageBuilder({ pageKey = "index", pages = [], onPageChange, onExit }) {
|
|
|
1604
1812
|
document.addEventListener("mousemove", onMouseMove);
|
|
1605
1813
|
document.addEventListener("mouseup", onMouseUp);
|
|
1606
1814
|
}, []);
|
|
1607
|
-
const resetAllPositions =
|
|
1815
|
+
const resetAllPositions = useCallback10(() => {
|
|
1608
1816
|
navDrag.reset();
|
|
1609
1817
|
editorDrag.reset();
|
|
1610
1818
|
editorResize.reset();
|
|
@@ -1613,7 +1821,7 @@ function PageBuilder({ pageKey = "index", pages = [], onPageChange, onExit }) {
|
|
|
1613
1821
|
const compactSplitMoved = compactSplit !== compactSplitDefault;
|
|
1614
1822
|
const anyMoved = navDrag.hasMoved || editorDrag.hasMoved || editorResize.hasResized || compactSplitMoved;
|
|
1615
1823
|
const configKey = "_" + pageKey.replace(/\//g, "--");
|
|
1616
|
-
|
|
1824
|
+
useEffect7(() => {
|
|
1617
1825
|
loadPageConfig();
|
|
1618
1826
|
}, [pageKey]);
|
|
1619
1827
|
async function loadPageConfig() {
|
|
@@ -1640,7 +1848,7 @@ function PageBuilder({ pageKey = "index", pages = [], onPageChange, onExit }) {
|
|
|
1640
1848
|
}
|
|
1641
1849
|
return null;
|
|
1642
1850
|
}
|
|
1643
|
-
const scrollToSection =
|
|
1851
|
+
const scrollToSection = useCallback10((sectionKey) => {
|
|
1644
1852
|
const iframe = iframeRef.current;
|
|
1645
1853
|
if (!iframe?.contentWindow) return;
|
|
1646
1854
|
iframe.contentWindow.postMessage(
|
|
@@ -1648,7 +1856,7 @@ function PageBuilder({ pageKey = "index", pages = [], onPageChange, onExit }) {
|
|
|
1648
1856
|
"*"
|
|
1649
1857
|
);
|
|
1650
1858
|
}, []);
|
|
1651
|
-
const syncSectionsToPreview =
|
|
1859
|
+
const syncSectionsToPreview = useCallback10((sections2) => {
|
|
1652
1860
|
const iframe = iframeRef.current;
|
|
1653
1861
|
if (!iframe?.contentWindow) return;
|
|
1654
1862
|
iframe.contentWindow.postMessage(
|
|
@@ -1656,9 +1864,9 @@ function PageBuilder({ pageKey = "index", pages = [], onPageChange, onExit }) {
|
|
|
1656
1864
|
"*"
|
|
1657
1865
|
);
|
|
1658
1866
|
}, []);
|
|
1659
|
-
const pageConfigRef =
|
|
1867
|
+
const pageConfigRef = useRef8(pageConfig);
|
|
1660
1868
|
pageConfigRef.current = pageConfig;
|
|
1661
|
-
const handleIframeLoad =
|
|
1869
|
+
const handleIframeLoad = useCallback10(() => {
|
|
1662
1870
|
setTimeout(() => {
|
|
1663
1871
|
if (scrollAfterLoadRef.current) {
|
|
1664
1872
|
scrollToSection(scrollAfterLoadRef.current);
|
|
@@ -1669,7 +1877,7 @@ function PageBuilder({ pageKey = "index", pages = [], onPageChange, onExit }) {
|
|
|
1669
1877
|
}
|
|
1670
1878
|
}, 200);
|
|
1671
1879
|
}, [scrollToSection, syncSectionsToPreview]);
|
|
1672
|
-
|
|
1880
|
+
useEffect7(() => {
|
|
1673
1881
|
function handleMessage(event) {
|
|
1674
1882
|
if (event.data?.type === "sk:visible-section") {
|
|
1675
1883
|
setVisibleSection(event.data.section);
|
|
@@ -1678,22 +1886,22 @@ function PageBuilder({ pageKey = "index", pages = [], onPageChange, onExit }) {
|
|
|
1678
1886
|
window.addEventListener("message", handleMessage);
|
|
1679
1887
|
return () => window.removeEventListener("message", handleMessage);
|
|
1680
1888
|
}, []);
|
|
1681
|
-
const openEditor =
|
|
1889
|
+
const openEditor = useCallback10((sectionKey) => {
|
|
1682
1890
|
setEditingSection(sectionKey);
|
|
1683
1891
|
setEditorOpen(true);
|
|
1684
1892
|
setEditorCollapsed(false);
|
|
1685
1893
|
scrollToSection(sectionKey);
|
|
1686
1894
|
}, [scrollToSection]);
|
|
1687
|
-
const closeEditor =
|
|
1895
|
+
const closeEditor = useCallback10(() => {
|
|
1688
1896
|
setEditorOpen(false);
|
|
1689
1897
|
setEditorCollapsed(false);
|
|
1690
1898
|
setEditingSection(null);
|
|
1691
1899
|
}, []);
|
|
1692
|
-
const reloadPreview =
|
|
1900
|
+
const reloadPreview = useCallback10((scrollTo) => {
|
|
1693
1901
|
scrollAfterLoadRef.current = scrollTo ?? visibleSection;
|
|
1694
1902
|
setPreviewKey((k) => k + 1);
|
|
1695
1903
|
}, [visibleSection]);
|
|
1696
|
-
const needsSsrReload =
|
|
1904
|
+
const needsSsrReload = useCallback10((sectionKey, values) => {
|
|
1697
1905
|
const product = Object.values(config.products)[0];
|
|
1698
1906
|
const section = product?.sections[sectionKey];
|
|
1699
1907
|
if (!section) return true;
|
|
@@ -1722,7 +1930,7 @@ function PageBuilder({ pageKey = "index", pages = [], onPageChange, onExit }) {
|
|
|
1722
1930
|
}
|
|
1723
1931
|
return hasNonTextChanges(prev, values, section.fields);
|
|
1724
1932
|
}, [config]);
|
|
1725
|
-
const updateDraft =
|
|
1933
|
+
const updateDraft = useCallback10((sectionKey, values) => {
|
|
1726
1934
|
const requiresReload = needsSsrReload(sectionKey, values);
|
|
1727
1935
|
draftCacheRef.current[sectionKey] = values;
|
|
1728
1936
|
if (requiresReload) {
|
|
@@ -1742,7 +1950,7 @@ function PageBuilder({ pageKey = "index", pages = [], onPageChange, onExit }) {
|
|
|
1742
1950
|
);
|
|
1743
1951
|
}
|
|
1744
1952
|
}, [needsSsrReload, reloadPreview]);
|
|
1745
|
-
const clearDraftCache =
|
|
1953
|
+
const clearDraftCache = useCallback10((sectionKey) => {
|
|
1746
1954
|
delete draftCacheRef.current[sectionKey];
|
|
1747
1955
|
fetch("/api/setzkasten/draft", {
|
|
1748
1956
|
method: "DELETE",
|
|
@@ -1751,11 +1959,11 @@ function PageBuilder({ pageKey = "index", pages = [], onPageChange, onExit }) {
|
|
|
1751
1959
|
}).catch(() => {
|
|
1752
1960
|
});
|
|
1753
1961
|
}, []);
|
|
1754
|
-
const discardDraft =
|
|
1962
|
+
const discardDraft = useCallback10((sectionKey) => {
|
|
1755
1963
|
clearDraftCache(sectionKey);
|
|
1756
1964
|
reloadPreview(sectionKey);
|
|
1757
1965
|
}, [clearDraftCache, reloadPreview]);
|
|
1758
|
-
const toggleSection =
|
|
1966
|
+
const toggleSection = useCallback10((sectionKey) => {
|
|
1759
1967
|
setPageConfig((prev) => {
|
|
1760
1968
|
if (!prev) return prev;
|
|
1761
1969
|
const updated = {
|
|
@@ -1769,14 +1977,14 @@ function PageBuilder({ pageKey = "index", pages = [], onPageChange, onExit }) {
|
|
|
1769
1977
|
});
|
|
1770
1978
|
setConfigDirty(true);
|
|
1771
1979
|
}, [syncSectionsToPreview]);
|
|
1772
|
-
const handleDragStart =
|
|
1980
|
+
const handleDragStart = useCallback10((index) => {
|
|
1773
1981
|
setDragIndex(index);
|
|
1774
1982
|
}, []);
|
|
1775
|
-
const handleDragOver =
|
|
1983
|
+
const handleDragOver = useCallback10((e, index) => {
|
|
1776
1984
|
e.preventDefault();
|
|
1777
1985
|
setDragOverIndex(index);
|
|
1778
1986
|
}, []);
|
|
1779
|
-
const handleDragEnd =
|
|
1987
|
+
const handleDragEnd = useCallback10(() => {
|
|
1780
1988
|
if (dragIndex !== null && dragOverIndex !== null && dragIndex !== dragOverIndex) {
|
|
1781
1989
|
setPageConfig((prev) => {
|
|
1782
1990
|
if (!prev) return prev;
|
|
@@ -1793,7 +2001,7 @@ function PageBuilder({ pageKey = "index", pages = [], onPageChange, onExit }) {
|
|
|
1793
2001
|
setDragIndex(null);
|
|
1794
2002
|
setDragOverIndex(null);
|
|
1795
2003
|
}, [dragIndex, dragOverIndex, syncSectionsToPreview]);
|
|
1796
|
-
const savePageConfig =
|
|
2004
|
+
const savePageConfig = useCallback10(async () => {
|
|
1797
2005
|
if (!pageConfig || savingConfig) return;
|
|
1798
2006
|
setSavingConfig(true);
|
|
1799
2007
|
try {
|
|
@@ -1822,26 +2030,26 @@ function PageBuilder({ pageKey = "index", pages = [], onPageChange, onExit }) {
|
|
|
1822
2030
|
const viewportWidth = viewportWidths[viewport];
|
|
1823
2031
|
const isCompact = viewport === "compact";
|
|
1824
2032
|
if (loading) {
|
|
1825
|
-
return /* @__PURE__ */
|
|
2033
|
+
return /* @__PURE__ */ jsx18("div", { className: "sk-pb", children: /* @__PURE__ */ jsx18("div", { className: "sk-pb__loading", children: "Lade Page Builder..." }) });
|
|
1826
2034
|
}
|
|
1827
2035
|
const sections = pageConfig?.sections ?? [];
|
|
1828
|
-
const navContent = /* @__PURE__ */
|
|
1829
|
-
/* @__PURE__ */
|
|
1830
|
-
navCollapsed && visibleSection && /* @__PURE__ */
|
|
2036
|
+
const navContent = /* @__PURE__ */ jsxs17(Fragment3, { children: [
|
|
2037
|
+
/* @__PURE__ */ jsxs17("div", { className: "sk-pb__nav-header", children: [
|
|
2038
|
+
navCollapsed && visibleSection && /* @__PURE__ */ jsxs17(
|
|
1831
2039
|
"button",
|
|
1832
2040
|
{
|
|
1833
2041
|
type: "button",
|
|
1834
2042
|
className: "sk-pb__inline-edit-btn",
|
|
1835
2043
|
onClick: () => openEditor(visibleSection),
|
|
1836
2044
|
children: [
|
|
1837
|
-
/* @__PURE__ */
|
|
2045
|
+
/* @__PURE__ */ jsx18(Edit, { size: 14 }),
|
|
1838
2046
|
getSectionDef(visibleSection)?.label ?? visibleSection
|
|
1839
2047
|
]
|
|
1840
2048
|
}
|
|
1841
2049
|
),
|
|
1842
|
-
!navCollapsed && /* @__PURE__ */
|
|
1843
|
-
!navCollapsed && /* @__PURE__ */
|
|
1844
|
-
/* @__PURE__ */
|
|
2050
|
+
!navCollapsed && /* @__PURE__ */ jsx18("span", { className: "sk-pb__nav-title", children: "Sections" }),
|
|
2051
|
+
!navCollapsed && /* @__PURE__ */ jsxs17("div", { className: "sk-pb__nav-actions", children: [
|
|
2052
|
+
/* @__PURE__ */ jsx18(
|
|
1845
2053
|
"button",
|
|
1846
2054
|
{
|
|
1847
2055
|
type: "button",
|
|
@@ -1851,10 +2059,10 @@ function PageBuilder({ pageKey = "index", pages = [], onPageChange, onExit }) {
|
|
|
1851
2059
|
setNavCollapsed(true);
|
|
1852
2060
|
},
|
|
1853
2061
|
title: "Compact Desktop",
|
|
1854
|
-
children: /* @__PURE__ */
|
|
2062
|
+
children: /* @__PURE__ */ jsx18(AppWindow, { size: 14 })
|
|
1855
2063
|
}
|
|
1856
2064
|
),
|
|
1857
|
-
/* @__PURE__ */
|
|
2065
|
+
/* @__PURE__ */ jsx18(
|
|
1858
2066
|
"button",
|
|
1859
2067
|
{
|
|
1860
2068
|
type: "button",
|
|
@@ -1864,10 +2072,10 @@ function PageBuilder({ pageKey = "index", pages = [], onPageChange, onExit }) {
|
|
|
1864
2072
|
setNavCollapsed(true);
|
|
1865
2073
|
},
|
|
1866
2074
|
title: "Desktop",
|
|
1867
|
-
children: /* @__PURE__ */
|
|
2075
|
+
children: /* @__PURE__ */ jsx18(Monitor, { size: 14 })
|
|
1868
2076
|
}
|
|
1869
2077
|
),
|
|
1870
|
-
/* @__PURE__ */
|
|
2078
|
+
/* @__PURE__ */ jsx18(
|
|
1871
2079
|
"button",
|
|
1872
2080
|
{
|
|
1873
2081
|
type: "button",
|
|
@@ -1877,10 +2085,10 @@ function PageBuilder({ pageKey = "index", pages = [], onPageChange, onExit }) {
|
|
|
1877
2085
|
setNavCollapsed(false);
|
|
1878
2086
|
},
|
|
1879
2087
|
title: "Tablet",
|
|
1880
|
-
children: /* @__PURE__ */
|
|
2088
|
+
children: /* @__PURE__ */ jsx18(Tablet, { size: 14 })
|
|
1881
2089
|
}
|
|
1882
2090
|
),
|
|
1883
|
-
/* @__PURE__ */
|
|
2091
|
+
/* @__PURE__ */ jsx18(
|
|
1884
2092
|
"button",
|
|
1885
2093
|
{
|
|
1886
2094
|
type: "button",
|
|
@@ -1890,54 +2098,54 @@ function PageBuilder({ pageKey = "index", pages = [], onPageChange, onExit }) {
|
|
|
1890
2098
|
setNavCollapsed(false);
|
|
1891
2099
|
},
|
|
1892
2100
|
title: "Mobile",
|
|
1893
|
-
children: /* @__PURE__ */
|
|
2101
|
+
children: /* @__PURE__ */ jsx18(Smartphone, { size: 14 })
|
|
1894
2102
|
}
|
|
1895
2103
|
)
|
|
1896
2104
|
] }),
|
|
1897
|
-
/* @__PURE__ */
|
|
1898
|
-
/* @__PURE__ */
|
|
2105
|
+
/* @__PURE__ */ jsxs17("div", { className: "sk-pb__nav-header-right", children: [
|
|
2106
|
+
/* @__PURE__ */ jsx18(
|
|
1899
2107
|
"button",
|
|
1900
2108
|
{
|
|
1901
2109
|
type: "button",
|
|
1902
2110
|
className: "sk-pb__collapse-btn",
|
|
1903
2111
|
onClick: () => setNavCollapsed((c) => !c),
|
|
1904
2112
|
title: navCollapsed ? "Navigation aufklappen" : "Navigation einklappen",
|
|
1905
|
-
children: navCollapsed ? /* @__PURE__ */
|
|
2113
|
+
children: navCollapsed ? /* @__PURE__ */ jsx18(ChevronDown, { size: 14 }) : /* @__PURE__ */ jsx18(ChevronUp, { size: 14 })
|
|
1906
2114
|
}
|
|
1907
2115
|
),
|
|
1908
|
-
/* @__PURE__ */
|
|
2116
|
+
/* @__PURE__ */ jsx18(
|
|
1909
2117
|
"button",
|
|
1910
2118
|
{
|
|
1911
2119
|
type: "button",
|
|
1912
2120
|
className: "sk-pb__exit-btn",
|
|
1913
2121
|
onClick: onExit,
|
|
1914
2122
|
title: "Page Builder verlassen",
|
|
1915
|
-
children: /* @__PURE__ */
|
|
2123
|
+
children: /* @__PURE__ */ jsx18(X, { size: 16 })
|
|
1916
2124
|
}
|
|
1917
2125
|
)
|
|
1918
2126
|
] })
|
|
1919
2127
|
] }),
|
|
1920
|
-
!navCollapsed && /* @__PURE__ */
|
|
1921
|
-
pages.length > 1 && onPageChange && /* @__PURE__ */
|
|
1922
|
-
/* @__PURE__ */
|
|
1923
|
-
/* @__PURE__ */
|
|
2128
|
+
!navCollapsed && /* @__PURE__ */ jsxs17(Fragment3, { children: [
|
|
2129
|
+
pages.length > 1 && onPageChange && /* @__PURE__ */ jsxs17("div", { className: "sk-pb__page-switcher", children: [
|
|
2130
|
+
/* @__PURE__ */ jsx18("label", { className: "sk-pb__page-switcher-label", children: "Seite" }),
|
|
2131
|
+
/* @__PURE__ */ jsx18(
|
|
1924
2132
|
"select",
|
|
1925
2133
|
{
|
|
1926
2134
|
className: "sk-pb__page-select",
|
|
1927
2135
|
value: pageKey,
|
|
1928
2136
|
onChange: (e) => onPageChange(e.target.value),
|
|
1929
|
-
children: pages.map((p) => /* @__PURE__ */
|
|
2137
|
+
children: pages.map((p) => /* @__PURE__ */ jsx18("option", { value: p.pageKey, children: p.label }, p.pageKey))
|
|
1930
2138
|
}
|
|
1931
2139
|
)
|
|
1932
2140
|
] }),
|
|
1933
|
-
/* @__PURE__ */
|
|
2141
|
+
/* @__PURE__ */ jsx18("div", { className: "sk-pb__section-list", children: sections.map((section, index) => {
|
|
1934
2142
|
const def = getSectionDef(section.key);
|
|
1935
2143
|
const IconComp = def?.icon ? ICON_MAP[def.icon] : null;
|
|
1936
2144
|
const isVisible = visibleSection === section.key;
|
|
1937
2145
|
const isEditing = editingSection === section.key;
|
|
1938
2146
|
const isDragging = dragIndex === index;
|
|
1939
2147
|
const isDragOver = dragOverIndex === index;
|
|
1940
|
-
return /* @__PURE__ */
|
|
2148
|
+
return /* @__PURE__ */ jsxs17(
|
|
1941
2149
|
"div",
|
|
1942
2150
|
{
|
|
1943
2151
|
className: `sk-pb__section-pill${isEditing ? " sk-pb__section-pill--editing" : ""}${isVisible && !isEditing ? " sk-pb__section-pill--visible" : ""}${!section.enabled ? " sk-pb__section-pill--disabled" : ""}${isDragging ? " sk-pb__section-pill--dragging" : ""}${isDragOver ? " sk-pb__section-pill--dragover" : ""}`,
|
|
@@ -1946,20 +2154,20 @@ function PageBuilder({ pageKey = "index", pages = [], onPageChange, onExit }) {
|
|
|
1946
2154
|
onDragOver: (e) => handleDragOver(e, index),
|
|
1947
2155
|
onDragEnd: handleDragEnd,
|
|
1948
2156
|
children: [
|
|
1949
|
-
/* @__PURE__ */
|
|
1950
|
-
/* @__PURE__ */
|
|
2157
|
+
/* @__PURE__ */ jsx18("span", { className: "sk-pb__section-grip", children: /* @__PURE__ */ jsx18(GripVertical, { size: 14 }) }),
|
|
2158
|
+
/* @__PURE__ */ jsxs17(
|
|
1951
2159
|
"button",
|
|
1952
2160
|
{
|
|
1953
2161
|
type: "button",
|
|
1954
2162
|
className: "sk-pb__section-main",
|
|
1955
2163
|
onClick: () => openEditor(section.key),
|
|
1956
2164
|
children: [
|
|
1957
|
-
IconComp && /* @__PURE__ */
|
|
1958
|
-
/* @__PURE__ */
|
|
2165
|
+
IconComp && /* @__PURE__ */ jsx18("span", { className: "sk-pb__section-icon", children: /* @__PURE__ */ jsx18(IconComp, { size: 16 }) }),
|
|
2166
|
+
/* @__PURE__ */ jsx18("span", { className: "sk-pb__section-label", children: def?.label ?? section.key })
|
|
1959
2167
|
]
|
|
1960
2168
|
}
|
|
1961
2169
|
),
|
|
1962
|
-
/* @__PURE__ */
|
|
2170
|
+
/* @__PURE__ */ jsx18(
|
|
1963
2171
|
"button",
|
|
1964
2172
|
{
|
|
1965
2173
|
type: "button",
|
|
@@ -1969,7 +2177,7 @@ function PageBuilder({ pageKey = "index", pages = [], onPageChange, onExit }) {
|
|
|
1969
2177
|
toggleSection(section.key);
|
|
1970
2178
|
},
|
|
1971
2179
|
title: section.enabled ? "Section ausblenden" : "Section einblenden",
|
|
1972
|
-
children: section.enabled ? /* @__PURE__ */
|
|
2180
|
+
children: section.enabled ? /* @__PURE__ */ jsx18(Eye, { size: 14 }) : /* @__PURE__ */ jsx18(EyeOff, { size: 14 })
|
|
1973
2181
|
}
|
|
1974
2182
|
)
|
|
1975
2183
|
]
|
|
@@ -1977,7 +2185,7 @@ function PageBuilder({ pageKey = "index", pages = [], onPageChange, onExit }) {
|
|
|
1977
2185
|
section.key
|
|
1978
2186
|
);
|
|
1979
2187
|
}) }),
|
|
1980
|
-
configDirty && /* @__PURE__ */
|
|
2188
|
+
configDirty && /* @__PURE__ */ jsx18("div", { className: "sk-pb__nav-footer", children: /* @__PURE__ */ jsxs17(
|
|
1981
2189
|
"button",
|
|
1982
2190
|
{
|
|
1983
2191
|
type: "button",
|
|
@@ -1985,14 +2193,14 @@ function PageBuilder({ pageKey = "index", pages = [], onPageChange, onExit }) {
|
|
|
1985
2193
|
onClick: savePageConfig,
|
|
1986
2194
|
disabled: savingConfig,
|
|
1987
2195
|
children: [
|
|
1988
|
-
/* @__PURE__ */
|
|
2196
|
+
/* @__PURE__ */ jsx18(Save, { size: 14 }),
|
|
1989
2197
|
savingConfig ? "Speichert..." : "Reihenfolge speichern"
|
|
1990
2198
|
]
|
|
1991
2199
|
}
|
|
1992
2200
|
) })
|
|
1993
2201
|
] })
|
|
1994
2202
|
] });
|
|
1995
|
-
const editorPanel = editorOpen && editingSection && !editorCollapsed && (getSectionDef(editingSection) ? /* @__PURE__ */
|
|
2203
|
+
const editorPanel = editorOpen && editingSection && !editorCollapsed && (getSectionDef(editingSection) ? /* @__PURE__ */ jsx18(
|
|
1996
2204
|
SectionSlideOver,
|
|
1997
2205
|
{
|
|
1998
2206
|
sectionKey: editingSection,
|
|
@@ -2005,25 +2213,25 @@ function PageBuilder({ pageKey = "index", pages = [], onPageChange, onExit }) {
|
|
|
2005
2213
|
onSaved: clearDraftCache
|
|
2006
2214
|
},
|
|
2007
2215
|
editingSection
|
|
2008
|
-
) : /* @__PURE__ */
|
|
2009
|
-
/* @__PURE__ */
|
|
2010
|
-
/* @__PURE__ */
|
|
2011
|
-
/* @__PURE__ */
|
|
2012
|
-
/* @__PURE__ */
|
|
2013
|
-
/* @__PURE__ */
|
|
2216
|
+
) : /* @__PURE__ */ jsxs17("div", { className: "sk-pb__slide-over", children: [
|
|
2217
|
+
/* @__PURE__ */ jsxs17("div", { className: "sk-pb__slide-over-header", children: [
|
|
2218
|
+
/* @__PURE__ */ jsx18("h3", { children: editingSection }),
|
|
2219
|
+
/* @__PURE__ */ jsxs17("div", { className: "sk-pb__slide-over-actions", children: [
|
|
2220
|
+
/* @__PURE__ */ jsx18("button", { type: "button", className: "sk-pb__collapse-btn", onClick: () => setEditorCollapsed(true), title: "Einklappen", children: /* @__PURE__ */ jsx18(PanelRightClose, { size: 16 }) }),
|
|
2221
|
+
/* @__PURE__ */ jsx18("button", { type: "button", className: "sk-pb__close-btn", onClick: closeEditor, children: /* @__PURE__ */ jsx18(X, { size: 18 }) })
|
|
2014
2222
|
] })
|
|
2015
2223
|
] }),
|
|
2016
|
-
/* @__PURE__ */
|
|
2224
|
+
/* @__PURE__ */ jsx18("div", { className: "sk-pb__slide-over-body", children: /* @__PURE__ */ jsx18("p", { className: "sk-pb__slide-over-info", children: "Diese Section hat noch kein editierbares Schema." }) })
|
|
2017
2225
|
] }));
|
|
2018
2226
|
const editorFloatTransform = editorDrag.hasMoved ? { transform: `translate(${editorDrag.offset.x}px, ${editorDrag.offset.y}px)` } : {};
|
|
2019
|
-
return /* @__PURE__ */
|
|
2227
|
+
return /* @__PURE__ */ jsxs17(
|
|
2020
2228
|
"div",
|
|
2021
2229
|
{
|
|
2022
2230
|
ref: pbRef,
|
|
2023
2231
|
className: `sk-pb${isCompact ? " sk-pb--compact" : ""}`,
|
|
2024
2232
|
style: isCompact ? { "--sk-split": `${compactSplit}` } : void 0,
|
|
2025
2233
|
children: [
|
|
2026
|
-
/* @__PURE__ */
|
|
2234
|
+
/* @__PURE__ */ jsx18("div", { className: "sk-pb__preview", children: /* @__PURE__ */ jsx18(
|
|
2027
2235
|
"div",
|
|
2028
2236
|
{
|
|
2029
2237
|
className: "sk-pb__iframe-container",
|
|
@@ -2031,7 +2239,7 @@ function PageBuilder({ pageKey = "index", pages = [], onPageChange, onExit }) {
|
|
|
2031
2239
|
maxWidth: isCompact ? "calc(var(--sk-split, 66) * 1vw)" : viewportWidth,
|
|
2032
2240
|
margin: viewport === "desktop" ? void 0 : isCompact ? "0" : "0 auto"
|
|
2033
2241
|
},
|
|
2034
|
-
children: /* @__PURE__ */
|
|
2242
|
+
children: /* @__PURE__ */ jsx18(
|
|
2035
2243
|
"iframe",
|
|
2036
2244
|
{
|
|
2037
2245
|
ref: iframeRef,
|
|
@@ -2044,7 +2252,7 @@ function PageBuilder({ pageKey = "index", pages = [], onPageChange, onExit }) {
|
|
|
2044
2252
|
)
|
|
2045
2253
|
}
|
|
2046
2254
|
) }),
|
|
2047
|
-
isCompact && /* @__PURE__ */
|
|
2255
|
+
isCompact && /* @__PURE__ */ jsx18(
|
|
2048
2256
|
"div",
|
|
2049
2257
|
{
|
|
2050
2258
|
className: "sk-pb__split-divider",
|
|
@@ -2052,7 +2260,7 @@ function PageBuilder({ pageKey = "index", pages = [], onPageChange, onExit }) {
|
|
|
2052
2260
|
onMouseDown: onSplitDragStart
|
|
2053
2261
|
}
|
|
2054
2262
|
),
|
|
2055
|
-
/* @__PURE__ */
|
|
2263
|
+
/* @__PURE__ */ jsx18(
|
|
2056
2264
|
"div",
|
|
2057
2265
|
{
|
|
2058
2266
|
ref: navRef,
|
|
@@ -2062,7 +2270,7 @@ function PageBuilder({ pageKey = "index", pages = [], onPageChange, onExit }) {
|
|
|
2062
2270
|
children: navContent
|
|
2063
2271
|
}
|
|
2064
2272
|
),
|
|
2065
|
-
editorPanel && /* @__PURE__ */
|
|
2273
|
+
editorPanel && /* @__PURE__ */ jsxs17(
|
|
2066
2274
|
"div",
|
|
2067
2275
|
{
|
|
2068
2276
|
className: "sk-pb__editor-float",
|
|
@@ -2073,7 +2281,7 @@ function PageBuilder({ pageKey = "index", pages = [], onPageChange, onExit }) {
|
|
|
2073
2281
|
},
|
|
2074
2282
|
onMouseDown: editorDrag.onMouseDown,
|
|
2075
2283
|
children: [
|
|
2076
|
-
/* @__PURE__ */
|
|
2284
|
+
/* @__PURE__ */ jsx18(
|
|
2077
2285
|
"div",
|
|
2078
2286
|
{
|
|
2079
2287
|
className: "sk-pb__resize-corner sk-pb__resize-corner--bl",
|
|
@@ -2084,24 +2292,24 @@ function PageBuilder({ pageKey = "index", pages = [], onPageChange, onExit }) {
|
|
|
2084
2292
|
]
|
|
2085
2293
|
}
|
|
2086
2294
|
),
|
|
2087
|
-
editorOpen && editingSection && editorCollapsed && /* @__PURE__ */
|
|
2295
|
+
editorOpen && editingSection && editorCollapsed && /* @__PURE__ */ jsx18(
|
|
2088
2296
|
"button",
|
|
2089
2297
|
{
|
|
2090
2298
|
type: "button",
|
|
2091
2299
|
className: "sk-pb__editor-expand-btn",
|
|
2092
2300
|
onClick: () => setEditorCollapsed(false),
|
|
2093
2301
|
title: "Editor aufklappen",
|
|
2094
|
-
children: /* @__PURE__ */
|
|
2302
|
+
children: /* @__PURE__ */ jsx18(PanelRightOpen, { size: 16 })
|
|
2095
2303
|
}
|
|
2096
2304
|
),
|
|
2097
|
-
anyMoved && /* @__PURE__ */
|
|
2305
|
+
anyMoved && /* @__PURE__ */ jsx18(
|
|
2098
2306
|
"button",
|
|
2099
2307
|
{
|
|
2100
2308
|
type: "button",
|
|
2101
2309
|
className: "sk-pb__reset-pos-btn",
|
|
2102
2310
|
onClick: resetAllPositions,
|
|
2103
2311
|
title: "Panel-Positionen zur\xFCcksetzen",
|
|
2104
|
-
children: /* @__PURE__ */
|
|
2312
|
+
children: /* @__PURE__ */ jsx18(RotateCcw, { size: 14 })
|
|
2105
2313
|
}
|
|
2106
2314
|
)
|
|
2107
2315
|
]
|
|
@@ -2111,22 +2319,22 @@ function PageBuilder({ pageKey = "index", pages = [], onPageChange, onExit }) {
|
|
|
2111
2319
|
function SectionSlideOver({ sectionKey, section, cachedValues, onClose, onCollapse, onDraftUpdate, onDiscard, onSaved }) {
|
|
2112
2320
|
const repository = useRepository();
|
|
2113
2321
|
const { toast } = useToast();
|
|
2114
|
-
const [initialValues, setInitialValues] =
|
|
2115
|
-
const [loading, setLoading] =
|
|
2116
|
-
const [saving, setSaving] =
|
|
2117
|
-
const [sha, setSha] =
|
|
2118
|
-
const [conflict, setConflict] =
|
|
2119
|
-
const storeRef =
|
|
2120
|
-
const [formStore, setFormStore] =
|
|
2121
|
-
const draftTimerRef =
|
|
2122
|
-
const saveRef =
|
|
2123
|
-
const undoRef =
|
|
2124
|
-
const redoRef =
|
|
2125
|
-
const storeSnapshotRef =
|
|
2322
|
+
const [initialValues, setInitialValues] = useState10({});
|
|
2323
|
+
const [loading, setLoading] = useState10(true);
|
|
2324
|
+
const [saving, setSaving] = useState10(false);
|
|
2325
|
+
const [sha, setSha] = useState10();
|
|
2326
|
+
const [conflict, setConflict] = useState10(null);
|
|
2327
|
+
const storeRef = useRef8(null);
|
|
2328
|
+
const [formStore, setFormStore] = useState10(null);
|
|
2329
|
+
const draftTimerRef = useRef8(null);
|
|
2330
|
+
const saveRef = useRef8(null);
|
|
2331
|
+
const undoRef = useRef8(null);
|
|
2332
|
+
const redoRef = useRef8(null);
|
|
2333
|
+
const storeSnapshotRef = useRef8({ dirty: false, canUndo: false, canRedo: false });
|
|
2126
2334
|
const storeState = useSyncExternalStore(
|
|
2127
|
-
|
|
2335
|
+
useCallback10((cb) => formStore?.subscribe(cb) ?? (() => {
|
|
2128
2336
|
}), [formStore]),
|
|
2129
|
-
|
|
2337
|
+
useCallback10(() => {
|
|
2130
2338
|
if (!formStore) return storeSnapshotRef.current;
|
|
2131
2339
|
const s = formStore.getState();
|
|
2132
2340
|
const dirty = s.isDirty();
|
|
@@ -2139,7 +2347,7 @@ function SectionSlideOver({ sectionKey, section, cachedValues, onClose, onCollap
|
|
|
2139
2347
|
return storeSnapshotRef.current;
|
|
2140
2348
|
}, [formStore])
|
|
2141
2349
|
);
|
|
2142
|
-
|
|
2350
|
+
useEffect7(() => {
|
|
2143
2351
|
setLoading(true);
|
|
2144
2352
|
repository.getEntry("_sections", sectionKey).then((result) => {
|
|
2145
2353
|
if (result.ok) {
|
|
@@ -2149,7 +2357,7 @@ function SectionSlideOver({ sectionKey, section, cachedValues, onClose, onCollap
|
|
|
2149
2357
|
setLoading(false);
|
|
2150
2358
|
});
|
|
2151
2359
|
}, [sectionKey, repository]);
|
|
2152
|
-
|
|
2360
|
+
useEffect7(() => {
|
|
2153
2361
|
if (formStore) return;
|
|
2154
2362
|
const check = setInterval(() => {
|
|
2155
2363
|
if (storeRef.current && !formStore) {
|
|
@@ -2159,7 +2367,7 @@ function SectionSlideOver({ sectionKey, section, cachedValues, onClose, onCollap
|
|
|
2159
2367
|
}, 50);
|
|
2160
2368
|
return () => clearInterval(check);
|
|
2161
2369
|
}, [formStore, loading]);
|
|
2162
|
-
|
|
2370
|
+
useEffect7(() => {
|
|
2163
2371
|
if (!formStore) return;
|
|
2164
2372
|
const unsub = formStore.subscribe((state) => {
|
|
2165
2373
|
if (draftTimerRef.current) clearTimeout(draftTimerRef.current);
|
|
@@ -2172,7 +2380,7 @@ function SectionSlideOver({ sectionKey, section, cachedValues, onClose, onCollap
|
|
|
2172
2380
|
if (draftTimerRef.current) clearTimeout(draftTimerRef.current);
|
|
2173
2381
|
};
|
|
2174
2382
|
}, [formStore, sectionKey, onDraftUpdate]);
|
|
2175
|
-
const handleSave =
|
|
2383
|
+
const handleSave = useCallback10(async (values) => {
|
|
2176
2384
|
setSaving(true);
|
|
2177
2385
|
const result = await repository.saveEntry("_sections", sectionKey, {
|
|
2178
2386
|
content: values,
|
|
@@ -2218,7 +2426,7 @@ function SectionSlideOver({ sectionKey, section, cachedValues, onClose, onCollap
|
|
|
2218
2426
|
if (!store) return;
|
|
2219
2427
|
store.getState().redo();
|
|
2220
2428
|
};
|
|
2221
|
-
const resolveConflictLocal =
|
|
2429
|
+
const resolveConflictLocal = useCallback10(async () => {
|
|
2222
2430
|
if (!conflict) return;
|
|
2223
2431
|
setSaving(true);
|
|
2224
2432
|
const result = await repository.saveEntry("_sections", sectionKey, {
|
|
@@ -2236,7 +2444,7 @@ function SectionSlideOver({ sectionKey, section, cachedValues, onClose, onCollap
|
|
|
2236
2444
|
}
|
|
2237
2445
|
setSaving(false);
|
|
2238
2446
|
}, [conflict, repository, sectionKey, onSaved, toast]);
|
|
2239
|
-
const resolveConflictRemote =
|
|
2447
|
+
const resolveConflictRemote = useCallback10(() => {
|
|
2240
2448
|
if (!conflict) return;
|
|
2241
2449
|
const store = storeRef.current;
|
|
2242
2450
|
if (store) {
|
|
@@ -2248,13 +2456,13 @@ function SectionSlideOver({ sectionKey, section, cachedValues, onClose, onCollap
|
|
|
2248
2456
|
onDiscard(sectionKey);
|
|
2249
2457
|
toast("Remote-Version \xFCbernommen.", "success");
|
|
2250
2458
|
}, [conflict, section.fields, sectionKey, onDiscard, toast]);
|
|
2251
|
-
const handleDiscard =
|
|
2459
|
+
const handleDiscard = useCallback10(() => {
|
|
2252
2460
|
const store = storeRef.current;
|
|
2253
2461
|
if (!store) return;
|
|
2254
2462
|
store.getState().resetToInitial();
|
|
2255
2463
|
onDiscard(sectionKey);
|
|
2256
2464
|
}, [sectionKey, onDiscard]);
|
|
2257
|
-
|
|
2465
|
+
useEffect7(() => {
|
|
2258
2466
|
const handler = (e) => {
|
|
2259
2467
|
if ((e.metaKey || e.ctrlKey) && e.key === "s") {
|
|
2260
2468
|
e.preventDefault();
|
|
@@ -2275,24 +2483,24 @@ function SectionSlideOver({ sectionKey, section, cachedValues, onClose, onCollap
|
|
|
2275
2483
|
document.addEventListener("keydown", handler);
|
|
2276
2484
|
return () => document.removeEventListener("keydown", handler);
|
|
2277
2485
|
}, [onClose]);
|
|
2278
|
-
return /* @__PURE__ */
|
|
2279
|
-
/* @__PURE__ */
|
|
2280
|
-
/* @__PURE__ */
|
|
2281
|
-
/* @__PURE__ */
|
|
2486
|
+
return /* @__PURE__ */ jsxs17("div", { className: "sk-pb__slide-over", children: [
|
|
2487
|
+
/* @__PURE__ */ jsxs17("div", { className: "sk-pb__slide-over-header", children: [
|
|
2488
|
+
/* @__PURE__ */ jsx18("div", { className: "sk-pb__slide-over-title", children: storeState.dirty && /* @__PURE__ */ jsxs17("span", { className: "sk-pb__draft-indicator", title: "Ungespeicherte \xC4nderungen", children: [
|
|
2489
|
+
/* @__PURE__ */ jsx18("span", { className: "sk-pb__draft-dot" }),
|
|
2282
2490
|
"Entwurf"
|
|
2283
2491
|
] }) }),
|
|
2284
|
-
/* @__PURE__ */
|
|
2285
|
-
storeState.dirty && /* @__PURE__ */
|
|
2492
|
+
/* @__PURE__ */ jsxs17("div", { className: "sk-pb__slide-over-actions", children: [
|
|
2493
|
+
storeState.dirty && /* @__PURE__ */ jsx18(
|
|
2286
2494
|
"button",
|
|
2287
2495
|
{
|
|
2288
2496
|
type: "button",
|
|
2289
2497
|
className: "sk-pb__discard-btn",
|
|
2290
2498
|
onClick: handleDiscard,
|
|
2291
2499
|
title: "\xC4nderungen verwerfen",
|
|
2292
|
-
children: /* @__PURE__ */
|
|
2500
|
+
children: /* @__PURE__ */ jsx18(Trash2, { size: 14 })
|
|
2293
2501
|
}
|
|
2294
2502
|
),
|
|
2295
|
-
/* @__PURE__ */
|
|
2503
|
+
/* @__PURE__ */ jsx18(
|
|
2296
2504
|
"button",
|
|
2297
2505
|
{
|
|
2298
2506
|
type: "button",
|
|
@@ -2300,10 +2508,10 @@ function SectionSlideOver({ sectionKey, section, cachedValues, onClose, onCollap
|
|
|
2300
2508
|
onClick: () => undoRef.current?.(),
|
|
2301
2509
|
disabled: !storeState.canUndo,
|
|
2302
2510
|
title: "R\xFCckg\xE4ngig (Cmd+Z)",
|
|
2303
|
-
children: /* @__PURE__ */
|
|
2511
|
+
children: /* @__PURE__ */ jsx18(Undo2, { size: 14 })
|
|
2304
2512
|
}
|
|
2305
2513
|
),
|
|
2306
|
-
/* @__PURE__ */
|
|
2514
|
+
/* @__PURE__ */ jsx18(
|
|
2307
2515
|
"button",
|
|
2308
2516
|
{
|
|
2309
2517
|
type: "button",
|
|
@@ -2311,10 +2519,10 @@ function SectionSlideOver({ sectionKey, section, cachedValues, onClose, onCollap
|
|
|
2311
2519
|
onClick: () => redoRef.current?.(),
|
|
2312
2520
|
disabled: !storeState.canRedo,
|
|
2313
2521
|
title: "Wiederholen (Cmd+Shift+Z)",
|
|
2314
|
-
children: /* @__PURE__ */
|
|
2522
|
+
children: /* @__PURE__ */ jsx18(Redo2, { size: 14 })
|
|
2315
2523
|
}
|
|
2316
2524
|
),
|
|
2317
|
-
/* @__PURE__ */
|
|
2525
|
+
/* @__PURE__ */ jsx18(
|
|
2318
2526
|
"button",
|
|
2319
2527
|
{
|
|
2320
2528
|
type: "button",
|
|
@@ -2322,41 +2530,41 @@ function SectionSlideOver({ sectionKey, section, cachedValues, onClose, onCollap
|
|
|
2322
2530
|
onClick: () => saveRef.current?.(),
|
|
2323
2531
|
disabled: saving || !storeState.dirty,
|
|
2324
2532
|
title: "Speichern (Cmd+S)",
|
|
2325
|
-
children: /* @__PURE__ */
|
|
2533
|
+
children: /* @__PURE__ */ jsx18(Save, { size: 14 })
|
|
2326
2534
|
}
|
|
2327
2535
|
),
|
|
2328
|
-
/* @__PURE__ */
|
|
2329
|
-
/* @__PURE__ */
|
|
2536
|
+
/* @__PURE__ */ jsx18("button", { type: "button", className: "sk-pb__collapse-btn", onClick: onCollapse, title: "Einklappen", children: /* @__PURE__ */ jsx18(PanelRightClose, { size: 16 }) }),
|
|
2537
|
+
/* @__PURE__ */ jsx18("button", { type: "button", className: "sk-pb__close-btn", onClick: onClose, children: /* @__PURE__ */ jsx18(X, { size: 18 }) })
|
|
2330
2538
|
] })
|
|
2331
2539
|
] }),
|
|
2332
|
-
/* @__PURE__ */
|
|
2333
|
-
conflict && /* @__PURE__ */
|
|
2334
|
-
/* @__PURE__ */
|
|
2335
|
-
/* @__PURE__ */
|
|
2336
|
-
/* @__PURE__ */
|
|
2540
|
+
/* @__PURE__ */ jsxs17("div", { className: "sk-pb__slide-over-body", children: [
|
|
2541
|
+
conflict && /* @__PURE__ */ jsxs17("div", { className: "sk-pb__conflict", children: [
|
|
2542
|
+
/* @__PURE__ */ jsxs17("div", { className: "sk-pb__conflict-header", children: [
|
|
2543
|
+
/* @__PURE__ */ jsx18(Shield, { size: 16 }),
|
|
2544
|
+
/* @__PURE__ */ jsx18("strong", { children: "Konflikt" }),
|
|
2337
2545
|
" \u2014 Die Datei wurde extern ge\xE4ndert."
|
|
2338
2546
|
] }),
|
|
2339
|
-
/* @__PURE__ */
|
|
2547
|
+
/* @__PURE__ */ jsx18("div", { className: "sk-pb__conflict-diff", children: Object.keys({ ...conflict.local, ...conflict.remote }).filter((key) => JSON.stringify(conflict.local[key]) !== JSON.stringify(conflict.remote[key])).map((key) => {
|
|
2340
2548
|
const fieldDef = section.fields[key];
|
|
2341
2549
|
const label = fieldDef?.label ?? key;
|
|
2342
2550
|
const localVal = JSON.stringify(conflict.local[key], null, 2) ?? "\u2014";
|
|
2343
2551
|
const remoteVal = JSON.stringify(conflict.remote[key], null, 2) ?? "\u2014";
|
|
2344
|
-
return /* @__PURE__ */
|
|
2345
|
-
/* @__PURE__ */
|
|
2346
|
-
/* @__PURE__ */
|
|
2347
|
-
/* @__PURE__ */
|
|
2348
|
-
/* @__PURE__ */
|
|
2349
|
-
/* @__PURE__ */
|
|
2552
|
+
return /* @__PURE__ */ jsxs17("div", { className: "sk-pb__conflict-field", children: [
|
|
2553
|
+
/* @__PURE__ */ jsx18("div", { className: "sk-pb__conflict-label", children: label }),
|
|
2554
|
+
/* @__PURE__ */ jsxs17("div", { className: "sk-pb__conflict-values", children: [
|
|
2555
|
+
/* @__PURE__ */ jsxs17("div", { className: "sk-pb__conflict-local", children: [
|
|
2556
|
+
/* @__PURE__ */ jsx18("span", { className: "sk-pb__conflict-tag", children: "Deine Version" }),
|
|
2557
|
+
/* @__PURE__ */ jsx18("pre", { children: localVal })
|
|
2350
2558
|
] }),
|
|
2351
|
-
/* @__PURE__ */
|
|
2352
|
-
/* @__PURE__ */
|
|
2353
|
-
/* @__PURE__ */
|
|
2559
|
+
/* @__PURE__ */ jsxs17("div", { className: "sk-pb__conflict-remote", children: [
|
|
2560
|
+
/* @__PURE__ */ jsx18("span", { className: "sk-pb__conflict-tag", children: "Remote" }),
|
|
2561
|
+
/* @__PURE__ */ jsx18("pre", { children: remoteVal })
|
|
2354
2562
|
] })
|
|
2355
2563
|
] })
|
|
2356
2564
|
] }, key);
|
|
2357
2565
|
}) }),
|
|
2358
|
-
/* @__PURE__ */
|
|
2359
|
-
/* @__PURE__ */
|
|
2566
|
+
/* @__PURE__ */ jsxs17("div", { className: "sk-pb__conflict-actions", children: [
|
|
2567
|
+
/* @__PURE__ */ jsx18(
|
|
2360
2568
|
"button",
|
|
2361
2569
|
{
|
|
2362
2570
|
type: "button",
|
|
@@ -2366,7 +2574,7 @@ function SectionSlideOver({ sectionKey, section, cachedValues, onClose, onCollap
|
|
|
2366
2574
|
children: "Meine Version \xFCbernehmen"
|
|
2367
2575
|
}
|
|
2368
2576
|
),
|
|
2369
|
-
/* @__PURE__ */
|
|
2577
|
+
/* @__PURE__ */ jsx18(
|
|
2370
2578
|
"button",
|
|
2371
2579
|
{
|
|
2372
2580
|
type: "button",
|
|
@@ -2377,7 +2585,7 @@ function SectionSlideOver({ sectionKey, section, cachedValues, onClose, onCollap
|
|
|
2377
2585
|
)
|
|
2378
2586
|
] })
|
|
2379
2587
|
] }),
|
|
2380
|
-
loading ? /* @__PURE__ */
|
|
2588
|
+
loading ? /* @__PURE__ */ jsx18("p", { className: "sk-pb__slide-over-loading", children: "Lade..." }) : /* @__PURE__ */ jsx18(
|
|
2381
2589
|
EntryForm,
|
|
2382
2590
|
{
|
|
2383
2591
|
schema: section.fields,
|
|
@@ -2393,12 +2601,12 @@ function SectionSlideOver({ sectionKey, section, cachedValues, onClose, onCollap
|
|
|
2393
2601
|
|
|
2394
2602
|
// src/components/admin-app.tsx
|
|
2395
2603
|
import { Layers, Globe as Globe2, Settings as Settings2 } from "lucide-react";
|
|
2396
|
-
import { jsx as
|
|
2604
|
+
import { jsx as jsx19, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
2397
2605
|
function AdminApp() {
|
|
2398
2606
|
const config = useConfig();
|
|
2399
|
-
const [user, setUser] =
|
|
2400
|
-
const [checking, setChecking] =
|
|
2401
|
-
|
|
2607
|
+
const [user, setUser] = useState11(null);
|
|
2608
|
+
const [checking, setChecking] = useState11(true);
|
|
2609
|
+
useEffect8(() => {
|
|
2402
2610
|
checkSession();
|
|
2403
2611
|
}, []);
|
|
2404
2612
|
async function checkSession() {
|
|
@@ -2414,53 +2622,53 @@ function AdminApp() {
|
|
|
2414
2622
|
}
|
|
2415
2623
|
}
|
|
2416
2624
|
if (checking) {
|
|
2417
|
-
return /* @__PURE__ */
|
|
2625
|
+
return /* @__PURE__ */ jsx19(LoadingScreen, {});
|
|
2418
2626
|
}
|
|
2419
2627
|
if (!user) {
|
|
2420
|
-
return /* @__PURE__ */
|
|
2628
|
+
return /* @__PURE__ */ jsx19(LoginScreen, { config });
|
|
2421
2629
|
}
|
|
2422
|
-
return /* @__PURE__ */
|
|
2630
|
+
return /* @__PURE__ */ jsx19(ToastProvider, { children: /* @__PURE__ */ jsx19(AdminShell, { config, user }) });
|
|
2423
2631
|
}
|
|
2424
2632
|
function LoadingScreen() {
|
|
2425
|
-
return /* @__PURE__ */
|
|
2426
|
-
/* @__PURE__ */
|
|
2427
|
-
/* @__PURE__ */
|
|
2633
|
+
return /* @__PURE__ */ jsxs18("div", { className: "sk-admin-loading", children: [
|
|
2634
|
+
/* @__PURE__ */ jsx19("div", { className: "sk-admin-loading__spinner" }),
|
|
2635
|
+
/* @__PURE__ */ jsx19("p", { className: "sk-admin-loading__text", children: "Lade Setzkasten..." })
|
|
2428
2636
|
] });
|
|
2429
2637
|
}
|
|
2430
2638
|
function LoginScreen({ config }) {
|
|
2431
2639
|
const providers = config.auth?.providers ?? ["github"];
|
|
2432
|
-
return /* @__PURE__ */
|
|
2433
|
-
/* @__PURE__ */
|
|
2434
|
-
/* @__PURE__ */
|
|
2435
|
-
/* @__PURE__ */
|
|
2436
|
-
providers.includes("github") && /* @__PURE__ */
|
|
2437
|
-
/* @__PURE__ */
|
|
2640
|
+
return /* @__PURE__ */ jsx19("div", { className: "sk-login", children: /* @__PURE__ */ jsxs18("div", { className: "sk-login__card", children: [
|
|
2641
|
+
/* @__PURE__ */ jsx19("div", { className: "sk-login__logo", children: "S" }),
|
|
2642
|
+
/* @__PURE__ */ jsx19("h1", { className: "sk-login__title", children: config.theme?.brandName ?? "Setzkasten" }),
|
|
2643
|
+
/* @__PURE__ */ jsx19("p", { className: "sk-login__subtitle", children: "Melde dich an, um Inhalte zu bearbeiten." }),
|
|
2644
|
+
providers.includes("github") && /* @__PURE__ */ jsxs18("a", { href: "/api/setzkasten/auth/login?provider=github", className: "sk-login__btn", children: [
|
|
2645
|
+
/* @__PURE__ */ jsx19("svg", { viewBox: "0 0 24 24", fill: "currentColor", width: "20", height: "20", children: /* @__PURE__ */ jsx19("path", { d: "M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844a9.59 9.59 0 012.504.337c1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.02 10.02 0 0022 12.017C22 6.484 17.522 2 12 2Z" }) }),
|
|
2438
2646
|
"Mit GitHub anmelden"
|
|
2439
2647
|
] }),
|
|
2440
|
-
providers.includes("google") && /* @__PURE__ */
|
|
2441
|
-
/* @__PURE__ */
|
|
2442
|
-
/* @__PURE__ */
|
|
2443
|
-
/* @__PURE__ */
|
|
2444
|
-
/* @__PURE__ */
|
|
2445
|
-
/* @__PURE__ */
|
|
2648
|
+
providers.includes("google") && /* @__PURE__ */ jsxs18("a", { href: "/api/setzkasten/auth/login?provider=google", className: "sk-login__btn", children: [
|
|
2649
|
+
/* @__PURE__ */ jsxs18("svg", { viewBox: "0 0 24 24", width: "20", height: "20", children: [
|
|
2650
|
+
/* @__PURE__ */ jsx19("path", { d: "M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92a5.06 5.06 0 01-2.2 3.32v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.1z", fill: "#4285F4" }),
|
|
2651
|
+
/* @__PURE__ */ jsx19("path", { d: "M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z", fill: "#34A853" }),
|
|
2652
|
+
/* @__PURE__ */ jsx19("path", { d: "M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z", fill: "#FBBC05" }),
|
|
2653
|
+
/* @__PURE__ */ jsx19("path", { d: "M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z", fill: "#EA4335" })
|
|
2446
2654
|
] }),
|
|
2447
2655
|
"Mit Google anmelden"
|
|
2448
2656
|
] })
|
|
2449
2657
|
] }) });
|
|
2450
2658
|
}
|
|
2451
2659
|
function AdminShell({ config, user }) {
|
|
2452
|
-
const [view, setView] =
|
|
2453
|
-
const [pages, setPages] =
|
|
2454
|
-
const [selectedPageKey, setSelectedPageKey] =
|
|
2455
|
-
const [loadingPages, setLoadingPages] =
|
|
2456
|
-
|
|
2660
|
+
const [view, setView] = useState11("dashboard");
|
|
2661
|
+
const [pages, setPages] = useState11([]);
|
|
2662
|
+
const [selectedPageKey, setSelectedPageKey] = useState11("index");
|
|
2663
|
+
const [loadingPages, setLoadingPages] = useState11(true);
|
|
2664
|
+
useEffect8(() => {
|
|
2457
2665
|
fetch("/api/setzkasten/pages").then((r) => r.json()).then((data) => {
|
|
2458
2666
|
setPages(data.pages ?? []);
|
|
2459
2667
|
}).catch(() => {
|
|
2460
2668
|
}).finally(() => setLoadingPages(false));
|
|
2461
2669
|
}, []);
|
|
2462
2670
|
if (view === "page-builder") {
|
|
2463
|
-
return /* @__PURE__ */
|
|
2671
|
+
return /* @__PURE__ */ jsx19(
|
|
2464
2672
|
PageBuilder,
|
|
2465
2673
|
{
|
|
2466
2674
|
pageKey: selectedPageKey,
|
|
@@ -2470,7 +2678,7 @@ function AdminShell({ config, user }) {
|
|
|
2470
2678
|
}
|
|
2471
2679
|
);
|
|
2472
2680
|
}
|
|
2473
|
-
return /* @__PURE__ */
|
|
2681
|
+
return /* @__PURE__ */ jsx19(
|
|
2474
2682
|
Dashboard,
|
|
2475
2683
|
{
|
|
2476
2684
|
config,
|
|
@@ -2493,43 +2701,43 @@ function Dashboard({
|
|
|
2493
2701
|
onOpenPageBuilder
|
|
2494
2702
|
}) {
|
|
2495
2703
|
const brandName = config.theme?.brandName ?? "Setzkasten";
|
|
2496
|
-
return /* @__PURE__ */
|
|
2497
|
-
/* @__PURE__ */
|
|
2498
|
-
/* @__PURE__ */
|
|
2499
|
-
/* @__PURE__ */
|
|
2500
|
-
/* @__PURE__ */
|
|
2704
|
+
return /* @__PURE__ */ jsxs18("div", { className: "sk-dashboard", children: [
|
|
2705
|
+
/* @__PURE__ */ jsxs18("header", { className: "sk-dashboard__topbar", children: [
|
|
2706
|
+
/* @__PURE__ */ jsxs18("div", { className: "sk-dashboard__brand", children: [
|
|
2707
|
+
/* @__PURE__ */ jsx19("span", { className: "sk-dashboard__logo", children: "S" }),
|
|
2708
|
+
/* @__PURE__ */ jsx19("span", { className: "sk-dashboard__brand-name", children: "Setzkasten" })
|
|
2501
2709
|
] }),
|
|
2502
|
-
/* @__PURE__ */
|
|
2503
|
-
user.avatarUrl ? /* @__PURE__ */
|
|
2504
|
-
/* @__PURE__ */
|
|
2505
|
-
/* @__PURE__ */
|
|
2710
|
+
/* @__PURE__ */ jsxs18("div", { className: "sk-dashboard__user", children: [
|
|
2711
|
+
user.avatarUrl ? /* @__PURE__ */ jsx19("img", { src: user.avatarUrl, className: "sk-dashboard__avatar", alt: "" }) : /* @__PURE__ */ jsx19("span", { className: "sk-dashboard__avatar sk-dashboard__avatar--placeholder", children: (user.name ?? user.email ?? "?")[0].toUpperCase() }),
|
|
2712
|
+
/* @__PURE__ */ jsx19("span", { className: "sk-dashboard__user-name", children: user.name || user.email }),
|
|
2713
|
+
/* @__PURE__ */ jsx19("a", { href: "/api/setzkasten/auth/logout", className: "sk-dashboard__logout", children: "Abmelden" })
|
|
2506
2714
|
] })
|
|
2507
2715
|
] }),
|
|
2508
|
-
/* @__PURE__ */
|
|
2509
|
-
/* @__PURE__ */
|
|
2510
|
-
/* @__PURE__ */
|
|
2511
|
-
/* @__PURE__ */
|
|
2512
|
-
/* @__PURE__ */
|
|
2513
|
-
/* @__PURE__ */
|
|
2716
|
+
/* @__PURE__ */ jsxs18("main", { className: "sk-dashboard__content", children: [
|
|
2717
|
+
/* @__PURE__ */ jsxs18("div", { className: "sk-dashboard__card sk-dashboard__card--primary", children: [
|
|
2718
|
+
/* @__PURE__ */ jsx19("div", { className: "sk-dashboard__card-icon", children: /* @__PURE__ */ jsx19(Layers, { size: 28 }) }),
|
|
2719
|
+
/* @__PURE__ */ jsx19("h2", { className: "sk-dashboard__card-title", children: "Zum Setzkasten f\xFCr" }),
|
|
2720
|
+
/* @__PURE__ */ jsxs18("div", { className: "sk-dashboard__card-controls", children: [
|
|
2721
|
+
/* @__PURE__ */ jsx19(
|
|
2514
2722
|
"select",
|
|
2515
2723
|
{
|
|
2516
2724
|
className: "sk-dashboard__select",
|
|
2517
2725
|
disabled: true,
|
|
2518
2726
|
value: brandName,
|
|
2519
|
-
children: /* @__PURE__ */
|
|
2727
|
+
children: /* @__PURE__ */ jsx19("option", { children: brandName })
|
|
2520
2728
|
}
|
|
2521
2729
|
),
|
|
2522
|
-
/* @__PURE__ */
|
|
2730
|
+
/* @__PURE__ */ jsx19(
|
|
2523
2731
|
"select",
|
|
2524
2732
|
{
|
|
2525
2733
|
className: "sk-dashboard__select",
|
|
2526
2734
|
value: selectedPageKey,
|
|
2527
2735
|
onChange: (e) => onSelectPage(e.target.value),
|
|
2528
2736
|
disabled: loadingPages || pages.length === 0,
|
|
2529
|
-
children: loadingPages ? /* @__PURE__ */
|
|
2737
|
+
children: loadingPages ? /* @__PURE__ */ jsx19("option", { children: "Lade..." }) : pages.length === 0 ? /* @__PURE__ */ jsx19("option", { value: "index", children: "Startseite" }) : pages.map((p) => /* @__PURE__ */ jsx19("option", { value: p.pageKey, children: p.label }, p.pageKey))
|
|
2530
2738
|
}
|
|
2531
2739
|
),
|
|
2532
|
-
/* @__PURE__ */
|
|
2740
|
+
/* @__PURE__ */ jsx19(
|
|
2533
2741
|
"button",
|
|
2534
2742
|
{
|
|
2535
2743
|
type: "button",
|
|
@@ -2540,16 +2748,16 @@ function Dashboard({
|
|
|
2540
2748
|
)
|
|
2541
2749
|
] })
|
|
2542
2750
|
] }),
|
|
2543
|
-
/* @__PURE__ */
|
|
2544
|
-
/* @__PURE__ */
|
|
2545
|
-
/* @__PURE__ */
|
|
2546
|
-
/* @__PURE__ */
|
|
2547
|
-
/* @__PURE__ */
|
|
2751
|
+
/* @__PURE__ */ jsxs18("div", { className: "sk-dashboard__cards-row", children: [
|
|
2752
|
+
/* @__PURE__ */ jsxs18("div", { className: "sk-dashboard__card sk-dashboard__card--disabled", children: [
|
|
2753
|
+
/* @__PURE__ */ jsx19("div", { className: "sk-dashboard__card-icon", children: /* @__PURE__ */ jsx19(Globe2, { size: 22 }) }),
|
|
2754
|
+
/* @__PURE__ */ jsx19("h3", { className: "sk-dashboard__card-subtitle", children: "Websites verwalten" }),
|
|
2755
|
+
/* @__PURE__ */ jsx19("span", { className: "sk-dashboard__badge", children: "Kommt bald" })
|
|
2548
2756
|
] }),
|
|
2549
|
-
/* @__PURE__ */
|
|
2550
|
-
/* @__PURE__ */
|
|
2551
|
-
/* @__PURE__ */
|
|
2552
|
-
/* @__PURE__ */
|
|
2757
|
+
/* @__PURE__ */ jsxs18("div", { className: "sk-dashboard__card sk-dashboard__card--disabled", children: [
|
|
2758
|
+
/* @__PURE__ */ jsx19("div", { className: "sk-dashboard__card-icon", children: /* @__PURE__ */ jsx19(Settings2, { size: 22 }) }),
|
|
2759
|
+
/* @__PURE__ */ jsx19("h3", { className: "sk-dashboard__card-subtitle", children: "Globale Konfiguration" }),
|
|
2760
|
+
/* @__PURE__ */ jsx19("span", { className: "sk-dashboard__badge", children: "Kommt bald" })
|
|
2553
2761
|
] })
|
|
2554
2762
|
] })
|
|
2555
2763
|
] })
|
|
@@ -2557,12 +2765,12 @@ function Dashboard({
|
|
|
2557
2765
|
}
|
|
2558
2766
|
|
|
2559
2767
|
// src/hooks/use-save.ts
|
|
2560
|
-
import { useCallback as
|
|
2768
|
+
import { useCallback as useCallback11, useState as useState12 } from "react";
|
|
2561
2769
|
function useSave(store, collection, slug) {
|
|
2562
2770
|
const repository = useRepository();
|
|
2563
2771
|
const eventBus = useEventBus();
|
|
2564
|
-
const [saving, setSaving] =
|
|
2565
|
-
const save =
|
|
2772
|
+
const [saving, setSaving] = useState12(false);
|
|
2773
|
+
const save = useCallback11(async () => {
|
|
2566
2774
|
const state = store.getState();
|
|
2567
2775
|
if (!state.isDirty()) {
|
|
2568
2776
|
return { ok: true, value: { sha: "", message: "No changes" } };
|