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

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
@@ -19217,7 +19217,16 @@ function ItemInteractionLayer({
19217
19217
  {
19218
19218
  "aria-hidden": true,
19219
19219
  className: "absolute inset-0",
19220
- style: { ...getChromeStyle(state), borderRadius: CHROME_RADIUS }
19220
+ style: {
19221
+ ...getChromeStyle(state),
19222
+ // Draw the stroke inside the measured rect so chromeGap={0} (dropdown options)
19223
+ // does not stick past the list edges (OHH-919 QA).
19224
+ boxSizing: "border-box",
19225
+ borderRadius: CHROME_RADIUS,
19226
+ // Soft ring still paints outside the border box — drop it when flush with the
19227
+ // target so the blue frame stays within the row.
19228
+ ...gap === 0 ? { boxShadow: "none" } : null
19229
+ }
19221
19230
  }
19222
19231
  ),
19223
19232
  itemDragEnabled && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
@@ -19452,7 +19461,7 @@ function apiBase() {
19452
19461
  function bridgeVersion() {
19453
19462
  try {
19454
19463
  if (true) {
19455
- return "0.1.179-next.473";
19464
+ return "0.1.179-next.475";
19456
19465
  }
19457
19466
  } catch {
19458
19467
  }
@@ -19466,7 +19475,7 @@ function stampBridgeVersionOnDocument() {
19466
19475
  return;
19467
19476
  }
19468
19477
  try {
19469
- const v = true ? "0.1.179-next.473" : "";
19478
+ const v = true ? "0.1.179-next.475" : "";
19470
19479
  if (v) {
19471
19480
  document.documentElement.setAttribute("data-ohw-bridge-version", v);
19472
19481
  window.__OHW_BRIDGE_VERSION__ = v;
@@ -19545,32 +19554,42 @@ function armLoaderHangBeacon(subdomain, fetchState, hangMs = 15e3) {
19545
19554
  }
19546
19555
 
19547
19556
  // src/lib/form-fields.ts
19557
+ var DEFAULT_DROPDOWN_OPTIONS = ["Option 1", "Option 2", "Option 3"];
19548
19558
  var FIELD_DEFAULTS = {
19549
19559
  "short-text": { label: "Short text", placeholder: "Type placeholder text..." },
19550
19560
  "long-text": { label: "Long text", placeholder: "How can we help?" },
19551
19561
  email: { label: "Email", placeholder: "hello@example.com" },
19552
- phone: { label: "Phone number", placeholder: "(555) 000-0000" }
19562
+ phone: { label: "Phone number", placeholder: "(555) 000-0000" },
19563
+ dropdown: { label: "Dropdown", placeholder: "" }
19553
19564
  };
19554
19565
  var FIELD_TYPES = [
19555
19566
  { type: "short-text", label: "Short text" },
19556
19567
  { type: "long-text", label: "Long text" },
19557
19568
  { type: "email", label: "Email" },
19558
- { type: "phone", label: "Phone" }
19569
+ { type: "phone", label: "Phone" },
19570
+ { type: "dropdown", label: "Dropdown" }
19559
19571
  ];
19560
19572
  var FIELD_ATTR = "data-ohw-form-field";
19561
19573
  var FIELD_TYPE_ATTR = "data-ohw-field-type";
19562
19574
  var PLACEHOLDER_EDIT_ATTR = "data-ohw-placeholder-edit";
19575
+ var DROPDOWN_PANEL_ATTR = "data-ohw-dropdown-panel";
19576
+ var DROPDOWN_OPTION_ATTR = "data-ohw-dropdown-option";
19577
+ var DROPDOWN_OPEN_ATTR = "data-ohw-dropdown-open";
19578
+ var DROPDOWN_OPTION_SELECTED_ATTR = "data-ohw-dropdown-option-selected";
19579
+ var CONTROL_SELECTOR = "input, textarea, select";
19563
19580
  var seedFieldByForm = /* @__PURE__ */ new WeakMap();
19564
19581
  function fieldsKey(formKey) {
19565
19582
  return `${formKey}-fields`;
19566
19583
  }
19567
19584
  function inputTagFor(type) {
19585
+ if (type === "dropdown") return { tag: "select" };
19568
19586
  if (type === "long-text") return { tag: "textarea" };
19569
19587
  if (type === "email") return { tag: "input", inputType: "email" };
19570
19588
  if (type === "phone") return { tag: "input", inputType: "tel" };
19571
19589
  return { tag: "input", inputType: "text" };
19572
19590
  }
19573
19591
  function inferType(input) {
19592
+ if (input.tagName === "SELECT") return "dropdown";
19574
19593
  if (input.tagName === "TEXTAREA") return "long-text";
19575
19594
  const type = input.type;
19576
19595
  if (type === "email") return "email";
@@ -19586,7 +19605,7 @@ function ensureFieldLabel(wrapper, key) {
19586
19605
  }
19587
19606
  return existing;
19588
19607
  }
19589
- const input = fieldInputOf(wrapper);
19608
+ const input = fieldControlOf(wrapper);
19590
19609
  const label = document.createElement("label");
19591
19610
  label.setAttribute("data-ohw-editable", "text");
19592
19611
  label.setAttribute("data-ohw-key", `${key}-label`);
@@ -19596,7 +19615,7 @@ function ensureFieldLabel(wrapper, key) {
19596
19615
  label.style.fontSize = "13px";
19597
19616
  label.style.fontWeight = "500";
19598
19617
  label.style.lineHeight = "1.3";
19599
- const fromPlaceholder = input?.getAttribute("placeholder")?.trim();
19618
+ const fromPlaceholder = input && "getAttribute" in input ? input.getAttribute("placeholder")?.trim() : void 0;
19600
19619
  const text = fromPlaceholder && fromPlaceholder.length < 40 ? fromPlaceholder : key.replace(/[-_]/g, " ");
19601
19620
  label.textContent = text;
19602
19621
  if (input && input.parentElement === wrapper) wrapper.insertBefore(label, input);
@@ -19609,8 +19628,13 @@ function listFieldWrappers(form) {
19609
19628
  function getFieldWrapper(el) {
19610
19629
  return el?.closest(`[${FIELD_ATTR}]`) ?? null;
19611
19630
  }
19631
+ function fieldControlOf(wrapper) {
19632
+ return wrapper.querySelector(CONTROL_SELECTOR);
19633
+ }
19612
19634
  function fieldInputOf(wrapper) {
19613
- return wrapper.querySelector("input, textarea");
19635
+ const control = fieldControlOf(wrapper);
19636
+ if (!control || control.tagName === "SELECT") return null;
19637
+ return control;
19614
19638
  }
19615
19639
  function fieldLabelOf(wrapper) {
19616
19640
  return wrapper.querySelector("label");
@@ -19622,17 +19646,236 @@ function fieldTypeOf(wrapper) {
19622
19646
  return wrapper.getAttribute(FIELD_TYPE_ATTR) ?? "short-text";
19623
19647
  }
19624
19648
  function isFieldRequired(wrapper) {
19625
- return fieldInputOf(wrapper)?.hasAttribute("required") ?? false;
19649
+ return fieldControlOf(wrapper)?.hasAttribute("required") ?? false;
19650
+ }
19651
+ function optionFallbackLabel(index) {
19652
+ return `Option ${index + 1}`;
19653
+ }
19654
+ function normalizeOptionText(text, index) {
19655
+ const trimmed = text.replace(/\u00a0/g, " ").trim();
19656
+ return trimmed || optionFallbackLabel(index);
19657
+ }
19658
+ function isPromptOption(opt) {
19659
+ return opt.disabled && opt.value === "";
19660
+ }
19661
+ function readDropdownPrompt(wrapper) {
19662
+ const select = fieldControlOf(wrapper);
19663
+ if (!select || select.tagName !== "SELECT") return "";
19664
+ const prompt = Array.from(select.options).find(isPromptOption);
19665
+ return (prompt?.textContent ?? "").replace(/\u00a0/g, " ").trim();
19666
+ }
19667
+ function readDropdownOptions(wrapper) {
19668
+ const select = fieldControlOf(wrapper);
19669
+ if (!select || select.tagName !== "SELECT") return [...DEFAULT_DROPDOWN_OPTIONS];
19670
+ const options = Array.from(select.options).filter((opt) => !isPromptOption(opt)).map((opt, i) => normalizeOptionText(opt.textContent ?? "", i));
19671
+ return options.length > 0 ? options : [...DEFAULT_DROPDOWN_OPTIONS];
19672
+ }
19673
+ function fillSelectOptions(select, options, prompt) {
19674
+ const keepPrompt = prompt === void 0 ? (() => {
19675
+ const existing = Array.from(select.options).find(isPromptOption);
19676
+ return existing ? (existing.textContent ?? "").replace(/\u00a0/g, " ").trim() : "";
19677
+ })() : (prompt ?? "").trim();
19678
+ select.replaceChildren();
19679
+ if (keepPrompt) {
19680
+ const opt = document.createElement("option");
19681
+ opt.value = "";
19682
+ opt.disabled = true;
19683
+ opt.selected = true;
19684
+ opt.textContent = keepPrompt;
19685
+ select.appendChild(opt);
19686
+ }
19687
+ options.forEach((text, i) => {
19688
+ const opt = document.createElement("option");
19689
+ const label = normalizeOptionText(text, i);
19690
+ opt.value = label;
19691
+ opt.textContent = label;
19692
+ select.appendChild(opt);
19693
+ });
19694
+ if (!keepPrompt && select.options.length > 0) select.selectedIndex = 0;
19695
+ }
19696
+ function removeDropdownEditorPanel(wrapper) {
19697
+ wrapper.querySelector(`[${DROPDOWN_PANEL_ATTR}]`)?.remove();
19698
+ wrapper.removeAttribute(DROPDOWN_OPEN_ATTR);
19699
+ }
19700
+ function styleDropdownPanelFromSelect(panel, select) {
19701
+ const cs = getComputedStyle(select);
19702
+ panel.style.boxSizing = "border-box";
19703
+ panel.style.width = "100%";
19704
+ panel.style.marginTop = "4px";
19705
+ panel.style.overflow = "hidden";
19706
+ panel.style.borderStyle = cs.borderStyle || "solid";
19707
+ panel.style.borderWidth = cs.borderWidth || "1px";
19708
+ panel.style.borderColor = cs.borderColor;
19709
+ panel.style.borderRadius = cs.borderRadius;
19710
+ panel.style.backgroundColor = cs.backgroundColor;
19711
+ panel.style.fontFamily = cs.fontFamily;
19712
+ panel.style.fontSize = cs.fontSize;
19713
+ panel.style.fontWeight = cs.fontWeight;
19714
+ panel.style.lineHeight = cs.lineHeight;
19715
+ panel.style.color = cs.color;
19716
+ panel.style.boxShadow = cs.boxShadow && cs.boxShadow !== "none" ? cs.boxShadow : "0 8px 24px color-mix(in srgb, #000 12%, transparent)";
19717
+ }
19718
+ function styleDropdownOptionFromSelect(row, select) {
19719
+ const cs = getComputedStyle(select);
19720
+ row.style.paddingTop = cs.paddingTop || "10px";
19721
+ row.style.paddingBottom = cs.paddingBottom || "10px";
19722
+ row.style.paddingLeft = cs.paddingLeft || "12px";
19723
+ row.style.paddingRight = cs.paddingRight || "12px";
19724
+ row.style.fontFamily = cs.fontFamily;
19725
+ row.style.fontSize = cs.fontSize;
19726
+ row.style.fontWeight = cs.fontWeight;
19727
+ row.style.lineHeight = cs.lineHeight;
19728
+ row.style.color = cs.color;
19729
+ row.style.background = "transparent";
19730
+ row.style.border = "none";
19731
+ row.style.outline = "none";
19732
+ row.style.cursor = "text";
19733
+ }
19734
+ function syncDropdownPanel(wrapper) {
19735
+ if (fieldTypeOf(wrapper) !== "dropdown") {
19736
+ wrapper.querySelector(`[${DROPDOWN_PANEL_ATTR}]`)?.remove();
19737
+ wrapper.removeAttribute(DROPDOWN_OPEN_ATTR);
19738
+ return null;
19739
+ }
19740
+ const select = fieldControlOf(wrapper);
19741
+ if (!select || select.tagName !== "SELECT") return null;
19742
+ let panel = wrapper.querySelector(`[${DROPDOWN_PANEL_ATTR}]`);
19743
+ if (!panel) {
19744
+ panel = document.createElement("div");
19745
+ panel.setAttribute(DROPDOWN_PANEL_ATTR, "");
19746
+ select.after(panel);
19747
+ }
19748
+ styleDropdownPanelFromSelect(panel, select);
19749
+ const options = readDropdownOptions(wrapper);
19750
+ const selected = selectedDropdownOptionIndex(wrapper);
19751
+ panel.replaceChildren();
19752
+ options.forEach((text, i) => {
19753
+ panel.appendChild(createDropdownOptionRow(text, i, select));
19754
+ });
19755
+ if (selected != null && selected >= 0 && selected < options.length) {
19756
+ const row = panel.querySelector(`[${DROPDOWN_OPTION_ATTR}="${selected}"]`);
19757
+ row?.setAttribute(DROPDOWN_OPTION_SELECTED_ATTR, "");
19758
+ }
19759
+ return panel;
19760
+ }
19761
+ function createDropdownOptionRow(text, index, select) {
19762
+ const row = document.createElement("div");
19763
+ row.setAttribute(DROPDOWN_OPTION_ATTR, String(index));
19764
+ row.setAttribute("contenteditable", "true");
19765
+ row.setAttribute("spellcheck", "false");
19766
+ row.textContent = text;
19767
+ styleDropdownOptionFromSelect(row, select);
19768
+ return row;
19769
+ }
19770
+ function setDropdownPreviewOpen(wrapper, open) {
19771
+ if (fieldTypeOf(wrapper) !== "dropdown") return;
19772
+ if (open) {
19773
+ if (!wrapper.hasAttribute(DROPDOWN_OPEN_ATTR) || !wrapper.querySelector(`[${DROPDOWN_PANEL_ATTR}]`)) {
19774
+ syncDropdownPanel(wrapper);
19775
+ }
19776
+ wrapper.setAttribute(DROPDOWN_OPEN_ATTR, "");
19777
+ } else {
19778
+ removeDropdownEditorPanel(wrapper);
19779
+ }
19780
+ }
19781
+ function isDropdownPreviewOpen(wrapper) {
19782
+ return wrapper.hasAttribute(DROPDOWN_OPEN_ATTR);
19783
+ }
19784
+ function listDropdownOptionRows(wrapper) {
19785
+ return Array.from(wrapper.querySelectorAll(`[${DROPDOWN_OPTION_ATTR}]`));
19786
+ }
19787
+ function getDropdownOptionIndex(el) {
19788
+ const row = el?.closest(`[${DROPDOWN_OPTION_ATTR}]`);
19789
+ if (!row) return null;
19790
+ const raw = row.getAttribute(DROPDOWN_OPTION_ATTR);
19791
+ if (raw == null || raw === "") return null;
19792
+ const index = Number(raw);
19793
+ return Number.isFinite(index) ? index : null;
19794
+ }
19795
+ function selectDropdownOption(wrapper, index) {
19796
+ listDropdownOptionRows(wrapper).forEach((row, i) => {
19797
+ if (i === index) row.setAttribute(DROPDOWN_OPTION_SELECTED_ATTR, "");
19798
+ else row.removeAttribute(DROPDOWN_OPTION_SELECTED_ATTR);
19799
+ });
19800
+ }
19801
+ function clearDropdownOptionSelection(wrapper) {
19802
+ if (!wrapper) return;
19803
+ listDropdownOptionRows(wrapper).forEach((row) => row.removeAttribute(DROPDOWN_OPTION_SELECTED_ATTR));
19804
+ }
19805
+ function selectedDropdownOptionIndex(wrapper) {
19806
+ const row = wrapper.querySelector(`[${DROPDOWN_OPTION_SELECTED_ATTR}]`);
19807
+ return getDropdownOptionIndex(row);
19808
+ }
19809
+ function commitDropdownOptionsFromPanel(wrapper, finalize = false) {
19810
+ const select = fieldControlOf(wrapper);
19811
+ if (!select || select.tagName !== "SELECT") return readDropdownOptions(wrapper);
19812
+ const rows = listDropdownOptionRows(wrapper);
19813
+ const options = rows.length > 0 ? rows.map((row, i) => {
19814
+ const trimmed = (row.textContent ?? "").replace(/\u00a0/g, " ").trim();
19815
+ return finalize ? normalizeOptionText(trimmed, i) : trimmed || optionFallbackLabel(i);
19816
+ }) : readDropdownOptions(wrapper);
19817
+ fillSelectOptions(select, options);
19818
+ if (finalize) {
19819
+ const panelRows = listDropdownOptionRows(wrapper);
19820
+ const realCount = Array.from(select.options).filter(
19821
+ (opt) => !isPromptOption(opt)
19822
+ ).length;
19823
+ if (panelRows.length !== realCount) {
19824
+ syncDropdownPanel(wrapper);
19825
+ } else {
19826
+ panelRows.forEach((row, i) => {
19827
+ const label = options[i] ?? optionFallbackLabel(i);
19828
+ if (row.textContent !== label) row.textContent = label;
19829
+ row.setAttribute(DROPDOWN_OPTION_ATTR, String(i));
19830
+ });
19831
+ }
19832
+ }
19833
+ return readDropdownOptions(wrapper);
19834
+ }
19835
+ function writeDropdownOptions(wrapper, options, prompt) {
19836
+ const select = fieldControlOf(wrapper);
19837
+ if (!select || select.tagName !== "SELECT") return;
19838
+ const normalized = (options.length > 0 ? options : [...DEFAULT_DROPDOWN_OPTIONS]).map(
19839
+ (text, i) => normalizeOptionText(text, i)
19840
+ );
19841
+ fillSelectOptions(select, normalized, prompt);
19842
+ if (wrapper.querySelector(`[${DROPDOWN_PANEL_ATTR}]`)) syncDropdownPanel(wrapper);
19843
+ }
19844
+ function currentDropdownOptions(wrapper) {
19845
+ const rows = listDropdownOptionRows(wrapper);
19846
+ if (rows.length === 0) return readDropdownOptions(wrapper);
19847
+ return rows.map((row, i) => normalizeOptionText(row.textContent ?? "", i));
19848
+ }
19849
+ function duplicateDropdownOption(wrapper, index) {
19850
+ const options = currentDropdownOptions(wrapper);
19851
+ if (index < 0 || index >= options.length) return index;
19852
+ const next = [...options];
19853
+ next.splice(index + 1, 0, options[index]);
19854
+ writeDropdownOptions(wrapper, next);
19855
+ selectDropdownOption(wrapper, index + 1);
19856
+ return index + 1;
19857
+ }
19858
+ function removeDropdownOption(wrapper, index) {
19859
+ const options = currentDropdownOptions(wrapper);
19860
+ if (options.length <= 1 || index < 0 || index >= options.length) {
19861
+ selectDropdownOption(wrapper, Math.max(0, Math.min(index, options.length - 1)));
19862
+ return selectedDropdownOptionIndex(wrapper);
19863
+ }
19864
+ const next = options.filter((_, i) => i !== index);
19865
+ writeDropdownOptions(wrapper, next);
19866
+ const nextIndex = Math.min(index, next.length - 1);
19867
+ selectDropdownOption(wrapper, nextIndex);
19868
+ return nextIndex;
19626
19869
  }
19627
19870
  function markFormFields(form) {
19628
- form.querySelectorAll("input, textarea").forEach((input) => {
19871
+ form.querySelectorAll(CONTROL_SELECTOR).forEach((input) => {
19629
19872
  const type = input.type;
19630
19873
  if (type === "submit" || type === "button" || type === "reset" || type === "hidden" || type === "checkbox" || type === "radio") {
19631
19874
  return;
19632
19875
  }
19633
19876
  if (getFieldWrapper(input)) return;
19634
19877
  let wrapper = input;
19635
- while (wrapper.parentElement && wrapper.parentElement !== form && wrapper.parentElement.querySelectorAll("input, textarea").length === 1) {
19878
+ while (wrapper.parentElement && wrapper.parentElement !== form && wrapper.parentElement.querySelectorAll(CONTROL_SELECTOR).length === 1) {
19636
19879
  wrapper = wrapper.parentElement;
19637
19880
  }
19638
19881
  if (wrapper === input) {
@@ -19646,6 +19889,7 @@ function markFormFields(form) {
19646
19889
  wrapper.setAttribute(FIELD_ATTR, key);
19647
19890
  wrapper.setAttribute(FIELD_TYPE_ATTR, inferType(input));
19648
19891
  ensureFieldLabel(wrapper, key);
19892
+ if (inferType(input) === "dropdown") removeDropdownEditorPanel(wrapper);
19649
19893
  syncRequiredMark(wrapper);
19650
19894
  });
19651
19895
  const wrappers = listFieldWrappers(form);
@@ -19656,16 +19900,21 @@ function markFormFields(form) {
19656
19900
  }
19657
19901
  function readFieldsFromDom(form) {
19658
19902
  return listFieldWrappers(form).map((wrapper) => {
19659
- const input = fieldInputOf(wrapper);
19903
+ const type = fieldTypeOf(wrapper);
19904
+ const control = fieldControlOf(wrapper);
19905
+ const isDropdown = type === "dropdown";
19906
+ if (isDropdown) commitDropdownOptionsFromPanel(wrapper, true);
19660
19907
  return {
19661
19908
  key: fieldKeyOf(wrapper),
19662
- type: fieldTypeOf(wrapper),
19909
+ type,
19663
19910
  label: fieldLabelText(fieldLabelOf(wrapper)).trim(),
19664
19911
  // While a field is selected its placeholder text lives in the value (see
19665
19912
  // beginPlaceholderEdit), so reading the attribute would store an empty one — whoever
19666
19913
  // 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"))
19914
+ // Dropdown: the disabled empty prompt (template placeholder), not an input placeholder.
19915
+ placeholder: isDropdown ? readDropdownPrompt(wrapper) : control && control.tagName !== "SELECT" ? control.hasAttribute(PLACEHOLDER_EDIT_ATTR) ? control.value : control.getAttribute("placeholder") ?? "" : "",
19916
+ required: Boolean(control?.hasAttribute("required")),
19917
+ ...isDropdown ? { options: readDropdownOptions(wrapper) } : {}
19669
19918
  };
19670
19919
  });
19671
19920
  }
@@ -19683,8 +19932,8 @@ function isDefaultText(value, pick) {
19683
19932
  if (!trimmed) return true;
19684
19933
  return Object.values(FIELD_DEFAULTS).some((defaults) => pick(defaults) === trimmed);
19685
19934
  }
19686
- function applyFieldType(wrapper, type) {
19687
- const input = fieldInputOf(wrapper);
19935
+ function applyFieldType(wrapper, type, options) {
19936
+ const input = fieldControlOf(wrapper);
19688
19937
  if (!input) return;
19689
19938
  const defaults = FIELD_DEFAULTS[type];
19690
19939
  const placeholder = input.getAttribute("placeholder") ?? "";
@@ -19696,6 +19945,10 @@ function applyFieldType(wrapper, type) {
19696
19945
  };
19697
19946
  const { tag, inputType } = inputTagFor(type);
19698
19947
  wrapper.setAttribute(FIELD_TYPE_ATTR, type);
19948
+ if (type !== "dropdown") {
19949
+ wrapper.querySelector(`[${DROPDOWN_PANEL_ATTR}]`)?.remove();
19950
+ wrapper.removeAttribute(DROPDOWN_OPEN_ATTR);
19951
+ }
19699
19952
  const shedSize = (el) => {
19700
19953
  if (type === "long-text") return;
19701
19954
  el.style.removeProperty("height");
@@ -19707,28 +19960,40 @@ function applyFieldType(wrapper, type) {
19707
19960
  }
19708
19961
  };
19709
19962
  const applyDefaults = (el) => {
19963
+ if (type === "dropdown") return;
19710
19964
  el.setAttribute("placeholder", defaults.placeholder);
19711
19965
  if (label && followsDefaults.label) {
19712
19966
  label.textContent = defaults.label;
19713
19967
  }
19714
19968
  };
19969
+ const applyDropdown = (select) => {
19970
+ const nextOptions = options && options.length > 0 ? options.map((text, i) => normalizeOptionText(text, i)) : [...DEFAULT_DROPDOWN_OPTIONS];
19971
+ fillSelectOptions(select, nextOptions, options !== void 0 ? void 0 : null);
19972
+ select.removeAttribute("placeholder");
19973
+ if (label && followsDefaults.label) label.textContent = defaults.label;
19974
+ if (wrapper.querySelector(`[${DROPDOWN_PANEL_ATTR}]`)) syncDropdownPanel(wrapper);
19975
+ else removeDropdownEditorPanel(wrapper);
19976
+ };
19715
19977
  if (input.tagName.toLowerCase() === tag) {
19716
19978
  if (inputType) input.type = inputType;
19717
19979
  shedSize(input);
19718
- applyDefaults(input);
19980
+ if (type === "dropdown") applyDropdown(input);
19981
+ else applyDefaults(input);
19719
19982
  requireIfEmail(wrapper, type);
19720
19983
  return;
19721
19984
  }
19722
19985
  const next = document.createElement(tag);
19723
19986
  Array.from(input.attributes).forEach((attr) => {
19724
19987
  if (attr.name === "type") return;
19988
+ if (tag === "select" && (attr.name === "value" || attr.name === "placeholder")) return;
19725
19989
  next.setAttribute(attr.name, attr.value);
19726
19990
  });
19727
19991
  if (inputType) next.setAttribute("type", inputType);
19728
19992
  shedSize(next);
19729
19993
  if (type === "long-text") next.setAttribute("rows", "4");
19730
19994
  input.replaceWith(next);
19731
- applyDefaults(next);
19995
+ if (type === "dropdown") applyDropdown(next);
19996
+ else applyDefaults(next);
19732
19997
  requireIfEmail(wrapper, type);
19733
19998
  }
19734
19999
  function requireIfEmail(wrapper, type) {
@@ -19750,7 +20015,7 @@ function syncRequiredMark(wrapper) {
19750
20015
  else label.removeAttribute(REQUIRED_MARK_ATTR);
19751
20016
  }
19752
20017
  function setFieldRequired(wrapper, required) {
19753
- const input = fieldInputOf(wrapper);
20018
+ const input = fieldControlOf(wrapper);
19754
20019
  const label = fieldLabelOf(wrapper);
19755
20020
  if (!input) return;
19756
20021
  if (required) input.setAttribute("required", "");
@@ -19758,6 +20023,7 @@ function setFieldRequired(wrapper, required) {
19758
20023
  if (label) syncRequiredMark(wrapper);
19759
20024
  }
19760
20025
  function beginPlaceholderEdit(wrapper) {
20026
+ if (fieldTypeOf(wrapper) === "dropdown") return;
19761
20027
  const input = fieldInputOf(wrapper);
19762
20028
  if (!input || input.hasAttribute(PLACEHOLDER_EDIT_ATTR)) return;
19763
20029
  input.style.setProperty("--ohw-placeholder-edit-color", getComputedStyle(input).color);
@@ -19767,6 +20033,11 @@ function beginPlaceholderEdit(wrapper) {
19767
20033
  }
19768
20034
  function commitPlaceholderEdit(wrapper) {
19769
20035
  if (!wrapper) return false;
20036
+ if (fieldTypeOf(wrapper) === "dropdown") {
20037
+ const before = readDropdownOptions(wrapper).join("\0");
20038
+ const after = commitDropdownOptionsFromPanel(wrapper, true).join("\0");
20039
+ return before !== after;
20040
+ }
19770
20041
  const input = fieldInputOf(wrapper);
19771
20042
  if (!input || !input.hasAttribute(PLACEHOLDER_EDIT_ATTR)) return false;
19772
20043
  const typed = input.value;
@@ -19778,6 +20049,10 @@ function commitPlaceholderEdit(wrapper) {
19778
20049
  return previous !== typed;
19779
20050
  }
19780
20051
  function setFieldPlaceholder(wrapper, placeholder) {
20052
+ if (fieldTypeOf(wrapper) === "dropdown") {
20053
+ writeDropdownOptions(wrapper, readDropdownOptions(wrapper), placeholder || null);
20054
+ return;
20055
+ }
19781
20056
  fieldInputOf(wrapper)?.setAttribute("placeholder", placeholder);
19782
20057
  }
19783
20058
  function uniqueKey(form, base) {
@@ -19821,14 +20096,17 @@ function insertField(form, type) {
19821
20096
  }
19822
20097
  wrapper.setAttribute(FIELD_ATTR, key);
19823
20098
  wrapper.setAttribute(FIELD_TYPE_ATTR, type);
20099
+ wrapper.removeAttribute(DROPDOWN_OPEN_ATTR);
19824
20100
  applyFieldType(wrapper, type);
19825
20101
  const defaults = FIELD_DEFAULTS[type];
19826
- const input = fieldInputOf(wrapper);
20102
+ const input = fieldControlOf(wrapper);
19827
20103
  if (input) {
19828
20104
  input.setAttribute("name", key);
19829
20105
  input.removeAttribute("required");
19830
- input.setAttribute("placeholder", defaults.placeholder);
19831
- input.value = "";
20106
+ if (type !== "dropdown") {
20107
+ input.setAttribute("placeholder", defaults.placeholder);
20108
+ if (input.tagName !== "SELECT") input.value = "";
20109
+ }
19832
20110
  }
19833
20111
  const label = ensureFieldLabel(wrapper, key);
19834
20112
  label.textContent = defaults.label;
@@ -19837,18 +20115,22 @@ function insertField(form, type) {
19837
20115
  return wrapper;
19838
20116
  }
19839
20117
  function duplicateField(form, wrapper) {
20118
+ if (fieldTypeOf(wrapper) === "dropdown") commitDropdownOptionsFromPanel(wrapper);
19840
20119
  const copy = wrapper.cloneNode(true);
19841
20120
  const key = uniqueKey(form, `${fieldKeyOf(wrapper)}-copy`);
19842
20121
  copy.setAttribute(FIELD_ATTR, key);
19843
- const input = fieldInputOf(copy);
20122
+ copy.removeAttribute(DROPDOWN_OPEN_ATTR);
20123
+ clearDropdownOptionSelection(copy);
20124
+ const input = fieldControlOf(copy);
19844
20125
  if (input) {
19845
20126
  input.setAttribute("name", key);
19846
20127
  input.removeAttribute("data-ohw-key");
19847
- input.value = "";
20128
+ if (input.tagName !== "SELECT") input.value = "";
19848
20129
  }
19849
20130
  const label = fieldLabelOf(copy);
19850
20131
  if (label) label.setAttribute("data-ohw-key", `${key}-label`);
19851
20132
  wrapper.after(copy);
20133
+ if (fieldTypeOf(copy) === "dropdown") removeDropdownEditorPanel(copy);
19852
20134
  return copy;
19853
20135
  }
19854
20136
  function removeField(wrapper) {
@@ -19887,16 +20169,27 @@ function reconcileFieldsFromContent(form, content) {
19887
20169
  wrapper = insertField(form, spec.type);
19888
20170
  if (!wrapper) return;
19889
20171
  wrapper.setAttribute(FIELD_ATTR, spec.key);
19890
- const input = fieldInputOf(wrapper);
20172
+ const input = fieldControlOf(wrapper);
19891
20173
  if (input) {
19892
20174
  input.setAttribute("name", spec.key);
19893
20175
  }
19894
20176
  fieldLabelOf(wrapper)?.setAttribute("data-ohw-key", `${spec.key}-label`);
19895
20177
  byKey.set(spec.key, wrapper);
19896
20178
  }
19897
- applyFieldType(wrapper, spec.type);
20179
+ const dropdownWasOpen = wrapper.hasAttribute(DROPDOWN_OPEN_ATTR);
20180
+ applyFieldType(wrapper, spec.type, spec.type === "dropdown" ? spec.options : void 0);
19898
20181
  setFieldRequired(wrapper, spec.required);
19899
20182
  setFieldPlaceholder(wrapper, spec.placeholder);
20183
+ if (spec.type === "dropdown") {
20184
+ writeDropdownOptions(
20185
+ wrapper,
20186
+ spec.options?.length ? spec.options : [...DEFAULT_DROPDOWN_OPTIONS],
20187
+ spec.placeholder || null
20188
+ );
20189
+ }
20190
+ if (spec.type === "dropdown" && dropdownWasOpen) setDropdownPreviewOpen(wrapper, true);
20191
+ else if (spec.type === "dropdown") removeDropdownEditorPanel(wrapper);
20192
+ else wrapper.removeAttribute(DROPDOWN_OPEN_ATTR);
19900
20193
  const label = fieldLabelOf(wrapper);
19901
20194
  if (label && spec.label) label.textContent = spec.label.replace(/\s*\*\s*$/, "").trimEnd();
19902
20195
  syncRequiredMark(wrapper);
@@ -19919,11 +20212,14 @@ var TYPE_ICONS = {
19919
20212
  "short-text": import_lucide_react4.Type,
19920
20213
  "long-text": import_lucide_react4.TextQuote,
19921
20214
  email: import_lucide_react4.AtSign,
19922
- phone: import_lucide_react4.Phone
20215
+ phone: import_lucide_react4.Phone,
20216
+ dropdown: import_lucide_react4.ChevronDown
19923
20217
  };
19924
20218
  function FormFieldToolbar({
19925
20219
  type,
19926
20220
  required,
20221
+ dropdownOpen = null,
20222
+ onDropdownOpenChange,
19927
20223
  onTypeChange,
19928
20224
  onRequiredToggle,
19929
20225
  onDuplicate,
@@ -19931,6 +20227,7 @@ function FormFieldToolbar({
19931
20227
  }) {
19932
20228
  const TypeIcon = TYPE_ICONS[type];
19933
20229
  const typeLabel = FIELD_TYPES.find((entry) => entry.type === type)?.label ?? "Short text";
20230
+ const showDropdownToggle = type === "dropdown" && dropdownOpen !== null && dropdownOpen !== void 0;
19934
20231
  return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
19935
20232
  "div",
19936
20233
  {
@@ -19982,29 +20279,131 @@ function FormFieldToolbar({
19982
20279
  ]
19983
20280
  }
19984
20281
  ),
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",
20282
+ showDropdownToggle ? /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_jsx_runtime15.Fragment, { children: [
20283
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "mx-0.5 h-5 w-px bg-border" }),
20284
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
20285
+ ToggleGroup,
19989
20286
  {
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 })
20287
+ value: dropdownOpen ? "open" : "closed",
20288
+ onValueChange: () => {
20289
+ },
20290
+ className: "h-7 gap-0.5 rounded-[calc(var(--radius,0.5rem)-2px)] bg-muted p-0.5",
20291
+ onMouseDown: (e) => {
20292
+ e.preventDefault();
20293
+ e.stopPropagation();
20294
+ },
20295
+ children: [
20296
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
20297
+ ToggleGroupItem,
20298
+ {
20299
+ value: "closed",
20300
+ size: "sm",
20301
+ "aria-label": "Closed",
20302
+ className: "h-6 min-w-0 px-2 text-xs font-medium",
20303
+ onMouseDown: (e) => {
20304
+ e.preventDefault();
20305
+ e.stopPropagation();
20306
+ if (dropdownOpen !== false) onDropdownOpenChange?.(false);
20307
+ },
20308
+ onClick: (e) => {
20309
+ e.preventDefault();
20310
+ e.stopPropagation();
20311
+ },
20312
+ children: "Closed"
20313
+ }
20314
+ ),
20315
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
20316
+ ToggleGroupItem,
20317
+ {
20318
+ value: "open",
20319
+ size: "sm",
20320
+ "aria-label": "Open",
20321
+ className: "h-6 min-w-0 px-2 text-xs font-medium",
20322
+ onMouseDown: (e) => {
20323
+ e.preventDefault();
20324
+ e.stopPropagation();
20325
+ if (dropdownOpen !== true) onDropdownOpenChange?.(true);
20326
+ },
20327
+ onClick: (e) => {
20328
+ e.preventDefault();
20329
+ e.stopPropagation();
20330
+ },
20331
+ children: "Open"
20332
+ }
20333
+ )
20334
+ ]
19995
20335
  }
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
- ] })
20336
+ )
20337
+ ] }) : null,
20338
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "mx-0.5 h-5 w-px bg-border" }),
20339
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
20340
+ "button",
20341
+ {
20342
+ type: "button",
20343
+ title: "Duplicate",
20344
+ "aria-label": "Duplicate",
20345
+ onClick: onDuplicate,
20346
+ className: "flex h-7 w-7 items-center justify-center rounded-md text-foreground transition-colors hover:bg-muted/70",
20347
+ children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_lucide_react4.Copy, { size: 15, strokeWidth: 1.75, "aria-hidden": true })
20348
+ }
20349
+ ),
20350
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
20351
+ "button",
20352
+ {
20353
+ type: "button",
20354
+ title: "Delete",
20355
+ "aria-label": "Delete",
20356
+ onClick: onDelete,
20357
+ className: "flex h-7 w-7 items-center justify-center rounded-md text-foreground transition-colors hover:bg-muted/70",
20358
+ children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_lucide_react4.Trash2, { size: 15, strokeWidth: 1.75, "aria-hidden": true })
20359
+ }
20360
+ )
20361
+ ]
20362
+ }
20363
+ );
20364
+ }
20365
+ function DropdownOptionToolbar({
20366
+ canDelete,
20367
+ onDuplicate,
20368
+ onDelete
20369
+ }) {
20370
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
20371
+ "div",
20372
+ {
20373
+ "data-ohw-dropdown-option-toolbar": "",
20374
+ className: "pointer-events-auto flex items-center gap-0.5 whitespace-nowrap rounded-lg border border-border bg-background p-1 shadow-md",
20375
+ children: [
20376
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
20377
+ "button",
20378
+ {
20379
+ type: "button",
20380
+ title: "Duplicate",
20381
+ "aria-label": "Duplicate",
20382
+ onMouseDown: (e) => {
20383
+ e.preventDefault();
20384
+ e.stopPropagation();
20385
+ onDuplicate();
20386
+ },
20387
+ className: "flex h-7 w-7 items-center justify-center rounded-md text-foreground transition-colors hover:bg-muted/70",
20388
+ children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_lucide_react4.Copy, { size: 15, strokeWidth: 1.75, "aria-hidden": true })
20389
+ }
20390
+ ),
20391
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
20392
+ "button",
20393
+ {
20394
+ type: "button",
20395
+ title: "Delete",
20396
+ "aria-label": "Delete",
20397
+ disabled: !canDelete,
20398
+ onMouseDown: (e) => {
20399
+ e.preventDefault();
20400
+ e.stopPropagation();
20401
+ if (canDelete) onDelete();
20402
+ },
20403
+ 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"),
20404
+ children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_lucide_react4.Trash2, { size: 15, strokeWidth: 1.75, "aria-hidden": true })
20405
+ }
20406
+ )
20008
20407
  ]
20009
20408
  }
