{"version":3,"file":"CopyButton.cjs","names":["useProps"],"sources":["../../../src/components/CopyButton/CopyButton.tsx"],"sourcesContent":["import { useClipboard } from '@mantine/hooks';\nimport { useProps } from '../../core';\n\nexport interface CopyButtonProps {\n  /** Children callback, provides current status and copy function as an argument */\n  children: (payload: { copied: boolean; copy: () => void }) => React.ReactNode;\n\n  /** Value that is copied to the clipboard when the button is clicked */\n  value: string;\n\n  /** Copied status timeout in ms @default 1000 */\n  timeout?: number;\n}\n\nconst defaultProps = {\n  timeout: 1000,\n} satisfies Partial<CopyButtonProps>;\n\nexport function CopyButton(props: CopyButtonProps) {\n  const { children, timeout, value, ...others } = useProps('CopyButton', defaultProps, props);\n  const clipboard = useClipboard({ timeout });\n  const copy = () => clipboard.copy(value);\n  return <>{children({ copy, copied: clipboard.copied, ...others })}</>;\n}\n\nCopyButton.displayName = '@mantine/core/CopyButton';\n\nexport namespace CopyButton {\n  export type Props = CopyButtonProps;\n}\n"],"mappings":";;;;;;AAcA,MAAM,eAAe,EACnB,SAAS,KACV;AAED,SAAgB,WAAW,OAAwB;CACjD,MAAM,EAAE,UAAU,SAAS,OAAO,GAAG,WAAWA,kBAAAA,SAAS,cAAc,cAAc,MAAM;CAC3F,MAAM,aAAA,GAAA,eAAA,cAAyB,EAAE,SAAS,CAAC;CAC3C,MAAM,aAAa,UAAU,KAAK,MAAM;AACxC,QAAO,iBAAA,GAAA,kBAAA,KAAA,kBAAA,UAAA,EAAA,UAAG,SAAS;EAAE;EAAM,QAAQ,UAAU;EAAQ,GAAG;EAAQ,CAAC,EAAI,CAAA;;AAGvE,WAAW,cAAc"}