@ohhwells/bridge 0.1.108-next.286 → 0.1.108-next.288

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
@@ -8367,6 +8367,7 @@ var FIELD_TYPES = [
8367
8367
  var FIELD_ATTR = "data-ohw-form-field";
8368
8368
  var FIELD_TYPE_ATTR = "data-ohw-field-type";
8369
8369
  var PLACEHOLDER_EDIT_ATTR = "data-ohw-placeholder-edit";
8370
+ var seedFieldByForm = /* @__PURE__ */ new WeakMap();
8370
8371
  function fieldsKey(formKey) {
8371
8372
  return `${formKey}-fields`;
8372
8373
  }
@@ -8452,7 +8453,11 @@ function markFormFields(form) {
8452
8453
  ensureFieldLabel(wrapper, key);
8453
8454
  syncRequiredMark(wrapper);
8454
8455
  });
8455
- return listFieldWrappers(form);
8456
+ const wrappers = listFieldWrappers(form);
8457
+ if (wrappers.length > 0 && !seedFieldByForm.has(form)) {
8458
+ seedFieldByForm.set(form, wrappers[0].cloneNode(true));
8459
+ }
8460
+ return wrappers;
8456
8461
  }
8457
8462
  function readFieldsFromDom(form) {
8458
8463
  return listFieldWrappers(form).map((wrapper) => {
@@ -8594,12 +8599,27 @@ function insertField(form, type) {
8594
8599
  wrapper = source.cloneNode(true);
8595
8600
  source.after(wrapper);
8596
8601
  } else {
8597
- wrapper = document.createElement("div");
8598
- const label2 = document.createElement("label");
8599
- const input2 = document.createElement("input");
8600
- wrapper.append(label2, input2);
8602
+ const seed = seedFieldByForm.get(form);
8603
+ if (seed) {
8604
+ wrapper = seed.cloneNode(true);
8605
+ } else {
8606
+ wrapper = document.createElement("div");
8607
+ const input2 = document.createElement("input");
8608
+ input2.style.width = "100%";
8609
+ input2.style.boxSizing = "border-box";
8610
+ input2.style.padding = "12px";
8611
+ input2.style.border = "1px solid color-mix(in srgb, currentColor 35%, transparent)";
8612
+ input2.style.borderRadius = "8px";
8613
+ input2.style.background = "#fff";
8614
+ input2.style.fontFamily = "inherit";
8615
+ input2.style.fontSize = "inherit";
8616
+ input2.style.color = "inherit";
8617
+ wrapper.append(input2);
8618
+ }
8601
8619
  const submit = form.querySelector('button, input[type="submit"]');
8602
- if (submit) submit.before(wrapper);
8620
+ let anchor = submit;
8621
+ while (anchor && anchor.parentElement !== form) anchor = anchor.parentElement;
8622
+ if (anchor) anchor.before(wrapper);
8603
8623
  else form.appendChild(wrapper);
8604
8624
  }
8605
8625
  wrapper.setAttribute(FIELD_ATTR, key);
@@ -19699,8 +19719,10 @@ function OhhwellsBridge() {
19699
19719
  crushed its fields together (OHH-490). Not media (image/bg-image/video/icon/map)
19700
19720
  either: those can be their own flex containers centering fallback content (a
19701
19721
  placeholder label, a mascot emoji) \u2014 forcing block broke that centering while the
19702
- image was unset (OHH-758-ish). */
19703
- [data-ohw-editable]:not([data-ohw-editable="form"]):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="map"]) {
19722
+ image was unset (OHH-758-ish). Not inside a container that declares its editables
19723
+ inline (data-ohw-inline-editables): a row of inline links \u2014 a footer's legal line \u2014
19724
+ keeps its line; blockified labels put each link on its own row in the editor only. */
19725
+ [data-ohw-editable]:not([data-ohw-editable="form"]):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="map"]):not([data-ohw-inline-editables] *) {
19704
19726
  display: block;
19705
19727
  }
19706
19728
  /* The block-force above is an author rule, so it beats the browser's own
@@ -21426,6 +21448,7 @@ function OhhwellsBridge() {
21426
21448
  applyMapQuery(el, val);
21427
21449
  } else if (el.dataset.ohwEditable === "icon") {
21428
21450
  applyIconMarkup(el, val);
21451
+ } else if (el.dataset.ohwEditable === "form") {
21429
21452
  } else if (isIconMarkupValue(val)) {
21430
21453
  } else {
21431
21454
  el.innerHTML = val;
@@ -21435,6 +21458,9 @@ function OhhwellsBridge() {
21435
21458
  }
21436
21459
  applyLogoFromContent(content);
21437
21460
  applyLogoSizes(content);
21461
+ document.querySelectorAll('[data-ohw-editable="form"]').forEach((form) => {
21462
+ reconcileFieldsFromContent(form, content);
21463
+ });
21438
21464
  if (sectionsJson) {
21439
21465
  initSectionsFromContent({ __ohw_sections: sectionsJson }, true);
21440
21466
  sectionsLoadedRef.current = true;