MCPcopy Create free account
hub / github.com/code-with-antonio/nightcode / DialogProvider

Function DialogProvider

packages/cli/src/providers/dialog/index.tsx:28–59  ·  view source on GitHub ↗
({ children }: DialogProviderProps)

Source from the content-addressed store, hash-verified

26};
27
28export function DialogProvider({ children }: DialogProviderProps) {
29 const [currentDialog, setCurrentDialog] = useState<DialogConfig | null>(null);
30 const { push, pop } = useKeyboardLayer();
31
32 const close = useCallback(() => {
33 setCurrentDialog(null);
34 pop("dialog");
35 }, [pop]);
36
37 const open = useCallback(
38 (config: DialogConfig) => {
39 setCurrentDialog(config);
40 push("dialog", () => {
41 close();
42 return true;
43 });
44 },
45 [push, close],
46 );
47
48 const value: DialogContextValue = {
49 open,
50 close,
51 };
52
53 return (
54 <DialogContext.Provider value={value}>
55 {children}
56 <Dialog currentDialog={currentDialog} close={close} />
57 </DialogContext.Provider>
58 );
59};
60
61type DialogProps = {
62 currentDialog: DialogConfig | null;

Callers

nothing calls this directly

Calls 2

useKeyboardLayerFunction · 0.90
closeFunction · 0.85

Tested by

no test coverage detected