{"version":3,"file":"ProgressSection.cjs","sources":["../../../../src/components/Progress/ProgressSection/ProgressSection.tsx"],"sourcesContent":["import {\n  Box,\n  BoxProps,\n  CompoundStylesApiProps,\n  ElementProps,\n  factory,\n  Factory,\n  getAutoContrastValue,\n  getContrastColor,\n  getThemeColor,\n  RaikouColor,\n  useProps,\n  useRaikouTheme,\n} from '../../../core';\nimport { useProgressContext } from '../Progress.context';\n\nexport type ProgressSectionStylesNames = 'section';\n\nexport interface ProgressSectionProps\n  extends BoxProps,\n    CompoundStylesApiProps<ProgressSectionFactory>,\n    ElementProps<'div'> {\n  /** Value of the section in 0–100 range  */\n  value: number;\n\n  /** Determines whether `aria-*` props should be added to the root element, `true` by default */\n  withAria?: boolean;\n\n  /** Key of `theme.colors` or any valid CSS value, `theme.primaryColor` by default */\n  color?: RaikouColor;\n\n  /** Determines whether the section should have stripes, `false` by default */\n  striped?: boolean;\n\n  /** Determines whether the sections stripes should be animated, if set, `striped` prop is ignored, `false` by default */\n  animated?: boolean;\n}\n\nexport type ProgressSectionFactory = Factory<{\n  props: ProgressSectionProps;\n  ref: HTMLDivElement;\n  stylesNames: ProgressSectionStylesNames;\n  compound: true;\n}>;\n\nconst defaultProps: Partial<ProgressSectionProps> = {\n  withAria: true,\n};\n\nexport const ProgressSection = factory<ProgressSectionFactory>((props, ref) => {\n  const {\n    classNames,\n    className,\n    style,\n    styles,\n    vars,\n    value,\n    withAria,\n    color,\n    striped,\n    animated,\n    mod,\n    ...others\n  } = useProps('ProgressSection', defaultProps, props);\n\n  const ctx = useProgressContext();\n  const theme = useRaikouTheme();\n\n  const ariaAttributes = withAria\n    ? {\n        role: 'progressbar',\n        'aria-valuemax': 100,\n        'aria-valuemin': 0,\n        'aria-valuenow': value,\n        'aria-valuetext': `${value}%`,\n      }\n    : {};\n\n  return (\n    <Box\n      ref={ref}\n      {...ctx.getStyles('section', { className, classNames, styles, style })}\n      {...others}\n      {...ariaAttributes}\n      mod={[{ striped: striped || animated, animated }, mod]}\n      __vars={{\n        '--progress-section-width': `${value}%`,\n        '--progress-section-color': getThemeColor(color, theme),\n        '--progress-label-color': getAutoContrastValue(ctx.autoContrast, theme)\n          ? getContrastColor({ color, theme, autoContrast: ctx.autoContrast })\n          : undefined,\n      }}\n    />\n  );\n});\n\nProgressSection.displayName = '@raikou/core/ProgressSection';\n"],"names":["factory","useProps","useProgressContext","useRaikouTheme","jsx","Box","getThemeColor","getAutoContrastValue","getContrastColor"],"mappings":";;;;;;;;;;;;;;;;AA6CA,MAAM,YAA8C,GAAA;AAAA,EAClD,QAAU,EAAA;AACZ,CAAA;AAEO,MAAM,eAAkB,GAAAA,eAAA,CAAgC,CAAC,KAAA,EAAO,GAAQ,KAAA;AAC7E,EAAM,MAAA;AAAA,IACJ,UAAA;AAAA,IACA,SAAA;AAAA,IACA,KAAA;AAAA,IACA,MAAA;AAAA,IACA,IAAA;AAAA,IACA,KAAA;AAAA,IACA,QAAA;AAAA,IACA,KAAA;AAAA,IACA,OAAA;AAAA,IACA,QAAA;AAAA,IACA,GAAA;AAAA,IACA,GAAG;AAAA,GACD,GAAAC,iBAAA,CAAS,iBAAmB,EAAA,YAAA,EAAc,KAAK,CAAA;AAEnD,EAAA,MAAM,MAAMC,mCAAmB,EAAA;AAC/B,EAAA,MAAM,QAAQC,6BAAe,EAAA;AAE7B,EAAA,MAAM,iBAAiB,QACnB,GAAA;AAAA,IACE,IAAM,EAAA,aAAA;AAAA,IACN,eAAiB,EAAA,GAAA;AAAA,IACjB,eAAiB,EAAA,CAAA;AAAA,IACjB,eAAiB,EAAA,KAAA;AAAA,IACjB,gBAAA,EAAkB,GAAG,KAAK,CAAA,CAAA;AAAA,MAE5B,EAAC;AAEL,EACE,uBAAAC,cAAA;AAAA,IAACC,OAAA;AAAA,IAAA;AAAA,MACC,GAAA;AAAA,MACC,GAAG,IAAI,SAAU,CAAA,SAAA,EAAW,EAAE,SAAW,EAAA,UAAA,EAAY,MAAQ,EAAA,KAAA,EAAO,CAAA;AAAA,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