@jbpark/live-editor 1.17.0 → 1.18.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/dnd/index.d.ts +2 -2
- package/dist/dnd/index.js +2 -2
- package/dist/{dnd-D8hsq1Fl.js → dnd-l2V0EmfS.js} +150 -175
- package/dist/dnd-l2V0EmfS.js.map +1 -0
- package/dist/{index-qdhllaw-.d.ts → index-soMhswGI.d.ts} +25 -2
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/dist/dnd-D8hsq1Fl.js.map +0 -1
package/dist/dnd/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
export { DraggableItem, type DraggableItemDragState, type DraggableItemProps, ICON_MAP, type PaletteRenderData, type PanelBinding, type PanelRenderData, type Props, Dnd as default };
|
|
1
|
+
import { a as ICON_OPTIONS, c as PanelRenderData, d as DraggableItemDragState, f as DraggableItemProps, i as ICON_MAP, l as Props, n as Panel, o as PaletteRenderData, r as PanelProps, s as PanelBinding, t as Dnd, u as DraggableItem } from "../index-soMhswGI.js";
|
|
2
|
+
export { Panel as DefaultPanel, DraggableItem, type DraggableItemDragState, type DraggableItemProps, ICON_MAP, ICON_OPTIONS, type PaletteRenderData, type PanelBinding, type PanelProps, type PanelRenderData, type Props, Dnd as default };
|
package/dist/dnd/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as
|
|
2
|
-
export { DraggableItem, ICON_MAP, Dnd as default };
|
|
1
|
+
import { a as DraggableItem, i as ICON_OPTIONS, n as Panel, r as ICON_MAP, t as Dnd } from "../dnd-l2V0EmfS.js";
|
|
2
|
+
export { Panel as DefaultPanel, DraggableItem, ICON_MAP, ICON_OPTIONS, Dnd as default };
|
|
@@ -18,8 +18,6 @@ import Placeholder from "@tiptap/extension-placeholder";
|
|
|
18
18
|
import { EditorContent, useEditor } from "@tiptap/react";
|
|
19
19
|
import StarterKit from "@tiptap/starter-kit";
|
|
20
20
|
//#region src/components/dnd/draggable.tsx
|
|
21
|
-
var import_lib = require_lib();
|
|
22
|
-
var import_lib$1 = /* @__PURE__ */ __toESM(require_lib$1(), 1);
|
|
23
21
|
const DraggableItem = ({ item, children }) => {
|
|
24
22
|
const { attributes, listeners, setNodeRef, isDragging } = useDraggable({
|
|
25
23
|
id: item.id,
|
|
@@ -191,6 +189,63 @@ const Tiptap = ({ value = "", placeholder = "Enter text...", className, onChange
|
|
|
191
189
|
});
|
|
192
190
|
};
|
|
193
191
|
//#endregion
|
|
192
|
+
//#region src/components/dnd/panel/node.tsx
|
|
193
|
+
var import_lib = require_lib();
|
|
194
|
+
var import_lib$1 = /* @__PURE__ */ __toESM(require_lib$1(), 1);
|
|
195
|
+
const Node = ({ data, onChange }) => {
|
|
196
|
+
const idAttr = data.dataAttributes.find((a) => a.name === "data-id");
|
|
197
|
+
const bindingAttr = data.dataAttributes.find((a) => a.name === "data-binding");
|
|
198
|
+
if (!idAttr?.value || !bindingAttr?.value) return null;
|
|
199
|
+
const dataId = idAttr.value;
|
|
200
|
+
const bindings = data.bindings || parseBinding(bindingAttr.value);
|
|
201
|
+
if (!bindings.length) return null;
|
|
202
|
+
return /* @__PURE__ */ jsx("div", {
|
|
203
|
+
className: "space-y-2 rounded",
|
|
204
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
205
|
+
className: "space-y-1",
|
|
206
|
+
children: bindings.map((binding) => {
|
|
207
|
+
const currentValue = getCurrentValue(data, binding.property);
|
|
208
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
209
|
+
className: "space-y-1",
|
|
210
|
+
children: [/* @__PURE__ */ jsxs("label", {
|
|
211
|
+
className: "block text-xs font-semibold text-gray-700",
|
|
212
|
+
children: [binding.label, /* @__PURE__ */ jsxs("span", {
|
|
213
|
+
className: "ml-1 text-gray-400",
|
|
214
|
+
children: [
|
|
215
|
+
"(",
|
|
216
|
+
binding.property,
|
|
217
|
+
")"
|
|
218
|
+
]
|
|
219
|
+
})]
|
|
220
|
+
}), /* @__PURE__ */ jsx(Field, {
|
|
221
|
+
binding: {
|
|
222
|
+
id: dataId,
|
|
223
|
+
label: binding.label,
|
|
224
|
+
property: binding.property,
|
|
225
|
+
type: binding.type,
|
|
226
|
+
widget: binding.widget,
|
|
227
|
+
options: binding.options,
|
|
228
|
+
render: binding.render,
|
|
229
|
+
min: binding.min,
|
|
230
|
+
max: binding.max,
|
|
231
|
+
pattern: binding.pattern,
|
|
232
|
+
required: binding.required,
|
|
233
|
+
value: currentValue,
|
|
234
|
+
onChange: (next) => onChange?.({
|
|
235
|
+
id: dataId,
|
|
236
|
+
label: binding.label,
|
|
237
|
+
property: binding.property,
|
|
238
|
+
value: next
|
|
239
|
+
})
|
|
240
|
+
},
|
|
241
|
+
onNodeChange: onChange
|
|
242
|
+
})]
|
|
243
|
+
}, binding.label);
|
|
244
|
+
})
|
|
245
|
+
})
|
|
246
|
+
});
|
|
247
|
+
};
|
|
248
|
+
//#endregion
|
|
194
249
|
//#region src/components/dnd/panel/selection.ts
|
|
195
250
|
const removeIndices = (items, indices) => {
|
|
196
251
|
return items.filter((_, index) => !indices.has(index));
|
|
@@ -550,12 +605,13 @@ const Items = ({ value, render, onChange, onChildChange }) => {
|
|
|
550
605
|
})]
|
|
551
606
|
}), /* @__PURE__ */ jsx(Field, {
|
|
552
607
|
binding: {
|
|
608
|
+
id: `primitive-${item.id}`,
|
|
553
609
|
label: `item-${i}`,
|
|
554
|
-
property: item.type
|
|
610
|
+
property: item.type,
|
|
611
|
+
value: String(item.value ?? ""),
|
|
612
|
+
onChange: (next) => updatePrimitive(item.index, next)
|
|
555
613
|
},
|
|
556
|
-
|
|
557
|
-
value: String(item.value ?? ""),
|
|
558
|
-
onChange: ({ value: next }) => updatePrimitive(item.index, next)
|
|
614
|
+
onNodeChange: onChildChange
|
|
559
615
|
})]
|
|
560
616
|
}, item.id))
|
|
561
617
|
]
|
|
@@ -645,14 +701,15 @@ const Items = ({ value, render, onChange, onChildChange }) => {
|
|
|
645
701
|
children: key
|
|
646
702
|
}), /* @__PURE__ */ jsx(Field, {
|
|
647
703
|
binding: {
|
|
704
|
+
id: `item-${item.id}-${key}`,
|
|
648
705
|
label: key,
|
|
649
706
|
property: render?.[key] && "type" in render[key] ? render[key].property ?? render[key].type : key,
|
|
650
707
|
type: render?.[key] && "type" in render[key] ? render[key].type : void 0,
|
|
651
|
-
render: render?.[key] && "type" in render[key] ? render[key].render : render?.[key] && !("type" in render[key]) ? render[key] : void 0
|
|
708
|
+
render: render?.[key] && "type" in render[key] ? render[key].render : render?.[key] && !("type" in render[key]) ? render[key] : void 0,
|
|
709
|
+
value: String(prop.value),
|
|
710
|
+
onChange: (next) => updateProperty(item.index, key, parseValue(next))
|
|
652
711
|
},
|
|
653
|
-
|
|
654
|
-
value: String(prop.value),
|
|
655
|
-
onChange: ({ value: next }) => updateProperty(item.index, key, parseValue(next))
|
|
712
|
+
onNodeChange: onChildChange
|
|
656
713
|
})]
|
|
657
714
|
}), /* @__PURE__ */ jsxs("span", {
|
|
658
715
|
className: "text-right text-xs text-gray-500",
|
|
@@ -896,7 +953,7 @@ const Children = ({ value, onChange, onNodeChange }) => {
|
|
|
896
953
|
});
|
|
897
954
|
};
|
|
898
955
|
//#endregion
|
|
899
|
-
//#region src/components/dnd/panel/icon-map.
|
|
956
|
+
//#region src/components/dnd/panel/icon-map.tsx
|
|
900
957
|
const ICON_MAP = {
|
|
901
958
|
AlertCircle,
|
|
902
959
|
ArrowDown,
|
|
@@ -936,6 +993,13 @@ const ICON_MAP = {
|
|
|
936
993
|
User,
|
|
937
994
|
X
|
|
938
995
|
};
|
|
996
|
+
const ICON_OPTIONS = Object.entries(ICON_MAP).map(([name, Icon]) => ({
|
|
997
|
+
label: /* @__PURE__ */ jsxs("span", {
|
|
998
|
+
className: "flex items-center gap-2",
|
|
999
|
+
children: [/* @__PURE__ */ jsx(Icon, { size: 14 }), name]
|
|
1000
|
+
}),
|
|
1001
|
+
value: name
|
|
1002
|
+
}));
|
|
939
1003
|
//#endregion
|
|
940
1004
|
//#region src/components/dnd/panel/field.tsx
|
|
941
1005
|
const isColorProperty = (propertyName) => {
|
|
@@ -957,7 +1021,7 @@ const formatDateValue = (date) => {
|
|
|
957
1021
|
return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")}`;
|
|
958
1022
|
};
|
|
959
1023
|
const COLOR_COMMIT_DELAY = 75;
|
|
960
|
-
const ColorPickerField = ({
|
|
1024
|
+
const ColorPickerField = ({ value, onChange }) => {
|
|
961
1025
|
const [liveValue, setLiveValue] = useState(value);
|
|
962
1026
|
const [prevValue, setPrevValue] = useState(value);
|
|
963
1027
|
const lastCommittedRef = useRef(value);
|
|
@@ -971,12 +1035,7 @@ const ColorPickerField = ({ id, label, property, value, onChange }) => {
|
|
|
971
1035
|
const commit = (next) => {
|
|
972
1036
|
if (next === lastCommittedRef.current) return;
|
|
973
1037
|
lastCommittedRef.current = next;
|
|
974
|
-
onChange
|
|
975
|
-
id,
|
|
976
|
-
label,
|
|
977
|
-
property,
|
|
978
|
-
value: next
|
|
979
|
-
});
|
|
1038
|
+
onChange(next);
|
|
980
1039
|
};
|
|
981
1040
|
const debouncedCommit = useDebounce(() => commit(liveValue), {
|
|
982
1041
|
delay: COLOR_COMMIT_DELAY,
|
|
@@ -994,14 +1053,8 @@ const ColorPickerField = ({ id, label, property, value, onChange }) => {
|
|
|
994
1053
|
}
|
|
995
1054
|
});
|
|
996
1055
|
};
|
|
997
|
-
const
|
|
998
|
-
|
|
999
|
-
className: "flex items-center gap-2",
|
|
1000
|
-
children: [/* @__PURE__ */ jsx(Icon, { size: 14 }), name]
|
|
1001
|
-
}),
|
|
1002
|
-
value: name
|
|
1003
|
-
}));
|
|
1004
|
-
const Field = ({ binding, id, value, onChange }) => {
|
|
1056
|
+
const Field = ({ binding, onNodeChange }) => {
|
|
1057
|
+
const { id, value, onChange } = binding;
|
|
1005
1058
|
const parsedValue = useMemo(() => {
|
|
1006
1059
|
return parseValue(value);
|
|
1007
1060
|
}, [value]);
|
|
@@ -1009,25 +1062,13 @@ const Field = ({ binding, id, value, onChange }) => {
|
|
|
1009
1062
|
if (binding.property === "items" || binding.property === "data" || binding.type === "array") return /* @__PURE__ */ jsx(Items, {
|
|
1010
1063
|
value,
|
|
1011
1064
|
render: binding.render,
|
|
1012
|
-
onChange
|
|
1013
|
-
|
|
1014
|
-
id,
|
|
1015
|
-
label: binding.label,
|
|
1016
|
-
property: binding.property,
|
|
1017
|
-
value: next
|
|
1018
|
-
});
|
|
1019
|
-
},
|
|
1020
|
-
onChildChange: onChange
|
|
1065
|
+
onChange,
|
|
1066
|
+
onChildChange: onNodeChange
|
|
1021
1067
|
});
|
|
1022
1068
|
if (binding.type === "richtext") return /* @__PURE__ */ jsx(Tiptap, {
|
|
1023
1069
|
value,
|
|
1024
1070
|
onChange: (next) => {
|
|
1025
|
-
if (next !== value) onChange
|
|
1026
|
-
id,
|
|
1027
|
-
label: binding.label,
|
|
1028
|
-
property: binding.property,
|
|
1029
|
-
value: next
|
|
1030
|
-
});
|
|
1071
|
+
if (next !== value) onChange(next);
|
|
1031
1072
|
}
|
|
1032
1073
|
});
|
|
1033
1074
|
if (binding.property === BINDING_PROP.INNER_HTML || binding.type === "jsx") {
|
|
@@ -1038,26 +1079,14 @@ const Field = ({ binding, id, value, onChange }) => {
|
|
|
1038
1079
|
fragment: !isHTML,
|
|
1039
1080
|
raw: isHTML,
|
|
1040
1081
|
onSave: (next) => {
|
|
1041
|
-
if (next !== value) onChange
|
|
1042
|
-
id,
|
|
1043
|
-
label: binding.label,
|
|
1044
|
-
property: binding.property,
|
|
1045
|
-
value: next
|
|
1046
|
-
});
|
|
1082
|
+
if (next !== value) onChange(next);
|
|
1047
1083
|
}
|
|
1048
1084
|
});
|
|
1049
1085
|
}
|
|
1050
1086
|
if (binding.property === "children" && Array.isArray(parsedValue)) return /* @__PURE__ */ jsx(Children, {
|
|
1051
1087
|
value: parsedValue,
|
|
1052
|
-
onChange
|
|
1053
|
-
|
|
1054
|
-
id,
|
|
1055
|
-
label: binding.label,
|
|
1056
|
-
property: binding.property,
|
|
1057
|
-
value: next
|
|
1058
|
-
});
|
|
1059
|
-
},
|
|
1060
|
-
onNodeChange: onChange
|
|
1088
|
+
onChange,
|
|
1089
|
+
onNodeChange
|
|
1061
1090
|
});
|
|
1062
1091
|
if (typeof parsedValue === "object" && parsedValue !== null && !Array.isArray(parsedValue)) return /* @__PURE__ */ jsx("div", {
|
|
1063
1092
|
className: "space-y-2 rounded border border-gray-200 bg-gray-50 p-2",
|
|
@@ -1068,38 +1097,29 @@ const Field = ({ binding, id, value, onChange }) => {
|
|
|
1068
1097
|
children: key
|
|
1069
1098
|
}), /* @__PURE__ */ jsx(Field, {
|
|
1070
1099
|
binding: {
|
|
1100
|
+
id,
|
|
1071
1101
|
label: key,
|
|
1072
1102
|
property: binding.render?.[key] && "type" in binding.render[key] ? binding.render[key].type : key,
|
|
1073
1103
|
type: binding.render?.[key] && "type" in binding.render[key] ? binding.render[key].type : void 0,
|
|
1074
|
-
render: binding.render?.[key] && !("type" in binding.render[key]) ? binding.render[key] : void 0
|
|
1104
|
+
render: binding.render?.[key] && !("type" in binding.render[key]) ? binding.render[key] : void 0,
|
|
1105
|
+
value: typeof val === "object" ? JSON.stringify(val) : String(val),
|
|
1106
|
+
onChange: (next) => {
|
|
1107
|
+
const convertedValue = parseValue(next);
|
|
1108
|
+
const updated = {
|
|
1109
|
+
...parsedValue,
|
|
1110
|
+
[key]: convertedValue
|
|
1111
|
+
};
|
|
1112
|
+
onChange(JSON.stringify(updated));
|
|
1113
|
+
}
|
|
1075
1114
|
},
|
|
1076
|
-
|
|
1077
|
-
value: typeof val === "object" ? JSON.stringify(val) : String(val),
|
|
1078
|
-
onChange: ({ value: next }) => {
|
|
1079
|
-
const convertedValue = parseValue(next);
|
|
1080
|
-
const updated = {
|
|
1081
|
-
...parsedValue,
|
|
1082
|
-
[key]: convertedValue
|
|
1083
|
-
};
|
|
1084
|
-
onChange?.({
|
|
1085
|
-
id,
|
|
1086
|
-
label: binding.label,
|
|
1087
|
-
property: binding.property,
|
|
1088
|
-
value: JSON.stringify(updated)
|
|
1089
|
-
});
|
|
1090
|
-
}
|
|
1115
|
+
onNodeChange
|
|
1091
1116
|
})]
|
|
1092
1117
|
}, key))
|
|
1093
1118
|
});
|
|
1094
1119
|
if (binding.type === "boolean" || typeof parsedValue === "boolean") return /* @__PURE__ */ jsx(Checkbox, {
|
|
1095
1120
|
checked: parsedValue === true || parsedValue === "true",
|
|
1096
1121
|
onChange: (checked) => {
|
|
1097
|
-
onChange
|
|
1098
|
-
id,
|
|
1099
|
-
label: binding.label,
|
|
1100
|
-
property: binding.property,
|
|
1101
|
-
value: checked.toString()
|
|
1102
|
-
});
|
|
1122
|
+
onChange(checked.toString());
|
|
1103
1123
|
}
|
|
1104
1124
|
});
|
|
1105
1125
|
const stringValue = String(value);
|
|
@@ -1107,18 +1127,10 @@ const Field = ({ binding, id, value, onChange }) => {
|
|
|
1107
1127
|
value: stringValue,
|
|
1108
1128
|
options: binding.options,
|
|
1109
1129
|
onChange: (next) => {
|
|
1110
|
-
if (next !== value) onChange
|
|
1111
|
-
id,
|
|
1112
|
-
label: binding.label,
|
|
1113
|
-
property: binding.property,
|
|
1114
|
-
value: next
|
|
1115
|
-
});
|
|
1130
|
+
if (next !== value) onChange(next);
|
|
1116
1131
|
}
|
|
1117
1132
|
});
|
|
1118
1133
|
if (binding.type === "color" || isColorProperty(binding.property)) return /* @__PURE__ */ jsx(ColorPickerField, {
|
|
1119
|
-
id,
|
|
1120
|
-
label: binding.label,
|
|
1121
|
-
property: binding.property,
|
|
1122
1134
|
value: normalizeToHex(stringValue),
|
|
1123
1135
|
onChange
|
|
1124
1136
|
});
|
|
@@ -1132,12 +1144,7 @@ const Field = ({ binding, id, value, onChange }) => {
|
|
|
1132
1144
|
return;
|
|
1133
1145
|
}
|
|
1134
1146
|
setValidationError(null);
|
|
1135
|
-
if (next !== value) onChange
|
|
1136
|
-
id,
|
|
1137
|
-
label: binding.label,
|
|
1138
|
-
property: binding.property,
|
|
1139
|
-
value: next
|
|
1140
|
-
});
|
|
1147
|
+
if (next !== value) onChange(next);
|
|
1141
1148
|
}
|
|
1142
1149
|
}), validationError && /* @__PURE__ */ jsx("p", {
|
|
1143
1150
|
className: "mt-1 text-xs text-red-500",
|
|
@@ -1155,12 +1162,7 @@ const Field = ({ binding, id, value, onChange }) => {
|
|
|
1155
1162
|
return;
|
|
1156
1163
|
}
|
|
1157
1164
|
setValidationError(null);
|
|
1158
|
-
if (next !== value) onChange
|
|
1159
|
-
id,
|
|
1160
|
-
label: binding.label,
|
|
1161
|
-
property: binding.property,
|
|
1162
|
-
value: next
|
|
1163
|
-
});
|
|
1165
|
+
if (next !== value) onChange(next);
|
|
1164
1166
|
}
|
|
1165
1167
|
}), validationError && /* @__PURE__ */ jsx("p", {
|
|
1166
1168
|
className: "mt-1 text-xs text-red-500",
|
|
@@ -1174,12 +1176,7 @@ const Field = ({ binding, id, value, onChange }) => {
|
|
|
1174
1176
|
value: stringValue,
|
|
1175
1177
|
options: ICON_OPTIONS,
|
|
1176
1178
|
onChange: (next) => {
|
|
1177
|
-
if (next !== value) onChange
|
|
1178
|
-
id,
|
|
1179
|
-
label: binding.label,
|
|
1180
|
-
property: binding.property,
|
|
1181
|
-
value: next
|
|
1182
|
-
});
|
|
1179
|
+
if (next !== value) onChange(next);
|
|
1183
1180
|
}
|
|
1184
1181
|
}), SelectedIcon && /* @__PURE__ */ jsx(SelectedIcon, {
|
|
1185
1182
|
size: 18,
|
|
@@ -1207,12 +1204,7 @@ const Field = ({ binding, id, value, onChange }) => {
|
|
|
1207
1204
|
return;
|
|
1208
1205
|
}
|
|
1209
1206
|
setValidationError(null);
|
|
1210
|
-
if (next !== value) onChange
|
|
1211
|
-
id,
|
|
1212
|
-
label: binding.label,
|
|
1213
|
-
property: binding.property,
|
|
1214
|
-
value: next
|
|
1215
|
-
});
|
|
1207
|
+
if (next !== value) onChange(next);
|
|
1216
1208
|
}
|
|
1217
1209
|
}),
|
|
1218
1210
|
/* @__PURE__ */ jsx(Upload, {
|
|
@@ -1222,12 +1214,7 @@ const Field = ({ binding, id, value, onChange }) => {
|
|
|
1222
1214
|
defaultValue: defaultUploadValue,
|
|
1223
1215
|
onChange: (files) => {
|
|
1224
1216
|
const next = files[0]?.url ?? "";
|
|
1225
|
-
if (next !== value) onChange
|
|
1226
|
-
id,
|
|
1227
|
-
label: binding.label,
|
|
1228
|
-
property: binding.property,
|
|
1229
|
-
value: next
|
|
1230
|
-
});
|
|
1217
|
+
if (next !== value) onChange(next);
|
|
1231
1218
|
}
|
|
1232
1219
|
}),
|
|
1233
1220
|
validationError && /* @__PURE__ */ jsx("p", {
|
|
@@ -1249,12 +1236,7 @@ const Field = ({ binding, id, value, onChange }) => {
|
|
|
1249
1236
|
return;
|
|
1250
1237
|
}
|
|
1251
1238
|
setValidationError(null);
|
|
1252
|
-
if (next !== value) onChange
|
|
1253
|
-
id,
|
|
1254
|
-
label: binding.label,
|
|
1255
|
-
property: binding.property,
|
|
1256
|
-
value: next
|
|
1257
|
-
});
|
|
1239
|
+
if (next !== value) onChange(next);
|
|
1258
1240
|
}
|
|
1259
1241
|
}), validationError && /* @__PURE__ */ jsx("p", {
|
|
1260
1242
|
className: "mt-1 text-xs text-red-500",
|
|
@@ -1271,12 +1253,7 @@ const Field = ({ binding, id, value, onChange }) => {
|
|
|
1271
1253
|
return;
|
|
1272
1254
|
}
|
|
1273
1255
|
setValidationError(null);
|
|
1274
|
-
if (next !== value) onChange
|
|
1275
|
-
id,
|
|
1276
|
-
label: binding.label,
|
|
1277
|
-
property: binding.property,
|
|
1278
|
-
value: next
|
|
1279
|
-
});
|
|
1256
|
+
if (next !== value) onChange(next);
|
|
1280
1257
|
}
|
|
1281
1258
|
}), validationError && /* @__PURE__ */ jsx("p", {
|
|
1282
1259
|
className: "mt-1 text-xs text-red-500",
|
|
@@ -1284,46 +1261,43 @@ const Field = ({ binding, id, value, onChange }) => {
|
|
|
1284
1261
|
})] });
|
|
1285
1262
|
};
|
|
1286
1263
|
//#endregion
|
|
1287
|
-
//#region src/components/dnd/panel/
|
|
1288
|
-
const
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
const bindings = data.bindings || parseBinding(bindingAttr.value);
|
|
1294
|
-
if (!bindings.length) return null;
|
|
1295
|
-
return /* @__PURE__ */ jsx("div", {
|
|
1296
|
-
className: "space-y-2 rounded",
|
|
1297
|
-
children: /* @__PURE__ */ jsx("div", {
|
|
1264
|
+
//#region src/components/dnd/panel/field-group.tsx
|
|
1265
|
+
const FieldGroup = ({ bindings, onNodeChange }) => /* @__PURE__ */ jsx("div", {
|
|
1266
|
+
className: "space-y-2 rounded",
|
|
1267
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
1268
|
+
className: "space-y-1",
|
|
1269
|
+
children: bindings.map((binding) => /* @__PURE__ */ jsxs("div", {
|
|
1298
1270
|
className: "space-y-1",
|
|
1299
|
-
children:
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
className: "
|
|
1303
|
-
children: [
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
value: currentValue,
|
|
1317
|
-
onChange
|
|
1318
|
-
})]
|
|
1319
|
-
}, binding.label);
|
|
1320
|
-
})
|
|
1321
|
-
})
|
|
1322
|
-
});
|
|
1323
|
-
};
|
|
1271
|
+
children: [/* @__PURE__ */ jsxs("label", {
|
|
1272
|
+
className: "block text-xs font-semibold text-gray-700",
|
|
1273
|
+
children: [binding.label, /* @__PURE__ */ jsxs("span", {
|
|
1274
|
+
className: "ml-1 text-gray-400",
|
|
1275
|
+
children: [
|
|
1276
|
+
"(",
|
|
1277
|
+
binding.property,
|
|
1278
|
+
")"
|
|
1279
|
+
]
|
|
1280
|
+
})]
|
|
1281
|
+
}), /* @__PURE__ */ jsx(Field, {
|
|
1282
|
+
binding,
|
|
1283
|
+
onNodeChange
|
|
1284
|
+
})]
|
|
1285
|
+
}, binding.label))
|
|
1286
|
+
})
|
|
1287
|
+
});
|
|
1324
1288
|
//#endregion
|
|
1325
1289
|
//#region src/components/dnd/panel/panel.tsx
|
|
1326
|
-
const
|
|
1290
|
+
const groupBindingsById = (bindings) => {
|
|
1291
|
+
const groups = /* @__PURE__ */ new Map();
|
|
1292
|
+
for (const binding of bindings) {
|
|
1293
|
+
const group = groups.get(binding.id);
|
|
1294
|
+
if (group) group.push(binding);
|
|
1295
|
+
else groups.set(binding.id, [binding]);
|
|
1296
|
+
}
|
|
1297
|
+
return [...groups.values()];
|
|
1298
|
+
};
|
|
1299
|
+
const Panel = ({ item, onDelete, onMoveUp, onMoveDown, canMoveUp = false, canMoveDown = false, bindings, onNodeChange }) => {
|
|
1300
|
+
const groups = useMemo(() => groupBindingsById(bindings), [bindings]);
|
|
1327
1301
|
if (!item) return /* @__PURE__ */ jsx(Typography.Paragraph, {
|
|
1328
1302
|
className: cn("p-4 text-sm text-gray-500"),
|
|
1329
1303
|
children: "Please select a section."
|
|
@@ -1360,14 +1334,14 @@ const Panel = ({ item, onDelete, onMoveUp, onMoveDown, canMoveUp = false, canMov
|
|
|
1360
1334
|
]
|
|
1361
1335
|
})]
|
|
1362
1336
|
}),
|
|
1363
|
-
!
|
|
1337
|
+
!groups.length && /* @__PURE__ */ jsx(Typography.Text, {
|
|
1364
1338
|
className: "text-xs text-gray-400",
|
|
1365
1339
|
children: "No editable elements."
|
|
1366
1340
|
}),
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
},
|
|
1341
|
+
groups.map((group) => /* @__PURE__ */ jsx(FieldGroup, {
|
|
1342
|
+
bindings: group,
|
|
1343
|
+
onNodeChange
|
|
1344
|
+
}, group[0].id))
|
|
1371
1345
|
]
|
|
1372
1346
|
});
|
|
1373
1347
|
};
|
|
@@ -1593,8 +1567,8 @@ const Dnd$1 = ({ value: _value, props, modules = {}, onChange: _onChange, classN
|
|
|
1593
1567
|
onMoveDown: () => moveSection(selectedId, "down"),
|
|
1594
1568
|
canMoveUp,
|
|
1595
1569
|
canMoveDown,
|
|
1596
|
-
|
|
1597
|
-
onFieldChange
|
|
1570
|
+
bindings,
|
|
1571
|
+
onNodeChange: onFieldChange
|
|
1598
1572
|
});
|
|
1599
1573
|
};
|
|
1600
1574
|
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(DndContext, {
|
|
@@ -1702,7 +1676,8 @@ const Dnd$1 = ({ value: _value, props, modules = {}, onChange: _onChange, classN
|
|
|
1702
1676
|
//#region src/components/dnd/index.ts
|
|
1703
1677
|
const Dnd = Dnd$1;
|
|
1704
1678
|
Dnd.DraggableItem = DraggableItem;
|
|
1679
|
+
Dnd.DefaultPanel = Panel;
|
|
1705
1680
|
//#endregion
|
|
1706
|
-
export {
|
|
1681
|
+
export { DraggableItem as a, ICON_OPTIONS as i, Panel as n, ICON_MAP as r, Dnd as t };
|
|
1707
1682
|
|
|
1708
|
-
//# sourceMappingURL=dnd-
|
|
1683
|
+
//# sourceMappingURL=dnd-l2V0EmfS.js.map
|