@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/index.js
CHANGED
|
@@ -2729,7 +2729,7 @@ Available Console Commands:
|
|
|
2729
2729
|
if (typeof document === "undefined") return;
|
|
2730
2730
|
this.teardownComposerDragDrop();
|
|
2731
2731
|
const slotSelector = "[data-slot-id], [data-amplifyup-slot]";
|
|
2732
|
-
const componentSelector = "[data-amplifyup-component], [data-component-id]";
|
|
2732
|
+
const componentSelector = "[data-amplifyup-component], [data-component-id], [data-amplifyup-node], [data-node-id]";
|
|
2733
2733
|
const clearDragOverState = () => {
|
|
2734
2734
|
this.clearComposerDragHighlight();
|
|
2735
2735
|
};
|
|
@@ -2778,6 +2778,7 @@ Available Console Commands:
|
|
|
2778
2778
|
if (!target?.closest) return;
|
|
2779
2779
|
const component = target.closest(componentSelector);
|
|
2780
2780
|
const slot = target.closest(slotSelector);
|
|
2781
|
+
const pageSlot = slot && slot.getAttribute("data-slot-source") === "page" ? slot : null;
|
|
2781
2782
|
if (this.highlightComponentsEnabled && component) {
|
|
2782
2783
|
if (!component.classList.contains("amplifyup-component-hover")) {
|
|
2783
2784
|
clearComponentHover();
|
|
@@ -2789,7 +2790,7 @@ Available Console Commands:
|
|
|
2789
2790
|
return;
|
|
2790
2791
|
}
|
|
2791
2792
|
clearComponentHover();
|
|
2792
|
-
if (this.showZonesEnabled && slot) {
|
|
2793
|
+
if (this.showZonesEnabled && slot && !pageSlot) {
|
|
2793
2794
|
if (!slot.classList.contains("amplifyup-slot-hover")) {
|
|
2794
2795
|
clearSlotHover();
|
|
2795
2796
|
slot.classList.add("amplifyup-slot-hover");
|
|
@@ -2919,16 +2920,18 @@ Available Console Commands:
|
|
|
2919
2920
|
const lines = [];
|
|
2920
2921
|
if (highlightComponents) {
|
|
2921
2922
|
lines.push(
|
|
2922
|
-
"[data-amplifyup-component], [data-component-id] {",
|
|
2923
|
+
"[data-amplifyup-component], [data-component-id], [data-amplifyup-node], [data-node-id] {",
|
|
2923
2924
|
" cursor: pointer !important;",
|
|
2924
2925
|
"}",
|
|
2925
|
-
"[data-amplifyup-component].amplifyup-selected, [data-component-id].amplifyup-selected {",
|
|
2926
|
+
"[data-amplifyup-component].amplifyup-selected, [data-component-id].amplifyup-selected, [data-amplifyup-node].amplifyup-selected, [data-node-id].amplifyup-selected {",
|
|
2926
2927
|
` outline: 2px solid ${primary} !important;`,
|
|
2927
2928
|
" outline-offset: -2px !important;",
|
|
2928
2929
|
" box-shadow: inset 0 0 0 1px hsl(82 100% 52% / 0.25) !important;",
|
|
2929
2930
|
"}",
|
|
2930
2931
|
"[data-amplifyup-component].amplifyup-component-hover:not(.amplifyup-selected),",
|
|
2931
|
-
"[data-component-id].amplifyup-component-hover:not(.amplifyup-selected)
|
|
2932
|
+
"[data-component-id].amplifyup-component-hover:not(.amplifyup-selected),",
|
|
2933
|
+
"[data-amplifyup-node].amplifyup-component-hover:not(.amplifyup-selected),",
|
|
2934
|
+
"[data-node-id].amplifyup-component-hover:not(.amplifyup-selected) {",
|
|
2932
2935
|
` outline: 2px solid ${primary} !important;`,
|
|
2933
2936
|
" outline-offset: -2px !important;",
|
|
2934
2937
|
"}"
|
|
@@ -3131,7 +3134,7 @@ Available Console Commands:
|
|
|
3131
3134
|
let current = element;
|
|
3132
3135
|
let sawPageSlot = false;
|
|
3133
3136
|
while (current) {
|
|
3134
|
-
if (current.hasAttribute("data-amplifyup-component") || current.hasAttribute("data-component-id") || current.hasAttribute("data-amplifyup-slot") || current.hasAttribute("data-slot-id")) {
|
|
3137
|
+
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")) {
|
|
3135
3138
|
hierarchy.push(current);
|
|
3136
3139
|
if (current.getAttribute("data-slot-source") === "page") {
|
|
3137
3140
|
sawPageSlot = true;
|
|
@@ -3156,13 +3159,14 @@ Available Console Commands:
|
|
|
3156
3159
|
const componentId = element.getAttribute("data-amplifyup-component") || element.getAttribute("data-component-id");
|
|
3157
3160
|
const slotName = componentId ? null : element.getAttribute("data-amplifyup-slot") || element.getAttribute("data-slot-id");
|
|
3158
3161
|
const componentName = element.getAttribute("data-component-name");
|
|
3162
|
+
const nodeId = element.getAttribute("data-node-id") || element.closest("[data-node-id]")?.getAttribute("data-node-id") || null;
|
|
3159
3163
|
const hierarchyInfo = hierarchy.map((el, index) => {
|
|
3160
3164
|
const elComponentId = el.getAttribute("data-amplifyup-component") || el.getAttribute("data-component-id");
|
|
3161
3165
|
const elSlotName = el.getAttribute("data-amplifyup-slot") || el.getAttribute("data-slot-id");
|
|
3162
3166
|
const elComponentName = el.getAttribute("data-component-name");
|
|
3163
3167
|
const isSlot = !elComponentId && !!elSlotName;
|
|
3164
3168
|
const isPageSlot = isSlot && el.getAttribute("data-slot-source") === "page";
|
|
3165
|
-
const
|
|
3169
|
+
const nodeId2 = el.getAttribute("data-node-id") || (isSlot ? el.getAttribute("data-parent-node-id") : null);
|
|
3166
3170
|
return {
|
|
3167
3171
|
index,
|
|
3168
3172
|
componentId: elComponentId,
|
|
@@ -3170,7 +3174,7 @@ Available Console Commands:
|
|
|
3170
3174
|
slotName: isSlot ? elSlotName : null,
|
|
3171
3175
|
isSlot,
|
|
3172
3176
|
isPageSlot,
|
|
3173
|
-
nodeId
|
|
3177
|
+
nodeId: nodeId2
|
|
3174
3178
|
};
|
|
3175
3179
|
});
|
|
3176
3180
|
const rect = element.getBoundingClientRect ? element.getBoundingClientRect() : null;
|
|
@@ -3180,6 +3184,7 @@ Available Console Commands:
|
|
|
3180
3184
|
componentId,
|
|
3181
3185
|
componentName,
|
|
3182
3186
|
slotName,
|
|
3187
|
+
nodeId,
|
|
3183
3188
|
hierarchy: hierarchyInfo,
|
|
3184
3189
|
selectedIndex: hierarchy.length - 1,
|
|
3185
3190
|
...bounds && { bounds },
|
|
@@ -3209,22 +3214,27 @@ Available Console Commands:
|
|
|
3209
3214
|
}
|
|
3210
3215
|
const doc = document;
|
|
3211
3216
|
if (highlightComponents) {
|
|
3212
|
-
const componentElements = doc.querySelectorAll(
|
|
3217
|
+
const componentElements = doc.querySelectorAll(
|
|
3218
|
+
"[data-amplifyup-component], [data-component-id], [data-amplifyup-node], [data-node-id]"
|
|
3219
|
+
);
|
|
3213
3220
|
console.log("[AmplifyUp SDK] Found", componentElements.length, "components to highlight");
|
|
3214
3221
|
componentElements.forEach((el) => {
|
|
3215
3222
|
const htmlEl = el;
|
|
3216
3223
|
const componentId = htmlEl.getAttribute("data-amplifyup-component") || htmlEl.getAttribute("data-component-id");
|
|
3217
|
-
|
|
3224
|
+
const isLayoutNode = htmlEl.hasAttribute("data-node-id") || htmlEl.hasAttribute("data-amplifyup-node");
|
|
3225
|
+
if (!componentId && !isLayoutNode) return;
|
|
3218
3226
|
if (htmlEl.classList.contains("amplifyup-component-highlight")) return;
|
|
3219
|
-
const component = this.componentRegistry.find((c) => c.component_id === componentId);
|
|
3227
|
+
const component = componentId ? this.componentRegistry.find((c) => c.component_id === componentId) : void 0;
|
|
3220
3228
|
htmlEl.classList.add("amplifyup-component-highlight");
|
|
3221
|
-
|
|
3222
|
-
|
|
3229
|
+
if (componentId) {
|
|
3230
|
+
htmlEl.setAttribute("data-component-id", componentId);
|
|
3231
|
+
htmlEl.setAttribute("data-component-name", component?.component_name || componentId);
|
|
3232
|
+
}
|
|
3223
3233
|
const hierarchy = this.buildComponentHierarchy(htmlEl);
|
|
3224
3234
|
const handleClick = (e) => {
|
|
3225
3235
|
e.stopPropagation();
|
|
3226
3236
|
this.sendSelectionMessage(htmlEl, hierarchy);
|
|
3227
|
-
if (window.parent && window.parent !== window) {
|
|
3237
|
+
if (componentId && window.parent && window.parent !== window) {
|
|
3228
3238
|
window.parent.postMessage({ type: "CHECK_COMPONENT_DELETABLE", componentId }, "*");
|
|
3229
3239
|
}
|
|
3230
3240
|
};
|
|
@@ -3265,6 +3275,15 @@ Available Console Commands:
|
|
|
3265
3275
|
htmlEl.classList.add("amplifyup-slot-highlight");
|
|
3266
3276
|
const hierarchy = this.buildComponentHierarchy(htmlEl);
|
|
3267
3277
|
const handleClick = (e) => {
|
|
3278
|
+
const clickTarget = e.target;
|
|
3279
|
+
if (htmlEl.getAttribute("data-slot-source") === "page" && clickTarget?.closest) {
|
|
3280
|
+
const nested = clickTarget.closest(
|
|
3281
|
+
"[data-node-id], [data-amplifyup-node], [data-amplifyup-component], [data-component-id]"
|
|
3282
|
+
);
|
|
3283
|
+
if (nested && nested !== htmlEl && htmlEl.contains(nested)) {
|
|
3284
|
+
return;
|
|
3285
|
+
}
|
|
3286
|
+
}
|
|
3268
3287
|
e.stopPropagation();
|
|
3269
3288
|
this.sendSelectionMessage(htmlEl, hierarchy, isEmpty);
|
|
3270
3289
|
};
|