{"version":3,"file":"RingProgress.cjs","names":["createVarsResolver","rem","factory","useProps","useStyles","getCurves","Curve","Box","classes"],"sources":["../../../src/components/RingProgress/RingProgress.tsx"],"sourcesContent":["import {\n  Box,\n  BoxProps,\n  createVarsResolver,\n  DataAttributes,\n  ElementProps,\n  factory,\n  Factory,\n  MantineColor,\n  rem,\n  StylesApiProps,\n  useProps,\n  useStyles,\n} from '../../core';\nimport { Curve } from './Curve/Curve';\nimport { getCurves } from './get-curves/get-curves';\nimport classes from './RingProgress.module.css';\n\nfunction getClampedThickness(thickness: number, size: number) {\n  return Math.min(thickness || 12, (size || 120) / 4);\n}\n\nexport interface RingProgressSection extends React.ComponentProps<'circle'>, DataAttributes {\n  value: number;\n  color: MantineColor;\n  tooltip?: React.ReactNode;\n}\n\nexport type RingProgressStylesNames = 'root' | 'svg' | 'label' | 'curve';\nexport type RingProgressCssVariables = {\n  root: '--rp-size' | '--rp-label-offset' | '--rp-transition-duration';\n  svg: '--rp-start-angle';\n};\n\nexport interface RingProgressProps\n  extends BoxProps, StylesApiProps<RingProgressFactory>, ElementProps<'div'> {\n  /** Label displayed in the center of the ring */\n  label?: React.ReactNode;\n\n  /** Ring thickness in pixels. Cannot exceed size / 4 and will be automatically clamped if necessary @default 12 */\n  thickness?: number;\n\n  /** Width and height of the progress ring @default 120 */\n  size?: number;\n\n  /** Applies rounded line caps to the start and end of visible sections @default false */\n  roundCaps?: boolean;\n\n  /**\n   * Array of sections to display in the ring. Each section should have a `value` (0-100),\n   * `color`, and optional `tooltip`. Sections can also receive any valid SVG circle element props.\n   */\n  sections: RingProgressSection[];\n\n  /** Color of the unfilled portion of the ring (background). Defaults to gray-2 in light mode, dark-4 in dark mode */\n  rootColor?: MantineColor;\n\n  /** Transition duration in milliseconds for section value and color changes @default 0 */\n  transitionDuration?: number;\n\n  /** Gap between sections in degrees. Reduces the visual size of each section @default 0 */\n  sectionGap?: number;\n\n  /** Starting angle in degrees. 0 = right, 90 = bottom, 180 = left, 270 = top @default 270 */\n  startAngle?: number;\n}\n\nexport type RingProgressFactory = Factory<{\n  props: RingProgressProps;\n  ref: HTMLDivElement;\n  stylesNames: RingProgressStylesNames;\n  vars: RingProgressCssVariables;\n}>;\n\nconst defaultProps = {\n  size: 120,\n  thickness: 12,\n  startAngle: 270,\n} satisfies Partial<RingProgressProps>;\n\nconst varsResolver = createVarsResolver<RingProgressFactory>(\n  (_, { size, thickness, transitionDuration, startAngle }) => ({\n    root: {\n      '--rp-size': rem(size),\n      '--rp-label-offset': rem(thickness! * 2),\n      '--rp-transition-duration': transitionDuration ? `${transitionDuration}ms` : undefined,\n    },\n    svg: {\n      '--rp-start-angle': `${startAngle}deg`,\n    },\n  })\n);\n\nexport const RingProgress = factory<RingProgressFactory>((_props) => {\n  const props = useProps('RingProgress', defaultProps, _props);\n  const {\n    classNames,\n    className,\n    style,\n    styles,\n    unstyled,\n    vars,\n    label,\n    sections,\n    size,\n    thickness,\n    roundCaps,\n    rootColor,\n    transitionDuration,\n    sectionGap,\n    startAngle,\n    attributes,\n    ...others\n  } = props;\n\n  const getStyles = useStyles<RingProgressFactory>({\n    name: 'RingProgress',\n    classes,\n    props,\n    className,\n    style,\n    classNames,\n    styles,\n    unstyled,\n    attributes,\n    vars,\n    varsResolver,\n  });\n\n  const clampedThickness = getClampedThickness(thickness, size);\n\n  const curves = getCurves({\n    size,\n    thickness: clampedThickness,\n    sections,\n    renderRoundedLineCaps: roundCaps,\n    rootColor,\n    sectionGap,\n  }).map(({ data, sum, root, lineRoundCaps, offset }, index) => (\n    <Curve\n      {...data}\n      key={index}\n      size={size}\n      thickness={clampedThickness}\n      sum={sum}\n      offset={offset}\n      color={data?.color}\n      root={root}\n      lineRoundCaps={lineRoundCaps}\n      getStyles={getStyles}\n    />\n  ));\n\n  return (\n    <Box {...getStyles('root')} size={size} {...others}>\n      <svg {...getStyles('svg')}>{curves}</svg>\n      {label && <div {...getStyles('label')}>{label}</div>}\n    </Box>\n  );\n});\n\nRingProgress.classes = classes;\nRingProgress.varsResolver = varsResolver;\nRingProgress.displayName = '@mantine/core/RingProgress';\n"],"mappings":";;;;;;;;;;;;;;AAkBA,SAAS,oBAAoB,WAAmB,MAAc;AAC5D,QAAO,KAAK,IAAI,aAAa,KAAK,QAAQ,OAAO,EAAE;;AAuDrD,MAAM,eAAe;CACnB,MAAM;CACN,WAAW;CACX,YAAY;CACb;AAED,MAAM,eAAeA,6BAAAA,oBAClB,GAAG,EAAE,MAAM,WAAW,oBAAoB,kBAAkB;CAC3D,MAAM;EACJ,aAAaC,YAAAA,IAAI,KAAK;EACtB,qBAAqBA,YAAAA,IAAI,YAAa,EAAE;EACxC,4BAA4B,qBAAqB,GAAG,mBAAmB,MAAM,KAAA;EAC9E;CACD,KAAK,EACH,oBAAoB,GAAG,WAAW,MACnC;CACF,EACF;AAED,MAAa,eAAeC,gBAAAA,SAA8B,WAAW;CACnE,MAAM,QAAQC,kBAAAA,SAAS,gBAAgB,cAAc,OAAO;CAC5D,MAAM,EACJ,YACA,WACA,OACA,QACA,UACA,MACA,OACA,UACA,MACA,WACA,WACA,WACA,oBACA,YACA,YACA,YACA,GAAG,WACD;CAEJ,MAAM,YAAYC,mBAAAA,UAA+B;EAC/C,MAAM;EACN,SAAA,4BAAA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC;CAEF,MAAM,mBAAmB,oBAAoB,WAAW,KAAK;CAE7D,MAAM,SAASC,mBAAAA,UAAU;EACvB;EACA,WAAW;EACX;EACA,uBAAuB;EACvB;EACA;EACD,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,eAAe,UAAU,UAClD,iBAAA,GAAA,MAAA,eAACC,cAAAA,OAAD;EACE,GAAI;EACJ,KAAK;EACC;EACN,WAAW;EACN;EACG;EACR,OAAO,MAAM;EACP;EACS;EACJ;EACX,CAAA,CACF;AAEF,QACE,iBAAA,GAAA,kBAAA,MAACC,YAAAA,KAAD;EAAK,GAAI,UAAU,OAAO;EAAQ;EAAM,GAAI;YAA5C,CACE,iBAAA,GAAA,kBAAA,KAAC,OAAD;GAAK,GAAI,UAAU,MAAM;aAAG;GAAa,CAAA,EACxC,SAAS,iBAAA,GAAA,kBAAA,KAAC,OAAD;GAAK,GAAI,UAAU,QAAQ;aAAG;GAAY,CAAA,CAChD;;EAER;AAEF,aAAa,UAAUC,4BAAAA;AACvB,aAAa,eAAe;AAC5B,aAAa,cAAc"}