@amplifyup/sdk 0.2.1 → 0.2.3
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 +89 -112
- package/dist/AmplifyRenderer.js.map +1 -1
- package/dist/AmplifyRenderer.mjs +89 -112
- package/dist/AmplifyRenderer.mjs.map +1 -1
- package/dist/index.js +88 -105
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +88 -105
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.mts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js +108 -180
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +108 -180
- package/dist/react.mjs.map +1 -1
- package/dist/server.js +3 -1
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +3 -1
- package/dist/server.mjs.map +1 -1
- package/package.json +1 -1
package/dist/react.mjs
CHANGED
|
@@ -421,7 +421,7 @@ function isComposerPreview() {
|
|
|
421
421
|
if (window.self !== window.top && document.referrer) {
|
|
422
422
|
try {
|
|
423
423
|
const refUrl = new URL(document.referrer);
|
|
424
|
-
if (refUrl.hostname === "amplifyup.ai" || refUrl.hostname.endsWith(".amplifyup.ai") || refUrl.hostname === "localhost" && refUrl.port === "5001" || refUrl.pathname.includes("/dashboard/composer")
|
|
424
|
+
if (refUrl.hostname === "amplifyup.ai" || refUrl.hostname.endsWith(".amplifyup.ai") || refUrl.hostname === "localhost" && refUrl.port === "5001" || refUrl.pathname.includes("/dashboard/composer")) {
|
|
425
425
|
return true;
|
|
426
426
|
}
|
|
427
427
|
} catch {
|
|
@@ -1063,7 +1063,8 @@ function layoutProviderCacheKey(opts) {
|
|
|
1063
1063
|
opts.preview ? "1" : "0",
|
|
1064
1064
|
opts.working ? "1" : "0",
|
|
1065
1065
|
opts.zoneId || "",
|
|
1066
|
-
opts.compositionId || ""
|
|
1066
|
+
opts.compositionId || "",
|
|
1067
|
+
opts.layoutId || ""
|
|
1067
1068
|
].join("|");
|
|
1068
1069
|
}
|
|
1069
1070
|
function getSettledLayoutProvider(key) {
|
|
@@ -1580,7 +1581,7 @@ var AmplifyUpSDK = class {
|
|
|
1580
1581
|
if (document.referrer) {
|
|
1581
1582
|
try {
|
|
1582
1583
|
const referrerUrl = new URL(document.referrer);
|
|
1583
|
-
if (referrerUrl.hostname === "localhost" && referrerUrl.port === "5001" || referrerUrl.pathname.includes("/dashboard/composer")
|
|
1584
|
+
if (referrerUrl.hostname === "localhost" && referrerUrl.port === "5001" || referrerUrl.pathname.includes("/dashboard/composer")) {
|
|
1584
1585
|
return true;
|
|
1585
1586
|
}
|
|
1586
1587
|
} catch {
|
|
@@ -1857,11 +1858,7 @@ var AmplifyUpSDK = class {
|
|
|
1857
1858
|
this.page(resumePath, { resumed: true });
|
|
1858
1859
|
this.lastTrackedPath = resumePath;
|
|
1859
1860
|
if (this.config?.debug) {
|
|
1860
|
-
console.log(
|
|
1861
|
-
"[AmplifyUp SDK] Idle resume page view",
|
|
1862
|
-
resumePath,
|
|
1863
|
-
`(hidden ${Math.round(idleMs / 6e4)}m)`
|
|
1864
|
-
);
|
|
1861
|
+
console.log("[AmplifyUp SDK] Idle resume page view", resumePath, `(hidden ${Math.round(idleMs / 6e4)}m)`);
|
|
1865
1862
|
}
|
|
1866
1863
|
}
|
|
1867
1864
|
noteActivity();
|
|
@@ -1881,12 +1878,7 @@ var AmplifyUpSDK = class {
|
|
|
1881
1878
|
}
|
|
1882
1879
|
state.visibleSince = null;
|
|
1883
1880
|
};
|
|
1884
|
-
const activityEvents = [
|
|
1885
|
-
"pointerdown",
|
|
1886
|
-
"keydown",
|
|
1887
|
-
"scroll",
|
|
1888
|
-
"touchstart"
|
|
1889
|
-
];
|
|
1881
|
+
const activityEvents = ["pointerdown", "keydown", "scroll", "touchstart"];
|
|
1890
1882
|
const onActivity = () => noteActivity();
|
|
1891
1883
|
window.addEventListener("scroll", onScroll, { passive: true });
|
|
1892
1884
|
document.addEventListener("visibilitychange", onVisibility);
|
|
@@ -2034,11 +2026,7 @@ var AmplifyUpSDK = class {
|
|
|
2034
2026
|
hosts.forEach((host) => observer.observe(host));
|
|
2035
2027
|
this.componentViewObservers.push(observer);
|
|
2036
2028
|
if (this.config?.debug) {
|
|
2037
|
-
console.log(
|
|
2038
|
-
"[AmplifyUp SDK] Component View tracking enabled for",
|
|
2039
|
-
hosts.length,
|
|
2040
|
-
"hosts"
|
|
2041
|
-
);
|
|
2029
|
+
console.log("[AmplifyUp SDK] Component View tracking enabled for", hosts.length, "hosts");
|
|
2042
2030
|
}
|
|
2043
2031
|
}
|
|
2044
2032
|
cleanupComponentViewTracking() {
|
|
@@ -2510,6 +2498,8 @@ Available Console Commands:
|
|
|
2510
2498
|
const compositionId = pageSearch.get("compositionId");
|
|
2511
2499
|
if (zoneId) params.set("zoneId", zoneId);
|
|
2512
2500
|
if (compositionId) params.set("compositionId", compositionId);
|
|
2501
|
+
const layoutId = pageSearch.get("layoutId");
|
|
2502
|
+
if (layoutId) params.set("layoutId", layoutId);
|
|
2513
2503
|
}
|
|
2514
2504
|
}
|
|
2515
2505
|
if (isOnOrchestratorOrigin) {
|
|
@@ -2530,7 +2520,8 @@ Available Console Commands:
|
|
|
2530
2520
|
preview,
|
|
2531
2521
|
working: pageSearch ? isWorkingContentRequest(pageSearch) : false,
|
|
2532
2522
|
zoneId: pageSearch?.get("zoneId"),
|
|
2533
|
-
compositionId: pageSearch?.get("compositionId")
|
|
2523
|
+
compositionId: pageSearch?.get("compositionId"),
|
|
2524
|
+
layoutId: pageSearch?.get("layoutId")
|
|
2534
2525
|
});
|
|
2535
2526
|
return dedupeLayoutProviderFetch(cacheKey, async () => {
|
|
2536
2527
|
const startedAt = Date.now();
|
|
@@ -2612,15 +2603,11 @@ Available Console Commands:
|
|
|
2612
2603
|
) : document;
|
|
2613
2604
|
if (!scopeRoot) {
|
|
2614
2605
|
if (this.config?.debug) {
|
|
2615
|
-
console.log(
|
|
2616
|
-
`[AmplifyUp SDK] Component host not found for ${eventConfig.componentId}`
|
|
2617
|
-
);
|
|
2606
|
+
console.log(`[AmplifyUp SDK] Component host not found for ${eventConfig.componentId}`);
|
|
2618
2607
|
}
|
|
2619
2608
|
return;
|
|
2620
2609
|
}
|
|
2621
|
-
targetElements = Array.from(
|
|
2622
|
-
scopeRoot.querySelectorAll(eventConfig.selector)
|
|
2623
|
-
);
|
|
2610
|
+
targetElements = Array.from(scopeRoot.querySelectorAll(eventConfig.selector));
|
|
2624
2611
|
if (scopeRoot instanceof Element && scopeRoot !== document.documentElement && scopeRoot.matches?.(eventConfig.selector)) {
|
|
2625
2612
|
targetElements.unshift(scopeRoot);
|
|
2626
2613
|
}
|
|
@@ -2653,7 +2640,9 @@ Available Console Commands:
|
|
|
2653
2640
|
});
|
|
2654
2641
|
}
|
|
2655
2642
|
if (this.config?.debug) {
|
|
2656
|
-
console.log(
|
|
2643
|
+
console.log(
|
|
2644
|
+
`[AmplifyUp SDK] Attached ${eventConfig.eventType} listener for ${eventConfig.eventName} on selector: ${eventConfig.selector}`
|
|
2645
|
+
);
|
|
2657
2646
|
}
|
|
2658
2647
|
});
|
|
2659
2648
|
});
|
|
@@ -2663,16 +2652,16 @@ Available Console Commands:
|
|
|
2663
2652
|
*/
|
|
2664
2653
|
mapEventType(eventType) {
|
|
2665
2654
|
const eventMap = {
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2655
|
+
click: "click",
|
|
2656
|
+
submit: "submit",
|
|
2657
|
+
focus: "focus",
|
|
2658
|
+
blur: "blur",
|
|
2659
|
+
hover: "mouseenter",
|
|
2660
|
+
change: "change",
|
|
2661
|
+
scroll: "scroll",
|
|
2662
|
+
view: "view",
|
|
2674
2663
|
// Handled separately with IntersectionObserver
|
|
2675
|
-
|
|
2664
|
+
custom: "custom"
|
|
2676
2665
|
};
|
|
2677
2666
|
return eventMap[eventType] || eventType;
|
|
2678
2667
|
}
|
|
@@ -2748,11 +2737,7 @@ Available Console Commands:
|
|
|
2748
2737
|
(entries) => {
|
|
2749
2738
|
entries.forEach((entry) => {
|
|
2750
2739
|
if (entry.isIntersecting) {
|
|
2751
|
-
this.handleTrackedEvent(
|
|
2752
|
-
new CustomEvent("view"),
|
|
2753
|
-
config,
|
|
2754
|
-
element
|
|
2755
|
-
);
|
|
2740
|
+
this.handleTrackedEvent(new CustomEvent("view"), config, element);
|
|
2756
2741
|
observer.unobserve(element);
|
|
2757
2742
|
}
|
|
2758
2743
|
});
|
|
@@ -2895,21 +2880,15 @@ Available Console Commands:
|
|
|
2895
2880
|
return;
|
|
2896
2881
|
}
|
|
2897
2882
|
if (event.data?.type === "AMPLIFYUP_FIELD_PATCH") {
|
|
2898
|
-
window.dispatchEvent(
|
|
2899
|
-
new CustomEvent("amplifyup:field-patch", { detail: event.data })
|
|
2900
|
-
);
|
|
2883
|
+
window.dispatchEvent(new CustomEvent("amplifyup:field-patch", { detail: event.data }));
|
|
2901
2884
|
return;
|
|
2902
2885
|
}
|
|
2903
2886
|
if (event.data?.type === "AMPLIFYUP_PROPS_PATCH") {
|
|
2904
|
-
window.dispatchEvent(
|
|
2905
|
-
new CustomEvent("amplifyup:props-patch", { detail: event.data })
|
|
2906
|
-
);
|
|
2887
|
+
window.dispatchEvent(new CustomEvent("amplifyup:props-patch", { detail: event.data }));
|
|
2907
2888
|
return;
|
|
2908
2889
|
}
|
|
2909
2890
|
if (event.data?.type === "AMPLIFYUP_LAYOUT_PATCH") {
|
|
2910
|
-
window.dispatchEvent(
|
|
2911
|
-
new CustomEvent("amplifyup:layout-patch", { detail: event.data })
|
|
2912
|
-
);
|
|
2891
|
+
window.dispatchEvent(new CustomEvent("amplifyup:layout-patch", { detail: event.data }));
|
|
2913
2892
|
return;
|
|
2914
2893
|
}
|
|
2915
2894
|
if (event.data?.type === "COMPONENT_DELETABLE_STATUS") {
|
|
@@ -2972,9 +2951,7 @@ Available Console Commands:
|
|
|
2972
2951
|
const { componentId, slotName, nodeId, isPageSlot } = event.data;
|
|
2973
2952
|
let element = null;
|
|
2974
2953
|
if (isPageSlot || slotName === "main" && !nodeId && !componentId) {
|
|
2975
|
-
element = document.querySelector(
|
|
2976
|
-
'[data-slot-source="page"]'
|
|
2977
|
-
);
|
|
2954
|
+
element = document.querySelector('[data-slot-source="page"]');
|
|
2978
2955
|
}
|
|
2979
2956
|
if (!element && nodeId && slotName) {
|
|
2980
2957
|
element = document.querySelector(
|
|
@@ -2982,9 +2959,7 @@ Available Console Commands:
|
|
|
2982
2959
|
);
|
|
2983
2960
|
}
|
|
2984
2961
|
if (!element && nodeId && !slotName) {
|
|
2985
|
-
element = document.querySelector(
|
|
2986
|
-
`[data-node-id="${nodeId}"]`
|
|
2987
|
-
);
|
|
2962
|
+
element = document.querySelector(`[data-node-id="${nodeId}"]`);
|
|
2988
2963
|
}
|
|
2989
2964
|
if (!element && slotName) {
|
|
2990
2965
|
element = document.querySelector(
|
|
@@ -3025,30 +3000,33 @@ Available Console Commands:
|
|
|
3025
3000
|
};
|
|
3026
3001
|
if (window.parent && window.parent !== window) {
|
|
3027
3002
|
const hierarchyEls = this.buildComponentHierarchy(element);
|
|
3028
|
-
window.parent.postMessage(
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3003
|
+
window.parent.postMessage(
|
|
3004
|
+
{
|
|
3005
|
+
type: "ELEMENT_POSITION",
|
|
3006
|
+
componentId: componentId || null,
|
|
3007
|
+
slotName: slotName || null,
|
|
3008
|
+
nodeId: nodeId || null,
|
|
3009
|
+
isPageSlot: !!isPageSlot || element.getAttribute("data-slot-source") === "page",
|
|
3010
|
+
hierarchy: hierarchyEls.map((el, index) => {
|
|
3011
|
+
const elComponentId = el.getAttribute("data-amplifyup-component") || el.getAttribute("data-component-id");
|
|
3012
|
+
const elSlotName = el.getAttribute("data-amplifyup-slot") || el.getAttribute("data-slot-id");
|
|
3013
|
+
const isSlot = !elComponentId && !!elSlotName;
|
|
3014
|
+
const pageSlot = isSlot && el.getAttribute("data-slot-source") === "page";
|
|
3015
|
+
return {
|
|
3016
|
+
index,
|
|
3017
|
+
componentId: elComponentId,
|
|
3018
|
+
componentName: pageSlot ? "Page" : el.getAttribute("data-component-name"),
|
|
3019
|
+
slotName: isSlot ? elSlotName : null,
|
|
3020
|
+
isSlot,
|
|
3021
|
+
isPageSlot: pageSlot,
|
|
3022
|
+
nodeId: el.getAttribute("data-node-id") || (isSlot ? el.getAttribute("data-parent-node-id") : null)
|
|
3023
|
+
};
|
|
3024
|
+
}),
|
|
3025
|
+
position,
|
|
3026
|
+
bounds
|
|
3027
|
+
},
|
|
3028
|
+
"*"
|
|
3029
|
+
);
|
|
3052
3030
|
}
|
|
3053
3031
|
} else {
|
|
3054
3032
|
console.warn("[AmplifyUp SDK] Element not found for position request");
|
|
@@ -3064,7 +3042,11 @@ Available Console Commands:
|
|
|
3064
3042
|
switch (message.type) {
|
|
3065
3043
|
case "ENABLE_HIGHLIGHTING":
|
|
3066
3044
|
case "UPDATE_HIGHLIGHTING":
|
|
3067
|
-
console.log(
|
|
3045
|
+
console.log(
|
|
3046
|
+
"[AmplifyUp SDK] Enabling highlighting with registry:",
|
|
3047
|
+
message.componentRegistry?.length || 0,
|
|
3048
|
+
"components"
|
|
3049
|
+
);
|
|
3068
3050
|
this.enableHighlighting(
|
|
3069
3051
|
message.componentRegistry || [],
|
|
3070
3052
|
message.highlightComponents ?? true,
|
|
@@ -3124,12 +3106,15 @@ Available Console Commands:
|
|
|
3124
3106
|
const tagName = target.tagName.toLowerCase();
|
|
3125
3107
|
const text = (target.textContent || "").replace(/\s+/g, " ").trim().substring(0, 80);
|
|
3126
3108
|
if (window.parent && window.parent !== window) {
|
|
3127
|
-
window.parent.postMessage(
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3109
|
+
window.parent.postMessage(
|
|
3110
|
+
{
|
|
3111
|
+
type: "ELEMENT_CLICKED_FOR_EVENT",
|
|
3112
|
+
selector,
|
|
3113
|
+
tagName,
|
|
3114
|
+
text
|
|
3115
|
+
},
|
|
3116
|
+
"*"
|
|
3117
|
+
);
|
|
3133
3118
|
}
|
|
3134
3119
|
};
|
|
3135
3120
|
document.addEventListener("click", this.eventSelectionClickHandler, true);
|
|
@@ -3155,9 +3140,7 @@ Available Console Commands:
|
|
|
3155
3140
|
return "[" + attr.name + '="' + attr.value + '"]';
|
|
3156
3141
|
}
|
|
3157
3142
|
if (el.className && typeof el.className === "string") {
|
|
3158
|
-
const classes = el.className.split(" ").filter(
|
|
3159
|
-
(c) => c && !c.startsWith("has-") && !c.includes("selectable") && !c.includes("selected")
|
|
3160
|
-
);
|
|
3143
|
+
const classes = el.className.split(" ").filter((c) => c && !c.startsWith("has-") && !c.includes("selectable") && !c.includes("selected"));
|
|
3161
3144
|
if (classes.length > 0) {
|
|
3162
3145
|
return el.tagName.toLowerCase() + "." + classes[0];
|
|
3163
3146
|
}
|
|
@@ -3207,9 +3190,7 @@ Available Console Commands:
|
|
|
3207
3190
|
}
|
|
3208
3191
|
});
|
|
3209
3192
|
if (containing.length === 0) return null;
|
|
3210
|
-
const innermost = containing.filter(
|
|
3211
|
-
(el) => !containing.some((other) => other !== el && el.contains(other))
|
|
3212
|
-
);
|
|
3193
|
+
const innermost = containing.filter((el) => !containing.some((other) => other !== el && el.contains(other)));
|
|
3213
3194
|
if (innermost.length === 1) return innermost[0];
|
|
3214
3195
|
let best = innermost[0];
|
|
3215
3196
|
let bestArea = Infinity;
|
|
@@ -3326,9 +3307,7 @@ Available Console Commands:
|
|
|
3326
3307
|
*/
|
|
3327
3308
|
enableHighlighting(componentRegistry, highlightComponents, showZones) {
|
|
3328
3309
|
if (typeof document === "undefined") return;
|
|
3329
|
-
const previouslySelected = Array.from(
|
|
3330
|
-
document.querySelectorAll(".amplifyup-selected")
|
|
3331
|
-
);
|
|
3310
|
+
const previouslySelected = Array.from(document.querySelectorAll(".amplifyup-selected"));
|
|
3332
3311
|
this.componentRegistry = componentRegistry;
|
|
3333
3312
|
this.highlightingEnabled = true;
|
|
3334
3313
|
this.highlightComponentsEnabled = highlightComponents;
|
|
@@ -3701,10 +3680,7 @@ Available Console Commands:
|
|
|
3701
3680
|
if (shouldReapply && this.highlightingEnabled) {
|
|
3702
3681
|
setTimeout(() => {
|
|
3703
3682
|
if (this.highlightingEnabled) {
|
|
3704
|
-
this.applyComponentHighlights(
|
|
3705
|
-
this.highlightComponentsEnabled,
|
|
3706
|
-
this.showZonesEnabled
|
|
3707
|
-
);
|
|
3683
|
+
this.applyComponentHighlights(this.highlightComponentsEnabled, this.showZonesEnabled);
|
|
3708
3684
|
}
|
|
3709
3685
|
}, 100);
|
|
3710
3686
|
}
|
|
@@ -3713,7 +3689,13 @@ Available Console Commands:
|
|
|
3713
3689
|
childList: true,
|
|
3714
3690
|
subtree: true,
|
|
3715
3691
|
attributes: true,
|
|
3716
|
-
attributeFilter: [
|
|
3692
|
+
attributeFilter: [
|
|
3693
|
+
"data-amplifyup-component",
|
|
3694
|
+
"data-component-id",
|
|
3695
|
+
"data-amplifyup-slot",
|
|
3696
|
+
"data-slot-id",
|
|
3697
|
+
"data-slot-empty"
|
|
3698
|
+
]
|
|
3717
3699
|
});
|
|
3718
3700
|
}
|
|
3719
3701
|
/**
|
|
@@ -3727,9 +3709,7 @@ Available Console Commands:
|
|
|
3727
3709
|
this.teardownComposerDragDrop();
|
|
3728
3710
|
if (opts?.clearSelection !== false && typeof window !== "undefined") {
|
|
3729
3711
|
window.__AMPLIFYUP_COMPOSER_EDIT__ = false;
|
|
3730
|
-
window.dispatchEvent(
|
|
3731
|
-
new CustomEvent("amplifyup:composer-edit", { detail: { enabled: false } })
|
|
3732
|
-
);
|
|
3712
|
+
window.dispatchEvent(new CustomEvent("amplifyup:composer-edit", { detail: { enabled: false } }));
|
|
3733
3713
|
}
|
|
3734
3714
|
if (this.mutationObserver) {
|
|
3735
3715
|
this.mutationObserver.disconnect();
|
|
@@ -3887,7 +3867,10 @@ Available Console Commands:
|
|
|
3887
3867
|
e.stopPropagation();
|
|
3888
3868
|
this.sendSelectionMessage(htmlEl, hierarchy);
|
|
3889
3869
|
if (window.parent && window.parent !== window) {
|
|
3890
|
-
window.parent.postMessage(
|
|
3870
|
+
window.parent.postMessage(
|
|
3871
|
+
{ type: "CHECK_COMPONENT_DELETABLE", componentId: component.component_id },
|
|
3872
|
+
"*"
|
|
3873
|
+
);
|
|
3891
3874
|
}
|
|
3892
3875
|
};
|
|
3893
3876
|
htmlEl.addEventListener("click", handleClick);
|
|
@@ -4262,23 +4245,12 @@ function ComponentContextProvider({
|
|
|
4262
4245
|
componentId
|
|
4263
4246
|
}) {
|
|
4264
4247
|
const next = hydratePageResourceProps(props || {}, getPageResourceFields());
|
|
4265
|
-
return /* @__PURE__ */ jsx(
|
|
4266
|
-
ComponentContext.Provider,
|
|
4267
|
-
{
|
|
4268
|
-
value: { slots, props: next, layoutNodeId, componentId },
|
|
4269
|
-
children
|
|
4270
|
-
}
|
|
4271
|
-
);
|
|
4248
|
+
return /* @__PURE__ */ jsx(ComponentContext.Provider, { value: { slots, props: next, layoutNodeId, componentId }, children });
|
|
4272
4249
|
}
|
|
4273
|
-
function Slot({
|
|
4274
|
-
name,
|
|
4275
|
-
className
|
|
4276
|
-
}) {
|
|
4250
|
+
function Slot({ name, className }) {
|
|
4277
4251
|
const context = useContext(ComponentContext);
|
|
4278
4252
|
if (!context) {
|
|
4279
|
-
console.warn(
|
|
4280
|
-
`[AmplifyUp SDK] Slot "${name}" only works inside a component rendered from your component registry`
|
|
4281
|
-
);
|
|
4253
|
+
console.warn(`[AmplifyUp SDK] Slot "${name}" only works inside a component rendered from your component registry`);
|
|
4282
4254
|
return null;
|
|
4283
4255
|
}
|
|
4284
4256
|
const slotContent = context.slots?.[name];
|
|
@@ -4294,21 +4266,17 @@ function Slot({
|
|
|
4294
4266
|
window.self !== window.top && document.referrer && (() => {
|
|
4295
4267
|
try {
|
|
4296
4268
|
const referrerUrl = new URL(document.referrer);
|
|
4297
|
-
return referrerUrl.hostname === "localhost" && referrerUrl.port === "5001" || referrerUrl.pathname.includes("/dashboard/composer")
|
|
4269
|
+
return referrerUrl.hostname === "localhost" && referrerUrl.port === "5001" || referrerUrl.pathname.includes("/dashboard/composer");
|
|
4298
4270
|
} catch {
|
|
4299
4271
|
return false;
|
|
4300
4272
|
}
|
|
4301
4273
|
})());
|
|
4302
|
-
sdkDebugOnce(
|
|
4303
|
-
|
|
4304
|
-
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
|
|
4308
|
-
isEditorMode,
|
|
4309
|
-
availableSlotKeys: context.slots ? Object.keys(context.slots) : []
|
|
4310
|
-
}
|
|
4311
|
-
);
|
|
4274
|
+
sdkDebugOnce(`slot:${context.layoutNodeId || ""}:${name}`, `[Slot:${name}]`, {
|
|
4275
|
+
slotState,
|
|
4276
|
+
isEmpty,
|
|
4277
|
+
isEditorMode,
|
|
4278
|
+
availableSlotKeys: context.slots ? Object.keys(context.slots) : []
|
|
4279
|
+
});
|
|
4312
4280
|
return /* @__PURE__ */ jsx(
|
|
4313
4281
|
"div",
|
|
4314
4282
|
{
|
|
@@ -4398,18 +4366,12 @@ function canInlineEditRichText(name, value) {
|
|
|
4398
4366
|
return true;
|
|
4399
4367
|
}
|
|
4400
4368
|
function useComposerEditMode() {
|
|
4401
|
-
return useSyncExternalStore(
|
|
4402
|
-
subscribeComposerEdit,
|
|
4403
|
-
isComposerEditMode,
|
|
4404
|
-
getComposerEditModeServer
|
|
4405
|
-
);
|
|
4369
|
+
return useSyncExternalStore(subscribeComposerEdit, isComposerEditMode, getComposerEditModeServer);
|
|
4406
4370
|
}
|
|
4407
4371
|
function useBoundField(field, value, name, component) {
|
|
4408
4372
|
const bound = resolveEditableBinding(field, value, name);
|
|
4409
4373
|
if (bound.requiresName) {
|
|
4410
|
-
console.warn(
|
|
4411
|
-
`[AmplifyUp SDK] ${component} value={\u2026} requires name="\u2026" for computed values`
|
|
4412
|
-
);
|
|
4374
|
+
console.warn(`[AmplifyUp SDK] ${component} value={\u2026} requires name="\u2026" for computed values`);
|
|
4413
4375
|
}
|
|
4414
4376
|
const fieldValue = useComposerFieldValue(bound.name, bound.value, bound.ref);
|
|
4415
4377
|
return { editName: bound.name, fieldValue, ref: bound.ref };
|
|
@@ -4490,9 +4452,7 @@ function ComposerInlineField({
|
|
|
4490
4452
|
const el = elRef.current;
|
|
4491
4453
|
if (!el) return;
|
|
4492
4454
|
if (document.activeElement === el) return;
|
|
4493
|
-
if (el.querySelector(
|
|
4494
|
-
"input, button, select, textarea, form, svg, iframe, img"
|
|
4495
|
-
)) {
|
|
4455
|
+
if (el.querySelector("input, button, select, textarea, form, svg, iframe, img")) {
|
|
4496
4456
|
return;
|
|
4497
4457
|
}
|
|
4498
4458
|
const next = idleDisplay || "";
|
|
@@ -4699,9 +4659,7 @@ function warnReadOnlyRowField(name) {
|
|
|
4699
4659
|
const key = name || "(unnamed)";
|
|
4700
4660
|
if (warnedReadOnlyFields.has(key)) return;
|
|
4701
4661
|
warnedReadOnlyFields.add(key);
|
|
4702
|
-
console.warn(
|
|
4703
|
-
`[AmplifyUp SDK] ${key} has no write target; rendered read-only.`
|
|
4704
|
-
);
|
|
4662
|
+
console.warn(`[AmplifyUp SDK] ${key} has no write target; rendered read-only.`);
|
|
4705
4663
|
}
|
|
4706
4664
|
function canComposerBind(field, ref, editName) {
|
|
4707
4665
|
if (isReadOnlyRowField(field) || isFieldEnvelope(field) && field.readOnly) {
|
|
@@ -4713,9 +4671,7 @@ function canComposerBind(field, ref, editName) {
|
|
|
4713
4671
|
function warnProjectionProps(component, hasField, hasValue, name) {
|
|
4714
4672
|
if (process.env.NODE_ENV === "production") return;
|
|
4715
4673
|
if (!hasField && !hasValue && !name) {
|
|
4716
|
-
console.warn(
|
|
4717
|
-
`[AmplifyUp SDK] ${component} needs field={fields.yourProp} (or value + name for computed values)`
|
|
4718
|
-
);
|
|
4674
|
+
console.warn(`[AmplifyUp SDK] ${component} needs field={fields.yourProp} (or value + name for computed values)`);
|
|
4719
4675
|
}
|
|
4720
4676
|
}
|
|
4721
4677
|
function hasOwnProp(props, key) {
|
|
@@ -4769,26 +4725,14 @@ function markdownToHtml(markdown) {
|
|
|
4769
4725
|
}
|
|
4770
4726
|
}
|
|
4771
4727
|
function RichText(props) {
|
|
4772
|
-
const {
|
|
4773
|
-
field,
|
|
4774
|
-
value,
|
|
4775
|
-
name,
|
|
4776
|
-
className,
|
|
4777
|
-
as: Tag = "div",
|
|
4778
|
-
children
|
|
4779
|
-
} = props;
|
|
4728
|
+
const { field, value, name, className, as: Tag = "div", children } = props;
|
|
4780
4729
|
const context = useContext(ComponentContext);
|
|
4781
4730
|
const composerEdit = useComposerEditMode();
|
|
4782
4731
|
const childrenValue = typeof children === "string" || typeof children === "number" ? String(children) : void 0;
|
|
4783
4732
|
const hasField = isFieldEnvelope(field);
|
|
4784
4733
|
const hasValueProp = hasOwnProp(props, "value") || childrenValue !== void 0;
|
|
4785
4734
|
const boundValue = hasOwnProp(props, "value") ? value : childrenValue !== void 0 ? childrenValue : value;
|
|
4786
|
-
const { editName, fieldValue, ref } = useBoundField(
|
|
4787
|
-
field,
|
|
4788
|
-
boundValue,
|
|
4789
|
-
name,
|
|
4790
|
-
"RichText"
|
|
4791
|
-
);
|
|
4735
|
+
const { editName, fieldValue, ref } = useBoundField(field, boundValue, name, "RichText");
|
|
4792
4736
|
assertNamedEnvelope("RichText", field);
|
|
4793
4737
|
if (!hasField && !hasValueProp && !name) {
|
|
4794
4738
|
return null;
|
|
@@ -4890,28 +4834,14 @@ function coerceImageField(field, value, name) {
|
|
|
4890
4834
|
};
|
|
4891
4835
|
}
|
|
4892
4836
|
function Image(props) {
|
|
4893
|
-
const {
|
|
4894
|
-
field,
|
|
4895
|
-
value,
|
|
4896
|
-
name,
|
|
4897
|
-
alt: altProp,
|
|
4898
|
-
className,
|
|
4899
|
-
width: widthProp,
|
|
4900
|
-
height: heightProp,
|
|
4901
|
-
...imgProps
|
|
4902
|
-
} = props;
|
|
4837
|
+
const { field, value, name, alt: altProp, className, width: widthProp, height: heightProp, ...imgProps } = props;
|
|
4903
4838
|
const context = useContext(ComponentContext);
|
|
4904
4839
|
assertNamedEnvelope("Image", field);
|
|
4905
4840
|
const coerced = coerceImageField(field, value, name);
|
|
4906
4841
|
const boundField = coerced.field;
|
|
4907
4842
|
const hasField = isFieldEnvelope(boundField);
|
|
4908
4843
|
const hasValue = hasOwnProp(props, "value");
|
|
4909
|
-
const { editName, fieldValue, ref } = useBoundField(
|
|
4910
|
-
boundField,
|
|
4911
|
-
coerced.value,
|
|
4912
|
-
coerced.name,
|
|
4913
|
-
"Image"
|
|
4914
|
-
);
|
|
4844
|
+
const { editName, fieldValue, ref } = useBoundField(boundField, coerced.value, coerced.name, "Image");
|
|
4915
4845
|
const composerEdit = useComposerEditMode();
|
|
4916
4846
|
warnProjectionProps("Image", hasField || isBrandedFields(field), hasValue, coerced.name || name);
|
|
4917
4847
|
if (!isBrandedFields(field) && warnNotScalarField("Image", boundField, fieldValue)) {
|
|
@@ -4934,9 +4864,7 @@ function Image(props) {
|
|
|
4934
4864
|
"data-amplifyup-ref-id": ref?.id || void 0
|
|
4935
4865
|
} : null;
|
|
4936
4866
|
if (composerEdit && !editName && (hasField || hasValue)) {
|
|
4937
|
-
console.warn(
|
|
4938
|
-
'[AmplifyUp SDK] Image value={\u2026} requires name="\u2026" for computed values'
|
|
4939
|
-
);
|
|
4867
|
+
console.warn('[AmplifyUp SDK] Image value={\u2026} requires name="\u2026" for computed values');
|
|
4940
4868
|
}
|
|
4941
4869
|
if (!src) {
|
|
4942
4870
|
if (!composerEdit || !fieldAttrs) return null;
|