@ohhwells/bridge 0.1.179-next.473 → 0.1.179-next.474

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
@@ -19452,7 +19452,7 @@ function apiBase() {
19452
19452
  function bridgeVersion() {
19453
19453
  try {
19454
19454
  if (true) {
19455
- return "0.1.179-next.473";
19455
+ return "0.1.179-next.474";
19456
19456
  }
19457
19457
  } catch {
19458
19458
  }
@@ -19466,7 +19466,7 @@ function stampBridgeVersionOnDocument() {
19466
19466
  return;
19467
19467
  }
19468
19468
  try {
19469
- const v = true ? "0.1.179-next.473" : "";
19469
+ const v = true ? "0.1.179-next.474" : "";
19470
19470
  if (v) {
19471
19471
  document.documentElement.setAttribute("data-ohw-bridge-version", v);
19472
19472
  window.__OHW_BRIDGE_VERSION__ = v;
@@ -19545,32 +19545,42 @@ function armLoaderHangBeacon(subdomain, fetchState, hangMs = 15e3) {
19545
19545
  }
19546
19546
 
19547
19547
  // src/lib/form-fields.ts
19548
+ var DEFAULT_DROPDOWN_OPTIONS = ["Option 1", "Option 2", "Option 3"];
19548
19549
  var FIELD_DEFAULTS = {
19549
19550
  "short-text": { label: "Short text", placeholder: "Type placeholder text..." },
19550
19551
  "long-text": { label: "Long text", placeholder: "How can we help?" },
19551
19552
  email: { label: "Email", placeholder: "hello@example.com" },
19552
- phone: { label: "Phone number", placeholder: "(555) 000-0000" }
19553
+ phone: { label: "Phone number", placeholder: "(555) 000-0000" },
19554
+ dropdown: { label: "Dropdown", placeholder: "" }
19553
19555
  };
19554
19556
  var FIELD_TYPES = [
19555
19557
  { type: "short-text", label: "Short text" },
19556
19558
  { type: "long-text", label: "Long text" },
19557
19559
  { type: "email", label: "Email" },
19558
- { type: "phone", label: "Phone" }
19560
+ { type: "phone", label: "Phone" },
19561
+ { type: "dropdown", label: "Dropdown" }
19559
19562
  ];
19560
19563
  var FIELD_ATTR = "data-ohw-form-field";
19561
19564
  var FIELD_TYPE_ATTR = "data-ohw-field-type";
19562
19565
  var PLACEHOLDER_EDIT_ATTR = "data-ohw-placeholder-edit";
19566
+ var DROPDOWN_PANEL_ATTR = "data-ohw-dropdown-panel";
19567
+ var DROPDOWN_OPTION_ATTR = "data-ohw-dropdown-option";
19568
+ var DROPDOWN_OPEN_ATTR = "data-ohw-dropdown-open";
19569
+ var DROPDOWN_OPTION_SELECTED_ATTR = "data-ohw-dropdown-option-selected";
19570
+ var CONTROL_SELECTOR = "input, textarea, select";
19563
19571
  var seedFieldByForm = /* @__PURE__ */ new WeakMap();
19564
19572
  function fieldsKey(formKey) {
19565
19573
  return `${formKey}-fields`;
19566
19574
  }
19567
19575
  function inputTagFor(type) {
19576
+ if (type === "dropdown") return { tag: "select" };
19568
19577
  if (type === "long-text") return { tag: "textarea" };
19569
19578
  if (type === "email") return { tag: "input", inputType: "email" };
19570
19579
  if (type === "phone") return { tag: "input", inputType: "tel" };
19571
19580
  return { tag: "input", inputType: "text" };
19572
19581
  }
19573
19582
  function inferType(input) {
19583
+ if (input.tagName === "SELECT") return "dropdown";
19574
19584
  if (input.tagName === "TEXTAREA") return "long-text";
19575
19585
  const type = input.type;
19576
19586
  if (type === "email") return "email";
@@ -19586,7 +19596,7 @@ function ensureFieldLabel(wrapper, key) {
19586
19596
  }
19587
19597
  return existing;
19588
19598
  }
19589
- const input = fieldInputOf(wrapper);
19599
+ const input = fieldControlOf(wrapper);
19590
19600
  const label = document.createElement("label");
19591
19601
  label.setAttribute("data-ohw-editable", "text");
19592
19602
  label.setAttribute("data-ohw-key", `${key}-label`);
@@ -19596,7 +19606,7 @@ function ensureFieldLabel(wrapper, key) {
19596
19606
  label.style.fontSize = "13px";
19597
19607
  label.style.fontWeight = "500";
19598
19608
  label.style.lineHeight = "1.3";
19599
- const fromPlaceholder = input?.getAttribute("placeholder")?.trim();
19609
+ const fromPlaceholder = input && "getAttribute" in input ? input.getAttribute("placeholder")?.trim() : void 0;
19600
19610
  const text = fromPlaceholder && fromPlaceholder.length < 40 ? fromPlaceholder : key.replace(/[-_]/g, " ");
19601
19611
  label.textContent = text;
19602
19612
  if (input && input.parentElement === wrapper) wrapper.insertBefore(label, input);
@@ -19609,8 +19619,13 @@ function listFieldWrappers(form) {
19609
19619
  function getFieldWrapper(el) {
19610
19620
  return el?.closest(`[${FIELD_ATTR}]`) ?? null;
19611
19621
  }
19622
+ function fieldControlOf(wrapper) {
19623
+ return wrapper.querySelector(CONTROL_SELECTOR);
19624
+ }
19612
19625
  function fieldInputOf(wrapper) {
19613
- return wrapper.querySelector("input, textarea");
19626
+ const control = fieldControlOf(wrapper);
19627
+ if (!control || control.tagName === "SELECT") return null;
19628
+ return control;
19614
19629
  }
19615
19630
  function fieldLabelOf(wrapper) {
19616
19631
  return wrapper.querySelector("label");
@@ -19622,17 +19637,208 @@ function fieldTypeOf(wrapper) {
19622
19637
  return wrapper.getAttribute(FIELD_TYPE_ATTR) ?? "short-text";
19623
19638
  }
19624
19639
  function isFieldRequired(wrapper) {
19625
- return fieldInputOf(wrapper)?.hasAttribute("required") ?? false;
19640
+ return fieldControlOf(wrapper)?.hasAttribute("required") ?? false;
19641
+ }
19642
+ function optionFallbackLabel(index) {
19643
+ return `Option ${index + 1}`;
19644
+ }
19645
+ function normalizeOptionText(text, index) {
19646
+ const trimmed = text.replace(/\u00a0/g, " ").trim();
19647
+ return trimmed || optionFallbackLabel(index);
19648
+ }
19649
+ function readDropdownOptions(wrapper) {
19650
+ const select = fieldControlOf(wrapper);
19651
+ if (!select || select.tagName !== "SELECT") return [...DEFAULT_DROPDOWN_OPTIONS];
19652
+ const options = Array.from(select.options).map(
19653
+ (opt, i) => normalizeOptionText(opt.textContent ?? "", i)
19654
+ );
19655
+ return options.length > 0 ? options : [...DEFAULT_DROPDOWN_OPTIONS];
19656
+ }
19657
+ function fillSelectOptions(select, options) {
19658
+ select.replaceChildren();
19659
+ options.forEach((text, i) => {
19660
+ const opt = document.createElement("option");
19661
+ const label = normalizeOptionText(text, i);
19662
+ opt.value = label;
19663
+ opt.textContent = label;
19664
+ select.appendChild(opt);
19665
+ });
19666
+ if (select.options.length > 0) select.selectedIndex = 0;
19667
+ }
19668
+ function styleDropdownPanelFromSelect(panel, select) {
19669
+ const cs = getComputedStyle(select);
19670
+ panel.style.boxSizing = "border-box";
19671
+ panel.style.width = "100%";
19672
+ panel.style.marginTop = "4px";
19673
+ panel.style.overflow = "hidden";
19674
+ panel.style.borderStyle = cs.borderStyle || "solid";
19675
+ panel.style.borderWidth = cs.borderWidth || "1px";
19676
+ panel.style.borderColor = cs.borderColor;
19677
+ panel.style.borderRadius = cs.borderRadius;
19678
+ panel.style.backgroundColor = cs.backgroundColor;
19679
+ panel.style.fontFamily = cs.fontFamily;
19680
+ panel.style.fontSize = cs.fontSize;
19681
+ panel.style.fontWeight = cs.fontWeight;
19682
+ panel.style.lineHeight = cs.lineHeight;
19683
+ panel.style.color = cs.color;
19684
+ panel.style.boxShadow = cs.boxShadow && cs.boxShadow !== "none" ? cs.boxShadow : "0 8px 24px color-mix(in srgb, #000 12%, transparent)";
19685
+ }
19686
+ function styleDropdownOptionFromSelect(row, select) {
19687
+ const cs = getComputedStyle(select);
19688
+ row.style.paddingTop = cs.paddingTop || "10px";
19689
+ row.style.paddingBottom = cs.paddingBottom || "10px";
19690
+ row.style.paddingLeft = cs.paddingLeft || "12px";
19691
+ row.style.paddingRight = cs.paddingRight || "12px";
19692
+ row.style.fontFamily = cs.fontFamily;
19693
+ row.style.fontSize = cs.fontSize;
19694
+ row.style.fontWeight = cs.fontWeight;
19695
+ row.style.lineHeight = cs.lineHeight;
19696
+ row.style.color = cs.color;
19697
+ row.style.background = "transparent";
19698
+ row.style.border = "none";
19699
+ row.style.outline = "none";
19700
+ row.style.cursor = "text";
19701
+ }
19702
+ function syncDropdownPanel(wrapper) {
19703
+ if (fieldTypeOf(wrapper) !== "dropdown") {
19704
+ wrapper.querySelector(`[${DROPDOWN_PANEL_ATTR}]`)?.remove();
19705
+ wrapper.removeAttribute(DROPDOWN_OPEN_ATTR);
19706
+ return null;
19707
+ }
19708
+ const select = fieldControlOf(wrapper);
19709
+ if (!select || select.tagName !== "SELECT") return null;
19710
+ let panel = wrapper.querySelector(`[${DROPDOWN_PANEL_ATTR}]`);
19711
+ if (!panel) {
19712
+ panel = document.createElement("div");
19713
+ panel.setAttribute(DROPDOWN_PANEL_ATTR, "");
19714
+ select.after(panel);
19715
+ }
19716
+ styleDropdownPanelFromSelect(panel, select);
19717
+ const options = readDropdownOptions(wrapper);
19718
+ const selected = selectedDropdownOptionIndex(wrapper);
19719
+ panel.replaceChildren();
19720
+ options.forEach((text, i) => {
19721
+ panel.appendChild(createDropdownOptionRow(text, i, select));
19722
+ });
19723
+ if (selected != null && selected >= 0 && selected < options.length) {
19724
+ const row = panel.querySelector(`[${DROPDOWN_OPTION_ATTR}="${selected}"]`);
19725
+ row?.setAttribute(DROPDOWN_OPTION_SELECTED_ATTR, "");
19726
+ }
19727
+ return panel;
19728
+ }
19729
+ function createDropdownOptionRow(text, index, select) {
19730
+ const row = document.createElement("div");
19731
+ row.setAttribute(DROPDOWN_OPTION_ATTR, String(index));
19732
+ row.setAttribute("contenteditable", "true");
19733
+ row.setAttribute("spellcheck", "false");
19734
+ row.textContent = text;
19735
+ styleDropdownOptionFromSelect(row, select);
19736
+ return row;
19737
+ }
19738
+ function setDropdownPreviewOpen(wrapper, open) {
19739
+ if (fieldTypeOf(wrapper) !== "dropdown") return;
19740
+ syncDropdownPanel(wrapper);
19741
+ if (open) wrapper.setAttribute(DROPDOWN_OPEN_ATTR, "");
19742
+ else {
19743
+ wrapper.removeAttribute(DROPDOWN_OPEN_ATTR);
19744
+ clearDropdownOptionSelection(wrapper);
19745
+ }
19746
+ }
19747
+ function isDropdownPreviewOpen(wrapper) {
19748
+ return wrapper.hasAttribute(DROPDOWN_OPEN_ATTR);
19749
+ }
19750
+ function listDropdownOptionRows(wrapper) {
19751
+ return Array.from(wrapper.querySelectorAll(`[${DROPDOWN_OPTION_ATTR}]`));
19752
+ }
19753
+ function getDropdownOptionIndex(el) {
19754
+ const row = el?.closest(`[${DROPDOWN_OPTION_ATTR}]`);
19755
+ if (!row) return null;
19756
+ const raw = row.getAttribute(DROPDOWN_OPTION_ATTR);
19757
+ if (raw == null || raw === "") return null;
19758
+ const index = Number(raw);
19759
+ return Number.isFinite(index) ? index : null;
19760
+ }
19761
+ function selectDropdownOption(wrapper, index) {
19762
+ listDropdownOptionRows(wrapper).forEach((row, i) => {
19763
+ if (i === index) row.setAttribute(DROPDOWN_OPTION_SELECTED_ATTR, "");
19764
+ else row.removeAttribute(DROPDOWN_OPTION_SELECTED_ATTR);
19765
+ });
19766
+ }
19767
+ function clearDropdownOptionSelection(wrapper) {
19768
+ if (!wrapper) return;
19769
+ listDropdownOptionRows(wrapper).forEach((row) => row.removeAttribute(DROPDOWN_OPTION_SELECTED_ATTR));
19770
+ }
19771
+ function selectedDropdownOptionIndex(wrapper) {
19772
+ const row = wrapper.querySelector(`[${DROPDOWN_OPTION_SELECTED_ATTR}]`);
19773
+ return getDropdownOptionIndex(row);
19774
+ }
19775
+ function commitDropdownOptionsFromPanel(wrapper, finalize = false) {
19776
+ const select = fieldControlOf(wrapper);
19777
+ if (!select || select.tagName !== "SELECT") return readDropdownOptions(wrapper);
19778
+ const rows = listDropdownOptionRows(wrapper);
19779
+ const options = rows.length > 0 ? rows.map((row, i) => {
19780
+ const trimmed = (row.textContent ?? "").replace(/\u00a0/g, " ").trim();
19781
+ return finalize ? normalizeOptionText(trimmed, i) : trimmed || optionFallbackLabel(i);
19782
+ }) : readDropdownOptions(wrapper);
19783
+ fillSelectOptions(select, options);
19784
+ if (finalize) {
19785
+ const panelRows = listDropdownOptionRows(wrapper);
19786
+ if (panelRows.length !== select.options.length) {
19787
+ syncDropdownPanel(wrapper);
19788
+ } else {
19789
+ panelRows.forEach((row, i) => {
19790
+ const label = options[i] ?? optionFallbackLabel(i);
19791
+ if (row.textContent !== label) row.textContent = label;
19792
+ row.setAttribute(DROPDOWN_OPTION_ATTR, String(i));
19793
+ });
19794
+ }
19795
+ }
19796
+ return readDropdownOptions(wrapper);
19797
+ }
19798
+ function writeDropdownOptions(wrapper, options) {
19799
+ const select = fieldControlOf(wrapper);
19800
+ if (!select || select.tagName !== "SELECT") return;
19801
+ const normalized = (options.length > 0 ? options : [...DEFAULT_DROPDOWN_OPTIONS]).map(
19802
+ (text, i) => normalizeOptionText(text, i)
19803
+ );
19804
+ fillSelectOptions(select, normalized);
19805
+ syncDropdownPanel(wrapper);
19806
+ }
19807
+ function currentDropdownOptions(wrapper) {
19808
+ const rows = listDropdownOptionRows(wrapper);
19809
+ if (rows.length === 0) return readDropdownOptions(wrapper);
19810
+ return rows.map((row, i) => normalizeOptionText(row.textContent ?? "", i));
19811
+ }
19812
+ function duplicateDropdownOption(wrapper, index) {
19813
+ const options = currentDropdownOptions(wrapper);
19814
+ if (index < 0 || index >= options.length) return index;
19815
+ const next = [...options];
19816
+ next.splice(index + 1, 0, options[index]);
19817
+ writeDropdownOptions(wrapper, next);
19818
+ selectDropdownOption(wrapper, index + 1);
19819
+ return index + 1;
19820
+ }
19821
+ function removeDropdownOption(wrapper, index) {
19822
+ const options = currentDropdownOptions(wrapper);
19823
+ if (options.length <= 1 || index < 0 || index >= options.length) {
19824
+ selectDropdownOption(wrapper, Math.max(0, Math.min(index, options.length - 1)));
19825
+ return selectedDropdownOptionIndex(wrapper);
19826
+ }
19827
+ const next = options.filter((_, i) => i !== index);
19828
+ writeDropdownOptions(wrapper, next);
19829
+ const nextIndex = Math.min(index, next.length - 1);
19830
+ selectDropdownOption(wrapper, nextIndex);
19831
+ return nextIndex;
19626
19832
  }
19627
19833
  function markFormFields(form) {
19628
- form.querySelectorAll("input, textarea").forEach((input) => {
19834
+ form.querySelectorAll(CONTROL_SELECTOR).forEach((input) => {
19629
19835
  const type = input.type;
19630
19836
  if (type === "submit" || type === "button" || type === "reset" || type === "hidden" || type === "checkbox" || type === "radio") {
19631
19837
  return;
19632
19838
  }
19633
19839
  if (getFieldWrapper(input)) return;
19634
19840
  let wrapper = input;
19635
- while (wrapper.parentElement && wrapper.parentElement !== form && wrapper.parentElement.querySelectorAll("input, textarea").length === 1) {
19841
+ while (wrapper.parentElement && wrapper.parentElement !== form && wrapper.parentElement.querySelectorAll(CONTROL_SELECTOR).length === 1) {
19636
19842
  wrapper = wrapper.parentElement;
19637
19843
  }
19638
19844
  if (wrapper === input) {
@@ -19646,6 +19852,7 @@ function markFormFields(form) {
19646
19852
  wrapper.setAttribute(FIELD_ATTR, key);
19647
19853
  wrapper.setAttribute(FIELD_TYPE_ATTR, inferType(input));
19648
19854
  ensureFieldLabel(wrapper, key);
19855
+ if (inferType(input) === "dropdown") syncDropdownPanel(wrapper);
19649
19856
  syncRequiredMark(wrapper);
19650
19857
  });
19651
19858
  const wrappers = listFieldWrappers(form);
@@ -19656,16 +19863,20 @@ function markFormFields(form) {
19656
19863
  }
19657
19864
  function readFieldsFromDom(form) {
19658
19865
  return listFieldWrappers(form).map((wrapper) => {
19659
- const input = fieldInputOf(wrapper);
19866
+ const type = fieldTypeOf(wrapper);
19867
+ const control = fieldControlOf(wrapper);
19868
+ const isDropdown = type === "dropdown";
19869
+ if (isDropdown) commitDropdownOptionsFromPanel(wrapper, true);
19660
19870
  return {
19661
19871
  key: fieldKeyOf(wrapper),
19662
- type: fieldTypeOf(wrapper),
19872
+ type,
19663
19873
  label: fieldLabelText(fieldLabelOf(wrapper)).trim(),
19664
19874
  // While a field is selected its placeholder text lives in the value (see
19665
19875
  // beginPlaceholderEdit), so reading the attribute would store an empty one — whoever
19666
19876
  // happens to save at that moment must still record what the owner typed.
19667
- placeholder: input ? input.hasAttribute(PLACEHOLDER_EDIT_ATTR) ? input.value : input.getAttribute("placeholder") ?? "" : "",
19668
- required: Boolean(input?.hasAttribute("required"))
19877
+ placeholder: !isDropdown && control && control.tagName !== "SELECT" ? control.hasAttribute(PLACEHOLDER_EDIT_ATTR) ? control.value : control.getAttribute("placeholder") ?? "" : "",
19878
+ required: Boolean(control?.hasAttribute("required")),
19879
+ ...isDropdown ? { options: readDropdownOptions(wrapper) } : {}
19669
19880
  };
19670
19881
  });
19671
19882
  }
@@ -19683,8 +19894,8 @@ function isDefaultText(value, pick) {
19683
19894
  if (!trimmed) return true;
19684
19895
  return Object.values(FIELD_DEFAULTS).some((defaults) => pick(defaults) === trimmed);
19685
19896
  }
19686
- function applyFieldType(wrapper, type) {
19687
- const input = fieldInputOf(wrapper);
19897
+ function applyFieldType(wrapper, type, options) {
19898
+ const input = fieldControlOf(wrapper);
19688
19899
  if (!input) return;
19689
19900
  const defaults = FIELD_DEFAULTS[type];
19690
19901
  const placeholder = input.getAttribute("placeholder") ?? "";
@@ -19696,6 +19907,10 @@ function applyFieldType(wrapper, type) {
19696
19907
  };
19697
19908
  const { tag, inputType } = inputTagFor(type);
19698
19909
  wrapper.setAttribute(FIELD_TYPE_ATTR, type);
19910
+ if (type !== "dropdown") {
19911
+ wrapper.querySelector(`[${DROPDOWN_PANEL_ATTR}]`)?.remove();
19912
+ wrapper.removeAttribute(DROPDOWN_OPEN_ATTR);
19913
+ }
19699
19914
  const shedSize = (el) => {
19700
19915
  if (type === "long-text") return;
19701
19916
  el.style.removeProperty("height");
@@ -19707,28 +19922,39 @@ function applyFieldType(wrapper, type) {
19707
19922
  }
19708
19923
  };
19709
19924
  const applyDefaults = (el) => {
19925
+ if (type === "dropdown") return;
19710
19926
  el.setAttribute("placeholder", defaults.placeholder);
19711
19927
  if (label && followsDefaults.label) {
19712
19928
  label.textContent = defaults.label;
19713
19929
  }
19714
19930
  };
19931
+ const applyDropdown = (select) => {
19932
+ const nextOptions = options && options.length > 0 ? options.map((text, i) => normalizeOptionText(text, i)) : [...DEFAULT_DROPDOWN_OPTIONS];
19933
+ fillSelectOptions(select, nextOptions);
19934
+ select.removeAttribute("placeholder");
19935
+ if (label && followsDefaults.label) label.textContent = defaults.label;
19936
+ syncDropdownPanel(wrapper);
19937
+ };
19715
19938
  if (input.tagName.toLowerCase() === tag) {
19716
19939
  if (inputType) input.type = inputType;
19717
19940
  shedSize(input);
19718
- applyDefaults(input);
19941
+ if (type === "dropdown") applyDropdown(input);
19942
+ else applyDefaults(input);
19719
19943
  requireIfEmail(wrapper, type);
19720
19944
  return;
19721
19945
  }
19722
19946
  const next = document.createElement(tag);
19723
19947
  Array.from(input.attributes).forEach((attr) => {
19724
19948
  if (attr.name === "type") return;
19949
+ if (tag === "select" && (attr.name === "value" || attr.name === "placeholder")) return;
19725
19950
  next.setAttribute(attr.name, attr.value);
19726
19951
  });
19727
19952
  if (inputType) next.setAttribute("type", inputType);
19728
19953
  shedSize(next);
19729
19954
  if (type === "long-text") next.setAttribute("rows", "4");
19730
19955
  input.replaceWith(next);
19731
- applyDefaults(next);
19956
+ if (type === "dropdown") applyDropdown(next);
19957
+ else applyDefaults(next);
19732
19958
  requireIfEmail(wrapper, type);
19733
19959
  }
19734
19960
  function requireIfEmail(wrapper, type) {
@@ -19750,7 +19976,7 @@ function syncRequiredMark(wrapper) {
19750
19976
  else label.removeAttribute(REQUIRED_MARK_ATTR);
19751
19977
  }
19752
19978
  function setFieldRequired(wrapper, required) {
19753
- const input = fieldInputOf(wrapper);
19979
+ const input = fieldControlOf(wrapper);
19754
19980
  const label = fieldLabelOf(wrapper);
19755
19981
  if (!input) return;
19756
19982
  if (required) input.setAttribute("required", "");
@@ -19758,6 +19984,7 @@ function setFieldRequired(wrapper, required) {
19758
19984
  if (label) syncRequiredMark(wrapper);
19759
19985
  }
19760
19986
  function beginPlaceholderEdit(wrapper) {
19987
+ if (fieldTypeOf(wrapper) === "dropdown") return;
19761
19988
  const input = fieldInputOf(wrapper);
19762
19989
  if (!input || input.hasAttribute(PLACEHOLDER_EDIT_ATTR)) return;
19763
19990
  input.style.setProperty("--ohw-placeholder-edit-color", getComputedStyle(input).color);
@@ -19767,6 +19994,11 @@ function beginPlaceholderEdit(wrapper) {
19767
19994
  }
19768
19995
  function commitPlaceholderEdit(wrapper) {
19769
19996
  if (!wrapper) return false;
19997
+ if (fieldTypeOf(wrapper) === "dropdown") {
19998
+ const before = readDropdownOptions(wrapper).join("\0");
19999
+ const after = commitDropdownOptionsFromPanel(wrapper, true).join("\0");
20000
+ return before !== after;
20001
+ }
19770
20002
  const input = fieldInputOf(wrapper);
19771
20003
  if (!input || !input.hasAttribute(PLACEHOLDER_EDIT_ATTR)) return false;
19772
20004
  const typed = input.value;
@@ -19778,6 +20010,7 @@ function commitPlaceholderEdit(wrapper) {
19778
20010
  return previous !== typed;
19779
20011
  }
19780
20012
  function setFieldPlaceholder(wrapper, placeholder) {
20013
+ if (fieldTypeOf(wrapper) === "dropdown") return;
19781
20014
  fieldInputOf(wrapper)?.setAttribute("placeholder", placeholder);
19782
20015
  }
19783
20016
  function uniqueKey(form, base) {
@@ -19821,14 +20054,17 @@ function insertField(form, type) {
19821
20054
  }
19822
20055
  wrapper.setAttribute(FIELD_ATTR, key);
19823
20056
  wrapper.setAttribute(FIELD_TYPE_ATTR, type);
20057
+ wrapper.removeAttribute(DROPDOWN_OPEN_ATTR);
19824
20058
  applyFieldType(wrapper, type);
19825
20059
  const defaults = FIELD_DEFAULTS[type];
19826
- const input = fieldInputOf(wrapper);
20060
+ const input = fieldControlOf(wrapper);
19827
20061
  if (input) {
19828
20062
  input.setAttribute("name", key);
19829
20063
  input.removeAttribute("required");
19830
- input.setAttribute("placeholder", defaults.placeholder);
19831
- input.value = "";
20064
+ if (type !== "dropdown") {
20065
+ input.setAttribute("placeholder", defaults.placeholder);
20066
+ if (input.tagName !== "SELECT") input.value = "";
20067
+ }
19832
20068
  }
19833
20069
  const label = ensureFieldLabel(wrapper, key);
19834
20070
  label.textContent = defaults.label;
@@ -19837,18 +20073,22 @@ function insertField(form, type) {
19837
20073
  return wrapper;
19838
20074
  }
19839
20075
  function duplicateField(form, wrapper) {
20076
+ if (fieldTypeOf(wrapper) === "dropdown") commitDropdownOptionsFromPanel(wrapper);
19840
20077
  const copy = wrapper.cloneNode(true);
19841
20078
  const key = uniqueKey(form, `${fieldKeyOf(wrapper)}-copy`);
19842
20079
  copy.setAttribute(FIELD_ATTR, key);
19843
- const input = fieldInputOf(copy);
20080
+ copy.removeAttribute(DROPDOWN_OPEN_ATTR);
20081
+ clearDropdownOptionSelection(copy);
20082
+ const input = fieldControlOf(copy);
19844
20083
  if (input) {
19845
20084
  input.setAttribute("name", key);
19846
20085
  input.removeAttribute("data-ohw-key");
19847
- input.value = "";
20086
+ if (input.tagName !== "SELECT") input.value = "";
19848
20087
  }
19849
20088
  const label = fieldLabelOf(copy);
19850
20089
  if (label) label.setAttribute("data-ohw-key", `${key}-label`);
19851
20090
  wrapper.after(copy);
20091
+ if (fieldTypeOf(copy) === "dropdown") syncDropdownPanel(copy);
19852
20092
  return copy;
19853
20093
  }
19854
20094
  function removeField(wrapper) {
@@ -19887,16 +20127,22 @@ function reconcileFieldsFromContent(form, content) {
19887
20127
  wrapper = insertField(form, spec.type);
19888
20128
  if (!wrapper) return;
19889
20129
  wrapper.setAttribute(FIELD_ATTR, spec.key);
19890
- const input = fieldInputOf(wrapper);
20130
+ const input = fieldControlOf(wrapper);
19891
20131
  if (input) {
19892
20132
  input.setAttribute("name", spec.key);
19893
20133
  }
19894
20134
  fieldLabelOf(wrapper)?.setAttribute("data-ohw-key", `${spec.key}-label`);
19895
20135
  byKey.set(spec.key, wrapper);
19896
20136
  }
19897
- applyFieldType(wrapper, spec.type);
20137
+ const dropdownWasOpen = wrapper.hasAttribute(DROPDOWN_OPEN_ATTR);
20138
+ applyFieldType(wrapper, spec.type, spec.type === "dropdown" ? spec.options : void 0);
19898
20139
  setFieldRequired(wrapper, spec.required);
19899
20140
  setFieldPlaceholder(wrapper, spec.placeholder);
20141
+ if (spec.type === "dropdown") {
20142
+ writeDropdownOptions(wrapper, spec.options?.length ? spec.options : [...DEFAULT_DROPDOWN_OPTIONS]);
20143
+ }
20144
+ if (spec.type === "dropdown" && dropdownWasOpen) setDropdownPreviewOpen(wrapper, true);
20145
+ else wrapper.removeAttribute(DROPDOWN_OPEN_ATTR);
19900
20146
  const label = fieldLabelOf(wrapper);
19901
20147
  if (label && spec.label) label.textContent = spec.label.replace(/\s*\*\s*$/, "").trimEnd();
19902
20148
  syncRequiredMark(wrapper);
@@ -19919,11 +20165,14 @@ var TYPE_ICONS = {
19919
20165
  "short-text": import_lucide_react4.Type,
19920
20166
  "long-text": import_lucide_react4.TextQuote,
19921
20167
  email: import_lucide_react4.AtSign,
19922
- phone: import_lucide_react4.Phone
20168
+ phone: import_lucide_react4.Phone,
20169
+ dropdown: import_lucide_react4.ChevronDown
19923
20170
  };
19924
20171
  function FormFieldToolbar({
19925
20172
  type,
19926
20173
  required,
20174
+ dropdownOpen = null,
20175
+ onDropdownOpenChange,
19927
20176
  onTypeChange,
19928
20177
  onRequiredToggle,
19929
20178
  onDuplicate,
@@ -19931,6 +20180,7 @@ function FormFieldToolbar({
19931
20180
  }) {
19932
20181
  const TypeIcon = TYPE_ICONS[type];
19933
20182
  const typeLabel = FIELD_TYPES.find((entry) => entry.type === type)?.label ?? "Short text";
20183
+ const showDropdownToggle = type === "dropdown" && dropdownOpen !== null && dropdownOpen !== void 0;
19934
20184
  return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
19935
20185
  "div",
19936
20186
  {
@@ -19982,29 +20232,131 @@ function FormFieldToolbar({
19982
20232
  ]
19983
20233
  }
19984
20234
  ),
19985
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "mx-0.5 h-5 w-px bg-border" }),
19986
- /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(DropdownMenu, { children: [
19987
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
19988
- "button",
20235
+ showDropdownToggle ? /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_jsx_runtime15.Fragment, { children: [
20236
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "mx-0.5 h-5 w-px bg-border" }),
20237
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
20238
+ ToggleGroup,
19989
20239
  {
19990
- type: "button",
19991
- title: "More",
19992
- "aria-label": "More",
19993
- className: "flex h-7 w-7 items-center justify-center rounded-md text-foreground transition-colors hover:bg-muted/70",
19994
- children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_lucide_react4.MoreHorizontal, { size: 15, "aria-hidden": true })
20240
+ value: dropdownOpen ? "open" : "closed",
20241
+ onValueChange: () => {
20242
+ },
20243
+ className: "h-7 gap-0.5 rounded-[calc(var(--radius,0.5rem)-2px)] bg-muted p-0.5",
20244
+ onMouseDown: (e) => {
20245
+ e.preventDefault();
20246
+ e.stopPropagation();
20247
+ },
20248
+ children: [
20249
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
20250
+ ToggleGroupItem,
20251
+ {
20252
+ value: "closed",
20253
+ size: "sm",
20254
+ "aria-label": "Closed",
20255
+ className: "h-6 min-w-0 px-2 text-xs font-medium",
20256
+ onMouseDown: (e) => {
20257
+ e.preventDefault();
20258
+ e.stopPropagation();
20259
+ if (dropdownOpen !== false) onDropdownOpenChange?.(false);
20260
+ },
20261
+ onClick: (e) => {
20262
+ e.preventDefault();
20263
+ e.stopPropagation();
20264
+ },
20265
+ children: "Closed"
20266
+ }
20267
+ ),
20268
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
20269
+ ToggleGroupItem,
20270
+ {
20271
+ value: "open",
20272
+ size: "sm",
20273
+ "aria-label": "Open",
20274
+ className: "h-6 min-w-0 px-2 text-xs font-medium",
20275
+ onMouseDown: (e) => {
20276
+ e.preventDefault();
20277
+ e.stopPropagation();
20278
+ if (dropdownOpen !== true) onDropdownOpenChange?.(true);
20279
+ },
20280
+ onClick: (e) => {
20281
+ e.preventDefault();
20282
+ e.stopPropagation();
20283
+ },
20284
+ children: "Open"
20285
+ }
20286
+ )
20287
+ ]
19995
20288
  }
19996
- ) }),
19997
- /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(DropdownMenuContent, { align: "start", sideOffset: 8, className: "min-w-42.5 p-1", children: [
19998
- /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(DropdownMenuItem, { onSelect: onDuplicate, className: "rounded-md py-2 text-[13px]", children: [
19999
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_lucide_react4.Copy, { size: 14, strokeWidth: 1.75, className: "shrink-0", "aria-hidden": true }),
20000
- "Duplicate"
20001
- ] }),
20002
- /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(DropdownMenuItem, { variant: "destructive", onSelect: onDelete, className: "rounded-md py-2 text-[13px]", children: [
20003
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_lucide_react4.Trash2, { size: 14, strokeWidth: 1.75, className: "shrink-0", "aria-hidden": true }),
20004
- "Delete"
20005
- ] })
20006
- ] })
20007
- ] })
20289
+ )
20290
+ ] }) : null,
20291
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "mx-0.5 h-5 w-px bg-border" }),
20292
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
20293
+ "button",
20294
+ {
20295
+ type: "button",
20296
+ title: "Duplicate",
20297
+ "aria-label": "Duplicate",
20298
+ onClick: onDuplicate,
20299
+ className: "flex h-7 w-7 items-center justify-center rounded-md text-foreground transition-colors hover:bg-muted/70",
20300
+ children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_lucide_react4.Copy, { size: 15, strokeWidth: 1.75, "aria-hidden": true })
20301
+ }
20302
+ ),
20303
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
20304
+ "button",
20305
+ {
20306
+ type: "button",
20307
+ title: "Delete",
20308
+ "aria-label": "Delete",
20309
+ onClick: onDelete,
20310
+ className: "flex h-7 w-7 items-center justify-center rounded-md text-foreground transition-colors hover:bg-muted/70",
20311
+ children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_lucide_react4.Trash2, { size: 15, strokeWidth: 1.75, "aria-hidden": true })
20312
+ }
20313
+ )
20314
+ ]
20315
+ }
20316
+ );
20317
+ }
20318
+ function DropdownOptionToolbar({
20319
+ canDelete,
20320
+ onDuplicate,
20321
+ onDelete
20322
+ }) {
20323
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
20324
+ "div",
20325
+ {
20326
+ "data-ohw-dropdown-option-toolbar": "",
20327
+ className: "pointer-events-auto flex items-center gap-0.5 whitespace-nowrap rounded-lg border border-border bg-background p-1 shadow-md",
20328
+ children: [
20329
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
20330
+ "button",
20331
+ {
20332
+ type: "button",
20333
+ title: "Duplicate",
20334
+ "aria-label": "Duplicate",
20335
+ onMouseDown: (e) => {
20336
+ e.preventDefault();
20337
+ e.stopPropagation();
20338
+ onDuplicate();
20339
+ },
20340
+ className: "flex h-7 w-7 items-center justify-center rounded-md text-foreground transition-colors hover:bg-muted/70",
20341
+ children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_lucide_react4.Copy, { size: 15, strokeWidth: 1.75, "aria-hidden": true })
20342
+ }
20343
+ ),
20344
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
20345
+ "button",
20346
+ {
20347
+ type: "button",
20348
+ title: "Delete",
20349
+ "aria-label": "Delete",
20350
+ disabled: !canDelete,
20351
+ onMouseDown: (e) => {
20352
+ e.preventDefault();
20353
+ e.stopPropagation();
20354
+ if (canDelete) onDelete();
20355
+ },
20356
+ className: "flex h-7 w-7 items-center justify-center rounded-md transition-colors " + (canDelete ? "text-foreground hover:bg-muted/70" : "cursor-not-allowed text-muted-foreground opacity-40"),
20357
+ children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_lucide_react4.Trash2, { size: 15, strokeWidth: 1.75, "aria-hidden": true })
20358
+ }
20359
+ )
20008
20360
  ]
