{"version":3,"file":"UpdateEntry.cjs","names":[],"sources":["../../../src/createEntry/UpdateEntry/UpdateEntry.tsx"],"sourcesContent":["import { cloneElement, useState } from 'react';\nimport type { UpdateEntryProps } from './types';\n\n/**\n * React component that listens for external entry updates\n * and re-renders its child element with updated props.\n *\n * `UpdateEntry` is designed to integrate with an event-based\n * entry system where updates are emitted through an `update`\n * event listener.\n *\n * Whenever the `update` event is triggered, the component\n * replaces the current child props with the new payload and\n * re-renders the child element.\n *\n * @param props - Component configuration.\n *\n * @param props.on - Event subscription function used to listen\n * for entry updates.\n *\n * @param props.children - The React element to clone and update\n * with incoming props.\n *\n * @param props.restProps - Initial props passed to the child element.\n *\n * @returns A cloned React element with reactive props applied.\n *\n * @remarks\n * - The child must be a valid React element.\n * - Incoming update payloads fully replace the current props state.\n * - Initial props are taken from the remaining component props.\n *\n * @example\n * ```tsx\n * <UpdateEntry on={entry.on} title=\"Hello\">\n *   <App />\n * </UpdateEntry>\n * ```\n *\n * @example\n * ```ts\n * entry.emit('update', {\n *   title: 'Updated title'\n * });\n * ```\n */\nexport function UpdateEntry({ on, children, ...restProps }: UpdateEntryProps) {\n  const [entryProps, setEntryProps] = useState<{ [propName: string]: any }>(restProps);\n\n  on('update', (newProps: { [propName: string]: any }): void => {\n    console.log('UpdateEntry', newProps);\n    setEntryProps(newProps);\n  });\n\n  return cloneElement(children, entryProps);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8CA,SAAgB,YAAY,EAAE,IAAI,UAAU,GAAG,aAA+B;CAC5E,MAAM,CAAC,YAAY,kBAAA,GAAA,MAAA,SAAA,CAAuD,SAAS;CAEnF,GAAG,WAAW,aAAgD;EAC5D,QAAQ,IAAI,eAAe,QAAQ;EACnC,cAAc,QAAQ;CACxB,CAAC;CAED,QAAA,GAAA,MAAA,aAAA,CAAoB,UAAU,UAAU;AAC1C"}