@ohhwells/bridge 0.1.179-next.474 → 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.474";
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.474" : "";
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;
@@ -19646,16 +19655,35 @@ function normalizeOptionText(text, index) {
19646
19655
  const trimmed = text.replace(/\u00a0/g, " ").trim();
19647
19656
  return trimmed || optionFallbackLabel(index);
19648
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
+ }
19649
19667
  function readDropdownOptions(wrapper) {
19650
19668
  const select = fieldControlOf(wrapper);
19651
19669
  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
- );
19670
+ const options = Array.from(select.options).filter((opt) => !isPromptOption(opt)).map((opt, i) => normalizeOptionText(opt.textContent ?? "", i));
19655
19671
  return options.length > 0 ? options : [...DEFAULT_DROPDOWN_OPTIONS];
19656
19672
  }
19657
- function fillSelectOptions(select, options) {
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();
19658
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
+ }
19659
19687
  options.forEach((text, i) => {
19660
19688
  const opt = document.createElement("option");
19661
19689
  const label = normalizeOptionText(text, i);
@@ -19663,7 +19691,11 @@ function fillSelectOptions(select, options) {
19663
19691
  opt.textContent = label;
19664
19692
  select.appendChild(opt);
19665
19693
  });
19666
- if (select.options.length > 0) select.selectedIndex = 0;
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);
19667
19699
  }
19668
19700
  function styleDropdownPanelFromSelect(panel, select) {
19669
19701
  const cs = getComputedStyle(select);
@@ -19737,11 +19769,13 @@ function createDropdownOptionRow(text, index, select) {
19737
19769
  }
19738
19770
  function setDropdownPreviewOpen(wrapper, open) {
19739
19771
  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);
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);
19745
19779
  }
19746
19780
  }
