@amplifyup/sdk 0.1.68 → 0.1.69
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 +4 -0
- package/dist/AmplifyRenderer.js.map +1 -1
- package/dist/AmplifyRenderer.mjs +4 -0
- package/dist/AmplifyRenderer.mjs.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.mts +19 -1
- package/dist/react.d.ts +19 -1
- package/dist/react.js +119 -70
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +65 -20
- package/dist/react.mjs.map +1 -1
- package/package.json +1 -1
package/dist/react.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import
|
|
2
|
+
import React3, { createContext, memo, useState, useEffect, Fragment as Fragment$1, useContext, useRef, Component, useMemo, useSyncExternalStore, useCallback } from 'react';
|
|
3
3
|
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
4
4
|
import { marked } from 'marked';
|
|
5
5
|
|
|
@@ -1038,7 +1038,7 @@ function dedupeLayoutProviderFetch(key, fetchFn) {
|
|
|
1038
1038
|
function previewLayoutReady(opts) {
|
|
1039
1039
|
if (opts.hasClientLayout) return true;
|
|
1040
1040
|
if (opts.clientLoading) return false;
|
|
1041
|
-
return
|
|
1041
|
+
return true;
|
|
1042
1042
|
}
|
|
1043
1043
|
|
|
1044
1044
|
// src/edge/normalizeRoute.ts
|
|
@@ -4492,6 +4492,7 @@ function AmplifyRendererInner({
|
|
|
4492
4492
|
"data-slot-id": "main",
|
|
4493
4493
|
"data-amplifyup-slot": "main",
|
|
4494
4494
|
"data-slot-source": "page",
|
|
4495
|
+
"data-slot-state": layoutTree.length === 0 ? "empty" : "filled",
|
|
4495
4496
|
"data-slot-empty": layoutTree.length === 0 ? "true" : void 0,
|
|
4496
4497
|
children: layoutTree.map((node) => /* @__PURE__ */ jsx(Fragment$1, { children: renderNode(node) }, node.id))
|
|
4497
4498
|
}
|
|
@@ -4592,16 +4593,34 @@ function EmptySlotHint({
|
|
|
4592
4593
|
}
|
|
4593
4594
|
);
|
|
4594
4595
|
}
|
|
4595
|
-
|
|
4596
|
+
var ComposerLayoutStatusContext = createContext({
|
|
4597
|
+
ready: true
|
|
4598
|
+
});
|
|
4599
|
+
function ComposerLayoutStatusProvider({
|
|
4600
|
+
ready,
|
|
4601
|
+
children
|
|
4602
|
+
}) {
|
|
4603
|
+
return /* @__PURE__ */ jsx(ComposerLayoutStatusContext.Provider, { value: { ready }, children });
|
|
4604
|
+
}
|
|
4605
|
+
function useComposerLayoutStatus() {
|
|
4606
|
+
return useContext(ComposerLayoutStatusContext);
|
|
4607
|
+
}
|
|
4608
|
+
function previewPageSlot(state) {
|
|
4596
4609
|
return /* @__PURE__ */ jsx(
|
|
4597
4610
|
"div",
|
|
4598
4611
|
{
|
|
4599
4612
|
"data-slot-id": "main",
|
|
4600
4613
|
"data-amplifyup-slot": "main",
|
|
4601
4614
|
"data-slot-source": "page",
|
|
4602
|
-
"data-slot-
|
|
4603
|
-
|
|
4604
|
-
|
|
4615
|
+
"data-slot-state": state,
|
|
4616
|
+
"data-slot-empty": state === "empty" ? "true" : void 0,
|
|
4617
|
+
style: {
|
|
4618
|
+
minHeight: state === "empty" ? "50vh" : void 0,
|
|
4619
|
+
width: "100%",
|
|
4620
|
+
display: "block",
|
|
4621
|
+
position: "relative"
|
|
4622
|
+
},
|
|
4623
|
+
children: state === "empty" ? /* @__PURE__ */ jsx(EmptySlotHint, {}) : null
|
|
4605
4624
|
}
|
|
4606
4625
|
);
|
|
4607
4626
|
}
|
|
@@ -4648,25 +4667,26 @@ function AmplifyPageContent({
|
|
|
4648
4667
|
}
|
|
4649
4668
|
const loading = !hasAmplifyLayout(pageConfig) && client.loading;
|
|
4650
4669
|
const error = hasAmplifyLayout(pageConfig) ? null : pageConfigProp ? null : client.error;
|
|
4651
|
-
const
|
|
4652
|
-
const previewLoading = previewLoadingComponent ??
|
|
4670
|
+
const previewEmpty = previewEmptyComponent ?? previewPageSlot("empty");
|
|
4671
|
+
const previewLoading = previewLoadingComponent ?? previewPageSlot("loading");
|
|
4653
4672
|
if (preview) {
|
|
4654
4673
|
const ready = previewLayoutReady({
|
|
4655
4674
|
clientLoading: client.loading,
|
|
4656
|
-
hasClientLayout: !!clientLayout
|
|
4657
|
-
|
|
4658
|
-
|
|
4659
|
-
|
|
4675
|
+
hasClientLayout: !!clientLayout});
|
|
4676
|
+
if (!ready) {
|
|
4677
|
+
return /* @__PURE__ */ jsx(ComposerLayoutStatusProvider, { ready: false, children: previewLoading });
|
|
4678
|
+
}
|
|
4679
|
+
return /* @__PURE__ */ jsx(ComposerLayoutStatusProvider, { ready: true, children: /* @__PURE__ */ jsx(
|
|
4660
4680
|
AmplifyRenderer,
|
|
4661
4681
|
{
|
|
4662
|
-
pageConfig:
|
|
4682
|
+
pageConfig: pageConfig ?? void 0,
|
|
4663
4683
|
renderComponent,
|
|
4664
4684
|
composerPreview: true,
|
|
4665
4685
|
loadingComponent: loadingComponent ?? previewLoading,
|
|
4666
|
-
emptyComponent: emptyComponent ??
|
|
4667
|
-
errorComponent: errorComponent ?? (() =>
|
|
4686
|
+
emptyComponent: emptyComponent ?? previewEmpty,
|
|
4687
|
+
errorComponent: errorComponent ?? (() => previewEmpty)
|
|
4668
4688
|
}
|
|
4669
|
-
);
|
|
4689
|
+
) });
|
|
4670
4690
|
}
|
|
4671
4691
|
if (loading) {
|
|
4672
4692
|
return loadingComponent ? /* @__PURE__ */ jsx(Fragment, { children: loadingComponent }) : null;
|
|
@@ -4690,6 +4710,24 @@ function AmplifyPageContent({
|
|
|
4690
4710
|
);
|
|
4691
4711
|
}
|
|
4692
4712
|
|
|
4713
|
+
// src/slot-state.ts
|
|
4714
|
+
function resolveSlotState(opts) {
|
|
4715
|
+
if (!opts.layoutReady) return "loading";
|
|
4716
|
+
return opts.hasContent ? "filled" : "empty";
|
|
4717
|
+
}
|
|
4718
|
+
function slotShowsAddComponent(state) {
|
|
4719
|
+
return state === "empty";
|
|
4720
|
+
}
|
|
4721
|
+
function slotStateFromEl(el) {
|
|
4722
|
+
if (!el) return null;
|
|
4723
|
+
const explicit = el.getAttribute("data-slot-state");
|
|
4724
|
+
if (explicit === "loading" || explicit === "empty" || explicit === "filled") {
|
|
4725
|
+
return explicit;
|
|
4726
|
+
}
|
|
4727
|
+
if (el.getAttribute("data-slot-empty") === "true") return "empty";
|
|
4728
|
+
return null;
|
|
4729
|
+
}
|
|
4730
|
+
|
|
4693
4731
|
// src/composer-edit-mode.ts
|
|
4694
4732
|
function isComposerEditMode() {
|
|
4695
4733
|
if (typeof window === "undefined") return false;
|
|
@@ -4731,7 +4769,12 @@ function Slot({
|
|
|
4731
4769
|
return null;
|
|
4732
4770
|
}
|
|
4733
4771
|
const slotContent = context.slots?.[name];
|
|
4734
|
-
const
|
|
4772
|
+
const { ready: layoutReady } = useComposerLayoutStatus();
|
|
4773
|
+
const slotState = resolveSlotState({
|
|
4774
|
+
layoutReady,
|
|
4775
|
+
hasContent: !!slotContent
|
|
4776
|
+
});
|
|
4777
|
+
const isEmpty = slotState === "empty";
|
|
4735
4778
|
const isEditorMode = typeof window !== "undefined" && // Check for preview mode flag set by proxy
|
|
4736
4779
|
(window.__AMPLIFYUP_PREVIEW_MODE__ === true || // Check URL query params
|
|
4737
4780
|
new URLSearchParams(window.location.search).get("preview") === "true" || new URLSearchParams(window.location.search).get("visualEditor") === "true" || // Check if in iframe from orchestrator (check referrer hostname/port)
|
|
@@ -4747,6 +4790,7 @@ function Slot({
|
|
|
4747
4790
|
`slot:${context.layoutNodeId || ""}:${name}`,
|
|
4748
4791
|
`[Slot:${name}]`,
|
|
4749
4792
|
{
|
|
4793
|
+
slotState,
|
|
4750
4794
|
isEmpty,
|
|
4751
4795
|
isEditorMode,
|
|
4752
4796
|
availableSlotKeys: context.slots ? Object.keys(context.slots) : []
|
|
@@ -4759,6 +4803,7 @@ function Slot({
|
|
|
4759
4803
|
"data-slot-name": name,
|
|
4760
4804
|
"data-slot-id": name,
|
|
4761
4805
|
"data-amplifyup-slot": name,
|
|
4806
|
+
"data-slot-state": slotState,
|
|
4762
4807
|
"data-slot-empty": isEmpty ? "true" : void 0,
|
|
4763
4808
|
"data-parent-node-id": context.layoutNodeId || void 0,
|
|
4764
4809
|
"data-parent-component-id": context.componentId || void 0,
|
|
@@ -4768,7 +4813,7 @@ function Slot({
|
|
|
4768
4813
|
// Only add position relative for overlay positioning in editor mode
|
|
4769
4814
|
position: isEditorMode ? "relative" : void 0
|
|
4770
4815
|
},
|
|
4771
|
-
children: isEmpty ? isEditorMode ? /* @__PURE__ */ jsx(EmptySlotHint, { compact: true }) : /* @__PURE__ */ jsx(
|
|
4816
|
+
children: slotState === "loading" ? null : isEmpty ? isEditorMode ? /* @__PURE__ */ jsx(EmptySlotHint, { compact: true }) : /* @__PURE__ */ jsx(
|
|
4772
4817
|
"div",
|
|
4773
4818
|
{
|
|
4774
4819
|
className: "amplifyup-slot-placeholder",
|
|
@@ -5062,7 +5107,7 @@ function ComposerInlineHtml({
|
|
|
5062
5107
|
fieldRef
|
|
5063
5108
|
});
|
|
5064
5109
|
};
|
|
5065
|
-
return
|
|
5110
|
+
return React3.createElement(Tag, {
|
|
5066
5111
|
ref: elRef,
|
|
5067
5112
|
className,
|
|
5068
5113
|
"data-amplifyup-field": name,
|
|
@@ -5669,6 +5714,6 @@ function useAmplifyUp() {
|
|
|
5669
5714
|
return context;
|
|
5670
5715
|
}
|
|
5671
5716
|
|
|
5672
|
-
export { AmplifyPageContent, AmplifyRenderer, AmplifyUpProvider, ComponentContextProvider, ComposerProvider, Field, Image, MaybeComposerProvider, QueryContentError, RichText, SelectVariantsError, Slot, attachFieldEnvelopes, composerStoreKey, envelopeListRows, isBrandedFields, isComposerPreview, isFieldEnvelope, isPreviewRequest, isReadOnlyRowField, isWorkingContentRequest, listOwnerFromSpec, nextPageSpec, queryContent, searchSpec, selectVariants, toFieldEnvelopes, useAmplifyUp };
|
|
5717
|
+
export { AmplifyPageContent, AmplifyRenderer, AmplifyUpProvider, ComponentContextProvider, ComposerLayoutStatusProvider, ComposerProvider, Field, Image, MaybeComposerProvider, QueryContentError, RichText, SelectVariantsError, Slot, attachFieldEnvelopes, composerStoreKey, envelopeListRows, isBrandedFields, isComposerPreview, isFieldEnvelope, isPreviewRequest, isReadOnlyRowField, isWorkingContentRequest, listOwnerFromSpec, nextPageSpec, queryContent, resolveSlotState, searchSpec, selectVariants, slotShowsAddComponent, slotStateFromEl, toFieldEnvelopes, useAmplifyUp };
|
|
5673
5718
|
//# sourceMappingURL=react.mjs.map
|
|
5674
5719
|
//# sourceMappingURL=react.mjs.map
|