Browse Source

fix(storybook): support prompt state capture (#33798)

Brendan Allan 1 month ago
parent
commit
6ec6db4ad6
1 changed files with 3 additions and 1 deletions
  1. 3 1
      packages/storybook/.storybook/mocks/app/context/prompt.ts

+ 3 - 1
packages/storybook/.storybook/mocks/app/context/prompt.ts

@@ -73,7 +73,7 @@ export function createPromptState() {
     key: item.key ?? `ctx:${++index}`,
   })
 
-  return {
+  const value = {
     ready,
     current: () => store.prompt,
     cursor: () => store.cursor,
@@ -87,6 +87,7 @@ export function createPromptState() {
       setStore("cursor", 0)
       setStore("items", (current) => current.filter((item) => !!item.comment?.trim()))
     },
+    capture: () => value,
     context: {
       items: () => store.items,
       add(item: Omit<ContextItem, "key"> & { key?: string }) {
@@ -116,6 +117,7 @@ export function createPromptState() {
       },
     },
   }
+  return value
 }
 
 const prompt = createPromptState()