{"version":3,"file":"CodeHighlightControl.mjs","names":[],"sources":["../../../src/CodeHighlight/CodeHighlightControl/CodeHighlightControl.tsx"],"sourcesContent":["import {\n  ActionIcon,\n  BoxProps,\n  MantinePolymorphicComponent,\n  polymorphicFactory,\n  PolymorphicFactory,\n  StylesApiProps,\n  Tooltip,\n  useProps,\n} from '@mantine/core';\nimport { useCodeHighlightContext } from '../CodeHighlight.context';\n\nexport interface CodeHighlightControlProps\n  extends BoxProps, StylesApiProps<CodeHighlightControlFactory> {\n  /** Control icon */\n  children?: React.ReactNode;\n\n  /** Label displayed in the tooltip when the control is hovered */\n  tooltipLabel?: string;\n}\n\nexport type CodeHighlightControlFactory = PolymorphicFactory<{\n  props: CodeHighlightControlProps;\n  defaultRef: HTMLButtonElement;\n  defaultComponent: 'button';\n}>;\n\nexport const CodeHighlightControl: MantinePolymorphicComponent<CodeHighlightControlFactory> =\n  polymorphicFactory<CodeHighlightControlFactory>((_props) => {\n    const props = useProps('CodeHighlightControl', null, _props);\n    const { children, vars, tooltipLabel, ...others } = props;\n    const ctx = useCodeHighlightContext();\n    const tooltipStyles = ctx.getStyles('controlTooltip');\n\n    const control = (\n      <ActionIcon\n        {...ctx.getStyles('control')}\n        {...others}\n        variant=\"none\"\n        data-code-color-scheme={ctx.codeColorScheme}\n      >\n        {children}\n      </ActionIcon>\n    );\n\n    if (tooltipLabel) {\n      return (\n        <Tooltip\n          label={tooltipLabel}\n          fz=\"sm\"\n          position=\"bottom\"\n          classNames={{ tooltip: tooltipStyles.className }}\n          styles={{ tooltip: tooltipStyles.style }}\n          data-code-color-scheme={ctx.codeColorScheme}\n          transitionProps={{ duration: 0 }}\n        >\n          {control}\n        </Tooltip>\n      );\n    }\n\n    return control;\n  });\n\nCodeHighlightControl.displayName = '@mantine/code-highlight/CodeHighlightControl';\n"],"mappings":";;;;;AA2BA,MAAa,uBACX,oBAAiD,WAAW;CAE1D,MAAM,EAAE,UAAU,MAAM,cAAc,GAAG,WAD3B,SAAS,wBAAwB,MAAM,MACG;CACxD,MAAM,MAAM,wBAAwB;CACpC,MAAM,gBAAgB,IAAI,UAAU,gBAAgB;CAEpD,MAAM,UACJ,oBAAC,YAAD;EACE,GAAI,IAAI,UAAU,SAAS;EAC3B,GAAI;EACJ,SAAQ;EACR,0BAAwB,IAAI;EAE3B;CACS,CAAA;CAGd,IAAI,cACF,OACE,oBAAC,SAAD;EACE,OAAO;EACP,IAAG;EACH,UAAS;EACT,YAAY,EAAE,SAAS,cAAc,UAAU;EAC/C,QAAQ,EAAE,SAAS,cAAc,MAAM;EACvC,0BAAwB,IAAI;EAC5B,iBAAiB,EAAE,UAAU,EAAE;YAE9B;CACM,CAAA;CAIb,OAAO;AACT,CAAC;AAEH,qBAAqB,cAAc"}