@ohhwells/bridge 0.1.65-next.187 → 0.1.65-next.189
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.cjs +45 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +45 -22
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -14304,7 +14304,8 @@ function isNavItemPointerTarget(el) {
|
|
|
14304
14304
|
function getNavigationItemAnchor(el) {
|
|
14305
14305
|
const anchor = el.matches("[data-ohw-href-key]") ? el : el.closest("[data-ohw-href-key]");
|
|
14306
14306
|
if (!anchor) return null;
|
|
14307
|
-
if (!anchor.querySelector('[data-ohw-editable="text"]') && !getSocialItem(anchor))
|
|
14307
|
+
if (!anchor.matches('[data-ohw-editable="text"], [data-ohw-editable="plain"]') && !anchor.querySelector('[data-ohw-editable="text"], [data-ohw-editable="plain"]') && !getSocialItem(anchor))
|
|
14308
|
+
return null;
|
|
14308
14309
|
if (!isNavItemPointerTarget(anchor)) return null;
|
|
14309
14310
|
return anchor;
|
|
14310
14311
|
}
|
|
@@ -15330,17 +15331,37 @@ function OhhwellsBridge() {
|
|
|
15330
15331
|
[persistFields, selectField]
|
|
15331
15332
|
);
|
|
15332
15333
|
const fieldDragRef = (0, import_react16.useRef)(null);
|
|
15334
|
+
const buildFieldDropSlots = (0, import_react16.useCallback)((form, draggedKey) => {
|
|
15335
|
+
const others = listFieldWrappers(form).filter((el) => fieldKeyOf(el) !== draggedKey);
|
|
15336
|
+
const slots = others.map((el) => {
|
|
15337
|
+
const rect = el.getBoundingClientRect();
|
|
15338
|
+
return { top: rect.top, left: rect.left, width: rect.width };
|
|
15339
|
+
});
|
|
15340
|
+
const last = others[others.length - 1];
|
|
15341
|
+
if (last) {
|
|
15342
|
+
const rect = last.getBoundingClientRect();
|
|
15343
|
+
slots.push({ top: rect.bottom, left: rect.left, width: rect.width });
|
|
15344
|
+
}
|
|
15345
|
+
return slots;
|
|
15346
|
+
}, []);
|
|
15333
15347
|
const handleFieldDragStart = (0, import_react16.useCallback)(() => {
|
|
15334
15348
|
const wrapper = fieldPickElRef.current;
|
|
15335
15349
|
const form = formPickElRef.current;
|
|
15336
15350
|
if (!wrapper || !form) return;
|
|
15337
|
-
|
|
15338
|
-
|
|
15351
|
+
const key = fieldKeyOf(wrapper);
|
|
15352
|
+
fieldDragRef.current = { key, form };
|
|
15353
|
+
setFieldDragging(true);
|
|
15354
|
+
setFieldDropSlots(buildFieldDropSlots(form, key));
|
|
15355
|
+
}, [buildFieldDropSlots]);
|
|
15339
15356
|
const handleFieldDragEnd = (0, import_react16.useCallback)(() => {
|
|
15340
15357
|
fieldDragRef.current = null;
|
|
15341
15358
|
setFieldDropIndex(null);
|
|
15359
|
+
setFieldDropSlots([]);
|
|
15360
|
+
setFieldDragging(false);
|
|
15342
15361
|
}, []);
|
|
15343
15362
|
const [fieldDropIndex, setFieldDropIndex] = (0, import_react16.useState)(null);
|
|
15363
|
+
const [fieldDropSlots, setFieldDropSlots] = (0, import_react16.useState)([]);
|
|
15364
|
+
const [fieldDragging, setFieldDragging] = (0, import_react16.useState)(false);
|
|
15344
15365
|
const clearFormPickRef = (0, import_react16.useRef)(clearFormPick);
|
|
15345
15366
|
clearFormPickRef.current = clearFormPick;
|
|
15346
15367
|
(0, import_react16.useEffect)(() => {
|
|
@@ -16801,6 +16822,7 @@ function OhhwellsBridge() {
|
|
|
16801
16822
|
e.preventDefault();
|
|
16802
16823
|
e.stopPropagation();
|
|
16803
16824
|
if (e.dataTransfer) e.dataTransfer.dropEffect = "move";
|
|
16825
|
+
setFieldDropSlots(buildFieldDropSlots(session.form, session.key));
|
|
16804
16826
|
setFieldDropIndex(resolveIndex(session.form, e.clientY));
|
|
16805
16827
|
};
|
|
16806
16828
|
const onDrop = (e) => {
|
|
@@ -16815,6 +16837,8 @@ function OhhwellsBridge() {
|
|
|
16815
16837
|
setFormPickRect(session.form.getBoundingClientRect());
|
|
16816
16838
|
fieldDragRef.current = null;
|
|
16817
16839
|
setFieldDropIndex(null);
|
|
16840
|
+
setFieldDropSlots([]);
|
|
16841
|
+
setFieldDragging(false);
|
|
16818
16842
|
};
|
|
16819
16843
|
window.addEventListener("dragover", onDragOver, true);
|
|
16820
16844
|
window.addEventListener("drop", onDrop, true);
|
|
@@ -16822,7 +16846,7 @@ function OhhwellsBridge() {
|
|
|
16822
16846
|
window.removeEventListener("dragover", onDragOver, true);
|
|
16823
16847
|
window.removeEventListener("drop", onDrop, true);
|
|
16824
16848
|
};
|
|
16825
|
-
}, [isEditMode, persistFields, selectField]);
|
|
16849
|
+
}, [buildFieldDropSlots, isEditMode, persistFields, selectField]);
|
|
16826
16850
|
(0, import_react16.useEffect)(() => {
|
|
16827
16851
|
if (!isEditMode) return;
|
|
16828
16852
|
const mark = () => document.querySelectorAll('[data-ohw-editable="form"]').forEach((form) => {
|
|
@@ -20248,7 +20272,7 @@ function OhhwellsBridge() {
|
|
|
20248
20272
|
ItemInteractionLayer,
|
|
20249
20273
|
{
|
|
20250
20274
|
rect: fieldPickRect,
|
|
20251
|
-
state: "active-top",
|
|
20275
|
+
state: fieldDragging ? "dragging" : "active-top",
|
|
20252
20276
|
itemDragSurface: false,
|
|
20253
20277
|
toolbarAlign: "left",
|
|
20254
20278
|
chromeGap: 10,
|
|
@@ -20269,23 +20293,22 @@ function OhhwellsBridge() {
|
|
|
20269
20293
|
)
|
|
20270
20294
|
}
|
|
20271
20295
|
),
|
|
20272
|
-
|
|
20273
|
-
|
|
20274
|
-
|
|
20275
|
-
|
|
20276
|
-
|
|
20277
|
-
|
|
20278
|
-
|
|
20279
|
-
|
|
20280
|
-
|
|
20281
|
-
|
|
20282
|
-
|
|
20283
|
-
|
|
20284
|
-
|
|
20285
|
-
|
|
20286
|
-
|
|
20287
|
-
|
|
20288
|
-
})() : null,
|
|
20296
|
+
fieldDragging ? fieldDropSlots.map((slot, i) => /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
20297
|
+
"div",
|
|
20298
|
+
{
|
|
20299
|
+
className: "pointer-events-none fixed z-[2147483644]",
|
|
20300
|
+
style: { top: slot.top, left: slot.left, width: slot.width },
|
|
20301
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
20302
|
+
DropIndicator,
|
|
20303
|
+
{
|
|
20304
|
+
direction: "horizontal",
|
|
20305
|
+
state: fieldDropIndex === i ? "dragActive" : "dragIdle",
|
|
20306
|
+
className: "!w-full"
|
|
20307
|
+
}
|
|
20308
|
+
)
|
|
20309
|
+
},
|
|
20310
|
+
`field-drop-${i}`
|
|
20311
|
+
)) : null,
|
|
20289
20312
|
fieldTypePickerOpen && formPickRect && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
20290
20313
|
"div",
|
|
20291
20314
|
{
|