koval-ui
Version:
React components collection with minimalistic design. Supports theming, layout, and input validation.
1 lines • 2.81 kB
Source Map (JSON)
{"version":3,"file":"Progress.cjs","sources":["../../../../src/lib/Progress/Progress.tsx"],"sourcesContent":["import {forwardRef} from 'react';\nimport classNames from 'classnames';\n\nimport type {DataAttributes, LibraryProps} from '@/internal/LibraryAPI';\nimport {useInternalId} from '@/internal/hooks/useInternalId.ts';\n\nimport classes from './Progress.module.css';\n\nenum Variants {\n plain = 'plain',\n dashed = 'dashed',\n}\n\nexport type Props = DataAttributes &\n LibraryProps & {\n /**\n * Provide maximum for progress scale\n * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/progress#max\n */\n max?: number;\n /**\n * Provide value for progress scale\n * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/progress#value\n */\n value?: number;\n /**\n * Choose appearance of progress bar\n */\n variant?: keyof typeof Variants;\n /**\n * Provide an optional label to display on the left side\n */\n label?: string;\n };\n\nexport const Progress = forwardRef<HTMLProgressElement, Props>(\n (\n {max = 100, value, className, variant = Variants.plain, label, id: idProp, ...nativeProps},\n ref\n ) => {\n const id = useInternalId(idProp);\n return (\n <div className={classes.wrapper}>\n {label && (\n <label className={classes.label} htmlFor={id}>\n {label}:\n </label>\n )}\n <progress\n {...nativeProps}\n id={id}\n max={max}\n value={value}\n className={classNames(\n classes.progress,\n {[classes.dashed]: variant === Variants.dashed},\n className\n )}\n ref={ref}\n />\n </div>\n );\n }\n);\n\nProgress.displayName = 'Progress';\n"],"names":["Progress","forwardRef","max","value","className","variant","label","idProp","nativeProps","ref","id","useInternalId","jsxs","classes","jsx","classNames"],"mappings":"wQAmCaA,EAAWC,EAAA,WACpB,CACI,CAAC,IAAAC,EAAM,IAAK,MAAAC,EAAO,UAAAC,EAAW,QAAAC,EAAU,QAAgB,MAAAC,EAAO,GAAIC,EAAQ,GAAGC,CAAA,EAC9EC,IACC,CACK,MAAAC,EAAKC,gBAAcJ,CAAM,EAC/B,OACKK,EAAAA,KAAA,MAAA,CAAI,UAAWC,EAAA,QAAQ,QACnB,SAAA,CAAAP,UACI,QAAM,CAAA,UAAWO,EAAQ,QAAA,MAAO,QAASH,EACrC,SAAA,CAAAJ,EAAM,GAAA,EACX,EAEJQ,EAAA,IAAC,WAAA,CACI,GAAGN,EACJ,GAAAE,EACA,IAAAR,EACA,MAAAC,EACA,UAAWY,EACPF,EAAAA,QAAQ,SACR,CAAC,CAACA,EAAA,QAAQ,MAAM,EAAGR,IAAY,QAAe,EAC9CD,CACJ,EACA,IAAAK,CAAA,CAAA,CACJ,EACJ,CAAA,CAGZ,EAEAT,EAAS,YAAc"}