@ohhwells/bridge 0.1.65-next.181 → 0.1.65-next.182

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 CHANGED
@@ -6907,7 +6907,7 @@ function showSuccess(form, message) {
6907
6907
  });
6908
6908
  return;
6909
6909
  }
6910
- const text = message ?? form.getAttribute("data-ohw-success-text") ?? DEFAULT_SUCCESS_TEXT;
6910
+ const text = message || form.getAttribute("data-ohw-success-text") || DEFAULT_SUCCESS_TEXT;
6911
6911
  const note = document.createElement("p");
6912
6912
  note.setAttribute("data-ohw-form-success", "");
6913
6913
  note.setAttribute("role", "status");
@@ -6949,6 +6949,9 @@ function ensureSuccessTextEl(form, formKey, initialText) {
6949
6949
  form.appendChild(el);
6950
6950
  return el;
6951
6951
  }
6952
+ function successInitialFor(form, formKey, content) {
6953
+ return content[formSuccessKey(formKey)] || form.getAttribute("data-ohw-success-text") || DEFAULT_SUCCESS_TEXT;
6954
+ }
6952
6955
  function setFormViewState(form, formKey, state, initialText) {
6953
6956
  const success = ensureSuccessTextEl(form, formKey, initialText);
6954
6957
  Array.from(form.children).forEach((child) => {
@@ -7301,6 +7304,7 @@ function reconcileFieldsFromContent(form, content) {
7301
7304
  setFieldPlaceholder(wrapper, spec.placeholder);
7302
7305
  const label = fieldLabelOf(wrapper);
7303
7306
  if (label && spec.label) label.textContent = spec.label;
7307
+ syncRequiredMark(wrapper);
7304
7308
  });
7305
7309
  const wanted = new Set(stored.map((spec) => spec.key));
7306
7310
  listFieldWrappers(form).forEach((wrapper) => {
@@ -14129,6 +14133,10 @@ function isIconEditable(el) {
14129
14133
  return el.dataset.ohwEditable === "icon";
14130
14134
  }
14131
14135
  var MEDIA_SELECTOR = '[data-ohw-editable="image"], [data-ohw-editable="bg-image"], [data-ohw-editable="video"]';
14136
+ var EDITOR_CHROME_SELECTOR = '[data-ohw-toolbar], [data-ohw-form-toolbar], [data-ohw-field-toolbar], [data-ohw-item-toolbar], [data-ohw-more-menu], [data-ohw-state-toggle], [data-ohw-max-badge], [data-slot="dropdown-menu-content"], [data-slot="dropdown-menu-item"]';
14137
+ function isOverEditorChrome(x, y) {
14138
+ return document.elementsFromPoint(x, y).some((el) => el instanceof HTMLElement && el.matches(EDITOR_CHROME_SELECTOR));
14139
+ }
14132
14140
  var NON_MEDIA_SELECTOR = '[data-ohw-editable]:not([data-ohw-editable="image"]):not([data-ohw-editable="bg-image"]):not([data-ohw-editable="video"]):not([data-ohw-editable="icon"]):not([data-ohw-editable="form"])';
14133
14141
  function getVideoEl2(el) {
14134
14142
  return el instanceof HTMLVideoElement ? el : el.querySelector("video");
@@ -15167,9 +15175,14 @@ function OhhwellsBridge() {
15167
15175
  const [fieldTypePickerOpen, setFieldTypePickerOpen] = (0, import_react16.useState)(false);
15168
15176
  const clearFormPick = (0, import_react16.useCallback)(() => {
15169
15177
  const form = formPickElRef.current;
15178
+ const editing = fieldPickElRef.current;
15179
+ if (commitPlaceholderEdit(editing) && editing) {
15180
+ const owner = editing.closest('[data-ohw-editable="form"]');
15181
+ if (owner) persistFieldsRef.current(owner);
15182
+ }
15170
15183
  if (form) {
15171
15184
  const key = formKeyOf(form);
15172
- if (key) setFormViewState(form, key, "default", DEFAULT_SUCCESS_TEXT);
15185
+ if (key) setFormViewState(form, key, "default", successInitialFor(form, key, editContentRef.current));
15173
15186
  }
15174
15187
  setFormViewStateUi("default");
15175
15188
  setFormPickCount(null);
@@ -15563,7 +15576,9 @@ function OhhwellsBridge() {
15563
15576
  const deactivate = (0, import_react16.useCallback)(() => {
15564
15577
  const el = activeElRef.current;
15565
15578
  if (!el) return;
15566
- const key = el.dataset.ohwKey;
15579
+ const isFormBlock = el.dataset.ohwEditable === "form";
15580
+ const isFormControl = el instanceof HTMLInputElement || el instanceof HTMLTextAreaElement || el instanceof HTMLSelectElement;
15581
+ const key = isFormBlock || isFormControl ? void 0 : el.dataset.ohwKey;
15567
15582
  if (key) {
15568
15583
  const timer = autoSaveTimers.current.get(key);
15569
15584
  if (timer !== void 0) {
@@ -16672,6 +16687,7 @@ function OhhwellsBridge() {
16672
16687
  applyLinkHref(el, val);
16673
16688
  } else if (el.dataset.ohwEditable === "icon") {
16674
16689
  applyIconMarkup(el, val);
16690
+ } else if (el.dataset.ohwEditable === "form") {
16675
16691
  } else if (el.innerHTML !== val) {
16676
16692
  el.innerHTML = val;
16677
16693
  }
@@ -16774,8 +16790,9 @@ function OhhwellsBridge() {
16774
16790
  const wrapper = getFieldWrapper(input);
16775
16791
  if (!wrapper || wrapper !== fieldPickElRef.current) return;
16776
16792
  if (saveTimer) clearTimeout(saveTimer);
16793
+ const owner = wrapper.closest('[data-ohw-editable="form"]');
16777
16794
  saveTimer = setTimeout(() => {
16778
- const form = formPickElRef.current;
16795
+ const form = owner ?? formPickElRef.current;
16779
16796
  if (!form) return;
16780
16797
  const previous = input.getAttribute("placeholder");
16781
16798
  input.setAttribute("placeholder", input.value);
@@ -16847,6 +16864,7 @@ function OhhwellsBridge() {
16847
16864
  if (video && video.src !== val) applyVideoSrc(video, val);
16848
16865
  } else if (el.dataset.ohwEditable === "link") {
16849
16866
  applyLinkHref(el, val);
16867
+ } else if (el.dataset.ohwEditable === "form") {
16850
16868
  } else if (el.innerHTML !== val) {
16851
16869
  el.innerHTML = val;
16852
16870
  }
@@ -17489,6 +17507,19 @@ function OhhwellsBridge() {
17489
17507
  setHoveredNavContainerRect(null);
17490
17508
  return;
17491
17509
  }
17510
+ if (target.closest(EDITOR_CHROME_SELECTOR) || isOverEditorChrome(e.clientX, e.clientY) || isInsideLinkEditor(target)) {
17511
+ document.querySelectorAll("[data-ohw-hovered]").forEach((el) => el.removeAttribute("data-ohw-hovered"));
17512
+ hoveredItemElRef.current = null;
17513
+ setHoveredItemRect(null);
17514
+ hoveredNavContainerRef.current = null;
17515
+ setHoveredNavContainerRect(null);
17516
+ formHoverElRef.current = null;
17517
+ setFormHoverRect(null);
17518
+ siblingHintElRef.current = null;
17519
+ setSiblingHintRect(null);
17520
+ setSiblingHintRects([]);
17521
+ return;
17522
+ }
17492
17523
  if (document.documentElement.hasAttribute("data-ohw-panel-dragging") || isInsideFloatingPanel(target) || isPointOverFloatingPanel(e.clientX, e.clientY)) {
17493
17524
  hoveredItemElRef.current = null;
17494
17525
  setHoveredItemRect(null);
@@ -18230,7 +18261,10 @@ function OhhwellsBridge() {
18230
18261
  };
18231
18262
  const handleMouseMove = (e) => {
18232
18263
  const { clientX, clientY } = e;
18233
- if (document.documentElement.hasAttribute("data-ohw-panel-dragging") || floatingPanelOpenRef.current && isPointOverFloatingPanel(clientX, clientY)) {
18264
+ if (document.documentElement.hasAttribute("data-ohw-panel-dragging") || floatingPanelOpenRef.current && isPointOverFloatingPanel(clientX, clientY) || isOverEditorChrome(clientX, clientY)) {
18265
+ document.querySelectorAll("[data-ohw-hovered]").forEach((el) => el.removeAttribute("data-ohw-hovered"));
18266
+ formHoverElRef.current = null;
18267
+ setFormHoverRect(null);
18234
18268
  hoveredItemElRef.current = null;
18235
18269
  setHoveredItemRect(null);
18236
18270
  hoveredNavContainerRef.current = null;
@@ -20105,28 +20139,6 @@ function OhhwellsBridge() {
20105
20139
  }
20106
20140
  ),
20107
20141
  /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: "mx-0.5 h-5 w-px bg-border" }),
20108
- /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
20109
- "button",
20110
- {
20111
- type: "button",
20112
- className: "flex h-7 items-center gap-1.5 whitespace-nowrap rounded-md px-2 text-[13px] font-semibold text-foreground transition-colors hover:bg-muted/80",
20113
- onClick: () => {
20114
- const form = formPickElRef.current;
20115
- if (!form) return;
20116
- postToParent2({
20117
- type: "ow:form-submissions",
20118
- formKey: formKeyOf(form),
20119
- hasLongText: formHasLongText(form)
20120
- });
20121
- },
20122
- "data-ohw-view-submissions": "",
20123
- children: [
20124
- /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_lucide_react18.Table, { size: 14, "aria-hidden": true }),
20125
- "View submissions"
20126
- ]
20127
- }
20128
- ),
20129
- /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: "mx-0.5 h-5 w-px bg-border" }),
20130
20142
  /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: "flex items-center rounded-md bg-muted/70 p-0.5", children: ["default", "success"].map((state) => /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
20131
20143
  "button",
20132
20144
  {
@@ -20137,7 +20149,7 @@ function OhhwellsBridge() {
20137
20149
  const form = formPickElRef.current;
20138
20150
  const key = form ? formKeyOf(form) : null;
20139
20151
  if (!form || !key) return;
20140
- const initial = editContentRef.current[formSuccessKey(key)] ?? DEFAULT_SUCCESS_TEXT;
20152
+ const initial = successInitialFor(form, key, editContentRef.current);
20141
20153
  setFormViewState(form, key, state, initial);
20142
20154
  setFormViewStateUi(state);
20143
20155
  setFormPickRect(form.getBoundingClientRect());
@@ -20165,7 +20177,7 @@ function OhhwellsBridge() {
20165
20177
  chromeGap: formHoverElRef.current && getFieldWrapper(formHoverElRef.current) ? 8 : 24
20166
20178
  }
20167
20179
  ),
20168
- fieldPickRect && fieldPickState && !isItemDragging && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
20180
+ fieldPickRect && fieldPickState && !isItemDragging && toolbarVariant !== "rich-text" && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
20169
20181
  ItemInteractionLayer,
20170
20182
  {
20171
20183
  rect: fieldPickRect,