20009
20361
  }
20010
20362
  );
@@ -27059,7 +27411,7 @@ function isIconEditable(el) {
27059
27411
  return el.dataset.ohwEditable === "icon";
27060
27412
  }
27061
27413
  var MEDIA_SELECTOR = '[data-ohw-editable="image"], [data-ohw-editable="bg-image"], [data-ohw-editable="video"]';
27062
- 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"]';
27414
+ var EDITOR_CHROME_SELECTOR = '[data-ohw-toolbar], [data-ohw-form-toolbar], [data-ohw-field-toolbar], [data-ohw-dropdown-option-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"]';
27063
27415
  function isOverEditorChrome(x, y) {
27064
27416
  return document.elementsFromPoint(x, y).some((el) => el instanceof HTMLElement && el.matches(EDITOR_CHROME_SELECTOR));
27065
27417
  }
@@ -28447,10 +28799,14 @@ function OhhwellsBridge() {
28447
28799
  const [fieldPickRect, setFieldPickRect] = (0, import_react26.useState)(null);
28448
28800
  const fieldPickElRef = (0, import_react26.useRef)(null);
28449
28801
  const [fieldPickState, setFieldPickState] = (0, import_react26.useState)(null);
28802
+ const [dropdownOptionPick, setDropdownOptionPick] = (0, import_react26.useState)(null);
28450
28803
  const [fieldTypePickerOpen, setFieldTypePickerOpen] = (0, import_react26.useState)(false);
28451
28804
  const clearFormPick = (0, import_react26.useCallback)(() => {
28452
28805
  const form = formPickElRef.current;
28453
28806
  const editing = fieldPickElRef.current;
28807
+ if (editing && fieldTypeOf(editing) === "dropdown") {
28808
+ setDropdownPreviewOpen(editing, false);
28809
+ }
28454
28810
  if (commitPlaceholderEdit(editing) && editing) {
28455
28811
  const owner = editing.closest('[data-ohw-editable="form"]');
28456
28812
  if (owner) persistFieldsRef.current(owner);
@@ -28462,6 +28818,7 @@ function OhhwellsBridge() {
28462
28818
  setFormViewStateUi("default");
28463
28819
  setFormPickCount(null);
28464
28820
  setFieldTypePickerOpen(false);
28821
+ setDropdownOptionPick(null);
28465
28822
  fieldPickElRef.current = null;
28466
28823
  setFieldPickRect(null);
28467
28824
  setFieldPickState(null);
@@ -28470,10 +28827,14 @@ function OhhwellsBridge() {
28470
28827
  }, []);
28471
28828
  const clearFieldPick = (0, import_react26.useCallback)(() => {
28472
28829
  const wrapper = fieldPickElRef.current;
28830
+ if (wrapper && fieldTypeOf(wrapper) === "dropdown") {
28831
+ setDropdownPreviewOpen(wrapper, false);
28832
+ }
28473
28833
  if (commitPlaceholderEdit(wrapper) && wrapper) {
28474
28834
  const form = wrapper.closest('[data-ohw-editable="form"]');
28475
28835
  if (form) persistFieldsRef.current(form);
28476
28836
  }
28837
+ setDropdownOptionPick(null);
28477
28838
  fieldPickElRef.current = null;
28478
28839
  setFieldPickRect(null);
28479
28840
  setFieldPickState(null);
@@ -28491,17 +28852,50 @@ function OhhwellsBridge() {
28491
28852
  []
28492
28853
  );
28493
28854
  persistFieldsRef.current = persistFields;
28855
+ const refreshDropdownOptionPick = (0, import_react26.useCallback)((wrapper, index) => {
28856
+ if (index == null || fieldTypeOf(wrapper) !== "dropdown") {
28857
+ clearDropdownOptionSelection(wrapper);
28858
+ setDropdownOptionPick(null);
28859
+ return;
28860
+ }
28861
+ selectDropdownOption(wrapper, index);
28862
+ const row = listDropdownOptionRows(wrapper)[index];
28863
+ if (!row) {
28864
+ setDropdownOptionPick(null);
28865
+ return;
28866
+ }
28867
+ setDropdownOptionPick({
28868
+ index,
28869
+ rect: row.getBoundingClientRect(),
28870
+ canDelete: listDropdownOptionRows(wrapper).length > 1
28871
+ });
28872
+ setFieldPickRect(null);
28873
+ }, []);
28494
28874
  const selectField = (0, import_react26.useCallback)((wrapper) => {
28495
28875
  if (fieldPickElRef.current && fieldPickElRef.current !== wrapper) {
28496
- commitPlaceholderEdit(fieldPickElRef.current);
28876
+ const prev = fieldPickElRef.current;
28877
+ if (fieldTypeOf(prev) === "dropdown") setDropdownPreviewOpen(prev, false);
28878
+ commitPlaceholderEdit(prev);
28497
28879
  }
28498
28880
  syncRequiredMark(wrapper);
28499
- beginPlaceholderEdit(wrapper);
28881
+ const type = fieldTypeOf(wrapper);
28882
+ if (type === "dropdown") {
28883
+ syncDropdownPanel(wrapper);
28884
+ if (!isDropdownPreviewOpen(wrapper)) setDropdownPreviewOpen(wrapper, false);
28885
+ } else {
28886
+ beginPlaceholderEdit(wrapper);
28887
+ }
28500
28888
  formHoverElRef.current = null;
28501
28889
  setFormHoverRect(null);
28890
+ setDropdownOptionPick(null);
28891
+ clearDropdownOptionSelection(wrapper);
28502
28892
  fieldPickElRef.current = wrapper;
28503
28893
  setFieldPickRect(wrapper.getBoundingClientRect());
28504
- setFieldPickState({ type: fieldTypeOf(wrapper), required: isFieldRequired(wrapper) });
28894
+ setFieldPickState({
28895
+ type,
28896
+ required: isFieldRequired(wrapper),
28897
+ dropdownOpen: type === "dropdown" ? isDropdownPreviewOpen(wrapper) : null
28898
+ });
28505
28899
  setFieldTypePickerOpen(false);
28506
28900
  }, []);
28507
28901
  const withSelectedField = (0, import_react26.useCallback)(
@@ -28531,6 +28925,31 @@ function OhhwellsBridge() {
28531
28925
  }),
28532
28926
  [selectField, withSelectedField]
28533
28927
  );
28928
+ const handleFieldDropdownOpenChange = (0, import_react26.useCallback)((open) => {
28929
+ const wrapper = fieldPickElRef.current;
28930
+ if (!wrapper || fieldTypeOf(wrapper) !== "dropdown") return;
28931
+ if (!open) {
28932
+ commitDropdownOptionsFromPanel(wrapper, true);
28933
+ const form = formPickElRef.current;
28934
+ if (form) persistFieldsRef.current(form);
28935
+ }
28936
+ setDropdownPreviewOpen(wrapper, open);
28937
+ setDropdownOptionPick(null);
28938
+ clearDropdownOptionSelection(wrapper);
28939
+ suppressNextClickRef.current = true;
28940
+ suppressClickUntilRef.current = Date.now() + 400;
28941
+ setFieldPickRect(wrapper.getBoundingClientRect());
28942
+ setFieldPickState({
28943
+ type: "dropdown",
28944
+ required: isFieldRequired(wrapper),
28945
+ dropdownOpen: open
28946
+ });
28947
+ requestAnimationFrame(() => {
28948
+ if (fieldPickElRef.current === wrapper) {
28949
+ setFieldPickRect(wrapper.getBoundingClientRect());
28950
+ }
28951
+ });
28952
+ }, []);
28534
28953
  const handleFieldDuplicate = (0, import_react26.useCallback)(
28535
28954
  () => withSelectedField((form, wrapper) => {
28536
28955
  const copy = duplicateField(form, wrapper);
@@ -28546,6 +28965,28 @@ function OhhwellsBridge() {
28546
28965
  }),
28547
28966
  [clearFieldPick, withSelectedField]
28548
28967
  );
28968
+ const handleDropdownOptionDuplicate = (0, import_react26.useCallback)(() => {
28969
+ const wrapper = fieldPickElRef.current;
28970
+ const form = formPickElRef.current;
28971
+ if (!wrapper || !form || !dropdownOptionPick) return;
28972
+ suppressNextClickRef.current = true;
28973
+ suppressClickUntilRef.current = Date.now() + 400;
28974
+ const nextIndex = duplicateDropdownOption(wrapper, dropdownOptionPick.index);
28975
+ persistFields(form);
28976
+ setDropdownPreviewOpen(wrapper, true);
28977
+ requestAnimationFrame(() => refreshDropdownOptionPick(wrapper, nextIndex));
28978
+ }, [dropdownOptionPick, persistFields, refreshDropdownOptionPick]);
28979
+ const handleDropdownOptionDelete = (0, import_react26.useCallback)(() => {
28980
+ const wrapper = fieldPickElRef.current;
28981
+ const form = formPickElRef.current;
28982
+ if (!wrapper || !form || !dropdownOptionPick || !dropdownOptionPick.canDelete) return;
28983
+ suppressNextClickRef.current = true;
28984
+ suppressClickUntilRef.current = Date.now() + 400;
28985
+ const nextIndex = removeDropdownOption(wrapper, dropdownOptionPick.index);
28986
+ persistFields(form);
28987
+ setDropdownPreviewOpen(wrapper, true);
28988
+ requestAnimationFrame(() => refreshDropdownOptionPick(wrapper, nextIndex));
28989
+ }, [dropdownOptionPick, persistFields, refreshDropdownOptionPick]);
28549
28990
  const handleAddField = (0, import_react26.useCallback)(
28550
28991
  (type) => {
28551
28992
  const form = formPickElRef.current;
@@ -30674,8 +31115,32 @@ function OhhwellsBridge() {
30674
31115
  if (!isEditMode) return;
30675
31116
  let saveTimer = null;
30676
31117
  const onInput = (e) => {
30677
- const input = e.target;
30678
- if (!input || !("value" in input)) return;
31118
+ const target = e.target;
31119
+ if (!target) return;
31120
+ const optionIndex = getDropdownOptionIndex(target);
31121
+ if (optionIndex != null) {
31122
+ const wrapper2 = getFieldWrapper(target);
31123
+ if (!wrapper2 || wrapper2 !== fieldPickElRef.current) return;
31124
+ if (saveTimer) clearTimeout(saveTimer);
31125
+ const owner2 = wrapper2.closest('[data-ohw-editable="form"]');
31126
+ saveTimer = setTimeout(() => {
31127
+ const form = owner2 ?? formPickElRef.current;
31128
+ if (!form) return;
31129
+ commitDropdownOptionsFromPanel(wrapper2);
31130
+ persistFields(form);
31131
+ const row = listDropdownOptionRows(wrapper2)[optionIndex];
31132
+ if (row) {
31133
+ setDropdownOptionPick({
31134
+ index: optionIndex,
31135
+ rect: row.getBoundingClientRect(),
31136
+ canDelete: listDropdownOptionRows(wrapper2).length > 1
31137
+ });
31138
+ }
31139
+ }, 400);
31140
+ return;
31141
+ }
31142
+ const input = target;
31143
+ if (!("value" in input)) return;
30679
31144
  const wrapper = getFieldWrapper(input);
30680
31145
  if (!wrapper || wrapper !== fieldPickElRef.current) return;
30681
31146
  if (saveTimer) clearTimeout(saveTimer);
@@ -31187,6 +31652,7 @@ function OhhwellsBridge() {
31187
31652
  field can be picked and hovered from anywhere inside it (OHH-642). */
31188
31653
  [data-ohw-editable="form"] [data-ohw-form-field] input,
31189
31654
  [data-ohw-editable="form"] [data-ohw-form-field] textarea,
31655
+ [data-ohw-editable="form"] [data-ohw-form-field] select,
31190
31656
  [data-ohw-editable="form"] [data-ohw-form-field] label {
31191
31657
  pointer-events: auto !important;
31192
31658
  cursor: pointer !important;
@@ -31200,10 +31666,35 @@ function OhhwellsBridge() {
31200
31666
  max-width: 100% !important;
31201
31667
  }
31202
31668
  [data-ohw-editable="form"] [data-ohw-form-field] input,
31203
- [data-ohw-editable="form"] [data-ohw-form-field] textarea {
31669
+ [data-ohw-editable="form"] [data-ohw-form-field] textarea,
31670
+ [data-ohw-editable="form"] [data-ohw-form-field] select {
31204
31671
  box-sizing: border-box !important;
31205
31672
  width: 100% !important;
31206
31673
  }
31674
+ /* Dropdown field editor (OHH-919): Closed = select alone; Open = select + panel below.
31675
+ Caret only \u2014 keep the template's own background/border/type on the select. */
31676
+ [data-ohw-editable="form"] [data-ohw-form-field][data-ohw-field-type="dropdown"] select {
31677
+ appearance: none !important;
31678
+ -webkit-appearance: none !important;
31679
+ background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2378716C' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") !important;
31680
+ background-repeat: no-repeat !important;
31681
+ background-position: right 12px center !important;
31682
+ padding-right: 36px !important;
31683
+ pointer-events: none !important;
31684
+ }
31685
+ [data-ohw-editable="form"] [data-ohw-form-field][data-ohw-dropdown-open] select {
31686
+ background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2378716C' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='18 15 12 9 6 15'/%3E%3C/svg%3E") !important;
31687
+ }
31688
+ [data-ohw-editable="form"] [data-ohw-form-field] [data-ohw-dropdown-panel] {
31689
+ display: none !important;
31690
+ }
31691
+ [data-ohw-editable="form"] [data-ohw-form-field][data-ohw-dropdown-open] [data-ohw-dropdown-panel] {
31692
+ display: block !important;
31693
+ }
31694
+ [data-ohw-editable="form"] [data-ohw-dropdown-option] {
31695
+ cursor: text !important;
31696
+ outline: none !important;
31697
+ }
31207
31698
  /* Somewhere to click the block itself, on every side (OHH-642) \u2014 editor only. */
31208
31699
  [data-ohw-editable="form"] {
31209
31700
  padding: 18px !important;
@@ -31211,13 +31702,14 @@ function OhhwellsBridge() {
31211
31702
  flex-wrap: wrap !important;
31212
31703
  align-items: flex-end !important;
31213
31704
  }
31214
- /* Generated forms are excluded: they are always a single column, so the 12rem
31215
- flex BASIS \u2014 a minimum width in a horizontal row \u2014 reads as a 12rem HEIGHT
31216
- there and inflates every field to the tallest one's size. */
31705
+ /* Width floor for horizontal rows \u2014 never flex-basis. On a column form
31706
+ 'flex-basis: 12rem' becomes HEIGHT and fields grow empty space (OHH-919). */
31217
31707
  [data-ohw-editable="form"]:not([data-ai-form]) [data-ohw-form-field] {
31218
- flex: 1 1 12rem !important;
31708
+ flex: 1 1 auto !important;
31219
31709
  min-width: min(12rem, 100%) !important;
31220
31710
  max-width: 100% !important;
31711
+ height: auto !important;
31712
+ align-self: flex-start !important;
31221
31713
  }
31222
31714
  /* Placeholder text lives in the value while selected. currentColor inside color-mix
31223
31715
  resolves to the *inherited* color, so reverse-print footers washed it out on white
@@ -31364,14 +31856,40 @@ function OhhwellsBridge() {
31364
31856
  });
31365
31857
  return;
31366
31858
  }
31859
+ if (target.closest(
31860
+ '[data-ohw-field-toolbar], [data-ohw-dropdown-option-toolbar], [data-ohw-field-type-picker], [data-radix-popper-content-wrapper], [role="menu"], [data-slot="dropdown-menu-content"]'
31861
+ )) {
31862
+ return;
31863
+ }
31367
31864
  {
31368
31865
  const formEl = getFormElement(target);
31369
31866
  const onSuccessText = target.closest(`[${SUCCESS_TEXT_ATTR}]`);
31370
31867
  if (formEl && formKeyOf(formEl) && !onSuccessText && !isCtaButton(target)) {
31371
31868
  const fieldEl = getFieldWrapper(target);
31372
31869
  if (fieldEl) {
31870
+ const optionIndex = getDropdownOptionIndex(target);
31871
+ if (optionIndex != null && fieldTypeOf(fieldEl) === "dropdown" && isDropdownPreviewOpen(fieldEl)) {
31872
+ e.preventDefault();
31873
+ e.stopPropagation();
31874
+ deactivateRef.current();
31875
+ deselectRef.current();
31876
+ formPickElRef.current = formEl;
31877
+ setFormPickRect(null);
31878
+ if (fieldPickElRef.current !== fieldEl) selectField(fieldEl);
31879
+ setDropdownPreviewOpen(fieldEl, true);
31880
+ setFieldPickState({
31881
+ type: "dropdown",
31882
+ required: isFieldRequired(fieldEl),
31883
+ dropdownOpen: true
31884
+ });
31885
+ refreshDropdownOptionPick(fieldEl, optionIndex);
31886
+ listDropdownOptionRows(fieldEl)[optionIndex]?.focus();
31887
+ return;
31888
+ }
31373
31889
  const label = target.closest("label");
31374
- if (label && fieldPickElRef.current === fieldEl) return;
31890
+ if (label && fieldPickElRef.current === fieldEl && selectedDropdownOptionIndex(fieldEl) == null) {
31891
+ return;
31892
+ }
31375
31893
  e.preventDefault();
31376
31894
  e.stopPropagation();
31377
31895
  deactivateRef.current();
@@ -31379,7 +31897,9 @@ function OhhwellsBridge() {
31379
31897
  formPickElRef.current = formEl;
31380
31898
  setFormPickRect(null);
31381
31899
  selectField(fieldEl);
31382
- if (!label) fieldEl.querySelector("input, textarea")?.focus();
31900
+ if (!label && fieldTypeOf(fieldEl) !== "dropdown") {
31901
+ fieldEl.querySelector("input, textarea")?.focus();
31902
+ }
31383
31903
  return;
31384
31904
  }
31385
31905
  clearFieldPick();
@@ -34851,7 +35371,7 @@ function OhhwellsBridge() {
34851
35371
  postToParent2({
34852
35372
  type: "ow:ready",
34853
35373
  version: "1",
34854
- bridgeVersion: "0.1.179-next.473",
35374
+ bridgeVersion: "0.1.179-next.474",
34855
35375
  path: pathname,
34856
35376
  nodes: collectEditableNodes(editContentRef.current),
34857
35377
  sections
@@ -35835,7 +36355,7 @@ function OhhwellsBridge() {
35835
36355
  chromeGap: formHoverElRef.current && getFieldWrapper(formHoverElRef.current) ? 8 : 24
35836
36356
  }
35837
36357
  ),
35838
- fieldPickRect && fieldPickState && !isItemDragging && toolbarVariant !== "rich-text" && /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
36358
+ fieldPickRect && fieldPickState && !dropdownOptionPick && !isItemDragging && toolbarVariant !== "rich-text" && /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
35839
36359
  ItemInteractionLayer,
35840
36360
  {
35841
36361
  rect: fieldPickRect,
@@ -35852,6 +36372,8 @@ function OhhwellsBridge() {
35852
36372
  {
35853
36373
  type: fieldPickState.type,
35854
36374
  required: fieldPickState.required,
36375
+ dropdownOpen: fieldPickState.dropdownOpen,
36376
+ onDropdownOpenChange: handleFieldDropdownOpenChange,
35855
36377
  onTypeChange: handleFieldTypeChange,
35856
36378
  onRequiredToggle: handleFieldRequiredToggle,
35857
36379
  onDuplicate: handleFieldDuplicate,
@@ -35860,6 +36382,25 @@ function OhhwellsBridge() {
35860
36382
  )
35861
36383
  }
35862
36384
  ),
36385
+ dropdownOptionPick && !isItemDragging && /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
36386
+ ItemInteractionLayer,
36387
+ {
36388
+ rect: dropdownOptionPick.rect,
36389
+ state: "active-top",
36390
+ itemDragSurface: false,
36391
+ toolbarAlign: "center",
36392
+ chromeGap: 4,
36393
+ showHandle: false,
36394
+ toolbar: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
36395
+ DropdownOptionToolbar,
36396
+ {
36397
+ canDelete: dropdownOptionPick.canDelete,
36398
+ onDuplicate: handleDropdownOptionDuplicate,
36399
+ onDelete: handleDropdownOptionDelete
36400
+ }
36401
+ )
36402
+ }
36403
+ ),
35863
36404
  fieldDragging ? fieldDropSlots.map((slot, i) => /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
35864
36405
  "div",
35865
36406
  {