@amplifyup/sdk 0.1.76 → 0.1.77

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.
@@ -3626,14 +3626,16 @@ function applyComposerPatch(store, name, value, ref, layoutNodeId) {
3626
3626
  store.set(composerStoreKey(name, ref, layoutNodeId), value);
3627
3627
  }
3628
3628
  function ComposerProvider({
3629
- children
3629
+ children,
3630
+ enabled = true
3630
3631
  }) {
3631
3632
  const existing = react.useContext(ComposerStoreContext);
3632
3633
  const storeRef = react.useRef(null);
3633
3634
  if (!storeRef.current) storeRef.current = new ComposerFieldStore();
3634
- const store = existing || storeRef.current;
3635
+ const ownsStore = !existing && enabled;
3636
+ const store = existing || (enabled ? storeRef.current : null);
3635
3637
  react.useEffect(() => {
3636
- if (existing) return;
3638
+ if (!ownsStore || !store) return;
3637
3639
  const applyField = (fieldName, value, nodeId, ref) => {
3638
3640
  if (!fieldName || typeof fieldName !== "string") return;
3639
3641
  const fieldRef = isFieldRef(ref) ? ref : void 0;
@@ -3691,8 +3693,7 @@ function ComposerProvider({
3691
3693
  window.removeEventListener("amplifyup:props-patch", onPropsPatch);
3692
3694
  window.removeEventListener("message", onMessage);
3693
3695
  };
3694
- }, [existing, store]);
3695
- if (existing) return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
3696
+ }, [ownsStore, store]);
3696
3697
  return /* @__PURE__ */ jsxRuntime.jsx(ComposerStoreContext.Provider, { value: store, children });
3697
3698
  }
3698
3699
  function MaybeComposerProvider({
@@ -3700,9 +3701,7 @@ function MaybeComposerProvider({
3700
3701
  layoutNodeId,
3701
3702
  children
3702
3703
  }) {
3703
- const content = react.useMemo(() => children, [children]);
3704
- if (!enabled) return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: content });
3705
- return /* @__PURE__ */ jsxRuntime.jsx(ComposerProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(ComposerNodeContext.Provider, { value: layoutNodeId, children }) });
3704
+ return /* @__PURE__ */ jsxRuntime.jsx(ComposerProvider, { enabled, children: /* @__PURE__ */ jsxRuntime.jsx(ComposerNodeContext.Provider, { value: enabled ? layoutNodeId : void 0, children }) });
3706
3705
  }
3707
3706
  react.createContext(null);
3708
3707
  var usePathname = null;
@@ -4154,17 +4153,16 @@ function AmplifyRendererInner({
4154
4153
  if (layoutTree.length === 0) {
4155
4154
  return /* @__PURE__ */ jsxRuntime.jsx("main", { children: emptyComponent || /* @__PURE__ */ jsxRuntime.jsx("div", { className: "container mx-auto px-4 py-16", children: /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground", children: "No content configured for this page." }) }) });
4156
4155
  }
4157
- return /* @__PURE__ */ jsxRuntime.jsx(ComposerProvider, { children: /* @__PURE__ */ jsxRuntime.jsx("main", { children: composerPreviewFlag ? /* @__PURE__ */ jsxRuntime.jsx(
4158
- "div",
4156
+ return /* @__PURE__ */ jsxRuntime.jsx(ComposerProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(
4157
+ "main",
4159
4158
  {
4160
- "data-slot-id": "main",
4161
- "data-amplifyup-slot": "main",
4162
- "data-slot-source": "page",
4163
- "data-slot-state": layoutTree.length === 0 ? "empty" : "filled",
4164
- "data-slot-empty": layoutTree.length === 0 ? "true" : void 0,
4159
+ "data-slot-id": composerPreviewFlag ? "main" : void 0,
4160
+ "data-amplifyup-slot": composerPreviewFlag ? "main" : void 0,
4161
+ "data-slot-source": composerPreviewFlag ? "page" : void 0,
4162
+ "data-slot-state": composerPreviewFlag ? "filled" : void 0,
4165
4163
  children: layoutTree.map((node) => /* @__PURE__ */ jsxRuntime.jsx(react.Fragment, { children: renderNode(node) }, node.id))
4166
4164
  }
4167
- ) : layoutTree.map((node) => /* @__PURE__ */ jsxRuntime.jsx(react.Fragment, { children: renderNode(node) }, node.id)) }) });
4165
+ ) });
4168
4166
  }
4169
4167
  var AmplifyRenderer = react.memo(AmplifyRendererInner);
4170
4168