@amplifyup/sdk 0.1.56 → 0.1.58

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.mjs CHANGED
@@ -2725,7 +2725,7 @@ Available Console Commands:
2725
2725
  if (typeof document === "undefined") return;
2726
2726
  this.teardownComposerDragDrop();
2727
2727
  const slotSelector = "[data-slot-id], [data-amplifyup-slot]";
2728
- const componentSelector = "[data-amplifyup-component], [data-component-id]";
2728
+ const componentSelector = "[data-amplifyup-component], [data-component-id], [data-amplifyup-node], [data-node-id]";
2729
2729
  const clearDragOverState = () => {
2730
2730
  this.clearComposerDragHighlight();
2731
2731
  };
@@ -2774,6 +2774,7 @@ Available Console Commands:
2774
2774
  if (!target?.closest) return;
2775
2775
  const component = target.closest(componentSelector);
2776
2776
  const slot = target.closest(slotSelector);
2777
+ const pageSlot = slot && slot.getAttribute("data-slot-source") === "page" ? slot : null;
2777
2778
  if (this.highlightComponentsEnabled && component) {
2778
2779
  if (!component.classList.contains("amplifyup-component-hover")) {
2779
2780
  clearComponentHover();
@@ -2785,7 +2786,7 @@ Available Console Commands:
2785
2786
  return;
2786
2787
  }
2787
2788
  clearComponentHover();
2788
- if (this.showZonesEnabled && slot) {
2789
+ if (this.showZonesEnabled && slot && !pageSlot) {
2789
2790
  if (!slot.classList.contains("amplifyup-slot-hover")) {
2790
2791
  clearSlotHover();
2791
2792
  slot.classList.add("amplifyup-slot-hover");
@@ -2915,16 +2916,18 @@ Available Console Commands:
2915
2916
  const lines = [];
2916
2917
  if (highlightComponents) {
2917
2918
  lines.push(
2918
- "[data-amplifyup-component], [data-component-id] {",
2919
+ "[data-amplifyup-component], [data-component-id], [data-amplifyup-node], [data-node-id] {",
2919
2920
  " cursor: pointer !important;",
2920
2921
  "}",
2921
- "[data-amplifyup-component].amplifyup-selected, [data-component-id].amplifyup-selected {",
2922
+ "[data-amplifyup-component].amplifyup-selected, [data-component-id].amplifyup-selected, [data-amplifyup-node].amplifyup-selected, [data-node-id].amplifyup-selected {",
2922
2923
  ` outline: 2px solid ${primary} !important;`,
2923
2924
  " outline-offset: -2px !important;",
2924
2925
  " box-shadow: inset 0 0 0 1px hsl(82 100% 52% / 0.25) !important;",
2925
2926
  "}",
2926
2927
  "[data-amplifyup-component].amplifyup-component-hover:not(.amplifyup-selected),",
2927
- "[data-component-id].amplifyup-component-hover:not(.amplifyup-selected) {",
2928
+ "[data-component-id].amplifyup-component-hover:not(.amplifyup-selected),",
2929
+ "[data-amplifyup-node].amplifyup-component-hover:not(.amplifyup-selected),",
2930
+ "[data-node-id].amplifyup-component-hover:not(.amplifyup-selected) {",
2928
2931
  ` outline: 2px solid ${primary} !important;`,
2929
2932
  " outline-offset: -2px !important;",
2930
2933
  "}"
@@ -3127,7 +3130,7 @@ Available Console Commands:
3127
3130
  let current = element;
3128
3131
  let sawPageSlot = false;
3129
3132
  while (current) {
3130
- if (current.hasAttribute("data-amplifyup-component") || current.hasAttribute("data-component-id") || current.hasAttribute("data-amplifyup-slot") || current.hasAttribute("data-slot-id")) {
3133
+ if (current.hasAttribute("data-amplifyup-component") || current.hasAttribute("data-component-id") || current.hasAttribute("data-amplifyup-slot") || current.hasAttribute("data-slot-id") || current.hasAttribute("data-node-id") || current.hasAttribute("data-amplifyup-node")) {
3131
3134
  hierarchy.push(current);
3132
3135
  if (current.getAttribute("data-slot-source") === "page") {
3133
3136
  sawPageSlot = true;
@@ -3152,13 +3155,14 @@ Available Console Commands:
3152
3155
  const componentId = element.getAttribute("data-amplifyup-component") || element.getAttribute("data-component-id");
3153
3156
  const slotName = componentId ? null : element.getAttribute("data-amplifyup-slot") || element.getAttribute("data-slot-id");
3154
3157
  const componentName = element.getAttribute("data-component-name");
3158
+ const nodeId = element.getAttribute("data-node-id") || element.closest("[data-node-id]")?.getAttribute("data-node-id") || null;
3155
3159
  const hierarchyInfo = hierarchy.map((el, index) => {
3156
3160
  const elComponentId = el.getAttribute("data-amplifyup-component") || el.getAttribute("data-component-id");
3157
3161
  const elSlotName = el.getAttribute("data-amplifyup-slot") || el.getAttribute("data-slot-id");
3158
3162
  const elComponentName = el.getAttribute("data-component-name");
3159
3163
  const isSlot = !elComponentId && !!elSlotName;
3160
3164
  const isPageSlot = isSlot && el.getAttribute("data-slot-source") === "page";
3161
- const nodeId = el.getAttribute("data-node-id") || (isSlot ? el.getAttribute("data-parent-node-id") : null);
3165
+ const nodeId2 = el.getAttribute("data-node-id") || (isSlot ? el.getAttribute("data-parent-node-id") : null);
3162
3166
  return {
3163
3167
  index,
3164
3168
  componentId: elComponentId,
@@ -3166,7 +3170,7 @@ Available Console Commands:
3166
3170
  slotName: isSlot ? elSlotName : null,
3167
3171
  isSlot,
3168
3172
  isPageSlot,
3169
- nodeId
3173
+ nodeId: nodeId2
3170
3174
  };
3171
3175
  });
3172
3176
  const rect = element.getBoundingClientRect ? element.getBoundingClientRect() : null;
@@ -3176,6 +3180,7 @@ Available Console Commands:
3176
3180
  componentId,
3177
3181
  componentName,
3178
3182
  slotName,
3183
+ nodeId,
3179
3184
  hierarchy: hierarchyInfo,
3180
3185
  selectedIndex: hierarchy.length - 1,
3181
3186
  ...bounds && { bounds },
@@ -3205,22 +3210,27 @@ Available Console Commands:
3205
3210
  }
3206
3211
  const doc = document;
3207
3212
  if (highlightComponents) {
3208
- const componentElements = doc.querySelectorAll("[data-amplifyup-component], [data-component-id]");
3213
+ const componentElements = doc.querySelectorAll(
3214
+ "[data-amplifyup-component], [data-component-id], [data-amplifyup-node], [data-node-id]"
3215
+ );
3209
3216
  console.log("[AmplifyUp SDK] Found", componentElements.length, "components to highlight");
3210
3217
  componentElements.forEach((el) => {
3211
3218
  const htmlEl = el;
3212
3219
  const componentId = htmlEl.getAttribute("data-amplifyup-component") || htmlEl.getAttribute("data-component-id");
3213
- if (!componentId) return;
3220
+ const isLayoutNode = htmlEl.hasAttribute("data-node-id") || htmlEl.hasAttribute("data-amplifyup-node");
3221
+ if (!componentId && !isLayoutNode) return;
3214
3222
  if (htmlEl.classList.contains("amplifyup-component-highlight")) return;
3215
- const component = this.componentRegistry.find((c) => c.component_id === componentId);
3223
+ const component = componentId ? this.componentRegistry.find((c) => c.component_id === componentId) : void 0;
3216
3224
  htmlEl.classList.add("amplifyup-component-highlight");
3217
- htmlEl.setAttribute("data-component-id", componentId);
3218
- htmlEl.setAttribute("data-component-name", component?.component_name || componentId);
3225
+ if (componentId) {
3226
+ htmlEl.setAttribute("data-component-id", componentId);
3227
+ htmlEl.setAttribute("data-component-name", component?.component_name || componentId);
3228
+ }
3219
3229
  const hierarchy = this.buildComponentHierarchy(htmlEl);
3220
3230
  const handleClick = (e) => {
3221
3231
  e.stopPropagation();
3222
3232
  this.sendSelectionMessage(htmlEl, hierarchy);
3223
- if (window.parent && window.parent !== window) {
3233
+ if (componentId && window.parent && window.parent !== window) {
3224
3234
  window.parent.postMessage({ type: "CHECK_COMPONENT_DELETABLE", componentId }, "*");
3225
3235
  }
3226
3236
  };
@@ -3261,6 +3271,15 @@ Available Console Commands:
3261
3271
  htmlEl.classList.add("amplifyup-slot-highlight");
3262
3272
  const hierarchy = this.buildComponentHierarchy(htmlEl);
3263
3273
  const handleClick = (e) => {
3274
+ const clickTarget = e.target;
3275
+ if (htmlEl.getAttribute("data-slot-source") === "page" && clickTarget?.closest) {
3276
+ const nested = clickTarget.closest(
3277
+ "[data-node-id], [data-amplifyup-node], [data-amplifyup-component], [data-component-id]"
3278
+ );
3279
+ if (nested && nested !== htmlEl && htmlEl.contains(nested)) {
3280
+ return;
3281
+ }
3282
+ }
3264
3283
  e.stopPropagation();
3265
3284
  this.sendSelectionMessage(htmlEl, hierarchy, isEmpty);
3266
3285
  };