From 71f8b2f1143b9774fd763a8f5a3685957474237b Mon Sep 17 00:00:00 2001 From: Chris Villa Date: Wed, 29 Nov 2023 17:21:56 +0000 Subject: [PATCH] feat: add "ui" prop to Puck to set the initial state --- packages/core/components/Puck/index.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/core/components/Puck/index.tsx b/packages/core/components/Puck/index.tsx index 82f274c5c0..8e928ab4ab 100644 --- a/packages/core/components/Puck/index.tsx +++ b/packages/core/components/Puck/index.tsx @@ -8,7 +8,7 @@ import { } from "react"; import { DragDropContext, DragStart, DragUpdate } from "@hello-pangea/dnd"; -import type { AppState, Config, Data } from "../../types/Config"; +import type { AppState, Config, Data, UiState } from "../../types/Config"; import { Button } from "../Button"; import { Plugin } from "../../types/Plugin"; @@ -68,6 +68,7 @@ export function Puck({ children, config, data: initialData = { content: [], root: { props: { title: "" } } }, + ui: initialUi = defaultAppState.ui, onChange, onPublish, plugins = [], @@ -80,6 +81,7 @@ export function Puck({ children?: ReactNode; config: Config; data: Data; + ui?: Partial; onChange?: (data: Data) => void; onPublish: (data: Data) => void; plugins?: Plugin[]; @@ -107,6 +109,7 @@ export function Puck({ data: initialData, ui: { ...defaultAppState.ui, + ...initialUi, // Store categories under componentList on state to allow render functions and plugins to modify componentList: config.categories ? Object.entries(config.categories).reduce( @@ -422,7 +425,7 @@ export function Puck({
- {headerTitle || data.root.props.title || "Page"} + {headerTitle || rootProps.title || "Page"} {headerPath && ( <> {" "}