19747
19781
  function isDropdownPreviewOpen(wrapper) {
@@ -19783,7 +19817,10 @@ function commitDropdownOptionsFromPanel(wrapper, finalize = false) {
19783
19817
  fillSelectOptions(select, options);
19784
19818
  if (finalize) {
19785
19819
  const panelRows = listDropdownOptionRows(wrapper);
19786
- if (panelRows.length !== select.options.length) {
19820
+ const realCount = Array.from(select.options).filter(
19821
+ (opt) => !isPromptOption(opt)
19822
+ ).length;
19823
+ if (panelRows.length !== realCount) {
19787
19824
  syncDropdownPanel(wrapper);
19788
19825
  } else {
19789
19826
  panelRows.forEach((row, i) => {
@@ -19795,14 +19832,14 @@ function commitDropdownOptionsFromPanel(wrapper, finalize = false) {
19795
19832
  }
19796
19833
  return readDropdownOptions(wrapper);
19797
19834
  }
19798
- function writeDropdownOptions(wrapper, options) {
19835
+ function writeDropdownOptions(wrapper, options, prompt) {
19799
19836
  const select = fieldControlOf(wrapper);
19800
19837
  if (!select || select.tagName !== "SELECT") return;
19801
19838
  const normalized = (options.length > 0 ? options : [...DEFAULT_DROPDOWN_OPTIONS]).map(
19802
19839
  (text, i) => normalizeOptionText(text, i)
19803
19840
  );
19804
- fillSelectOptions(select, normalized);
19805
- syncDropdownPanel(wrapper);
19841
+ fillSelectOptions(select, normalized, prompt);
19842
+ if (wrapper.querySelector(`[${DROPDOWN_PANEL_ATTR}]`)) syncDropdownPanel(wrapper);
19806
19843
  }
19807
19844
  function currentDropdownOptions(wrapper) {
19808
19845
  const rows = listDropdownOptionRows(wrapper);
@@ -19852,7 +19889,7 @@ function markFormFields(form) {
19852
19889
  wrapper.setAttribute(FIELD_ATTR, key);
19853
19890
  wrapper.setAttribute(FIELD_TYPE_ATTR, inferType(input));
19854
19891
  ensureFieldLabel(wrapper, key);
19855
- if (inferType(input) === "dropdown") syncDropdownPanel(wrapper);
19892
+ if (inferType(input) === "dropdown") removeDropdownEditorPanel(wrapper);
19856
19893
  syncRequiredMark(wrapper);
19857
19894
  });
19858
19895
  const wrappers = listFieldWrappers(form);
@@ -19874,7 +19911,8 @@ function readFieldsFromDom(form) {
19874
19911
  // While a field is selected its placeholder text lives in the value (see
19875
19912
  // beginPlaceholderEdit), so reading the attribute would store an empty one — whoever
19876
19913
  // happens to save at that moment must still record what the owner typed.
19877
- placeholder: !isDropdown && control && control.tagName !== "SELECT" ? control.hasAttribute(PLACEHOLDER_EDIT_ATTR) ? control.value : control.getAttribute("placeholder") ?? "" : "",
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") ?? "" : "",
19878
19916
  required: Boolean(control?.hasAttribute("required")),
19879
19917
  ...isDropdown ? { options: readDropdownOptions(wrapper) } : {}
19880
19918
  };
@@ -19930,10 +19968,11 @@ function applyFieldType(wrapper, type, options) {
19930
19968
  };
19931
19969
  const applyDropdown = (select) => {
19932
19970
  const nextOptions = options && options.length > 0 ? options.map((text, i) => normalizeOptionText(text, i)) : [...DEFAULT_DROPDOWN_OPTIONS];
19933
- fillSelectOptions(select, nextOptions);
19971
+ fillSelectOptions(select, nextOptions, options !== void 0 ? void 0 : null);
19934
19972
  select.removeAttribute("placeholder");
19935
19973
  if (label && followsDefaults.label) label.textContent = defaults.label;
19936
- syncDropdownPanel(wrapper);
19974
+ if (wrapper.querySelector(`[${DROPDOWN_PANEL_ATTR}]`)) syncDropdownPanel(wrapper);
19975
+ else removeDropdownEditorPanel(wrapper);
19937
19976
  };
19938
19977
  if (input.tagName.toLowerCase() === tag) {
19939
19978
  if (inputType) input.type = inputType;
@@ -20010,7 +20049,10 @@ function commitPlaceholderEdit(wrapper) {
20010
20049
  return previous !== typed;
20011
20050
  }
20012
20051
  function setFieldPlaceholder(wrapper, placeholder) {
20013
- if (fieldTypeOf(wrapper) === "dropdown") return;
20052
+ if (fieldTypeOf(wrapper) === "dropdown") {
20053
+ writeDropdownOptions(wrapper, readDropdownOptions(wrapper), placeholder || null);
20054
+ return;
20055
+ }
20014
20056
  fieldInputOf(wrapper)?.setAttribute("placeholder", placeholder);
20015
20057
  }
20016
20058
  function uniqueKey(form, base) {
@@ -20088,7 +20130,7 @@ function duplicateField(form, wrapper) {
20088
20130
  const label = fieldLabelOf(copy);
20089
20131
  if (label) label.setAttribute("data-ohw-key", `${key}-label`);
20090
20132
  wrapper.after(copy);
20091
- if (fieldTypeOf(copy) === "dropdown") syncDropdownPanel(copy);
20133
+ if (fieldTypeOf(copy) === "dropdown") removeDropdownEditorPanel(copy);
20092
20134
  return copy;
20093
20135
  }
20094
20136
  function removeField(wrapper) {
@@ -20139,9 +20181,14 @@ function reconcileFieldsFromContent(form, content) {
20139
20181
  setFieldRequired(wrapper, spec.required);
20140
20182
  setFieldPlaceholder(wrapper, spec.placeholder);
20141
20183
  if (spec.type === "dropdown") {
20142
- writeDropdownOptions(wrapper, spec.options?.length ? spec.options : [...DEFAULT_DROPDOWN_OPTIONS]);
20184
+ writeDropdownOptions(
20185
+ wrapper,
20186
+ spec.options?.length ? spec.options : [...DEFAULT_DROPDOWN_OPTIONS],
20187
+ spec.placeholder || null
20188
+ );
20143
20189
  }
20144
20190
  if (spec.type === "dropdown" && dropdownWasOpen) setDropdownPreviewOpen(wrapper, true);
20191
+ else if (spec.type === "dropdown") removeDropdownEditorPanel(wrapper);
20145
20192
  else wrapper.removeAttribute(DROPDOWN_OPEN_ATTR);
20146
20193
  const label = fieldLabelOf(wrapper);
20147
20194
  if (label && spec.label) label.textContent = spec.label.replace(/\s*\*\s*$/, "").trimEnd();
@@ -31869,8 +31916,6 @@ function OhhwellsBridge() {
31869
31916
  if (fieldEl) {
31870
31917
  const optionIndex = getDropdownOptionIndex(target);
31871
31918
  if (optionIndex != null && fieldTypeOf(fieldEl) === "dropdown" && isDropdownPreviewOpen(fieldEl)) {
31872
- e.preventDefault();
31873
- e.stopPropagation();
31874
31919
  deactivateRef.current();
31875
31920
  deselectRef.current();
31876
31921
  formPickElRef.current = formEl;
@@ -31883,7 +31928,6 @@ function OhhwellsBridge() {
31883
31928
  dropdownOpen: true
31884
31929
  });
31885
31930
  refreshDropdownOptionPick(fieldEl, optionIndex);
31886
- listDropdownOptionRows(fieldEl)[optionIndex]?.focus();
31887
31931
  return;
31888
31932
  }
31889
31933
  const label = target.closest("label");
@@ -35371,7 +35415,7 @@ function OhhwellsBridge() {
35371
35415
  postToParent2({
35372
35416
  type: "ow:ready",
35373
35417
  version: "1",
35374
- bridgeVersion: "0.1.179-next.474",
35418
+ bridgeVersion: "0.1.179-next.475",
35375
35419
  path: pathname,
35376
35420
  nodes: collectEditableNodes(editContentRef.current),
35377
35421
  sections
@@ -36389,7 +36433,7 @@ function OhhwellsBridge() {
36389
36433
  state: "active-top",
36390
36434
  itemDragSurface: false,
36391
36435
  toolbarAlign: "center",
36392
- chromeGap: 4,
36436
+ chromeGap: 0,
36393
36437
  showHandle: false,
36394
36438
  toolbar: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
36395
36439
  DropdownOptionToolbar,