@amplifyup/sdk 0.1.56 → 0.1.57

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/react.js CHANGED
@@ -2815,7 +2815,7 @@ Available Console Commands:
2815
2815
  if (typeof document === "undefined") return;
2816
2816
  this.teardownComposerDragDrop();
2817
2817
  const slotSelector = "[data-slot-id], [data-amplifyup-slot]";
2818
- const componentSelector = "[data-amplifyup-component], [data-component-id]";
2818
+ const componentSelector = "[data-amplifyup-component], [data-component-id], [data-amplifyup-node], [data-node-id]";
2819
2819
  const clearDragOverState = () => {
2820
2820
  this.clearComposerDragHighlight();
2821
2821
  };
@@ -2864,6 +2864,7 @@ Available Console Commands:
2864
2864
  if (!target?.closest) return;
2865
2865
  const component = target.closest(componentSelector);
2866
2866
  const slot = target.closest(slotSelector);
2867
+ const pageSlot = slot && slot.getAttribute("data-slot-source") === "page" ? slot : null;
2867
2868
  if (this.highlightComponentsEnabled && component) {
2868
2869
  if (!component.classList.contains("amplifyup-component-hover")) {
2869
2870
  clearComponentHover();
@@ -2875,7 +2876,7 @@ Available Console Commands:
2875
2876
  return;
2876
2877
  }
2877
2878
  clearComponentHover();
2878
- if (this.showZonesEnabled && slot) {
2879
+ if (this.showZonesEnabled && slot && !pageSlot) {
2879
2880
  if (!slot.classList.contains("amplifyup-slot-hover")) {
2880
2881
  clearSlotHover();
2881
2882
  slot.classList.add("amplifyup-slot-hover");
@@ -3005,16 +3006,18 @@ Available Console Commands:
3005
3006
  const lines = [];
3006
3007
  if (highlightComponents) {
3007
3008
  lines.push(
3008
- "[data-amplifyup-component], [data-component-id] {",
3009
+ "[data-amplifyup-component], [data-component-id], [data-amplifyup-node], [data-node-id] {",
3009
3010
  " cursor: pointer !important;",
3010
3011
  "}",
3011
- "[data-amplifyup-component].amplifyup-selected, [data-component-id].amplifyup-selected {",
3012
+ "[data-amplifyup-component].amplifyup-selected, [data-component-id].amplifyup-selected, [data-amplifyup-node].amplifyup-selected, [data-node-id].amplifyup-selected {",
3012
3013
  ` outline: 2px solid ${primary} !important;`,
3013
3014
  " outline-offset: -2px !important;",
3014
3015
  " box-shadow: inset 0 0 0 1px hsl(82 100% 52% / 0.25) !important;",
3015
3016
  "}",
3016
3017
  "[data-amplifyup-component].amplifyup-component-hover:not(.amplifyup-selected),",
3017
- "[data-component-id].amplifyup-component-hover:not(.amplifyup-selected) {",
3018
+ "[data-component-id].amplifyup-component-hover:not(.amplifyup-selected),",
3019
+ "[data-amplifyup-node].amplifyup-component-hover:not(.amplifyup-selected),",
3020
+ "[data-node-id].amplifyup-component-hover:not(.amplifyup-selected) {",
3018
3021
  ` outline: 2px solid ${primary} !important;`,
3019
3022
  " outline-offset: -2px !important;",
3020
3023
  "}"
@@ -3217,7 +3220,7 @@ Available Console Commands:
3217
3220
  let current = element;
3218
3221
  let sawPageSlot = false;
3219
3222
  while (current) {
3220
- if (current.hasAttribute("data-amplifyup-component") || current.hasAttribute("data-component-id") || current.hasAttribute("data-amplifyup-slot") || current.hasAttribute("data-slot-id")) {
3223
+ 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")) {
3221
3224
  hierarchy.push(current);
3222
3225
  if (current.getAttribute("data-slot-source") === "page") {
3223
3226
  sawPageSlot = true;
@@ -3242,13 +3245,14 @@ Available Console Commands:
3242
3245
  const componentId = element.getAttribute("data-amplifyup-component") || element.getAttribute("data-component-id");
3243
3246
  const slotName = componentId ? null : element.getAttribute("data-amplifyup-slot") || element.getAttribute("data-slot-id");
3244
3247
  const componentName = element.getAttribute("data-component-name");
3248
+ const nodeId = element.getAttribute("data-node-id") || element.closest("[data-node-id]")?.getAttribute("data-node-id") || null;
3245
3249
  const hierarchyInfo = hierarchy.map((el, index) => {
3246
3250
  const elComponentId = el.getAttribute("data-amplifyup-component") || el.getAttribute("data-component-id");
3247
3251
  const elSlotName = el.getAttribute("data-amplifyup-slot") || el.getAttribute("data-slot-id");
3248
3252
  const elComponentName = el.getAttribute("data-component-name");
3249
3253
  const isSlot = !elComponentId && !!elSlotName;
3250
3254
  const isPageSlot = isSlot && el.getAttribute("data-slot-source") === "page";
3251
- const nodeId = el.getAttribute("data-node-id") || (isSlot ? el.getAttribute("data-parent-node-id") : null);
3255
+ const nodeId2 = el.getAttribute("data-node-id") || (isSlot ? el.getAttribute("data-parent-node-id") : null);
3252
3256
  return {
3253
3257
  index,
3254
3258
  componentId: elComponentId,
@@ -3256,7 +3260,7 @@ Available Console Commands:
3256
3260
  slotName: isSlot ? elSlotName : null,
3257
3261
  isSlot,
3258
3262
  isPageSlot,
3259
- nodeId
3263
+ nodeId: nodeId2
3260
3264
  };
3261
3265
  });
3262
3266
  const rect = element.getBoundingClientRect ? element.getBoundingClientRect() : null;
@@ -3266,6 +3270,7 @@ Available Console Commands:
3266
3270
  componentId,
3267
3271
  componentName,
3268
3272
  slotName,
3273
+ nodeId,
3269
3274
  hierarchy: hierarchyInfo,
3270
3275
  selectedIndex: hierarchy.length - 1,
3271
3276
  ...bounds && { bounds },
@@ -3295,22 +3300,27 @@ Available Console Commands:
3295
3300
  }
3296
3301
  const doc = document;
3297
3302
  if (highlightComponents) {
3298
- const componentElements = doc.querySelectorAll("[data-amplifyup-component], [data-component-id]");
3303
+ const componentElements = doc.querySelectorAll(
3304
+ "[data-amplifyup-component], [data-component-id], [data-amplifyup-node], [data-node-id]"
3305
+ );
3299
3306
  console.log("[AmplifyUp SDK] Found", componentElements.length, "components to highlight");
3300
3307
  componentElements.forEach((el) => {
3301
3308
  const htmlEl = el;
3302
3309
  const componentId = htmlEl.getAttribute("data-amplifyup-component") || htmlEl.getAttribute("data-component-id");
3303
- if (!componentId) return;
3310
+ const isLayoutNode = htmlEl.hasAttribute("data-node-id") || htmlEl.hasAttribute("data-amplifyup-node");
3311
+ if (!componentId && !isLayoutNode) return;
3304
3312
  if (htmlEl.classList.contains("amplifyup-component-highlight")) return;
3305
- const component = this.componentRegistry.find((c) => c.component_id === componentId);
3313
+ const component = componentId ? this.componentRegistry.find((c) => c.component_id === componentId) : void 0;
3306
3314
  htmlEl.classList.add("amplifyup-component-highlight");
3307
- htmlEl.setAttribute("data-component-id", componentId);
3308
- htmlEl.setAttribute("data-component-name", component?.component_name || componentId);
3315
+ if (componentId) {
3316
+ htmlEl.setAttribute("data-component-id", componentId);
3317
+ htmlEl.setAttribute("data-component-name", component?.component_name || componentId);
3318
+ }
3309
3319
  const hierarchy = this.buildComponentHierarchy(htmlEl);
3310
3320
  const handleClick = (e) => {
3311
3321
  e.stopPropagation();
3312
3322
  this.sendSelectionMessage(htmlEl, hierarchy);
3313
- if (window.parent && window.parent !== window) {
3323
+ if (componentId && window.parent && window.parent !== window) {
3314
3324
  window.parent.postMessage({ type: "CHECK_COMPONENT_DELETABLE", componentId }, "*");
3315
3325
  }
3316
3326
  };
@@ -3351,6 +3361,15 @@ Available Console Commands:
3351
3361
  htmlEl.classList.add("amplifyup-slot-highlight");
3352
3362
  const hierarchy = this.buildComponentHierarchy(htmlEl);
3353
3363
  const handleClick = (e) => {
3364
+ const clickTarget = e.target;
3365
+ if (htmlEl.getAttribute("data-slot-source") === "page" && clickTarget?.closest) {
3366
+ const nested = clickTarget.closest(
3367
+ "[data-node-id], [data-amplifyup-node], [data-amplifyup-component], [data-component-id]"
3368
+ );
3369
+ if (nested && nested !== htmlEl && htmlEl.contains(nested)) {
3370
+ return;
3371
+ }
3372
+ }
3354
3373
  e.stopPropagation();
3355
3374
  this.sendSelectionMessage(htmlEl, hierarchy, isEmpty);
3356
3375
  };
@@ -4593,23 +4612,32 @@ function AmplifyRendererInner({
4593
4612
  }
4594
4613
  }
4595
4614
  const slotsToPass = Object.keys(slotChildren).length > 0 ? slotChildren : void 0;
4596
- return /* @__PURE__ */ jsxRuntime.jsx("div", { "data-node-id": node.id, "data-amplifyup-node": "", children: /* @__PURE__ */ jsxRuntime.jsx(
4597
- ComponentRenderBoundary,
4615
+ return /* @__PURE__ */ jsxRuntime.jsx(
4616
+ "div",
4598
4617
  {
4599
- componentId: node.componentId,
4600
- nodeId: node.id,
4618
+ "data-node-id": node.id,
4619
+ "data-amplifyup-node": "",
4620
+ "data-component-id": node.componentId,
4621
+ "data-amplifyup-component": node.componentId,
4601
4622
  children: /* @__PURE__ */ jsxRuntime.jsx(
4602
- LiveNodeRender,
4623
+ ComponentRenderBoundary,
4603
4624
  {
4604
- nodeId: node.id,
4605
4625
  componentId: node.componentId,
4606
- props: nodeRenderProps(node),
4607
- slots: slotsToPass,
4608
- renderComponent
4626
+ nodeId: node.id,
4627
+ children: /* @__PURE__ */ jsxRuntime.jsx(
4628
+ LiveNodeRender,
4629
+ {
4630
+ nodeId: node.id,
4631
+ componentId: node.componentId,
4632
+ props: nodeRenderProps(node),
4633
+ slots: slotsToPass,
4634
+ renderComponent
4635
+ }
4636
+ )
4609
4637
  }
4610
4638
  )
4611
4639
  }
4612
- ) });
4640
+ );
4613
4641
  };
4614
4642
  const rawTree = pageConfig.layoutTree;
4615
4643
  const layoutTree = Array.isArray(rawTree) ? rawTree : rawTree && typeof rawTree === "object" && rawTree.componentId ? [rawTree] : [];
@@ -4623,9 +4651,9 @@ function AmplifyRendererInner({
4623
4651
  "data-amplifyup-slot": "main",
4624
4652
  "data-slot-source": "page",
4625
4653
  "data-slot-empty": layoutTree.length === 0 ? "true" : void 0,
4626
- children: layoutTree.map((node) => /* @__PURE__ */ jsxRuntime.jsx("div", { children: renderNode(node) }, node.id))
4654
+ children: layoutTree.map((node) => /* @__PURE__ */ jsxRuntime.jsx(React.Fragment, { children: renderNode(node) }, node.id))
4627
4655
  }
4628
- ) : layoutTree.map((node) => /* @__PURE__ */ jsxRuntime.jsx("div", { children: renderNode(node) }, node.id)) });
4656
+ ) : layoutTree.map((node) => /* @__PURE__ */ jsxRuntime.jsx(React.Fragment, { children: renderNode(node) }, node.id)) });
4629
4657
  }
4630
4658
  var AmplifyRenderer = React.memo(AmplifyRendererInner);
4631
4659
  function defaultPreviewCanvas() {