@amplifyup/sdk 0.1.55 → 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/AmplifyRenderer.js +54 -26
- package/dist/AmplifyRenderer.js.map +1 -1
- package/dist/AmplifyRenderer.mjs +55 -27
- package/dist/AmplifyRenderer.mjs.map +1 -1
- package/dist/index.js +33 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +33 -14
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.mts +4 -4
- package/dist/react.d.ts +4 -4
- package/dist/react.js +98 -52
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +99 -53
- package/dist/react.mjs.map +1 -1
- package/package.json +1 -1
package/dist/AmplifyRenderer.js
CHANGED
|
@@ -2416,7 +2416,7 @@ Available Console Commands:
|
|
|
2416
2416
|
if (typeof document === "undefined") return;
|
|
2417
2417
|
this.teardownComposerDragDrop();
|
|
2418
2418
|
const slotSelector = "[data-slot-id], [data-amplifyup-slot]";
|
|
2419
|
-
const componentSelector = "[data-amplifyup-component], [data-component-id]";
|
|
2419
|
+
const componentSelector = "[data-amplifyup-component], [data-component-id], [data-amplifyup-node], [data-node-id]";
|
|
2420
2420
|
const clearDragOverState = () => {
|
|
2421
2421
|
this.clearComposerDragHighlight();
|
|
2422
2422
|
};
|
|
@@ -2465,6 +2465,7 @@ Available Console Commands:
|
|
|
2465
2465
|
if (!target?.closest) return;
|
|
2466
2466
|
const component = target.closest(componentSelector);
|
|
2467
2467
|
const slot = target.closest(slotSelector);
|
|
2468
|
+
const pageSlot = slot && slot.getAttribute("data-slot-source") === "page" ? slot : null;
|
|
2468
2469
|
if (this.highlightComponentsEnabled && component) {
|
|
2469
2470
|
if (!component.classList.contains("amplifyup-component-hover")) {
|
|
2470
2471
|
clearComponentHover();
|
|
@@ -2476,7 +2477,7 @@ Available Console Commands:
|
|
|
2476
2477
|
return;
|
|
2477
2478
|
}
|
|
2478
2479
|
clearComponentHover();
|
|
2479
|
-
if (this.showZonesEnabled && slot) {
|
|
2480
|
+
if (this.showZonesEnabled && slot && !pageSlot) {
|
|
2480
2481
|
if (!slot.classList.contains("amplifyup-slot-hover")) {
|
|
2481
2482
|
clearSlotHover();
|
|
2482
2483
|
slot.classList.add("amplifyup-slot-hover");
|
|
@@ -2606,16 +2607,18 @@ Available Console Commands:
|
|
|
2606
2607
|
const lines = [];
|
|
2607
2608
|
if (highlightComponents) {
|
|
2608
2609
|
lines.push(
|
|
2609
|
-
"[data-amplifyup-component], [data-component-id] {",
|
|
2610
|
+
"[data-amplifyup-component], [data-component-id], [data-amplifyup-node], [data-node-id] {",
|
|
2610
2611
|
" cursor: pointer !important;",
|
|
2611
2612
|
"}",
|
|
2612
|
-
"[data-amplifyup-component].amplifyup-selected, [data-component-id].amplifyup-selected {",
|
|
2613
|
+
"[data-amplifyup-component].amplifyup-selected, [data-component-id].amplifyup-selected, [data-amplifyup-node].amplifyup-selected, [data-node-id].amplifyup-selected {",
|
|
2613
2614
|
` outline: 2px solid ${primary} !important;`,
|
|
2614
2615
|
" outline-offset: -2px !important;",
|
|
2615
2616
|
" box-shadow: inset 0 0 0 1px hsl(82 100% 52% / 0.25) !important;",
|
|
2616
2617
|
"}",
|
|
2617
2618
|
"[data-amplifyup-component].amplifyup-component-hover:not(.amplifyup-selected),",
|
|
2618
|
-
"[data-component-id].amplifyup-component-hover:not(.amplifyup-selected)
|
|
2619
|
+
"[data-component-id].amplifyup-component-hover:not(.amplifyup-selected),",
|
|
2620
|
+
"[data-amplifyup-node].amplifyup-component-hover:not(.amplifyup-selected),",
|
|
2621
|
+
"[data-node-id].amplifyup-component-hover:not(.amplifyup-selected) {",
|
|
2619
2622
|
` outline: 2px solid ${primary} !important;`,
|
|
2620
2623
|
" outline-offset: -2px !important;",
|
|
2621
2624
|
"}"
|
|
@@ -2818,7 +2821,7 @@ Available Console Commands:
|
|
|
2818
2821
|
let current = element;
|
|
2819
2822
|
let sawPageSlot = false;
|
|
2820
2823
|
while (current) {
|
|
2821
|
-
if (current.hasAttribute("data-amplifyup-component") || current.hasAttribute("data-component-id") || current.hasAttribute("data-amplifyup-slot") || current.hasAttribute("data-slot-id")) {
|
|
2824
|
+
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")) {
|
|
2822
2825
|
hierarchy.push(current);
|
|
2823
2826
|
if (current.getAttribute("data-slot-source") === "page") {
|
|
2824
2827
|
sawPageSlot = true;
|
|
@@ -2843,13 +2846,14 @@ Available Console Commands:
|
|
|
2843
2846
|
const componentId = element.getAttribute("data-amplifyup-component") || element.getAttribute("data-component-id");
|
|
2844
2847
|
const slotName = componentId ? null : element.getAttribute("data-amplifyup-slot") || element.getAttribute("data-slot-id");
|
|
2845
2848
|
const componentName = element.getAttribute("data-component-name");
|
|
2849
|
+
const nodeId = element.getAttribute("data-node-id") || element.closest("[data-node-id]")?.getAttribute("data-node-id") || null;
|
|
2846
2850
|
const hierarchyInfo = hierarchy.map((el, index) => {
|
|
2847
2851
|
const elComponentId = el.getAttribute("data-amplifyup-component") || el.getAttribute("data-component-id");
|
|
2848
2852
|
const elSlotName = el.getAttribute("data-amplifyup-slot") || el.getAttribute("data-slot-id");
|
|
2849
2853
|
const elComponentName = el.getAttribute("data-component-name");
|
|
2850
2854
|
const isSlot = !elComponentId && !!elSlotName;
|
|
2851
2855
|
const isPageSlot = isSlot && el.getAttribute("data-slot-source") === "page";
|
|
2852
|
-
const
|
|
2856
|
+
const nodeId2 = el.getAttribute("data-node-id") || (isSlot ? el.getAttribute("data-parent-node-id") : null);
|
|
2853
2857
|
return {
|
|
2854
2858
|
index,
|
|
2855
2859
|
componentId: elComponentId,
|
|
@@ -2857,7 +2861,7 @@ Available Console Commands:
|
|
|
2857
2861
|
slotName: isSlot ? elSlotName : null,
|
|
2858
2862
|
isSlot,
|
|
2859
2863
|
isPageSlot,
|
|
2860
|
-
nodeId
|
|
2864
|
+
nodeId: nodeId2
|
|
2861
2865
|
};
|
|
2862
2866
|
});
|
|
2863
2867
|
const rect = element.getBoundingClientRect ? element.getBoundingClientRect() : null;
|
|
@@ -2867,6 +2871,7 @@ Available Console Commands:
|
|
|
2867
2871
|
componentId,
|
|
2868
2872
|
componentName,
|
|
2869
2873
|
slotName,
|
|
2874
|
+
nodeId,
|
|
2870
2875
|
hierarchy: hierarchyInfo,
|
|
2871
2876
|
selectedIndex: hierarchy.length - 1,
|
|
2872
2877
|
...bounds && { bounds },
|
|
@@ -2896,22 +2901,27 @@ Available Console Commands:
|
|
|
2896
2901
|
}
|
|
2897
2902
|
const doc = document;
|
|
2898
2903
|
if (highlightComponents) {
|
|
2899
|
-
const componentElements = doc.querySelectorAll(
|
|
2904
|
+
const componentElements = doc.querySelectorAll(
|
|
2905
|
+
"[data-amplifyup-component], [data-component-id], [data-amplifyup-node], [data-node-id]"
|
|
2906
|
+
);
|
|
2900
2907
|
console.log("[AmplifyUp SDK] Found", componentElements.length, "components to highlight");
|
|
2901
2908
|
componentElements.forEach((el) => {
|
|
2902
2909
|
const htmlEl = el;
|
|
2903
2910
|
const componentId = htmlEl.getAttribute("data-amplifyup-component") || htmlEl.getAttribute("data-component-id");
|
|
2904
|
-
|
|
2911
|
+
const isLayoutNode = htmlEl.hasAttribute("data-node-id") || htmlEl.hasAttribute("data-amplifyup-node");
|
|
2912
|
+
if (!componentId && !isLayoutNode) return;
|
|
2905
2913
|
if (htmlEl.classList.contains("amplifyup-component-highlight")) return;
|
|
2906
|
-
const component = this.componentRegistry.find((c) => c.component_id === componentId);
|
|
2914
|
+
const component = componentId ? this.componentRegistry.find((c) => c.component_id === componentId) : void 0;
|
|
2907
2915
|
htmlEl.classList.add("amplifyup-component-highlight");
|
|
2908
|
-
|
|
2909
|
-
|
|
2916
|
+
if (componentId) {
|
|
2917
|
+
htmlEl.setAttribute("data-component-id", componentId);
|
|
2918
|
+
htmlEl.setAttribute("data-component-name", component?.component_name || componentId);
|
|
2919
|
+
}
|
|
2910
2920
|
const hierarchy = this.buildComponentHierarchy(htmlEl);
|
|
2911
2921
|
const handleClick = (e) => {
|
|
2912
2922
|
e.stopPropagation();
|
|
2913
2923
|
this.sendSelectionMessage(htmlEl, hierarchy);
|
|
2914
|
-
if (window.parent && window.parent !== window) {
|
|
2924
|
+
if (componentId && window.parent && window.parent !== window) {
|
|
2915
2925
|
window.parent.postMessage({ type: "CHECK_COMPONENT_DELETABLE", componentId }, "*");
|
|
2916
2926
|
}
|
|
2917
2927
|
};
|
|
@@ -2952,6 +2962,15 @@ Available Console Commands:
|
|
|
2952
2962
|
htmlEl.classList.add("amplifyup-slot-highlight");
|
|
2953
2963
|
const hierarchy = this.buildComponentHierarchy(htmlEl);
|
|
2954
2964
|
const handleClick = (e) => {
|
|
2965
|
+
const clickTarget = e.target;
|
|
2966
|
+
if (htmlEl.getAttribute("data-slot-source") === "page" && clickTarget?.closest) {
|
|
2967
|
+
const nested = clickTarget.closest(
|
|
2968
|
+
"[data-node-id], [data-amplifyup-node], [data-amplifyup-component], [data-component-id]"
|
|
2969
|
+
);
|
|
2970
|
+
if (nested && nested !== htmlEl && htmlEl.contains(nested)) {
|
|
2971
|
+
return;
|
|
2972
|
+
}
|
|
2973
|
+
}
|
|
2955
2974
|
e.stopPropagation();
|
|
2956
2975
|
this.sendSelectionMessage(htmlEl, hierarchy, isEmpty);
|
|
2957
2976
|
};
|
|
@@ -3465,23 +3484,32 @@ function AmplifyRendererInner({
|
|
|
3465
3484
|
}
|
|
3466
3485
|
}
|
|
3467
3486
|
const slotsToPass = Object.keys(slotChildren).length > 0 ? slotChildren : void 0;
|
|
3468
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3469
|
-
|
|
3487
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3488
|
+
"div",
|
|
3470
3489
|
{
|
|
3471
|
-
|
|
3472
|
-
|
|
3490
|
+
"data-node-id": node.id,
|
|
3491
|
+
"data-amplifyup-node": "",
|
|
3492
|
+
"data-component-id": node.componentId,
|
|
3493
|
+
"data-amplifyup-component": node.componentId,
|
|
3473
3494
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3474
|
-
|
|
3495
|
+
ComponentRenderBoundary,
|
|
3475
3496
|
{
|
|
3476
|
-
nodeId: node.id,
|
|
3477
3497
|
componentId: node.componentId,
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3498
|
+
nodeId: node.id,
|
|
3499
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3500
|
+
LiveNodeRender,
|
|
3501
|
+
{
|
|
3502
|
+
nodeId: node.id,
|
|
3503
|
+
componentId: node.componentId,
|
|
3504
|
+
props: nodeRenderProps(node),
|
|
3505
|
+
slots: slotsToPass,
|
|
3506
|
+
renderComponent
|
|
3507
|
+
}
|
|
3508
|
+
)
|
|
3481
3509
|
}
|
|
3482
3510
|
)
|
|
3483
3511
|
}
|
|
3484
|
-
)
|
|
3512
|
+
);
|
|
3485
3513
|
};
|
|
3486
3514
|
const rawTree = pageConfig.layoutTree;
|
|
3487
3515
|
const layoutTree = Array.isArray(rawTree) ? rawTree : rawTree && typeof rawTree === "object" && rawTree.componentId ? [rawTree] : [];
|
|
@@ -3495,9 +3523,9 @@ function AmplifyRendererInner({
|
|
|
3495
3523
|
"data-amplifyup-slot": "main",
|
|
3496
3524
|
"data-slot-source": "page",
|
|
3497
3525
|
"data-slot-empty": layoutTree.length === 0 ? "true" : void 0,
|
|
3498
|
-
children: layoutTree.map((node) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
3526
|
+
children: layoutTree.map((node) => /* @__PURE__ */ jsxRuntime.jsx(react.Fragment, { children: renderNode(node) }, node.id))
|
|
3499
3527
|
}
|
|
3500
|
-
) : layoutTree.map((node) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
3528
|
+
) : layoutTree.map((node) => /* @__PURE__ */ jsxRuntime.jsx(react.Fragment, { children: renderNode(node) }, node.id)) });
|
|
3501
3529
|
}
|
|
3502
3530
|
var AmplifyRenderer = react.memo(AmplifyRendererInner);
|
|
3503
3531
|
|