@ohhwells/bridge 0.1.67-next.194 → 0.1.67-next.196

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
@@ -7181,6 +7181,7 @@ function applyFieldType(wrapper, type) {
7181
7181
  if (inputType) input.type = inputType;
7182
7182
  shedSize(input);
7183
7183
  applyDefaults(input);
7184
+ requireIfEmail(wrapper, type);
7184
7185
  return;
7185
7186
  }
7186
7187
  const next = document.createElement(tag);
@@ -7193,6 +7194,11 @@ function applyFieldType(wrapper, type) {
7193
7194
  if (type === "long-text") next.setAttribute("rows", "4");
7194
7195
  input.replaceWith(next);
7195
7196
  applyDefaults(next);
7197
+ requireIfEmail(wrapper, type);
7198
+ }
7199
+ function requireIfEmail(wrapper, type) {
7200
+ if (type !== "email") return;
7201
+ setFieldRequired(wrapper, true);
7196
7202
  }
7197
7203
  var REQUIRED_MARK_ATTR = "data-ohw-field-required";
7198
7204
  function fieldLabelText(label) {
@@ -7275,6 +7281,7 @@ function insertField(form, type) {
7275
7281
  const label = ensureFieldLabel(wrapper, key);
7276
7282
  label.textContent = defaults.label;
7277
7283
  label.setAttribute("data-ohw-key", `${key}-label`);
7284
+ requireIfEmail(wrapper, type);
7278
7285
  return wrapper;
7279
7286
  }
7280
7287
  function duplicateField(form, wrapper) {
@@ -7416,7 +7423,7 @@ function FormFieldToolbar({
7416
7423
  "aria-pressed": required,
7417
7424
  onClick: onRequiredToggle,
7418
7425
  className: "flex h-7 items-center gap-1.5 whitespace-nowrap rounded-md px-2 text-[13px] font-medium transition-colors " + (required ? "bg-primary/10 text-primary" : "text-foreground hover:bg-muted/70"),
7419
- "data-ohw-field-required": "",
7426
+ "data-ohw-field-required-toggle": "",
7420
7427
  children: [
7421
7428
  /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_lucide_react4.Asterisk, { size: 14, strokeWidth: 2, "aria-hidden": true }),
7422
7429
  "Required"
@@ -18728,7 +18735,9 @@ function OhhwellsBridge() {
18728
18735
  return;
18729
18736
  }
18730
18737
  const { y } = toProbeCoords(clientX, clientY, fromParentViewport);
18731
- const sections = Array.from(document.querySelectorAll("[data-ohw-section]")).sort((a, b) => a.getBoundingClientRect().top - b.getBoundingClientRect().top);
18738
+ const sections = Array.from(document.querySelectorAll("[data-ohw-section]")).filter(
18739
+ (el) => !el.hasAttribute("data-ohw-ai-template-hidden") && !el.hasAttribute("data-ohw-ai-removed") && !el.hasAttribute("data-ohw-ai-replaced-by") && el.getBoundingClientRect().height > 0
18740
+ ).sort((a, b) => a.getBoundingClientRect().top - b.getBoundingClientRect().top);
18732
18741
  const ZONE = 20;
18733
18742
  for (let i = 0; i < sections.length; i++) {
18734
18743
  const a = sections[i];
@@ -19152,10 +19161,16 @@ function OhhwellsBridge() {
19152
19161
  nodes: collectEditableNodes(editContentRef.current)
19153
19162
  });
19154
19163
  };
19164
+ const clearInteractionChrome = () => {
19165
+ deactivateRef.current();
19166
+ deselectRef.current();
19167
+ clearMediaSelectionRef.current();
19168
+ };
19155
19169
  const handleAiApplyTree = (e) => {
19156
19170
  if (e.data?.type !== "ow:ai-apply-tree") return;
19157
19171
  const payload = e.data.payload;
19158
19172
  if (!payload || typeof payload.id !== "string" || !isRenderableTree(payload.tree)) return;
19173
+ clearInteractionChrome();
19159
19174
  const previous = aiSectionsRef.current;
19160
19175
  const nextState = applyTreeToState(parseAiSectionsState(previous), {
19161
19176
  ...payload,
@@ -19180,6 +19195,7 @@ function OhhwellsBridge() {
19180
19195
  if (!sectionId || sectionId === "navbar" || sectionId === "footer") return;
19181
19196
  const exists = document.querySelector(`[data-ohw-section="${CSS.escape(sectionId)}"]`);
19182
19197
  if (!exists) return;
19198
+ clearInteractionChrome();
19183
19199
  const previous = aiSectionsRef.current;
19184
19200
  const nextState = deleteSectionFromState(parseAiSectionsState(previous), sectionId);
19185
19201
  const nextValue = serializeAiSectionsState(nextState);
@@ -19195,6 +19211,7 @@ function OhhwellsBridge() {
19195
19211
  const handleAiSetSections = (e) => {
19196
19212
  if (e.data?.type !== "ow:ai-set-sections") return;
19197
19213
  const value = typeof e.data.value === "string" ? e.data.value : "";
19214
+ clearInteractionChrome();
19198
19215
  aiSectionsRef.current = value;
19199
19216
  applyAiSectionsToDom(parseAiSectionsState(value));
19200
19217
  applyStylesToDom(parseStyleStore(stylesRef.current));
@@ -20820,14 +20837,20 @@ function OhhwellsBridge() {
20820
20837
  },
20821
20838
  `field-drop-${i}`
20822
20839
  )) : null,
20823
- fieldTypePickerOpen && formPickRect && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
20824
- "div",
20825
- {
20826
- className: "pointer-events-none fixed z-[2147483645]",
20827
- style: { top: formPickRect.top + 16, left: formPickRect.left + 24 },
20828
- children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(FieldTypePicker, { onPick: handleAddField })
20829
- }
20830
- ),
20840
+ fieldTypePickerOpen && formPickRect ? (() => {
20841
+ const toolbar = document.querySelector("[data-ohw-form-toolbar]")?.getBoundingClientRect();
20842
+ return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
20843
+ "div",
20844
+ {
20845
+ className: "pointer-events-none fixed z-[2147483645]",
20846
+ style: {
20847
+ top: toolbar ? toolbar.bottom + 6 : formPickRect.top + 16,
20848
+ left: toolbar ? toolbar.left : formPickRect.left + 24
20849
+ },
20850
+ children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(FieldTypePicker, { onPick: handleAddField })
20851
+ }
20852
+ );
20853
+ })() : null,
20831
20854
  toolbarVariant === "select-frame" && toolbarRect && !linkPopover && !isItemDragging && !isFooterFrameSelection && selectedElRef.current && isNavbarLinksContainer2(selectedElRef.current) && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(NavbarContainerChrome, { rect: toolbarRect, onAdd: handleAddTopLevelNavItem }),
20832
20855
  toolbarVariant === "select-frame" && toolbarRect && !linkPopover && !isItemDragging && !isFooterFrameSelection && selectedElRef.current && isFooterLinksContainer(selectedElRef.current) && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
20833
20856
  FooterContainerChrome,