20010
20409
  );
@@ -27059,7 +27458,7 @@ function isIconEditable(el) {
27059
27458
  return el.dataset.ohwEditable === "icon";
27060
27459
  }
27061
27460
  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"]';
27461
+ 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
27462
  function isOverEditorChrome(x, y) {
27064
27463
  return document.elementsFromPoint(x, y).some((el) => el instanceof HTMLElement && el.matches(EDITOR_CHROME_SELECTOR));
27065
27464
  }
@@ -28447,10 +28846,14 @@ function OhhwellsBridge() {
28447
28846
  const [fieldPickRect, setFieldPickRect] = (0, import_react26.useState)(null);
28448
28847
  const fieldPickElRef = (0, import_react26.useRef)(null);
28449
28848
  const [fieldPickState, setFieldPickState] = (0, import_react26.useState)(null);
28849
+ const [dropdownOptionPick, setDropdownOptionPick] = (0, import_react26.useState)(null);
28450
28850
  const [fieldTypePickerOpen, setFieldTypePickerOpen] = (0, import_react26.useState)(false);
28451
28851
  const clearFormPick = (0, import_react26.useCallback)(() => {
28452
28852
  const form = formPickElRef.current;
28453
28853
  const editing = fieldPickElRef.current;
28854
+ if (editing && fieldTypeOf(editing) === "dropdown") {
28855
+ setDropdownPreviewOpen(editing, false);
28856
+ }
28454
28857
  if (commitPlaceholderEdit(editing) && editing) {
28455
28858
  const owner = editing.closest('[data-ohw-editable="form"]');
28456
28859
  if (owner) persistFieldsRef.current(owner);
@@ -28462,6 +28865,7 @@ function OhhwellsBridge() {
28462
28865
  setFormViewStateUi("default");
28463
28866
  setFormPickCount(null);
28464
28867
  setFieldTypePickerOpen(false);
28868
+ setDropdownOptionPick(null);
28465
28869
  fieldPickElRef.current = null;
28466
28870
  setFieldPickRect(null);
28467
28871
  setFieldPickState(null);
@@ -28470,10 +28874,14 @@ function OhhwellsBridge() {
28470
28874
  }, []);
28471
28875
  const clearFieldPick = (0, import_react26.useCallback)(() => {
28472
28876
  const wrapper = fieldPickElRef.current;
28877
+ if (wrapper && fieldTypeOf(wrapper) === "dropdown") {
28878
+ setDropdownPreviewOpen(wrapper, false);
28879
+ }
28473
28880
  if (commitPlaceholderEdit(wrapper) && wrapper) {
28474
28881
  const form = wrapper.closest('[data-ohw-editable="form"]');
28475
28882
  if (form) persistFieldsRef.current(form);
28476
28883
  }
28884
+ setDropdownOptionPick(null);
28477
28885
  fieldPickElRef.current = null;
28478
28886
  setFieldPickRect(null);
28479
28887
  setFieldPickState(null);
@@ -28491,17 +28899,50 @@ function OhhwellsBridge() {
28491
28899
  []
28492
28900
  );
28493
28901
  persistFieldsRef.current = persistFields;
28902
+ const refreshDropdownOptionPick = (0, import_react26.useCallback)((wrapper, index) => {
28903
+ if (index == null || fieldTypeOf(wrapper) !== "dropdown") {
28904
+ clearDropdownOptionSelection(wrapper);
28905
+ setDropdownOptionPick(null);
28906
+ return;
28907
+ }
28908
+ selectDropdownOption(wrapper, index);
28909
+ const row = listDropdownOptionRows(wrapper)[index];
28910
+ if (!row) {
28911
+ setDropdownOptionPick(null);
28912
+ return;
28913
+ }
28914
+ setDropdownOptionPick({
28915
+ index,
28916
+ rect: row.getBoundingClientRect(),
28917
+ canDelete: listDropdownOptionRows(wrapper).length > 1
28918
+ });
28919
+ setFieldPickRect(null);
28920
+ }, []);
28494
28921
  const selectField = (0, import_react26.useCallback)((wrapper) => {
28495
28922
  if (fieldPickElRef.current && fieldPickElRef.current !== wrapper) {
28496
- commitPlaceholderEdit(fieldPickElRef.current);
28923
+ const prev = fieldPickElRef.current;
28924
+ if (fieldTypeOf(prev) === "dropdown") setDropdownPreviewOpen(prev, false);
28925
+ commitPlaceholderEdit(prev);
28497
28926
  }
28498
28927
  syncRequiredMark(wrapper);
28499
- beginPlaceholderEdit(wrapper);
28928
+ const type = fieldTypeOf(wrapper);
28929
+ if (type === "dropdown") {
28930
+ syncDropdownPanel(wrapper);
28931
+ if (!isDropdownPreviewOpen(wrapper)) setDropdownPreviewOpen(wrapper, false);
28932
+ } else {
28933
+ beginPlaceholderEdit(wrapper);
28934
+ }
28500
28935
  formHoverElRef.current = null;
28501
28936
  setFormHoverRect(null);
28937
+ setDropdownOptionPick(null);
28938
+ clearDropdownOptionSelection(wrapper);
28502
28939
  fieldPickElRef.current = wrapper;
28503
28940
  setFieldPickRect(wrapper.getBoundingClientRect());
28504
- setFieldPickState({ type: fieldTypeOf(wrapper), required: isFieldRequired(wrapper) });
28941
+ setFieldPickState({
28942
+ type,
28943
+ required: isFieldRequired(wrapper),
28944
+ dropdownOpen: type === "dropdown" ? isDropdownPreviewOpen(wrapper) : null
28945
+ });
28505
28946
  setFieldTypePickerOpen(false);
28506
28947
  }, []);
28507
28948
  const withSelectedField = (0, import_react26.useCallback)(
@@ -28531,6 +28972,31 @@ function OhhwellsBridge() {
28531
28972
  }),
28532
28973
  [selectField, withSelectedField]
28533
28974
  );
28975
+ const handleFieldDropdownOpenChange = (0, import_react26.useCallback)((open) => {
28976
+ const wrapper = fieldPickElRef.current;
28977
+ if (!wrapper || fieldTypeOf(wrapper) !== "dropdown") return;
28978
+ if (!open) {
28979
+ commitDropdownOptionsFromPanel(wrapper, true);
28980
+ const form = formPickElRef.current;
28981
+ if (form) persistFieldsRef.current(form);
28982
+ }
28983
+ setDropdownPreviewOpen(wrapper, open);
28984
+ setDropdownOptionPick(null);
28985
+ clearDropdownOptionSelection(wrapper);
28986
+ suppressNextClickRef.current = true;
28987
+ suppressClickUntilRef.current = Date.now() + 400;
28988
+ setFieldPickRect(wrapper.getBoundingClientRect());
28989
+ setFieldPickState({
28990
+ type: "dropdown",
28991
+ required: isFieldRequired(wrapper),
28992
+ dropdownOpen: open
28993
+ });
28994
+ requestAnimationFrame(() => {
28995
+ if (fieldPickElRef.current === wrapper) {
28996
+ setFieldPickRect(wrapper.getBoundingClientRect());
28997
+ }
28998
+ });
28999
+ }, []);
28534
29000
  const handleFieldDuplicate = (0, import_react26.useCallback)(
28535
29001
  () => withSelectedField((form, wrapper) => {
28536
29002
  const copy = duplicateField(form, wrapper);
@@ -28546,6 +29012,28 @@ function OhhwellsBridge() {
28546
29012
  }),
28547
29013
  [clearFieldPick, withSelectedField]
28548
29014
  );
29015
+ const handleDropdownOptionDuplicate = (0, import_react26.useCallback)(() => {
29016
+ const wrapper = fieldPickElRef.current;
29017
+ const form = formPickElRef.current;
29018
+ if (!wrapper || !form || !dropdownOptionPick) return;
29019
+ suppressNextClickRef.current = true;
29020
+ suppressClickUntilRef.current = Date.now() + 400;
29021
+ const nextIndex = duplicateDropdownOption(wrapper, dropdownOptionPick.index);
29022
+ persistFields(form);
29023
+ setDropdownPreviewOpen(wrapper, true);
29024
+ requestAnimationFrame(() => refreshDropdownOptionPick(wrapper, nextIndex));
29025
+ }, [dropdownOptionPick, persistFields, refreshDropdownOptionPick]);
29026
+ const handleDropdownOptionDelete = (0, import_react26.useCallback)(() => {
29027
+ const wrapper = fieldPickElRef.current;
29028
+ const form = formPickElRef.current;
29029
+ if (!wrapper || !form || !dropdownOptionPick || !dropdownOptionPick.canDelete) return;
29030
+ suppressNextClickRef.current = true;
29031
+ suppressClickUntilRef.current = Date.now() + 400;
29032
+ const nextIndex = removeDropdownOption(wrapper, dropdownOptionPick.index);
29033
+ persistFields(form);
29034
+ setDropdownPreviewOpen(wrapper, true);
29035
+ requestAnimationFrame(() => refreshDropdownOptionPick(wrapper, nextIndex));
29036
+ }, [dropdownOptionPick, persistFields, refreshDropdownOptionPick]);
28549
29037
  const handleAddField = (0, import_react26.useCallback)(
28550
29038
  (type) => {
28551
29039
  const form = formPickElRef.current;
@@ -30674,8 +31162,32 @@ function OhhwellsBridge() {
30674
31162
  if (!isEditMode) return;
30675
31163
  let saveTimer = null;
30676
31164
  const onInput = (e) => {
30677
- const input = e.target;
30678
- if (!input || !("value" in input)) return;
31165
+ const target = e.target;
31166
+ if (!target) return;
31167
+ const optionIndex = getDropdownOptionIndex(target);
31168
+ if (optionIndex != null) {
31169
+ const wrapper2 = getFieldWrapper(target);
31170
+ if (!wrapper2 || wrapper2 !== fieldPickElRef.current) return;
31171
+ if (saveTimer) clearTimeout(saveTimer);
31172
+ const owner2 = wrapper2.closest('[data-ohw-editable="form"]');
31173
+ saveTimer = setTimeout(() => {
31174
+ const form = owner2 ?? formPickElRef.current;
31175
+ if (!form) return;
31176
+ commitDropdownOptionsFromPanel(wrapper2);
31177
+ persistFields(form);
31178
+ const row = listDropdownOptionRows(wrapper2)[optionIndex];
31179
+ if (row) {
31180
+ setDropdownOptionPick({
31181
+ index: optionIndex,
31182
+ rect: row.getBoundingClientRect(),
31183
+ canDelete: listDropdownOptionRows(wrapper2).length > 1
31184
+ });
31185
+ }
31186
+ }, 400);
31187
+ return;
31188
+ }
31189
+ const input = target;
31190
+ if (!("value" in input)) return;
30679
31191
  const wrapper = getFieldWrapper(input);
30680
31192
  if (!wrapper || wrapper !== fieldPickElRef.current) return;
30681
31193
  if (saveTimer) clearTimeout(saveTimer);
@@ -31187,6 +31699,7 @@ function OhhwellsBridge() {
31187
31699
  field can be picked and hovered from anywhere inside it (OHH-642). */
31188
31700
  [data-ohw-editable="form"] [data-ohw-form-field] input,
31189
31701
  [data-ohw-editable="form"] [data-ohw-form-field] textarea,
31702
+ [data-ohw-editable="form"] [data-ohw-form-field] select,
31190
31703
  [data-ohw-editable="form"] [data-ohw-form-field] label {
31191
31704
  pointer-events: auto !important;
31192
31705
  cursor: pointer !important;
@@ -31200,10 +31713,35 @@ function OhhwellsBridge() {
31200
31713
  max-width: 100% !important;
31201
31714
  }
31202
31715
  [data-ohw-editable="form"] [data-ohw-form-field] input,
31203
- [data-ohw-editable="form"] [data-ohw-form-field] textarea {
31716
+ [data-ohw-editable="form"] [data-ohw-form-field] textarea,
31717
+ [data-ohw-editable="form"] [data-ohw-form-field] select {
31204
31718
  box-sizing: border-box !important;
31205
31719
  width: 100% !important;
31206
31720
  }
31721
+ /* Dropdown field editor (OHH-919): Closed = select alone; Open = select + panel below.
31722
+ Caret only \u2014 keep the template's own background/border/type on the select. */
31723
+ [data-ohw-editable="form"] [data-ohw-form-field][data-ohw-field-type="dropdown"] select {
31724
+ appearance: none !important;
31725
+ -webkit-appearance: none !important;
31726
+ 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;
31727
+ background-repeat: no-repeat !important;
31728
+ background-position: right 12px center !important;
31729
+ padding-right: 36px !important;
31730
+ pointer-events: none !important;
31731
+ }
31732
+ [data-ohw-editable="form"] [data-ohw-form-field][data-ohw-dropdown-open] select {
31733
+ 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;
31734
+ }
31735
+ [data-ohw-editable="form"] [data-ohw-form-field] [data-ohw-dropdown-panel] {
31736
+ display: none !important;
31737
+ }
31738
+ [data-ohw-editable="form"] [data-ohw-form-field][data-ohw-dropdown-open] [data-ohw-dropdown-panel] {
31739
+ display: block !important;
31740
+ }
31741
+ [data-ohw-editable="form"] [data-ohw-dropdown-option] {
31742
+ cursor: text !important;
31743
+ outline: none !important;
31744
+ }
31207
31745
  /* Somewhere to click the block itself, on every side (OHH-642) \u2014 editor only. */
31208
31746
  [data-ohw-editable="form"] {
31209
31747
  padding: 18px !important;
@@ -31211,13 +31749,14 @@ function OhhwellsBridge() {
31211
31749
  flex-wrap: wrap !important;
31212
31750
  align-items: flex-end !important;
31213
31751
  }
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. */
31752
+ /* Width floor for horizontal rows \u2014 never flex-basis. On a column form
31753
+ 'flex-basis: 12rem' becomes HEIGHT and fields grow empty space (OHH-919). */
31217
31754
  [data-ohw-editable="form"]:not([data-ai-form]) [data-ohw-form-field] {
31218
- flex: 1 1 12rem !important;
31755
+ flex: 1 1 auto !important;
31219
31756
  min-width: min(12rem, 100%) !important;
31220
31757
  max-width: 100% !important;
31758
+ height: auto !important;
31759
+ align-self: flex-start !important;
31221
31760
  }
31222
31761
  /* Placeholder text lives in the value while selected. currentColor inside color-mix
31223
31762
  resolves to the *inherited* color, so reverse-print footers washed it out on white
@@ -31364,14 +31903,37 @@ function OhhwellsBridge() {
31364
31903
  });
31365
31904
  return;
31366
31905
  }
31906
+ if (target.closest(
31907
+ '[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"]'
31908
+ )) {
31909
+ return;
31910
+ }
31367
31911
  {
31368
31912
  const formEl = getFormElement(target);
31369
31913
  const onSuccessText = target.closest(`[${SUCCESS_TEXT_ATTR}]`);
31370
31914
  if (formEl && formKeyOf(formEl) && !onSuccessText && !isCtaButton(target)) {
31371
31915
  const fieldEl = getFieldWrapper(target);
31372
31916
  if (fieldEl) {
31917
+ const optionIndex = getDropdownOptionIndex(target);
31918
+ if (optionIndex != null && fieldTypeOf(fieldEl) === "dropdown" && isDropdownPreviewOpen(fieldEl)) {
31919
+ deactivateRef.current();
31920
+ deselectRef.current();
31921
+ formPickElRef.current = formEl;
31922
+ setFormPickRect(null);
31923
+ if (fieldPickElRef.current !== fieldEl) selectField(fieldEl);
31924
+ setDropdownPreviewOpen(fieldEl, true);
31925
+ setFieldPickState({
31926
+ type: "dropdown",
31927
+ required: isFieldRequired(fieldEl),
31928
+ dropdownOpen: true
31929
+ });
31930
+ refreshDropdownOptionPick(fieldEl, optionIndex);
31931
+ return;
31932
+ }
31373
31933
  const label = target.closest("label");
31374
- if (label && fieldPickElRef.current === fieldEl) return;
31934
+ if (label && fieldPickElRef.current === fieldEl && selectedDropdownOptionIndex(fieldEl) == null) {
31935
+ return;
31936
+ }
31375
31937
  e.preventDefault();
31376
31938
  e.stopPropagation();
31377
31939
  deactivateRef.current();
@@ -31379,7 +31941,9 @@ function OhhwellsBridge() {
31379
31941
  formPickElRef.current = formEl;
31380
31942
  setFormPickRect(null);
31381
31943
  selectField(fieldEl);
31382
- if (!label) fieldEl.querySelector("input, textarea")?.focus();
31944
+ if (!label && fieldTypeOf(fieldEl) !== "dropdown") {
31945
+ fieldEl.querySelector("input, textarea")?.focus();
31946
+ }
31383
31947
  return;
31384
31948
  }
31385
31949
  clearFieldPick();
@@ -34851,7 +35415,7 @@ function OhhwellsBridge() {
34851
35415
  postToParent2({
34852
35416
  type: "ow:ready",
34853
35417
  version: "1",
34854
- bridgeVersion: "0.1.179-next.473",
35418
+ bridgeVersion: "0.1.179-next.475",
34855
35419
  path: pathname,
34856
35420
  nodes: collectEditableNodes(editContentRef.current),
34857
35421
  sections
@@ -35835,7 +36399,7 @@ function OhhwellsBridge() {
35835
36399
  chromeGap: formHoverElRef.current && getFieldWrapper(formHoverElRef.current) ? 8 : 24
35836
36400
  }
35837
36401
  ),
35838
- fieldPickRect && fieldPickState && !isItemDragging && toolbarVariant !== "rich-text" && /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
36402
+ fieldPickRect && fieldPickState && !dropdownOptionPick && !isItemDragging && toolbarVariant !== "rich-text" && /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
35839
36403
  ItemInteractionLayer,
35840
36404
  {
35841
36405
  rect: fieldPickRect,
@@ -35852,6 +36416,8 @@ function OhhwellsBridge() {
35852
36416
  {
35853
36417
  type: fieldPickState.type,
35854
36418
  required: fieldPickState.required,
36419
+ dropdownOpen: fieldPickState.dropdownOpen,
36420
+ onDropdownOpenChange: handleFieldDropdownOpenChange,
35855
36421
  onTypeChange: handleFieldTypeChange,
35856
36422
  onRequiredToggle: handleFieldRequiredToggle,
35857
36423
  onDuplicate: handleFieldDuplicate,
@@ -35860,6 +36426,25 @@ function OhhwellsBridge() {
35860
36426
  )
35861
36427
  }
35862
36428
  ),
36429
+ dropdownOptionPick && !isItemDragging && /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
36430
+ ItemInteractionLayer,
36431
+ {
36432
+ rect: dropdownOptionPick.rect,
36433
+ state: "active-top",
36434
+ itemDragSurface: false,
36435
+ toolbarAlign: "center",
36436
+ chromeGap: 0,
36437
+ showHandle: false,
36438
+ toolbar: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
36439
+ DropdownOptionToolbar,
36440
+ {
36441
+ canDelete: dropdownOptionPick.canDelete,
36442
+ onDuplicate: handleDropdownOptionDuplicate,
36443
+ onDelete: handleDropdownOptionDelete
36444
+ }
36445
+ )
36446
+ }
36447
+ ),
35863
36448
  fieldDragging ? fieldDropSlots.map((slot, i) => /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
35864
36449
  "div",
35865
36450
  {