@amplifyup/sdk 0.2.0 → 0.2.2
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 +83 -110
- package/dist/AmplifyRenderer.js.map +1 -1
- package/dist/AmplifyRenderer.mjs +83 -110
- package/dist/AmplifyRenderer.mjs.map +1 -1
- package/dist/index.js +82 -103
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +82 -103
- 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 +103 -178
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +103 -178
- package/dist/react.mjs.map +1 -1
- package/dist/server.js +1 -1
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +1 -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 {
|
|
@@ -1580,7 +1580,7 @@ var AmplifyUpSDK = class {
|
|
|
1580
1580
|
if (document.referrer) {
|
|
1581
1581
|
try {
|
|
1582
1582
|
const referrerUrl = new URL(document.referrer);
|
|
1583
|
-
if (referrerUrl.hostname === "localhost" && referrerUrl.port === "5001" || referrerUrl.pathname.includes("/dashboard/composer")
|
|
1583
|
+
if (referrerUrl.hostname === "localhost" && referrerUrl.port === "5001" || referrerUrl.pathname.includes("/dashboard/composer")) {
|
|
1584
1584
|
return true;
|
|
1585
1585
|
}
|
|
1586
1586
|
} catch {
|
|
@@ -1857,11 +1857,7 @@ var AmplifyUpSDK = class {
|
|
|
1857
1857
|
this.page(resumePath, { resumed: true });
|
|
1858
1858
|
this.lastTrackedPath = resumePath;
|
|
1859
1859
|
if (this.config?.debug) {
|
|
1860
|
-
console.log(
|
|
1861
|
-
"[AmplifyUp SDK] Idle resume page view",
|
|
1862
|
-
resumePath,
|
|
1863
|
-
`(hidden ${Math.round(idleMs / 6e4)}m)`
|
|
1864
|
-
);
|
|
1860
|
+
console.log("[AmplifyUp SDK] Idle resume page view", resumePath, `(hidden ${Math.round(idleMs / 6e4)}m)`);
|
|
1865
1861
|
}
|
|
1866
1862
|
}
|
|
1867
1863
|
noteActivity();
|
|
@@ -1881,12 +1877,7 @@ var AmplifyUpSDK = class {
|
|
|
1881
1877
|
}
|
|
1882
1878
|
state.visibleSince = null;
|
|
1883
1879
|
};
|
|
1884
|
-
const activityEvents = [
|
|
1885
|
-
"pointerdown",
|
|
1886
|
-
"keydown",
|
|
1887
|
-
"scroll",
|
|
1888
|
-
"touchstart"
|
|
1889
|
-
];
|
|
1880
|
+
const activityEvents = ["pointerdown", "keydown", "scroll", "touchstart"];
|
|
1890
1881
|
const onActivity = () => noteActivity();
|
|
1891
1882
|
window.addEventListener("scroll", onScroll, { passive: true });
|
|
1892
1883
|
document.addEventListener("visibilitychange", onVisibility);
|
|
@@ -2034,11 +2025,7 @@ var AmplifyUpSDK = class {
|
|
|
2034
2025
|
hosts.forEach((host) => observer.observe(host));
|
|
2035
2026
|
this.componentViewObservers.push(observer);
|
|
2036
2027
|
if (this.config?.debug) {
|
|
2037
|
-
console.log(
|
|
2038
|
-
"[AmplifyUp SDK] Component View tracking enabled for",
|
|
2039
|
-
hosts.length,
|
|
2040
|
-
"hosts"
|
|
2041
|
-
);
|
|
2028
|
+
console.log("[AmplifyUp SDK] Component View tracking enabled for", hosts.length, "hosts");
|
|
2042
2029
|
}
|
|
2043
2030
|
}
|
|
2044
2031
|
cleanupComponentViewTracking() {
|
|
@@ -2612,15 +2599,11 @@ Available Console Commands:
|
|
|
2612
2599
|
) : document;
|
|
2613
2600
|
if (!scopeRoot) {
|
|
2614
2601
|
if (this.config?.debug) {
|
|
2615
|
-
console.log(
|
|
2616
|
-
`[AmplifyUp SDK] Component host not found for ${eventConfig.componentId}`
|
|
2617
|
-
);
|
|
2602
|
+
console.log(`[AmplifyUp SDK] Component host not found for ${eventConfig.componentId}`);
|
|
2618
2603
|
}
|
|
2619
2604
|
return;
|
|
2620
2605
|
}
|
|
2621
|
-
targetElements = Array.from(
|
|
2622
|
-
scopeRoot.querySelectorAll(eventConfig.selector)
|
|
2623
|
-
);
|
|
2606
|
+
targetElements = Array.from(scopeRoot.querySelectorAll(eventConfig.selector));
|
|
2624
2607
|
if (scopeRoot instanceof Element && scopeRoot !== document.documentElement && scopeRoot.matches?.(eventConfig.selector)) {
|
|
2625
2608
|
targetElements.unshift(scopeRoot);
|
|
2626
2609
|
}
|
|
@@ -2653,7 +2636,9 @@ Available Console Commands:
|
|
|
2653
2636
|
});
|
|
2654
2637
|
}
|
|
2655
2638
|
if (this.config?.debug) {
|
|
2656
|
-
console.log(
|
|
2639
|
+
console.log(
|
|
2640
|
+
`[AmplifyUp SDK] Attached ${eventConfig.eventType} listener for ${eventConfig.eventName} on selector: ${eventConfig.selector}`
|
|
2641
|
+
);
|
|
2657
2642
|
}
|
|
2658
2643
|
});
|
|
2659
2644
|
});
|
|
@@ -2663,16 +2648,16 @@ Available Console Commands:
|
|
|
2663
2648
|
*/
|
|
2664
2649
|
mapEventType(eventType) {
|
|
2665
2650
|
const eventMap = {
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2651
|
+
click: "click",
|
|
2652
|
+
submit: "submit",
|
|
2653
|
+
focus: "focus",
|
|
2654
|
+
blur: "blur",
|
|
2655
|
+
hover: "mouseenter",
|
|
2656
|
+
change: "change",
|
|
2657
|
+
scroll: "scroll",
|
|
2658
|
+
view: "view",
|
|
2674
2659
|
// Handled separately with IntersectionObserver
|
|
2675
|
-
|
|
2660
|
+
custom: "custom"
|
|
2676
2661
|
};
|
|
2677
2662
|
return eventMap[eventType] || eventType;
|
|
2678
2663
|
}
|
|
@@ -2748,11 +2733,7 @@ Available Console Commands:
|
|
|
2748
2733
|
(entries) => {
|
|
2749
2734
|
entries.forEach((entry) => {
|
|
2750
2735
|
if (entry.isIntersecting) {
|
|
2751
|
-
this.handleTrackedEvent(
|
|
2752
|
-
new CustomEvent("view"),
|
|
2753
|
-
config,
|
|
2754
|
-
element
|
|
2755
|
-
);
|
|
2736
|
+
this.handleTrackedEvent(new CustomEvent("view"), config, element);
|
|
2756
2737
|
observer.unobserve(element);
|
|
2757
2738
|
}
|
|
2758
2739
|
});
|
|
@@ -2895,21 +2876,15 @@ Available Console Commands:
|
|
|
2895
2876
|
return;
|
|
2896
2877
|
}
|
|
2897
2878
|
if (event.data?.type === "AMPLIFYUP_FIELD_PATCH") {
|
|
2898
|
-
window.dispatchEvent(
|
|
2899
|
-
new CustomEvent("amplifyup:field-patch", { detail: event.data })
|
|
2900
|
-
);
|
|
2879
|
+
window.dispatchEvent(new CustomEvent("amplifyup:field-patch", { detail: event.data }));
|
|
2901
2880
|
return;
|
|
2902
2881
|
}
|
|
2903
2882
|
if (event.data?.type === "AMPLIFYUP_PROPS_PATCH") {
|
|
2904
|
-
window.dispatchEvent(
|
|
2905
|
-
new CustomEvent("amplifyup:props-patch", { detail: event.data })
|
|
2906
|
-
);
|
|
2883
|
+
window.dispatchEvent(new CustomEvent("amplifyup:props-patch", { detail: event.data }));
|
|
2907
2884
|
return;
|
|
2908
2885
|
}
|
|
2909
2886
|
if (event.data?.type === "AMPLIFYUP_LAYOUT_PATCH") {
|
|
2910
|
-
window.dispatchEvent(
|
|
2911
|
-
new CustomEvent("amplifyup:layout-patch", { detail: event.data })
|
|
2912
|
-
);
|
|
2887
|
+
window.dispatchEvent(new CustomEvent("amplifyup:layout-patch", { detail: event.data }));
|
|
2913
2888
|
return;
|
|
2914
2889
|
}
|
|
2915
2890
|
if (event.data?.type === "COMPONENT_DELETABLE_STATUS") {
|
|
@@ -2972,9 +2947,7 @@ Available Console Commands:
|
|
|
2972
2947
|
const { componentId, slotName, nodeId, isPageSlot } = event.data;
|
|
2973
2948
|
let element = null;
|
|
2974
2949
|
if (isPageSlot || slotName === "main" && !nodeId && !componentId) {
|
|
2975
|
-
element = document.querySelector(
|
|
2976
|
-
'[data-slot-source="page"]'
|
|
2977
|
-
);
|
|
2950
|
+
element = document.querySelector('[data-slot-source="page"]');
|
|
2978
2951
|
}
|
|
2979
2952
|
if (!element && nodeId && slotName) {
|
|
2980
2953
|
element = document.querySelector(
|
|
@@ -2982,9 +2955,7 @@ Available Console Commands:
|
|
|
2982
2955
|
);
|
|
2983
2956
|
}
|
|
2984
2957
|
if (!element && nodeId && !slotName) {
|
|
2985
|
-
element = document.querySelector(
|
|
2986
|
-
`[data-node-id="${nodeId}"]`
|
|
2987
|
-
);
|
|
2958
|
+
element = document.querySelector(`[data-node-id="${nodeId}"]`);
|
|
2988
2959
|
}
|
|
2989
2960
|
if (!element && slotName) {
|
|
2990
2961
|
element = document.querySelector(
|
|
@@ -3025,30 +2996,33 @@ Available Console Commands:
|
|
|
3025
2996
|
};
|
|
3026
2997
|
if (window.parent && window.parent !== window) {
|
|
3027
2998
|
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
|
-
|
|
2999
|
+
window.parent.postMessage(
|
|
3000
|
+
{
|
|
3001
|
+
type: "ELEMENT_POSITION",
|
|
3002
|
+
componentId: componentId || null,
|
|
3003
|
+
slotName: slotName || null,
|
|
3004
|
+
nodeId: nodeId || null,
|
|
3005
|
+
isPageSlot: !!isPageSlot || element.getAttribute("data-slot-source") === "page",
|
|
3006
|
+
hierarchy: hierarchyEls.map((el, index) => {
|
|
3007
|
+
const elComponentId = el.getAttribute("data-amplifyup-component") || el.getAttribute("data-component-id");
|
|
3008
|
+
const elSlotName = el.getAttribute("data-amplifyup-slot") || el.getAttribute("data-slot-id");
|
|
3009
|
+
const isSlot = !elComponentId && !!elSlotName;
|
|
3010
|
+
const pageSlot = isSlot && el.getAttribute("data-slot-source") === "page";
|
|
3011
|
+
return {
|
|
3012
|
+
index,
|
|
3013
|
+
componentId: elComponentId,
|
|
3014
|
+
componentName: pageSlot ? "Page" : el.getAttribute("data-component-name"),
|
|
3015
|
+
slotName: isSlot ? elSlotName : null,
|
|
3016
|
+
isSlot,
|
|
3017
|
+
isPageSlot: pageSlot,
|
|
3018
|
+
nodeId: el.getAttribute("data-node-id") || (isSlot ? el.getAttribute("data-parent-node-id") : null)
|
|
3019
|
+
};
|
|
3020
|
+
}),
|
|
3021
|
+
position,
|
|
3022
|
+
bounds
|
|
3023
|
+
},
|
|
3024
|
+
"*"
|
|
3025
|
+
);
|
|
3052
3026
|
}
|
|
3053
3027
|
} else {
|
|
3054
3028
|
console.warn("[AmplifyUp SDK] Element not found for position request");
|
|
@@ -3064,7 +3038,11 @@ Available Console Commands:
|
|
|
3064
3038
|
switch (message.type) {
|
|
3065
3039
|
case "ENABLE_HIGHLIGHTING":
|
|
3066
3040
|
case "UPDATE_HIGHLIGHTING":
|
|
3067
|
-
console.log(
|
|
3041
|
+
console.log(
|
|
3042
|
+
"[AmplifyUp SDK] Enabling highlighting with registry:",
|
|
3043
|
+
message.componentRegistry?.length || 0,
|
|
3044
|
+
"components"
|
|
3045
|
+
);
|
|
3068
3046
|
this.enableHighlighting(
|
|
3069
3047
|
message.componentRegistry || [],
|
|
3070
3048
|
message.highlightComponents ?? true,
|
|
@@ -3124,12 +3102,15 @@ Available Console Commands:
|
|
|
3124
3102
|
const tagName = target.tagName.toLowerCase();
|
|
3125
3103
|
const text = (target.textContent || "").replace(/\s+/g, " ").trim().substring(0, 80);
|
|
3126
3104
|
if (window.parent && window.parent !== window) {
|
|
3127
|
-
window.parent.postMessage(
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3105
|
+
window.parent.postMessage(
|
|
3106
|
+
{
|
|
3107
|
+
type: "ELEMENT_CLICKED_FOR_EVENT",
|
|
3108
|
+
selector,
|
|
3109
|
+
tagName,
|
|
3110
|
+
text
|
|
3111
|
+
},
|
|
3112
|
+
"*"
|
|
3113
|
+
);
|
|
3133
3114
|
}
|
|
3134
3115
|
};
|
|
3135
3116
|
document.addEventListener("click", this.eventSelectionClickHandler, true);
|
|
@@ -3155,9 +3136,7 @@ Available Console Commands:
|
|
|
3155
3136
|
return "[" + attr.name + '="' + attr.value + '"]';
|
|
3156
3137
|
}
|
|
3157
3138
|
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
|
-
);
|
|
3139
|
+
const classes = el.className.split(" ").filter((c) => c && !c.startsWith("has-") && !c.includes("selectable") && !c.includes("selected"));
|
|
3161
3140
|
if (classes.length > 0) {
|
|
3162
3141
|
return el.tagName.toLowerCase() + "." + classes[0];
|
|
3163
3142
|
}
|
|
@@ -3207,9 +3186,7 @@ Available Console Commands:
|
|
|
3207
3186
|
}
|
|
3208
3187
|
});
|
|
3209
3188
|
if (containing.length === 0) return null;
|
|
3210
|
-
const innermost = containing.filter(
|
|
3211
|
-
(el) => !containing.some((other) => other !== el && el.contains(other))
|
|
3212
|
-
);
|
|
3189
|
+
const innermost = containing.filter((el) => !containing.some((other) => other !== el && el.contains(other)));
|
|
3213
3190
|
if (innermost.length === 1) return innermost[0];
|
|
3214
3191
|
let best = innermost[0];
|
|
3215
3192
|
let bestArea = Infinity;
|
|
@@ -3326,9 +3303,7 @@ Available Console Commands:
|
|
|
3326
3303
|
*/
|
|
3327
3304
|
enableHighlighting(componentRegistry, highlightComponents, showZones) {
|
|
3328
3305
|
if (typeof document === "undefined") return;
|
|
3329
|
-
const previouslySelected = Array.from(
|
|
3330
|
-
document.querySelectorAll(".amplifyup-selected")
|
|
3331
|
-
);
|
|
3306
|
+
const previouslySelected = Array.from(document.querySelectorAll(".amplifyup-selected"));
|
|
3332
3307
|
this.componentRegistry = componentRegistry;
|
|
3333
3308
|
this.highlightingEnabled = true;
|
|
3334
3309
|
this.highlightComponentsEnabled = highlightComponents;
|
|
@@ -3701,10 +3676,7 @@ Available Console Commands:
|
|
|
3701
3676
|
if (shouldReapply && this.highlightingEnabled) {
|
|
3702
3677
|
setTimeout(() => {
|
|
3703
3678
|
if (this.highlightingEnabled) {
|
|
3704
|
-
this.applyComponentHighlights(
|
|
3705
|
-
this.highlightComponentsEnabled,
|
|
3706
|
-
this.showZonesEnabled
|
|
3707
|
-
);
|
|
3679
|
+
this.applyComponentHighlights(this.highlightComponentsEnabled, this.showZonesEnabled);
|
|
3708
3680
|
}
|
|
3709
3681
|
}, 100);
|
|
3710
3682
|
}
|
|
@@ -3713,7 +3685,13 @@ Available Console Commands:
|
|
|
3713
3685
|
childList: true,
|
|
3714
3686
|
subtree: true,
|
|
3715
3687
|
attributes: true,
|
|
3716
|
-
attributeFilter: [
|
|
3688
|
+
attributeFilter: [
|
|
3689
|
+
"data-amplifyup-component",
|
|
3690
|
+
"data-component-id",
|
|
3691
|
+
"data-amplifyup-slot",
|
|
3692
|
+
"data-slot-id",
|
|
3693
|
+
"data-slot-empty"
|
|
3694
|
+
]
|
|
3717
3695
|
});
|
|
3718
3696
|
}
|
|
3719
3697
|
/**
|
|
@@ -3727,9 +3705,7 @@ Available Console Commands:
|
|
|
3727
3705
|
this.teardownComposerDragDrop();
|
|
3728
3706
|
if (opts?.clearSelection !== false && typeof window !== "undefined") {
|
|
3729
3707
|
window.__AMPLIFYUP_COMPOSER_EDIT__ = false;
|
|
3730
|
-
window.dispatchEvent(
|
|
3731
|
-
new CustomEvent("amplifyup:composer-edit", { detail: { enabled: false } })
|
|
3732
|
-
);
|
|
3708
|
+
window.dispatchEvent(new CustomEvent("amplifyup:composer-edit", { detail: { enabled: false } }));
|
|
3733
3709
|
}
|
|
3734
3710
|
if (this.mutationObserver) {
|
|
3735
3711
|
this.mutationObserver.disconnect();
|
|
@@ -3887,7 +3863,10 @@ Available Console Commands:
|
|
|
3887
3863
|
e.stopPropagation();
|
|
3888
3864
|
this.sendSelectionMessage(htmlEl, hierarchy);
|
|
3889
3865
|
if (window.parent && window.parent !== window) {
|
|
3890
|
-
window.parent.postMessage(
|
|
3866
|
+
window.parent.postMessage(
|
|
3867
|
+
{ type: "CHECK_COMPONENT_DELETABLE", componentId: component.component_id },
|
|
3868
|
+
"*"
|
|
3869
|
+
);
|
|
3891
3870
|
}
|
|
3892
3871
|
};
|
|
3893
3872
|
htmlEl.addEventListener("click", handleClick);
|
|
@@ -4262,23 +4241,12 @@ function ComponentContextProvider({
|
|
|
4262
4241
|
componentId
|
|
4263
4242
|
}) {
|
|
4264
4243
|
const next = hydratePageResourceProps(props || {}, getPageResourceFields());
|
|
4265
|
-
return /* @__PURE__ */ jsx(
|
|
4266
|
-
ComponentContext.Provider,
|
|
4267
|
-
{
|
|
4268
|
-
value: { slots, props: next, layoutNodeId, componentId },
|
|
4269
|
-
children
|
|
4270
|
-
}
|
|
4271
|
-
);
|
|
4244
|
+
return /* @__PURE__ */ jsx(ComponentContext.Provider, { value: { slots, props: next, layoutNodeId, componentId }, children });
|
|
4272
4245
|
}
|
|
4273
|
-
function Slot({
|
|
4274
|
-
name,
|
|
4275
|
-
className
|
|
4276
|
-
}) {
|
|
4246
|
+
function Slot({ name, className }) {
|
|
4277
4247
|
const context = useContext(ComponentContext);
|
|
4278
4248
|
if (!context) {
|
|
4279
|
-
console.warn(
|
|
4280
|
-
`[AmplifyUp SDK] Slot "${name}" only works inside a component rendered from your component registry`
|
|
4281
|
-
);
|
|
4249
|
+
console.warn(`[AmplifyUp SDK] Slot "${name}" only works inside a component rendered from your component registry`);
|
|
4282
4250
|
return null;
|
|
4283
4251
|
}
|
|
4284
4252
|
const slotContent = context.slots?.[name];
|
|
@@ -4294,21 +4262,17 @@ function Slot({
|
|
|
4294
4262
|
window.self !== window.top && document.referrer && (() => {
|
|
4295
4263
|
try {
|
|
4296
4264
|
const referrerUrl = new URL(document.referrer);
|
|
4297
|
-
return referrerUrl.hostname === "localhost" && referrerUrl.port === "5001" || referrerUrl.pathname.includes("/dashboard/composer")
|
|
4265
|
+
return referrerUrl.hostname === "localhost" && referrerUrl.port === "5001" || referrerUrl.pathname.includes("/dashboard/composer");
|
|
4298
4266
|
} catch {
|
|
4299
4267
|
return false;
|
|
4300
4268
|
}
|
|
4301
4269
|
})());
|
|
4302
|
-
sdkDebugOnce(
|
|
4303
|
-
|
|
4304
|
-
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
|
|
4308
|
-
isEditorMode,
|
|
4309
|
-
availableSlotKeys: context.slots ? Object.keys(context.slots) : []
|
|
4310
|
-
}
|
|
4311
|
-
);
|
|
4270
|
+
sdkDebugOnce(`slot:${context.layoutNodeId || ""}:${name}`, `[Slot:${name}]`, {
|
|
4271
|
+
slotState,
|
|
4272
|
+
isEmpty,
|
|
4273
|
+
isEditorMode,
|
|
4274
|
+
availableSlotKeys: context.slots ? Object.keys(context.slots) : []
|
|
4275
|
+
});
|
|
4312
4276
|
return /* @__PURE__ */ jsx(
|
|
4313
4277
|
"div",
|
|
4314
4278
|
{
|
|
@@ -4398,18 +4362,12 @@ function canInlineEditRichText(name, value) {
|
|
|
4398
4362
|
return true;
|
|
4399
4363
|
}
|
|
4400
4364
|
function useComposerEditMode() {
|
|
4401
|
-
return useSyncExternalStore(
|
|
4402
|
-
subscribeComposerEdit,
|
|
4403
|
-
isComposerEditMode,
|
|
4404
|
-
getComposerEditModeServer
|
|
4405
|
-
);
|
|
4365
|
+
return useSyncExternalStore(subscribeComposerEdit, isComposerEditMode, getComposerEditModeServer);
|
|
4406
4366
|
}
|
|
4407
4367
|
function useBoundField(field, value, name, component) {
|
|
4408
4368
|
const bound = resolveEditableBinding(field, value, name);
|
|
4409
4369
|
if (bound.requiresName) {
|
|
4410
|
-
console.warn(
|
|
4411
|
-
`[AmplifyUp SDK] ${component} value={\u2026} requires name="\u2026" for computed values`
|
|
4412
|
-
);
|
|
4370
|
+
console.warn(`[AmplifyUp SDK] ${component} value={\u2026} requires name="\u2026" for computed values`);
|
|
4413
4371
|
}
|
|
4414
4372
|
const fieldValue = useComposerFieldValue(bound.name, bound.value, bound.ref);
|
|
4415
4373
|
return { editName: bound.name, fieldValue, ref: bound.ref };
|
|
@@ -4490,9 +4448,7 @@ function ComposerInlineField({
|
|
|
4490
4448
|
const el = elRef.current;
|
|
4491
4449
|
if (!el) return;
|
|
4492
4450
|
if (document.activeElement === el) return;
|
|
4493
|
-
if (el.querySelector(
|
|
4494
|
-
"input, button, select, textarea, form, svg, iframe, img"
|
|
4495
|
-
)) {
|
|
4451
|
+
if (el.querySelector("input, button, select, textarea, form, svg, iframe, img")) {
|
|
4496
4452
|
return;
|
|
4497
4453
|
}
|
|
4498
4454
|
const next = idleDisplay || "";
|
|
@@ -4699,9 +4655,7 @@ function warnReadOnlyRowField(name) {
|
|
|
4699
4655
|
const key = name || "(unnamed)";
|
|
4700
4656
|
if (warnedReadOnlyFields.has(key)) return;
|
|
4701
4657
|
warnedReadOnlyFields.add(key);
|
|
4702
|
-
console.warn(
|
|
4703
|
-
`[AmplifyUp SDK] ${key} has no write target; rendered read-only.`
|
|
4704
|
-
);
|
|
4658
|
+
console.warn(`[AmplifyUp SDK] ${key} has no write target; rendered read-only.`);
|
|
4705
4659
|
}
|
|
4706
4660
|
function canComposerBind(field, ref, editName) {
|
|
4707
4661
|
if (isReadOnlyRowField(field) || isFieldEnvelope(field) && field.readOnly) {
|
|
@@ -4713,9 +4667,7 @@ function canComposerBind(field, ref, editName) {
|
|
|
4713
4667
|
function warnProjectionProps(component, hasField, hasValue, name) {
|
|
4714
4668
|
if (process.env.NODE_ENV === "production") return;
|
|
4715
4669
|
if (!hasField && !hasValue && !name) {
|
|
4716
|
-
console.warn(
|
|
4717
|
-
`[AmplifyUp SDK] ${component} needs field={fields.yourProp} (or value + name for computed values)`
|
|
4718
|
-
);
|
|
4670
|
+
console.warn(`[AmplifyUp SDK] ${component} needs field={fields.yourProp} (or value + name for computed values)`);
|
|
4719
4671
|
}
|
|
4720
4672
|
}
|
|
4721
4673
|
function hasOwnProp(props, key) {
|
|
@@ -4769,26 +4721,14 @@ function markdownToHtml(markdown) {
|
|
|
4769
4721
|
}
|
|
4770
4722
|
}
|
|
4771
4723
|
function RichText(props) {
|
|
4772
|
-
const {
|
|
4773
|
-
field,
|
|
4774
|
-
value,
|
|
4775
|
-
name,
|
|
4776
|
-
className,
|
|
4777
|
-
as: Tag = "div",
|
|
4778
|
-
children
|
|
4779
|
-
} = props;
|
|
4724
|
+
const { field, value, name, className, as: Tag = "div", children } = props;
|
|
4780
4725
|
const context = useContext(ComponentContext);
|
|
4781
4726
|
const composerEdit = useComposerEditMode();
|
|
4782
4727
|
const childrenValue = typeof children === "string" || typeof children === "number" ? String(children) : void 0;
|
|
4783
4728
|
const hasField = isFieldEnvelope(field);
|
|
4784
4729
|
const hasValueProp = hasOwnProp(props, "value") || childrenValue !== void 0;
|
|
4785
4730
|
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
|
-
);
|
|
4731
|
+
const { editName, fieldValue, ref } = useBoundField(field, boundValue, name, "RichText");
|
|
4792
4732
|
assertNamedEnvelope("RichText", field);
|
|
4793
4733
|
if (!hasField && !hasValueProp && !name) {
|
|
4794
4734
|
return null;
|
|
@@ -4890,28 +4830,14 @@ function coerceImageField(field, value, name) {
|
|
|
4890
4830
|
};
|
|
4891
4831
|
}
|
|
4892
4832
|
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;
|
|
4833
|
+
const { field, value, name, alt: altProp, className, width: widthProp, height: heightProp, ...imgProps } = props;
|
|
4903
4834
|
const context = useContext(ComponentContext);
|
|
4904
4835
|
assertNamedEnvelope("Image", field);
|
|
4905
4836
|
const coerced = coerceImageField(field, value, name);
|
|
4906
4837
|
const boundField = coerced.field;
|
|
4907
4838
|
const hasField = isFieldEnvelope(boundField);
|
|
4908
4839
|
const hasValue = hasOwnProp(props, "value");
|
|
4909
|
-
const { editName, fieldValue, ref } = useBoundField(
|
|
4910
|
-
boundField,
|
|
4911
|
-
coerced.value,
|
|
4912
|
-
coerced.name,
|
|
4913
|
-
"Image"
|
|
4914
|
-
);
|
|
4840
|
+
const { editName, fieldValue, ref } = useBoundField(boundField, coerced.value, coerced.name, "Image");
|
|
4915
4841
|
const composerEdit = useComposerEditMode();
|
|
4916
4842
|
warnProjectionProps("Image", hasField || isBrandedFields(field), hasValue, coerced.name || name);
|
|
4917
4843
|
if (!isBrandedFields(field) && warnNotScalarField("Image", boundField, fieldValue)) {
|
|
@@ -4934,9 +4860,7 @@ function Image(props) {
|
|
|
4934
4860
|
"data-amplifyup-ref-id": ref?.id || void 0
|
|
4935
4861
|
} : null;
|
|
4936
4862
|
if (composerEdit && !editName && (hasField || hasValue)) {
|
|
4937
|
-
console.warn(
|
|
4938
|
-
'[AmplifyUp SDK] Image value={\u2026} requires name="\u2026" for computed values'
|
|
4939
|
-
);
|
|
4863
|
+
console.warn('[AmplifyUp SDK] Image value={\u2026} requires name="\u2026" for computed values');
|
|
4940
4864
|
}
|
|
4941
4865
|
if (!src) {
|
|
4942
4866
|
if (!composerEdit || !fieldAttrs) return null;
|
|
@@ -5892,6 +5816,7 @@ function AmplifyUpProvider({
|
|
|
5892
5816
|
});
|
|
5893
5817
|
return next;
|
|
5894
5818
|
});
|
|
5819
|
+
setError(null);
|
|
5895
5820
|
setLoading(false);
|
|
5896
5821
|
};
|
|
5897
5822
|
const onMessage = (event) => {
|